[hackers] [surf] Making more than one Modkey to work in keys. || Christoph Lohmann

From: <git_AT_suckless.org>
Date: Sat, 26 Jan 2013 16:01:11 +0100

commit 0415175e10880585c765613af0bd43e02de87116
Author: Christoph Lohmann <20h_AT_r-36.net>
Date: Sat Jan 26 16:00:52 2013 +0100

    Making more than one Modkey to work in keys.

diff --git a/config.def.h b/config.def.h
index 8a27a03..1cba4d7 100644
--- a/config.def.h
+++ b/config.def.h
_AT_@ -45,6 +45,10 @@ static Bool hidebackground = FALSE;
 #define MODKEY GDK_CONTROL_MASK
 
 /* hotkeys */
+/*
+ * If you use anything else but MODKEY and GDK_SHIFT_MASK, don't forget to
+ * edit the CLEANMASK() macro.
+ */
 static Key keys[] = {
     /* modifier keyval function arg Focus */
     { MODKEY|GDK_SHIFT_MASK,GDK_r, reload, { .b = TRUE } },
diff --git a/surf.c b/surf.c
index 14788e5..682c1e2 100644
--- a/surf.c
+++ b/surf.c
_AT_@ -28,6 +28,7 @@
 char *argv0;
 
 #define LENGTH(x) (sizeof x / sizeof x[0])
+#define CLEANMASK(mask) (mask & (MODKEY|GDK_SHIFT_MASK))
 #define COOKIEJAR_TYPE (cookiejar_get_type ())
 #define COOKIEJAR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), COOKIEJAR_TYPE, CookieJar))
 
_AT_@ -543,7 +544,7 @@ keypress(GtkWidget* w, GdkEventKey *ev, Client *c) {
         updatewinid(c);
         for(i = 0; i < LENGTH(keys); i++) {
                 if(gdk_keyval_to_lower(ev->keyval) == keys[i].keyval
- && (ev->state & keys[i].mod) == keys[i].mod
+ && CLEANMASK(ev->state) == keys[i].mod
                                 && keys[i].func) {
                         keys[i].func(c, &(keys[i].arg));
                         processed = TRUE;
Received on Sat Jan 26 2013 - 16:01:11 CET

This archive was generated by hypermail 2.3.0 : Sat Jan 26 2013 - 16:12:08 CET