aewl
changeset 372:a9b4077ec058
applied sanders focus_ patches
author | Anselm R. Garbe <arg@10kloc.org> |
---|---|
date | Mon, 28 Aug 2006 08:06:50 +0200 |
parents | fc9d35252ab4 |
children | 44a55e6e46bf |
files | client.c event.c |
diffstat | 2 files changed, 49 insertions(+), 26 deletions(-) [+] |
line diff
1.1 --- a/client.c Mon Aug 28 08:02:29 2006 +0200 1.2 +++ b/client.c Mon Aug 28 08:06:50 2006 +0200 1.3 @@ -11,16 +11,42 @@ 1.4 /* static functions */ 1.5 1.6 static void 1.7 -grabbutton(Client *c, unsigned int button, unsigned int modifier) 1.8 +grabbuttons(Client *c, Bool focus) 1.9 { 1.10 - XGrabButton(dpy, button, modifier, c->win, False, BUTTONMASK, 1.11 - GrabModeAsync, GrabModeSync, None, None); 1.12 - XGrabButton(dpy, button, modifier | LockMask, c->win, False, BUTTONMASK, 1.13 - GrabModeAsync, GrabModeSync, None, None); 1.14 - XGrabButton(dpy, button, modifier | numlockmask, c->win, False, BUTTONMASK, 1.15 - GrabModeAsync, GrabModeSync, None, None); 1.16 - XGrabButton(dpy, button, modifier | numlockmask | LockMask, c->win, False, BUTTONMASK, 1.17 - GrabModeAsync, GrabModeSync, None, None); 1.18 + XUngrabButton(dpy, AnyButton, AnyModifier, c->win); 1.19 + 1.20 + if(focus) { 1.21 + XGrabButton(dpy, Button1, MODKEY, c->win, False, BUTTONMASK, 1.22 + GrabModeAsync, GrabModeSync, None, None); 1.23 + XGrabButton(dpy, Button1, MODKEY | LockMask, c->win, False, BUTTONMASK, 1.24 + GrabModeAsync, GrabModeSync, None, None); 1.25 + XGrabButton(dpy, Button1, MODKEY | numlockmask, c->win, False, BUTTONMASK, 1.26 + GrabModeAsync, GrabModeSync, None, None); 1.27 + XGrabButton(dpy, Button1, MODKEY | numlockmask | LockMask, c->win, False, BUTTONMASK, 1.28 + GrabModeAsync, GrabModeSync, None, None); 1.29 + 1.30 + XGrabButton(dpy, Button2, MODKEY, c->win, False, BUTTONMASK, 1.31 + GrabModeAsync, GrabModeSync, None, None); 1.32 + XGrabButton(dpy, Button2, MODKEY | LockMask, c->win, False, BUTTONMASK, 1.33 + GrabModeAsync, GrabModeSync, None, None); 1.34 + XGrabButton(dpy, Button2, MODKEY | numlockmask, c->win, False, BUTTONMASK, 1.35 + GrabModeAsync, GrabModeSync, None, None); 1.36 + XGrabButton(dpy, Button2, MODKEY | numlockmask | LockMask, c->win, False, BUTTONMASK, 1.37 + GrabModeAsync, GrabModeSync, None, None); 1.38 + 1.39 + XGrabButton(dpy, Button3, MODKEY, c->win, False, BUTTONMASK, 1.40 + GrabModeAsync, GrabModeSync, None, None); 1.41 + XGrabButton(dpy, Button3, MODKEY | LockMask, c->win, False, BUTTONMASK, 1.42 + GrabModeAsync, GrabModeSync, None, None); 1.43 + XGrabButton(dpy, Button3, MODKEY | numlockmask, c->win, False, BUTTONMASK, 1.44 + GrabModeAsync, GrabModeSync, None, None); 1.45 + XGrabButton(dpy, Button3, MODKEY | numlockmask | LockMask, c->win, False, BUTTONMASK, 1.46 + GrabModeAsync, GrabModeSync, None, None); 1.47 + } 1.48 + else 1.49 + XGrabButton(dpy, AnyButton, AnyModifier, c->win, False, BUTTONMASK, 1.50 + GrabModeAsync, GrabModeSync, None, None); 1.51 + 1.52 } 1.53 1.54 static void 1.55 @@ -40,15 +66,6 @@ 1.56 1.57 } 1.58 1.59 -static void 1.60 -ungrabbutton(Client *c, unsigned int button, unsigned int modifier) 1.61 -{ 1.62 - XUngrabButton(dpy, button, modifier, c->win); 1.63 - XUngrabButton(dpy, button, modifier | LockMask, c->win); 1.64 - XUngrabButton(dpy, button, modifier | numlockmask, c->win); 1.65 - XUngrabButton(dpy, button, modifier | numlockmask | LockMask, c->win); 1.66 -} 1.67 - 1.68 static int 1.69 xerrordummy(Display *dsply, XErrorEvent *ee) 1.70 { 1.71 @@ -77,10 +94,10 @@ 1.72 if(sel->ismax) 1.73 togglemax(NULL); 1.74 sel = c; 1.75 - grabbutton(old, AnyButton, 0); 1.76 + grabbuttons(old, False); 1.77 drawtitle(old); 1.78 } 1.79 - ungrabbutton(c, AnyButton, 0); 1.80 + grabbuttons(c, True); 1.81 drawtitle(c); 1.82 XSetInputFocus(dpy, c->win, RevertToPointerRoot, CurrentTime); 1.83 } 1.84 @@ -220,9 +237,7 @@ 1.85 c->next = clients; 1.86 clients = c; 1.87 1.88 - grabbutton(c, Button1, MODKEY); 1.89 - grabbutton(c, Button2, MODKEY); 1.90 - grabbutton(c, Button3, MODKEY); 1.91 + grabbuttons(c, False); 1.92 1.93 if((tc = getclient(trans))) /* inherit tags */ 1.94 for(i = 0; i < ntags; i++) 1.95 @@ -384,9 +399,13 @@ 1.96 void 1.97 unmanage(Client *c) 1.98 { 1.99 + Client *tc; 1.100 + Window trans; 1.101 XGrabServer(dpy); 1.102 XSetErrorHandler(xerrordummy); 1.103 1.104 + XGetTransientForHint(dpy, c->win, &trans); 1.105 + 1.106 XUngrabButton(dpy, AnyButton, AnyModifier, c->win); 1.107 XDestroyWindow(dpy, c->twin); 1.108 1.109 @@ -396,8 +415,12 @@ 1.110 c->next->prev = c->prev; 1.111 if(c == clients) 1.112 clients = c->next; 1.113 - if(sel == c) 1.114 - sel = getnext(clients); 1.115 + if(sel == c) { 1.116 + if(trans && (tc = getclient(trans)) && isvisible(tc)) 1.117 + sel = tc; 1.118 + else 1.119 + sel = getnext(clients); 1.120 + } 1.121 free(c->tags); 1.122 free(c); 1.123
2.1 --- a/event.c Mon Aug 28 08:02:29 2006 +0200 2.2 +++ b/event.c Mon Aug 28 08:06:50 2006 +0200 2.3 @@ -123,7 +123,7 @@ 2.4 } 2.5 else if((c = getclient(ev->window))) { 2.6 focus(c); 2.7 - if(CLEANMASK(ev->state) == 0) 2.8 + if(CLEANMASK(ev->state) != MODKEY) 2.9 return; 2.10 switch(ev->button) { 2.11 default: