commit 05d83dd29476c78cfb78e6f42c242ce4b4fa384d
parent 3db63de615446e43fecc94463f6ed82062b10ac2
Author: Kris Maglione <jg@suckless.org>
Date: Fri, 9 Feb 2007 21:19:26 -0500
Relent and only grab AnyButton, AnyModifier on unfocused clients
Diffstat:
3 files changed, 29 insertions(+), 4 deletions(-)
diff --git a/client.c b/client.c
@@ -51,9 +51,8 @@ create_client(Window w, XWindowAttributes *wa) {
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 --git a/mouse.c b/mouse.c
@@ -434,3 +434,15 @@ do_mouse_resize(Client *c, BlitzAlign align) {
}
}
}
+
+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 --git a/wmii.h b/wmii.h
@@ -286,7 +286,7 @@ extern void newcol_client(Client *c, char *arg);
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 grab_mouse(Window w, unsigned long mod, unsigned int button);
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);