* Stuart Henderson <[email protected]> [120408 13:43]:
> On 2012/01/20 00:15, Alexander Polakov wrote:
> >  The obvious solution: just check for every possible modifier.
> 
> client.c: In function 'client_cycle':
> client.c:641: error: 'struct screen_ctx' has no member named 'altpersist'

It didn't apply cleanly without 2nd patch. This one should be fine:

Index: calmwm.h
===================================================================
RCS file: /cvs/xenocara/app/cwm/calmwm.h,v
retrieving revision 1.142
diff -u -p -u -r1.142 calmwm.h
--- calmwm.h    13 Sep 2011 08:41:57 -0000      1.142
+++ calmwm.h    8 Apr 2012 11:31:40 -0000
@@ -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;
@@ -306,6 +306,7 @@ __dead void          usage(void);
 void                    client_applysizehints(struct client_ctx *);
 struct client_ctx      *client_current(void);
 void                    client_cycle(struct screen_ctx *, int);
+void                    client_cycle_leave(struct screen_ctx *, struct 
client_ctx *);
 void                    client_delete(struct client_ctx *);
 void                    client_draw_border(struct client_ctx *);
 struct client_ctx      *client_find(Window);
Index: client.c
===================================================================
RCS file: /cvs/xenocara/app/cwm/client.c,v
retrieving revision 1.91
diff -u -p -u -r1.91 client.c
--- client.c    13 Sep 2011 08:41:57 -0000      1.91
+++ client.c    8 Apr 2012 11:31:41 -0000
@@ -228,7 +228,7 @@ client_setactive(struct client_ctx *cc, 
                 * 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);
@@ -637,10 +637,21 @@ client_cycle(struct screen_ctx *sc, int 
                }
        }
 
-       /* reset when alt is released. XXX I hate this hack */
-       sc->altpersist = 1;
+       /* reset when modkey is released. XXX I hate this hack */
+       sc->cycling = 1;
        client_ptrsave(oldcc);
        client_ptrwarp(newcc);
+}
+
+void
+client_cycle_leave(struct screen_ctx *sc, struct client_ctx *cc) 
+{
+       sc->cycling = 0;
+
+       client_mtf(NULL);
+       if (cc != NULL)
+               group_sticky_toggle_exit(cc);
+
 }
 
 static struct client_ctx *
Index: xevents.c
===================================================================
RCS file: /cvs/xenocara/app/cwm/xevents.c,v
retrieving revision 1.56
diff -u -p -u -r1.56 xevents.c
--- xevents.c   13 Sep 2011 08:41:57 -0000      1.56
+++ xevents.c   8 Apr 2012 11:31:42 -0000
@@ -70,6 +70,9 @@ void          (*xev_handlers[LASTEvent])(XEvent 
                        [MappingNotify] = xev_handle_mappingnotify,
 };
 
+static KeySym modkeys[] = { XK_Alt_L, XK_Alt_R, XK_Super_L, XK_Super_R,
+                           XK_Control_L, XK_Control_R };
+
 static void
 xev_handle_maprequest(XEvent *ee)
 {
@@ -314,7 +317,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)
@@ -322,26 +325,19 @@ xev_handle_keyrelease(XEvent *ee)
        XKeyEvent               *e = &ee->xkey;
        struct screen_ctx       *sc;
        struct client_ctx       *cc;
-       int                      keysym;
+       int                      i, keysym;
 
        sc = screen_fromroot(e->root);
        cc = client_current();
 
        keysym = XKeycodeToKeysym(X_Dpy, e->keycode, 0);
-       if (keysym != XK_Alt_L && keysym != XK_Alt_R)
-               return;
-
-       sc->altpersist = 0;
-
-       /*
-        * XXX - better interface... xevents should not know about
-        * how/when to mtf.
-        */
-       client_mtf(NULL);
-
-       if (cc != NULL) {
-               group_sticky_toggle_exit(cc);
-               XUngrabKeyboard(X_Dpy, CurrentTime);
+       for (i = 0; i < sizeof(modkeys)/sizeof(modkeys[0]); i++) {
+               if (keysym == modkeys[i]) {
+                       client_cycle_leave(sc, cc);
+                       if (cc)
+                               XUngrabKeyboard(X_Dpy, CurrentTime);
+                       break;
+               }
        }
 }
 

-- 
Alexander Polakov | plhk.ru

Reply via email to