The purpose of the following change is to alleviate the overconfigging
necessary to use a main modmask besides Meta/Alt with cwm's default
binds. Since Alt (like Ctrl and Shift) is useful (and sometimes perhaps
necessary) for normal programs, it's less than desirable for the wm to
be grabbing it. A lot of keyboards have a Mod4 key (Super key,
"windows" key, etc.) that could be used instead, so this config option
sets the modifiers on all binds using Meta with Mod4. This took my
cwmrc from 82 lines of tedious unbinding and rebinding of defaults to
not use Meta down to merely 22 lines of a few config options and a
handful of _actual_ user-defined binds, as it should be. I hope this
will be seen as useful.

Index: calmwm.h
===================================================================
RCS file: /cvs/xenocara/app/cwm/calmwm.h,v
retrieving revision 1.94
diff -u -r1.94 calmwm.h
--- calmwm.h    26 Jun 2009 12:21:58 -0000      1.94
+++ calmwm.h    29 Jun 2009 13:39:54 -0000
@@ -260,6 +260,7 @@
        struct mousebinding_q    mousebindingq;
 
 #define        CONF_STICKY_GROUPS       0x0001
+#define        CONF_USE_MOD4            0x0002
        int                      flags;
 #define CONF_BWIDTH             1
        int                      bwidth;
Index: cwmrc.5
===================================================================
RCS file: /cvs/xenocara/app/cwm/cwmrc.5,v
retrieving revision 1.25
diff -u -r1.25 cwmrc.5
--- cwmrc.5     17 May 2009 23:40:57 -0000      1.25
+++ cwmrc.5     29 Jun 2009 13:39:55 -0000
@@ -192,6 +192,10 @@
 By enabling sticky group mode,
 .Xr cwm 1
 will assign new windows to the currently selected group.
+.Pp
+.It Ic usemod4 Ic yes Ns \&| Ns Ic no
+Use the Mod4 key (normally the windows key) instead
+of the Meta key in all keyboard and mouse binds.
 .El
 .Sh EXAMPLE CONFIGURATION
 .Bd -literal
Index: parse.y
===================================================================
RCS file: /cvs/xenocara/app/cwm/parse.y,v
retrieving revision 1.21
diff -u -r1.21 parse.y
--- parse.y     20 Jun 2009 00:22:39 -0000      1.21
+++ parse.y     29 Jun 2009 13:39:55 -0000
@@ -64,7 +64,7 @@
 
 %}
 
-%token FONTNAME STICKY GAP MOUSEBIND
+%token FONTNAME STICKY USEMOD4 GAP MOUSEBIND
 %token AUTOGROUP BIND COMMAND IGNORE
 %token YES NO BORDERWIDTH MOVEAMOUNT
 %token COLOR
@@ -111,6 +111,12 @@
                        else
                                conf->flags |= CONF_STICKY_GROUPS;
                }
+               | USEMOD4 yesno {
+                       if ($2 == 0)
+                               conf->flags &= ~CONF_USE_MOD4;
+                       else
+                               conf->flags |= CONF_USE_MOD4;
+               }
                | BORDERWIDTH NUMBER {
                        conf->bwidth = $2;
                }
@@ -243,6 +249,7 @@
                { "no",                 NO},
                { "sticky",             STICKY},
                { "ungroupborder",      UNGROUPBORDER},
+               { "usemod4",            USEMOD4},
                { "yes",                YES}
        };
        const struct keywords   *p;
@@ -559,6 +566,21 @@
                while ((mb = TAILQ_FIRST(&conf->mousebindingq)) != NULL) {
                        TAILQ_REMOVE(&conf->mousebindingq, mb, entry);
                        TAILQ_INSERT_TAIL(&xconf->mousebindingq, mb, entry);
+               }
+
+               if (conf->flags & CONF_USE_MOD4) {
+                       TAILQ_FOREACH(kb, &xconf->keybindingq, entry)
+                               if (kb->modmask & Mod1Mask) {
+                                       conf_ungrab(xconf, kb);
+                                       kb->modmask &= ~Mod1Mask;
+                                       kb->modmask |= Mod4Mask;
+                                       conf_grab(xconf, kb);
+                               }
+                       TAILQ_FOREACH(mb, &xconf->mousebindingq, entry)
+                               if (mb->modmask & Mod1Mask) {
+                                       mb->modmask &= ~Mod1Mask;
+                                       mb->modmask |= Mod4Mask;
+                               }
                }
 
                strlcpy(xconf->termpath, conf->termpath,

Reply via email to