* Luis Henriques <hen...@camandro.org> [111230 02:21]:
> Hi,
> 
> I have been using for a while a hack to fix cwm windows cycle (the traditional
> Alt-Tab).  The problem is that I modified the default key binding but the
> code actually expects Alt to be the modifier.  The result is that, in some
> situations (e.g., after moving to a new group), the window does not get
> keyboard input until I hit the Alt key.
> 
> The code already uses some funny hack to handle this, but this hack does not
> work in my case (I'm using Mod4-Tab).  I'm attaching the patch that seems to
> sort this out, but I am not sure if there are any side effects (any x11 expert
> around?).

We should fix the hack, I guess. I see more than one way to do that.

1) dumb: check for Alt, Ctrl and Super(aka Mod4 aka Win) keys release

diff --git a/calmwm.h b/calmwm.h
index 3aaac3e..d03956b 100644
--- a/calmwm.h
+++ b/calmwm.h
@@ -202,7 +202,7 @@ struct screen_ctx {
        Window                   menuwin;
        struct color             color[CWM_COLOR_MAX];
        GC                       gc;
-       int                      altpersist;
+       int                      cycling;
        int                      xmax;
        int                      ymax;
        struct gap               gap;
diff --git a/client.c b/client.c
index 428b258..531432d 100644
--- a/client.c
+++ b/client.c
@@ -229,7 +229,7 @@ client_setactive(struct client_ctx *cc, int fg)
                 * If we're in the middle of alt-tabbing, don't change
                 * the order please.
                 */
-               if (!sc->altpersist)
+               if (!sc->cycling)
                        client_mtf(cc);
        } else
                client_leave(cc);
@@ -641,7 +641,7 @@ client_cycle(struct screen_ctx *sc, int flags)
        }
 
        /* reset when alt is released. XXX I hate this hack */
-       sc->altpersist = 1;
+       sc->cycling = 1;
        client_ptrsave(oldcc);
        client_ptrwarp(newcc);
 }
diff --git a/xevents.c b/xevents.c
index 2a3b49c..42feaa0 100644
--- a/xevents.c
+++ b/xevents.c
@@ -318,7 +318,7 @@ xev_handle_keypress(XEvent *ee)
 }
 
 /*
- * This is only used for the alt suppression detection.
+ * This is only used for the modifier suppression detection.
  */
 static void
 xev_handle_keyrelease(XEvent *ee)
@@ -332,10 +332,12 @@ xev_handle_keyrelease(XEvent *ee)
        cc = client_current();
 
        keysym = XKeycodeToKeysym(X_Dpy, e->keycode, 0);
-       if (keysym != XK_Alt_L && keysym != XK_Alt_R)
+       if ((keysym != XK_Alt_L && keysym != XK_Alt_R) &&
+           (keysym != XK_Super_L && keysym != XK_Super_R) &&
+           (keysym != XK_Control_L && keysym != XK_Control_R))
                return;
 
-       sc->altpersist = 0;
+       sc->cycling = 0;
 
        /*
         * XXX - better interface... xevents should not know about

2) a little bit smarter: we can extract keybinding search code from
handle_keypress(), search for cycle keybinding and check for their
modifier keys only (I can cook a diff by request).

3) something really smart

Or we can kill the idea of "most recently used goes first".
 
-- 
Alexander Polakov | plhk.ru

Reply via email to