summaryrefslogtreecommitdiffstats
path: root/client.c
diff options
context:
space:
mode:
authorAnselm R. Garbe <arg@10kloc.org>2006-09-04 08:55:49 +0200
committerAnselm R. Garbe <arg@10kloc.org>2006-09-04 08:55:49 +0200
commit26157e6973f240a9b5ee407b9d2d5eca9358844f (patch)
tree540e8c0d6b646782dc0a9fde26c3af6109103241 /client.c
parentsimplified buttonpress (diff)
downloaddwm-26157e6973f240a9b5ee407b9d2d5eca9358844f.tar.gz
dwm-26157e6973f240a9b5ee407b9d2d5eca9358844f.zip
applied Sanders max_and_focus.patch
Diffstat (limited to '')
-rw-r--r--client.c50
1 files changed, 29 insertions, 21 deletions
diff --git a/client.c b/client.c
index 9645444..8a8a99e 100644
--- a/client.c
+++ b/client.c
@@ -82,22 +82,29 @@ ban(Client *c)
82void 82void
83focus(Client *c) 83focus(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
103Client * 110Client *
@@ -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
366togglemax(Arg *arg) 371togglemax(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
397void 406void
398unmanage(Client *c) 407unmanage(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}