dwm-meillo
diff client.c @ 400:052657ff2e7b
applied Sanders max_and_focus.patch
author | Anselm R. Garbe <arg@10kloc.org> |
---|---|
date | Mon, 04 Sep 2006 08:55:49 +0200 |
parents | b00cc483d13b |
children | 6413ea66b1c2 |
line diff
1.1 --- a/client.c Fri Sep 01 15:31:59 2006 +0200 1.2 +++ b/client.c Mon Sep 04 08:55:49 2006 +0200 1.3 @@ -82,22 +82,29 @@ 1.4 void 1.5 focus(Client *c) 1.6 { 1.7 - Client *old = sel; 1.8 + Client *old; 1.9 1.10 if(!issel) 1.11 return; 1.12 if(!sel) 1.13 sel = c; 1.14 else if(sel != c) { 1.15 - if(sel->ismax) 1.16 + if(maximized) 1.17 togglemax(NULL); 1.18 + old = sel; 1.19 sel = c; 1.20 - grabbuttons(old, False); 1.21 - drawtitle(old); 1.22 + if(old) { 1.23 + grabbuttons(old, False); 1.24 + drawtitle(old); 1.25 + } 1.26 } 1.27 - grabbuttons(c, True); 1.28 - drawtitle(c); 1.29 - XSetInputFocus(dpy, c->win, RevertToPointerRoot, CurrentTime); 1.30 + if(c) { 1.31 + grabbuttons(c, True); 1.32 + drawtitle(c); 1.33 + XSetInputFocus(dpy, c->win, RevertToPointerRoot, CurrentTime); 1.34 + } 1.35 + else 1.36 + XSetInputFocus(dpy, root, RevertToPointerRoot, CurrentTime); 1.37 } 1.38 1.39 Client * 1.40 @@ -247,8 +254,6 @@ 1.41 clients = c; 1.42 1.43 settitle(c); 1.44 - if(isvisible(c)) 1.45 - sel = c; 1.46 arrange(NULL); 1.47 XMapWindow(dpy, c->win); 1.48 XMapWindow(dpy, c->twin); 1.49 @@ -366,12 +371,13 @@ 1.50 togglemax(Arg *arg) 1.51 { 1.52 int ox, oy, ow, oh; 1.53 + Client *c; 1.54 XEvent ev; 1.55 1.56 if(!sel) 1.57 return; 1.58 1.59 - if((sel->ismax = !sel->ismax)) { 1.60 + if((maximized = !maximized)) { 1.61 ox = sel->x; 1.62 oy = sel->y; 1.63 ow = sel->w; 1.64 @@ -382,6 +388,9 @@ 1.65 sel->h = sh - 2 - bh; 1.66 1.67 restack(); 1.68 + for(c = getnext(clients); c; c = getnext(c->next)) 1.69 + if(c != sel) 1.70 + ban(c); 1.71 resize(sel, arrange == dofloat, TopLeft); 1.72 1.73 sel->x = ox; 1.74 @@ -390,37 +399,36 @@ 1.75 sel->h = oh; 1.76 } 1.77 else 1.78 - resize(sel, False, TopLeft); 1.79 + arrange(NULL); 1.80 while(XCheckMaskEvent(dpy, EnterWindowMask, &ev)); 1.81 } 1.82 1.83 void 1.84 unmanage(Client *c) 1.85 { 1.86 - Client *tc; 1.87 + Client *tc, *fc; 1.88 Window trans; 1.89 XGrabServer(dpy); 1.90 XSetErrorHandler(xerrordummy); 1.91 1.92 - XGetTransientForHint(dpy, c->win, &trans); 1.93 + detach(c); 1.94 + if(sel == c) { 1.95 + XGetTransientForHint(dpy, c->win, &trans); 1.96 + if(trans && (tc = getclient(trans)) && isvisible(tc)) 1.97 + fc = tc; 1.98 + else 1.99 + fc = getnext(clients); 1.100 + focus(fc); 1.101 + } 1.102 1.103 XUngrabButton(dpy, AnyButton, AnyModifier, c->win); 1.104 XDestroyWindow(dpy, c->twin); 1.105 1.106 - detach(c); 1.107 - if(sel == c) { 1.108 - if(trans && (tc = getclient(trans)) && isvisible(tc)) 1.109 - sel = tc; 1.110 - else 1.111 - sel = getnext(clients); 1.112 - } 1.113 free(c->tags); 1.114 free(c); 1.115 1.116 XSync(dpy, False); 1.117 XSetErrorHandler(xerror); 1.118 XUngrabServer(dpy); 1.119 - if(sel) 1.120 - focus(sel); 1.121 arrange(NULL); 1.122 }