Hello,
below is a patch that shortens grabbuttons() a bit.
Cheers,
Johannes
PS: I really appreciate the attitude to reconsider everything from
time to time - even though I'm quite satisfied with current dwm.
diff --git a/dwm.c b/dwm.c
--- a/dwm.c
+++ b/dwm.c
@@ -805,36 +805,18 @@
void
grabbuttons(Client *c, Bool focused) {
+ unsigned int Buttons[] = {Button1, Button2, Button3};
+ unsigned int Modifiers[] = {MODKEY, MODKEY|LockMask,
+ MODKEY|numlockmask, MODKEY|numlockmask|LockMask};
+ int i, j;
+
XUngrabButton(dpy, AnyButton, AnyModifier, c->win);
- if(focused) {
- XGrabButton(dpy, Button1, MODKEY, c->win, False, BUTTONMASK,
- GrabModeAsync, GrabModeSync, None, None);
- XGrabButton(dpy, Button1, MODKEY|LockMask, c->win, False, BUTTONMASK,
- GrabModeAsync, GrabModeSync, None, None);
- XGrabButton(dpy, Button1, MODKEY|numlockmask, c->win, False, BUTTONMASK,
- GrabModeAsync, GrabModeSync, None, None);
- XGrabButton(dpy, Button1, MODKEY|numlockmask|LockMask, c->win, False, BUTTONMASK,
- GrabModeAsync, GrabModeSync, None, None);
-
- XGrabButton(dpy, Button2, MODKEY, c->win, False, BUTTONMASK,
- GrabModeAsync, GrabModeSync, None, None);
- XGrabButton(dpy, Button2, MODKEY|LockMask, c->win, False, BUTTONMASK,
- GrabModeAsync, GrabModeSync, None, None);
- XGrabButton(dpy, Button2, MODKEY|numlockmask, c->win, False, BUTTONMASK,
- GrabModeAsync, GrabModeSync, None, None);
- XGrabButton(dpy, Button2, MODKEY|numlockmask|LockMask, c->win, False, BUTTONMASK,
- GrabModeAsync, GrabModeSync, None, None);
-
- XGrabButton(dpy, Button3, MODKEY, c->win, False, BUTTONMASK,
- GrabModeAsync, GrabModeSync, None, None);
- XGrabButton(dpy, Button3, MODKEY|LockMask, c->win, False, BUTTONMASK,
- GrabModeAsync, GrabModeSync, None, None);
- XGrabButton(dpy, Button3, MODKEY|numlockmask, c->win, False, BUTTONMASK,
- GrabModeAsync, GrabModeSync, None, None);
- XGrabButton(dpy, Button3, MODKEY|numlockmask|LockMask, c->win, False, BUTTONMASK,
- GrabModeAsync, GrabModeSync, None, None);
- }
+ if(focused)
+ for (i = 0; i < LENGTH(Buttons); i++)
+ for (j = 0; j < LENGTH(Modifiers); j++)
+ XGrabButton(dpy, Buttons[i], Modifiers[j], c->win, False,
+ BUTTONMASK, GrabModeAsync, GrabModeSync, None, None);
else
XGrabButton(dpy, AnyButton, AnyModifier, c->win, False, BUTTONMASK,
GrabModeAsync, GrabModeSync, None, None);
Received on Wed Apr 02 2008 - 19:07:03 UTC
This archive was generated by hypermail 2.2.0 : Sun Jul 13 2008 - 15:30:28 UTC