[hackers] [wmii] Relent and only grab AnyButton, AnyModifier on unfocused clients

From: Kris Maglione <jg_AT_suckless.org>
Date: Sat Feb 10 03:23:42 2007

changeset: 1820:d25576a3ebc0
tag: tip
user: Kris Maglione <jg_AT_suckless.org>
date: Fri Feb 09 21:19:26 2007 -0500
summary: Relent and only grab AnyButton, AnyModifier on unfocused clients

diff -r 7e0b21bccd96 -r d25576a3ebc0 client.c
--- a/client.c Fri Feb 09 18:16:15 2007 -0500
+++ b/client.c Fri Feb 09 21:19:26 2007 -0500
@@ -51,9 +51,8 @@ create_client(Window w, XWindowAttribute
                         DefaultDepth(blz.dpy, blz.screen), CopyFromParent,
                         DefaultVisual(blz.dpy, blz.screen),
                         CWOverrideRedirect | CWBackPixmap | CWEventMask, &fwa);
- XGrabButton(blz.dpy, AnyButton, AnyModifier, c->framewin, False, ButtonMask,
- GrabModeSync, GrabModeSync, None, None);
         c->gc = XCreateGC(blz.dpy, c->framewin, 0, 0);
+ update_client_grab(c);
         XSync(blz.dpy, False);
         for(t=&client; *t; t=&(*t)->next);
         c->next = *t; /* *t == nil */
@@ -143,6 +142,16 @@ update_client_name(Client *c) {
                         XFree(ch.res_name);
         }
 }
+void
+update_client_grab(Client *c) {
+ if(c == sel_client()) {
+ XUngrabButton(blz.dpy, AnyButton, AnyModifier, c->framewin);
+ grab_button(c->framewin, Button1, def.mod);
+ grab_button(c->framewin, Button3, def.mod);
+ }
+ else
+ grab_button(c->framewin, AnyButton, AnyModifier);
+}
 
 void
 set_client_state(Client * c, int state)
@@ -198,8 +207,11 @@ focus_client(Client *c, Bool restack) {
                 else
                         write_event("FocusFloating\n");
         }
- if(c != old)
+ if(c != old) {
+ update_client_grab(c);
+ update_client_grab(old);
                 write_event("ClientFocus 0x%x\n", c->win);
+ }
 }
 
 void
diff -r 7e0b21bccd96 -r d25576a3ebc0 mouse.c
--- a/mouse.c Fri Feb 09 18:16:15 2007 -0500
+++ b/mouse.c Fri Feb 09 21:19:26 2007 -0500
@@ -434,3 +434,15 @@ do_mouse_resize(Client *c, BlitzAlign al
                 }
         }
 }
+
+void
+grab_button(Window w, unsigned int button, unsigned long mod) {
+ XGrabButton(blz.dpy, button, mod, w, False, ButtonMask,
+ GrabModeSync, GrabModeSync, None, None);
+ if((mod != AnyModifier) && num_lock_mask) {
+ XGrabButton(blz.dpy, button, mod | num_lock_mask, w, False, ButtonMask,
+ GrabModeSync, GrabModeSync, None, None);
+ XGrabButton(blz.dpy, button, mod | num_lock_mask | LockMask, w, False,
+ ButtonMask, GrabModeSync, GrabModeSync, None, None);
+ }
+}
diff -r 7e0b21bccd96 -r d25576a3ebc0 wmii.h
--- a/wmii.h Fri Feb 09 18:16:15 2007 -0500
+++ b/wmii.h Fri Feb 09 21:19:26 2007 -0500
@@ -286,7 +286,7 @@ extern Client *sel_client();
 extern Client *sel_client();
 extern Frame *frame_of_win(Window w);
 extern Client *client_of_win(Window w);
-extern void update_client_grab(Client *c, Bool is_sel);
+extern void update_client_grab(Client *c);
 extern void apply_rules(Client *c);
 extern void apply_tags(Client *c, const char *tags);
 
@@ -361,6 +361,7 @@ extern void ungrab_mouse(Window w, unsig
 extern void ungrab_mouse(Window w, unsigned long mod, unsigned int button);
 extern BlitzAlign snap_rect(XRectangle *rects, int num, XRectangle *current,
                                          BlitzAlign *mask, int snap);
+extern void grab_button(Window w, unsigned int button, unsigned long mod);
 
 /* rule.c */
 extern void update_rules(Rule **rule, const char *data);
Received on Sat Feb 10 2007 - 03:23:42 UTC

This archive was generated by hypermail 2.2.0 : Sun Jul 13 2008 - 15:55:07 UTC