applied anydot's 3 minor patches, thank you anydot
199a6016
4 file(s) · +31 −34
| 129 | 129 | ||
| 130 | 130 | void |
|
| 131 | 131 | focus(Client *c) { |
|
| 132 | - | if(c && !isvisible(c)) |
|
| 133 | - | return; |
|
| 132 | + | if( !c && selscreen || c && !isvisible(c)) |
|
| 133 | + | for(c = stack; c && !isvisible(c); c = c->snext); |
|
| 134 | 134 | if(sel && sel != c) { |
|
| 135 | 135 | grabbuttons(sel, False); |
|
| 136 | 136 | XSetWindowBorder(dpy, sel->win, dc.norm[ColBorder]); |
|
| 150 | 150 | } |
|
| 151 | 151 | else |
|
| 152 | 152 | XSetInputFocus(dpy, root, RevertToPointerRoot, CurrentTime); |
|
| 153 | - | } |
|
| 154 | - | ||
| 155 | - | void |
|
| 156 | - | focustopvisible(void) { |
|
| 157 | - | Client *c; |
|
| 158 | - | ||
| 159 | - | for(c = stack; c && !isvisible(c); c = c->snext); |
|
| 160 | - | focus(c); |
|
| 161 | 153 | } |
|
| 162 | 154 | ||
| 163 | 155 | void |
|
| 230 | 222 | XMoveWindow(dpy, w, c->x + 2 * sw, c->y); |
|
| 231 | 223 | XMapWindow(dpy, w); |
|
| 232 | 224 | setclientstate(c, NormalState); |
|
| 233 | - | if(isvisible(c)) |
|
| 234 | - | focus(c); |
|
| 225 | + | focus(c); |
|
| 235 | 226 | lt->arrange(); |
|
| 236 | 227 | } |
|
| 237 | 228 | ||
| 401 | 392 | detach(c); |
|
| 402 | 393 | detachstack(c); |
|
| 403 | 394 | if(sel == c) |
|
| 404 | - | focustopvisible(); |
|
| 395 | + | focus(NULL); |
|
| 405 | 396 | XUngrabButton(dpy, AnyButton, AnyModifier, c->win); |
|
| 406 | 397 | setclientstate(c, WithdrawnState); |
|
| 407 | 398 | free(c->tags); |
|
| 100 | 100 | void attach(Client *c); /* attaches c to global client list */ |
|
| 101 | 101 | void configure(Client *c); /* send synthetic configure event */ |
|
| 102 | 102 | void detach(Client *c); /* detaches c from global client list */ |
|
| 103 | - | void focus(Client *c); /* focus c, c may be NULL */ |
|
| 104 | - | void focustopvisible(void); /* focus top visible window on stack */ |
|
| 103 | + | void focus(Client *c); /* focus c if visible && !NULL, or focus top visible */ |
|
| 105 | 104 | void killclient(const char *arg); /* kill sel nicely */ |
|
| 106 | 105 | void manage(Window w, XWindowAttributes *wa); /* manage new client */ |
|
| 107 | 106 | void resize(Client *c, int x, int y, |
| 242 | 242 | ||
| 243 | 243 | if(ev->mode != NotifyNormal || ev->detail == NotifyInferior) |
|
| 244 | 244 | return; |
|
| 245 | - | if((c = getclient(ev->window)) && isvisible(c)) |
|
| 245 | + | if(c = getclient(ev->window)) |
|
| 246 | 246 | focus(c); |
|
| 247 | 247 | else if(ev->window == root) { |
|
| 248 | 248 | selscreen = True; |
|
| 249 | - | focustopvisible(); |
|
| 249 | + | focus(NULL); |
|
| 250 | 250 | } |
|
| 251 | 251 | } |
|
| 252 | 252 |
| 14 | 14 | static unsigned int nmaster = NMASTER; |
|
| 15 | 15 | ||
| 16 | 16 | static void |
|
| 17 | + | ban(Client *c) { |
|
| 18 | + | if (c->isbanned) |
|
| 19 | + | return; |
|
| 20 | + | XMoveWindow(dpy, c->win, c->x + 2 * sw, c->y); |
|
| 21 | + | c->isbanned = True; |
|
| 22 | + | } |
|
| 23 | + | ||
| 24 | + | static void |
|
| 25 | + | unban(Client *c) { |
|
| 26 | + | if (!c->isbanned) |
|
| 27 | + | return; |
|
| 28 | + | XMoveWindow(dpy, c->win, c->x, c->y); |
|
| 29 | + | c->isbanned = False; |
|
| 30 | + | } |
|
| 31 | + | ||
| 32 | + | static void |
|
| 17 | 33 | tile(void) { |
|
| 18 | 34 | unsigned int i, n, nx, ny, nw, nh, mw, mh, tw, th; |
|
| 19 | 35 | Client *c; |
|
| 28 | 44 | ||
| 29 | 45 | for(i = 0, c = clients; c; c = c->next) |
|
| 30 | 46 | if(isvisible(c)) { |
|
| 31 | - | if(c->isbanned) |
|
| 32 | - | XMoveWindow(dpy, c->win, c->x, c->y); |
|
| 33 | - | c->isbanned = False; |
|
| 47 | + | unban(c); |
|
| 34 | 48 | if(c->isfloating) |
|
| 35 | 49 | continue; |
|
| 36 | 50 | c->ismax = False; |
|
| 60 | 74 | resize(c, nx, ny, nw, nh, False); |
|
| 61 | 75 | i++; |
|
| 62 | 76 | } |
|
| 63 | - | else { |
|
| 64 | - | c->isbanned = True; |
|
| 65 | - | XMoveWindow(dpy, c->win, c->x + 2 * sw, c->y); |
|
| 66 | - | } |
|
| 67 | - | if(!sel || !isvisible(sel)) |
|
| 68 | - | focustopvisible(); |
|
| 77 | + | else |
|
| 78 | + | ban(c); |
|
| 79 | + | focus(NULL); |
|
| 69 | 80 | restack(); |
|
| 70 | 81 | } |
|
| 71 | 82 | ||
| 77 | 88 | floating(void) { |
|
| 78 | 89 | Client *c; |
|
| 79 | 90 | ||
| 80 | - | for(c = clients; c; c = c->next) { |
|
| 91 | + | for(c = clients; c; c = c->next) |
|
| 81 | 92 | if(isvisible(c)) { |
|
| 82 | 93 | if(c->isbanned) |
|
| 83 | 94 | XMoveWindow(dpy, c->win, c->x, c->y); |
|
| 84 | 95 | c->isbanned = False; |
|
| 85 | 96 | resize(c, c->x, c->y, c->w, c->h, True); |
|
| 86 | 97 | } |
|
| 87 | - | else { |
|
| 88 | - | c->isbanned = True; |
|
| 89 | - | XMoveWindow(dpy, c->win, c->x + 2 * sw, c->y); |
|
| 90 | - | } |
|
| 91 | - | } |
|
| 92 | - | if(!sel || !isvisible(sel)) |
|
| 93 | - | focustopvisible(); |
|
| 98 | + | else |
|
| 99 | + | ban(c); |
|
| 100 | + | focus(NULL); |
|
| 94 | 101 | restack(); |
|
| 95 | 102 | } |
|
| 96 | 103 | ||