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