applied Sanders max_and_focus.patch
26157e69
5 file(s) · +48 −44
| 82 | 82 | void |
|
| 83 | 83 | focus(Client *c) |
|
| 84 | 84 | { |
|
| 85 | - | Client *old = sel; |
|
| 85 | + | Client *old; |
|
| 86 | 86 | ||
| 87 | 87 | if(!issel) |
|
| 88 | 88 | return; |
|
| 89 | 89 | if(!sel) |
|
| 90 | 90 | sel = c; |
|
| 91 | 91 | else if(sel != c) { |
|
| 92 | - | if(sel->ismax) |
|
| 92 | + | if(maximized) |
|
| 93 | 93 | togglemax(NULL); |
|
| 94 | + | old = sel; |
|
| 94 | 95 | sel = c; |
|
| 95 | - | grabbuttons(old, False); |
|
| 96 | - | drawtitle(old); |
|
| 96 | + | if(old) { |
|
| 97 | + | grabbuttons(old, False); |
|
| 98 | + | drawtitle(old); |
|
| 99 | + | } |
|
| 100 | + | } |
|
| 101 | + | if(c) { |
|
| 102 | + | grabbuttons(c, True); |
|
| 103 | + | drawtitle(c); |
|
| 104 | + | XSetInputFocus(dpy, c->win, RevertToPointerRoot, CurrentTime); |
|
| 97 | 105 | } |
|
| 98 | - | grabbuttons(c, True); |
|
| 99 | - | drawtitle(c); |
|
| 100 | - | XSetInputFocus(dpy, c->win, RevertToPointerRoot, CurrentTime); |
|
| 106 | + | else |
|
| 107 | + | XSetInputFocus(dpy, root, RevertToPointerRoot, CurrentTime); |
|
| 101 | 108 | } |
|
| 102 | 109 | ||
| 103 | 110 | Client * |
|
| 247 | 254 | clients = c; |
|
| 248 | 255 | ||
| 249 | 256 | settitle(c); |
|
| 250 | - | if(isvisible(c)) |
|
| 251 | - | sel = c; |
|
| 252 | 257 | arrange(NULL); |
|
| 253 | 258 | XMapWindow(dpy, c->win); |
|
| 254 | 259 | XMapWindow(dpy, c->twin); |
|
| 366 | 371 | togglemax(Arg *arg) |
|
| 367 | 372 | { |
|
| 368 | 373 | int ox, oy, ow, oh; |
|
| 374 | + | Client *c; |
|
| 369 | 375 | XEvent ev; |
|
| 370 | 376 | ||
| 371 | 377 | if(!sel) |
|
| 372 | 378 | return; |
|
| 373 | 379 | ||
| 374 | - | if((sel->ismax = !sel->ismax)) { |
|
| 380 | + | if((maximized = !maximized)) { |
|
| 375 | 381 | ox = sel->x; |
|
| 376 | 382 | oy = sel->y; |
|
| 377 | 383 | ow = sel->w; |
|
| 382 | 388 | sel->h = sh - 2 - bh; |
|
| 383 | 389 | ||
| 384 | 390 | restack(); |
|
| 391 | + | for(c = getnext(clients); c; c = getnext(c->next)) |
|
| 392 | + | if(c != sel) |
|
| 393 | + | ban(c); |
|
| 385 | 394 | resize(sel, arrange == dofloat, TopLeft); |
|
| 386 | 395 | ||
| 387 | 396 | sel->x = ox; |
|
| 390 | 399 | sel->h = oh; |
|
| 391 | 400 | } |
|
| 392 | 401 | else |
|
| 393 | - | resize(sel, False, TopLeft); |
|
| 402 | + | arrange(NULL); |
|
| 394 | 403 | while(XCheckMaskEvent(dpy, EnterWindowMask, &ev)); |
|
| 395 | 404 | } |
|
| 396 | 405 | ||
| 397 | 406 | void |
|
| 398 | 407 | unmanage(Client *c) |
|
| 399 | 408 | { |
|
| 400 | - | Client *tc; |
|
| 409 | + | Client *tc, *fc; |
|
| 401 | 410 | Window trans; |
|
| 402 | 411 | XGrabServer(dpy); |
|
| 403 | 412 | XSetErrorHandler(xerrordummy); |
|
| 404 | - | ||
| 405 | - | XGetTransientForHint(dpy, c->win, &trans); |
|
| 406 | - | ||
| 407 | - | XUngrabButton(dpy, AnyButton, AnyModifier, c->win); |
|
| 408 | - | XDestroyWindow(dpy, c->twin); |
|
| 409 | 413 | ||
| 410 | 414 | detach(c); |
|
| 411 | 415 | if(sel == c) { |
|
| 416 | + | XGetTransientForHint(dpy, c->win, &trans); |
|
| 412 | 417 | if(trans && (tc = getclient(trans)) && isvisible(tc)) |
|
| 413 | - | sel = tc; |
|
| 418 | + | fc = tc; |
|
| 414 | 419 | else |
|
| 415 | - | sel = getnext(clients); |
|
| 420 | + | fc = getnext(clients); |
|
| 421 | + | focus(fc); |
|
| 416 | 422 | } |
|
| 423 | + | ||
| 424 | + | XUngrabButton(dpy, AnyButton, AnyModifier, c->win); |
|
| 425 | + | XDestroyWindow(dpy, c->twin); |
|
| 426 | + | ||
| 417 | 427 | free(c->tags); |
|
| 418 | 428 | free(c); |
|
| 419 | 429 | ||
| 420 | 430 | XSync(dpy, False); |
|
| 421 | 431 | XSetErrorHandler(xerror); |
|
| 422 | 432 | XUngrabServer(dpy); |
|
| 423 | - | if(sel) |
|
| 424 | - | focus(sel); |
|
| 425 | 433 | arrange(NULL); |
|
| 426 | 434 | } |
|
| 58 | 58 | long flags; |
|
| 59 | 59 | unsigned int border, weight; |
|
| 60 | 60 | Bool isfloat; |
|
| 61 | - | Bool ismax; |
|
| 62 | 61 | Bool *tags; |
|
| 63 | 62 | Client *next; |
|
| 64 | 63 | Client *prev; |
|
| 73 | 72 | extern void (*handler[LASTEvent])(XEvent *); |
|
| 74 | 73 | extern void (*arrange)(Arg *); |
|
| 75 | 74 | extern Atom wmatom[WMLast], netatom[NetLast]; |
|
| 76 | - | extern Bool running, issel, *seltag; |
|
| 75 | + | extern Bool running, issel, maximized, *seltag; |
|
| 77 | 76 | extern Client *clients, *sel; |
|
| 78 | 77 | extern Cursor cursor[CurLast]; |
|
| 79 | 78 | extern DC dc; |
|
| 131 | 131 | } |
|
| 132 | 132 | else if((c = getclient(ev->window))) { |
|
| 133 | 133 | focus(c); |
|
| 134 | - | if(c->ismax || CLEANMASK(ev->state) != MODKEY) |
|
| 134 | + | if(maximized || CLEANMASK(ev->state) != MODKEY) |
|
| 135 | 135 | return; |
|
| 136 | - | if((ev->button == Button1) && ((arrange == dofloat) || c->isfloat)) { |
|
| 136 | + | if(ev->button == Button1 && (arrange == dofloat || c->isfloat)) { |
|
| 137 | 137 | restack(c); |
|
| 138 | 138 | movemouse(c); |
|
| 139 | 139 | } |
|
| 140 | 140 | else if(ev->button == Button2) |
|
| 141 | 141 | zoom(NULL); |
|
| 142 | - | else if(ev->button == Button3 && ((arrange == dofloat) || c->isfloat)) { |
|
| 142 | + | else if(ev->button == Button3 && (arrange == dofloat || c->isfloat)) { |
|
| 143 | 143 | restack(c); |
|
| 144 | 144 | resizemouse(c); |
|
| 145 | 145 | } |
|
| 173 | 173 | XWindowChanges wc; |
|
| 174 | 174 | ||
| 175 | 175 | if((c = getclient(ev->window))) { |
|
| 176 | - | if(!c->isfloat && (arrange != dofloat) && c->ismax) { |
|
| 176 | + | if((c == sel) && !c->isfloat && (arrange != dofloat) && maximized) { |
|
| 177 | 177 | synconfig(c, sx, sy + bh, sw - 2, sh - 2 - bh, ev->border_width); |
|
| 178 | 178 | XSync(dpy, False); |
|
| 179 | 179 | return; |
|
| 24 | 24 | Atom wmatom[WMLast], netatom[NetLast]; |
|
| 25 | 25 | Bool running = True; |
|
| 26 | 26 | Bool issel = True; |
|
| 27 | + | Bool maximized = False; |
|
| 27 | 28 | Client *clients = NULL; |
|
| 28 | 29 | Client *sel = NULL; |
|
| 29 | 30 | Cursor cursor[CurLast]; |
| 57 | 57 | void |
|
| 58 | 58 | dofloat(Arg *arg) |
|
| 59 | 59 | { |
|
| 60 | - | Client *c; |
|
| 60 | + | Client *c, *fc; |
|
| 61 | + | ||
| 62 | + | maximized = False; |
|
| 61 | 63 | ||
| 62 | 64 | for(c = clients; c; c = c->next) { |
|
| 63 | - | c->ismax = False; |
|
| 64 | 65 | if(isvisible(c)) { |
|
| 65 | 66 | resize(c, True, TopLeft); |
|
| 66 | 67 | } |
|
| 67 | 68 | else |
|
| 68 | 69 | ban(c); |
|
| 69 | 70 | } |
|
| 70 | - | if(!sel || !isvisible(sel)) |
|
| 71 | - | sel = getnext(clients); |
|
| 72 | - | if(sel) |
|
| 73 | - | focus(sel); |
|
| 74 | - | else |
|
| 75 | - | XSetInputFocus(dpy, root, RevertToPointerRoot, CurrentTime); |
|
| 71 | + | if(!(fc = sel) || !isvisible(fc)) |
|
| 72 | + | fc = getnext(clients); |
|
| 73 | + | focus(fc); |
|
| 76 | 74 | restack(); |
|
| 77 | 75 | } |
|
| 78 | 76 | ||
| 80 | 78 | dotile(Arg *arg) |
|
| 81 | 79 | { |
|
| 82 | 80 | int h, i, n, w; |
|
| 83 | - | Client *c; |
|
| 81 | + | Client *c, *fc; |
|
| 82 | + | ||
| 83 | + | maximized = False; |
|
| 84 | 84 | ||
| 85 | 85 | w = sw - mw; |
|
| 86 | 86 | for(n = 0, c = clients; c; c = c->next) |
|
| 93 | 93 | h = sh - bh; |
|
| 94 | 94 | ||
| 95 | 95 | for(i = 0, c = clients; c; c = c->next) { |
|
| 96 | - | c->ismax = False; |
|
| 97 | 96 | if(isvisible(c)) { |
|
| 98 | 97 | if(c->isfloat) { |
|
| 99 | 98 | resize(c, True, TopLeft); |
|
| 132 | 131 | else |
|
| 133 | 132 | ban(c); |
|
| 134 | 133 | } |
|
| 135 | - | if(!sel || !isvisible(sel)) |
|
| 136 | - | sel = getnext(clients); |
|
| 137 | - | if(sel) |
|
| 138 | - | focus(sel); |
|
| 139 | - | else |
|
| 140 | - | XSetInputFocus(dpy, root, RevertToPointerRoot, CurrentTime); |
|
| 134 | + | if(!(fc = sel) || !isvisible(fc)) |
|
| 135 | + | fc = getnext(clients); |
|
| 136 | + | focus(fc); |
|
| 141 | 137 | restack(); |
|
| 142 | 138 | } |
|
| 143 | 139 | ||
| 289 | 285 | { |
|
| 290 | 286 | Client *c = sel; |
|
| 291 | 287 | ||
| 292 | - | if(!c || (arrange != dotile) || c->isfloat || c->ismax) |
|
| 288 | + | if(!c || (arrange != dotile) || c->isfloat || maximized) |
|
| 293 | 289 | return; |
|
| 294 | 290 | ||
| 295 | 291 | if(c == getnext(clients)) |
|