summaryrefslogtreecommitdiffstats
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
parentsimplified buttonpress (diff)
downloaddwm-26157e6973f240a9b5ee407b9d2d5eca9358844f.tar.gz
dwm-26157e6973f240a9b5ee407b9d2d5eca9358844f.zip
applied Sanders max_and_focus.patch
Diffstat (limited to '')
-rw-r--r--client.c50
-rw-r--r--dwm.h3
-rw-r--r--event.c8
-rw-r--r--main.c1
-rw-r--r--view.c30
5 files changed, 48 insertions, 44 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}
diff --git a/dwm.h b/dwm.h
index d8ce212..e1df6bc 100644
--- a/dwm.h
+++ b/dwm.h
@@ -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;
73extern void (*handler[LASTEvent])(XEvent *); 72extern void (*handler[LASTEvent])(XEvent *);
74extern void (*arrange)(Arg *); 73extern void (*arrange)(Arg *);
75extern Atom wmatom[WMLast], netatom[NetLast]; 74extern Atom wmatom[WMLast], netatom[NetLast];
76extern Bool running, issel, *seltag; 75extern Bool running, issel, maximized, *seltag;
77extern Client *clients, *sel; 76extern Client *clients, *sel;
78extern Cursor cursor[CurLast]; 77extern Cursor cursor[CurLast];
79extern DC dc; 78extern DC dc;
diff --git a/event.c b/event.c
index e5ea712..9974192 100644
--- a/event.c
+++ b/event.c
@@ -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;
diff --git a/main.c b/main.c
index 5dab0db..9856354 100644
--- a/main.c
+++ b/main.c
@@ -24,6 +24,7 @@ unsigned int ntags, numlockmask;
24Atom wmatom[WMLast], netatom[NetLast]; 24Atom wmatom[WMLast], netatom[NetLast];
25Bool running = True; 25Bool running = True;
26Bool issel = True; 26Bool issel = True;
27Bool maximized = False;
27Client *clients = NULL; 28Client *clients = NULL;
28Client *sel = NULL; 29Client *sel = NULL;
29Cursor cursor[CurLast]; 30Cursor cursor[CurLast];
diff --git a/view.c b/view.c
index 37b4fd7..86902d4 100644
--- a/view.c
+++ b/view.c
@@ -57,22 +57,20 @@ detach(Client *c)
57void 57void
58dofloat(Arg *arg) 58dofloat(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
80dotile(Arg *arg) 78dotile(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))