diff options
| author | Anselm R. Garbe <arg@10kloc.org> | 2006-08-29 13:40:09 +0200 |
|---|---|---|
| committer | Anselm R. Garbe <arg@10kloc.org> | 2006-08-29 13:40:09 +0200 |
| commit | 9d739090750ffb3b3a64e86e2331215b8901c360 (patch) | |
| tree | 6670ab450bf962433c148a6ff30107a411b6fb27 | |
| parent | this algorithm seems to keep order for any scenario (diff) | |
| download | dwm-9d739090750ffb3b3a64e86e2331215b8901c360.tar.gz dwm-9d739090750ffb3b3a64e86e2331215b8901c360.zip | |
still something wrong with reorder()
Diffstat (limited to '')
| -rw-r--r-- | client.c | 5 | ||||
| -rw-r--r-- | dwm.h | 3 | ||||
| -rw-r--r-- | tag.c | 6 | ||||
| -rw-r--r-- | view.c | 75 |
4 files changed, 33 insertions, 56 deletions
| @@ -241,7 +241,10 @@ manage(Window w, XWindowAttributes *wa) | |||
| 241 | || (c->maxw && c->minw && | 241 | || (c->maxw && c->minw && |
| 242 | c->maxw == c->minw && c->maxh == c->minh); | 242 | c->maxw == c->minw && c->maxh == c->minh); |
| 243 | 243 | ||
| 244 | attach(c); | 244 | if(clients) |
| 245 | clients->prev = c; | ||
| 246 | c->next = clients; | ||
| 247 | clients = c; | ||
| 245 | 248 | ||
| 246 | settitle(c); | 249 | settitle(c); |
| 247 | if(isvisible(c)) | 250 | if(isvisible(c)) |
| @@ -56,7 +56,7 @@ struct Client { | |||
| 56 | int basew, baseh, incw, inch, maxw, maxh, minw, minh; | 56 | int basew, baseh, incw, inch, maxw, maxh, minw, minh; |
| 57 | int grav; | 57 | int grav; |
| 58 | long flags; | 58 | long flags; |
| 59 | unsigned int border; | 59 | unsigned int border, weight; |
| 60 | Bool isfloat; | 60 | Bool isfloat; |
| 61 | Bool ismax; | 61 | Bool ismax; |
| 62 | Bool *tags; | 62 | Bool *tags; |
| @@ -127,7 +127,6 @@ extern void *erealloc(void *ptr, unsigned int size); | |||
| 127 | extern void spawn(Arg *arg); | 127 | extern void spawn(Arg *arg); |
| 128 | 128 | ||
| 129 | /* view.c */ | 129 | /* view.c */ |
| 130 | extern void attach(Client *c); | ||
| 131 | extern void detach(Client *c); | 130 | extern void detach(Client *c); |
| 132 | extern void dofloat(Arg *arg); | 131 | extern void dofloat(Arg *arg); |
| 133 | extern void dotile(Arg *arg); | 132 | extern void dotile(Arg *arg); |
| @@ -106,6 +106,8 @@ settags(Client *c) | |||
| 106 | if(!matched) | 106 | if(!matched) |
| 107 | for(i = 0; i < ntags; i++) | 107 | for(i = 0; i < ntags; i++) |
| 108 | c->tags[i] = seltag[i]; | 108 | c->tags[i] = seltag[i]; |
| 109 | for(i = 0; i < ntags && !c->tags[i]; i++); | ||
| 110 | c->weight = i; | ||
| 109 | } | 111 | } |
| 110 | 112 | ||
| 111 | void | 113 | void |
| @@ -120,8 +122,6 @@ tag(Arg *arg) | |||
| 120 | sel->tags[i] = False; | 122 | sel->tags[i] = False; |
| 121 | sel->tags[arg->i] = True; | 123 | sel->tags[arg->i] = True; |
| 122 | settitle(sel); | 124 | settitle(sel); |
| 123 | detach(sel); | ||
| 124 | attach(sel); | ||
| 125 | if(!isvisible(sel)) | 125 | if(!isvisible(sel)) |
| 126 | arrange(NULL); | 126 | arrange(NULL); |
| 127 | else | 127 | else |
| @@ -141,8 +141,6 @@ toggletag(Arg *arg) | |||
| 141 | if(i == ntags) | 141 | if(i == ntags) |
| 142 | sel->tags[arg->i] = True; | 142 | sel->tags[arg->i] = True; |
| 143 | settitle(sel); | 143 | settitle(sel); |
| 144 | detach(sel); | ||
| 145 | attach(sel); | ||
| 146 | if(!isvisible(sel)) | 144 | if(!isvisible(sel)) |
| 147 | arrange(NULL); | 145 | arrange(NULL); |
| 148 | else | 146 | else |
| @@ -6,62 +6,34 @@ | |||
| 6 | 6 | ||
| 7 | /* static */ | 7 | /* static */ |
| 8 | 8 | ||
| 9 | static Client * | 9 | static void |
| 10 | getslot(Client *c) | 10 | reorder() |
| 11 | { | 11 | { |
| 12 | unsigned int i, tic; | 12 | Client *c, *orig, *p; |
| 13 | Client *p; | ||
| 14 | |||
| 15 | for(tic = 0; tic < ntags && !c->tags[tic]; tic++); | ||
| 16 | for(p = clients; p; p = p->next) { | ||
| 17 | for(i = 0; i < ntags && !p->tags[i]; i++); | ||
| 18 | if(tic < i) | ||
| 19 | return p; | ||
| 20 | } | ||
| 21 | return p; | ||
| 22 | } | ||
| 23 | 13 | ||
| 24 | static Client * | 14 | orig = clients; |
| 25 | tail() | 15 | clients = NULL; |
| 26 | { | ||
| 27 | Client *c; | ||
| 28 | for(c = clients; c && c->next; c = c->next); | ||
| 29 | return c; | ||
| 30 | } | ||
| 31 | 16 | ||
| 32 | /* extern */ | 17 | while((c = orig)) { |
| 18 | orig = orig->next; | ||
| 19 | detach(c); | ||
| 33 | 20 | ||
| 34 | void (*arrange)(Arg *) = DEFMODE; | 21 | for(p = clients; p && p->next && p->weight <= c->weight; p = p->next); |
| 35 | |||
| 36 | void | ||
| 37 | attach(Client *c) | ||
| 38 | { | ||
| 39 | Client *p; | ||
| 40 | |||
| 41 | if(!clients) { | ||
| 42 | clients = c; | ||
| 43 | return; | ||
| 44 | } | ||
| 45 | if(!(p = getnext(clients)) && !(p = getslot(c))) { | ||
| 46 | p = tail(); | ||
| 47 | c->prev = p; | 22 | c->prev = p; |
| 48 | p->next = c; | 23 | if(p) { |
| 49 | return; | 24 | if((c->next = p->next)) |
| 50 | } | 25 | c->next->prev = c; |
| 51 | 26 | p->next = c; | |
| 52 | if(p == clients) { | 27 | } |
| 53 | c->next = clients; | 28 | else |
| 54 | clients->prev = c; | 29 | clients = c; |
| 55 | clients = c; | ||
| 56 | } | ||
| 57 | else { | ||
| 58 | p->prev->next = c; | ||
| 59 | c->prev = p->prev; | ||
| 60 | p->prev = c; | ||
| 61 | c->next = p; | ||
| 62 | } | 30 | } |
| 63 | } | 31 | } |
| 64 | 32 | ||
| 33 | /* extern */ | ||
| 34 | |||
| 35 | void (*arrange)(Arg *) = DEFMODE; | ||
| 36 | |||
| 65 | void | 37 | void |
| 66 | detach(Client *c) | 38 | detach(Client *c) |
| 67 | { | 39 | { |
| @@ -277,6 +249,7 @@ toggleview(Arg *arg) | |||
| 277 | for(i = 0; i < ntags && !seltag[i]; i++); | 249 | for(i = 0; i < ntags && !seltag[i]; i++); |
| 278 | if(i == ntags) | 250 | if(i == ntags) |
| 279 | seltag[arg->i] = True; /* cannot toggle last view */ | 251 | seltag[arg->i] = True; /* cannot toggle last view */ |
| 252 | reorder(); | ||
| 280 | arrange(NULL); | 253 | arrange(NULL); |
| 281 | } | 254 | } |
| 282 | 255 | ||
| @@ -284,10 +257,12 @@ void | |||
| 284 | view(Arg *arg) | 257 | view(Arg *arg) |
| 285 | { | 258 | { |
| 286 | unsigned int i; | 259 | unsigned int i; |
| 260 | Client *c; | ||
| 287 | 261 | ||
| 288 | for(i = 0; i < ntags; i++) | 262 | for(i = 0; i < ntags; i++) |
| 289 | seltag[i] = False; | 263 | seltag[i] = False; |
| 290 | seltag[arg->i] = True; | 264 | seltag[arg->i] = True; |
| 265 | reorder(); | ||
| 291 | arrange(NULL); | 266 | arrange(NULL); |
| 292 | } | 267 | } |
| 293 | 268 | ||
| @@ -303,7 +278,9 @@ zoom(Arg *arg) | |||
| 303 | if(!(c = getnext(c->next))) | 278 | if(!(c = getnext(c->next))) |
| 304 | return; | 279 | return; |
| 305 | detach(c); | 280 | detach(c); |
| 306 | attach(c); | 281 | c->next = clients; |
| 282 | clients->prev = c; | ||
| 283 | clients = c; | ||
| 307 | focus(c); | 284 | focus(c); |
| 308 | arrange(NULL); | 285 | arrange(NULL); |
| 309 | } | 286 | } |
