This patch changes the keybinding check in cycling keyrelease.

Now, the variable binding contains the keypressed, so we can
check if the key pressed is the same than the keybinding. If
the keybinding is different (user press other key) then finish.

Without the loop, the code is faster.

Then, the keybinding variable is not used anymore, and can be removed.

Signed-off-by: Rodolfo García Peñas (kix) <k...@kix.es>
---
 src/cycling.c | 31 ++++---------------------------
 1 file changed, 4 insertions(+), 27 deletions(-)

diff --git a/src/cycling.c b/src/cycling.c
index 2cba22b..bc638be 100644
--- a/src/cycling.c
+++ b/src/cycling.c
@@ -82,7 +82,6 @@ static WWindow *change_focus_and_raise(WWindow *newFocused, 
WWindow *oldFocused,
 void StartWindozeCycle(WWindow *wwin, XEvent *event, Bool next, Bool 
class_only)
 {
 
-       XModifierKeymap *keymap        = NULL;
        WShortKey binding;
        WSwitchPanel    *swpanel       = NULL;
        WScreen         *scr           = wScreenForRootWindow(event->xkey.root);
@@ -120,10 +119,8 @@ void StartWindozeCycle(WWindow *wwin, XEvent *event, Bool 
next, Bool class_only)
        }
 
        hasModifier = (binding.modifier != 0);
-       if (hasModifier) {
-               keymap = XGetModifierMapping(dpy);
+       if (hasModifier)
                XGrabKeyboard(dpy, scr->root_win, False, GrabModeAsync, 
GrabModeAsync, CurrentTime);
-       }
 
        scr->flags.doing_alt_tab = 1;
 
@@ -131,7 +128,6 @@ void StartWindozeCycle(WWindow *wwin, XEvent *event, Bool 
next, Bool class_only)
        oldFocused = wwin;
 
        if (swpanel) {
-
                if (wwin->flags.mapped && !wPreferences.panel_only_open)
                        newFocused = wSwitchPanelSelectNext(swpanel, !next, 
True, False);
                else
@@ -146,8 +142,6 @@ void StartWindozeCycle(WWindow *wwin, XEvent *event, Bool 
next, Bool class_only)
        }
 
        while (hasModifier && !done) {
-               int i;
-
                WMMaskEvent(dpy, KeyPressMask | KeyReleaseMask | ExposureMask
                            | PointerMotionMask | ButtonReleaseMask | 
EnterWindowMask, &ev);
 
@@ -158,9 +152,7 @@ void StartWindozeCycle(WWindow *wwin, XEvent *event, Bool 
next, Bool class_only)
                        break;
 
                switch (ev.type) {
-
                case KeyPress:
-
                        if ((wKeyBindings[WKBD_FOCUSNEXT].keycode == 
ev.xkey.keycode
                             && wKeyBindings[WKBD_FOCUSNEXT].modifier == 
modifiers)
                            || (wKeyBindings[WKBD_GROUPNEXT].keycode == 
ev.xkey.keycode
@@ -205,7 +197,6 @@ void StartWindozeCycle(WWindow *wwin, XEvent *event, Bool 
next, Bool class_only)
                        break;
 
                case KeyRelease:
-
                        if (ev.xkey.keycode == shiftLKey || ev.xkey.keycode == 
shiftRKey)
                                if (wPreferences.strict_windoze_cycle)
                                        break;
@@ -213,19 +204,9 @@ void StartWindozeCycle(WWindow *wwin, XEvent *event, Bool 
next, Bool class_only)
                        if (ev.xkey.keycode == XK_Return)
                                break;
 
-                       for (i = 0; i < 8 * keymap->max_keypermod; i++) {
-
-                               int mask = 1 << (i / keymap->max_keypermod);
+                       if (ev.xkey.keycode != binding.keycode)
+                               done = True;
 
-                               if (keymap->modifiermap[i] == ev.xkey.keycode &&
-                                   ((wKeyBindings[WKBD_FOCUSNEXT].modifier & 
mask)
-                                    || (wKeyBindings[WKBD_FOCUSPREV].modifier 
& mask)
-                                    || (wKeyBindings[WKBD_GROUPNEXT].modifier 
& mask)
-                                    || (wKeyBindings[WKBD_GROUPPREV].modifier 
& mask))) {
-                                       done = True;
-                                       break;
-                               }
-                       }
                        break;
 
                case EnterNotify:
@@ -255,13 +236,9 @@ void StartWindozeCycle(WWindow *wwin, XEvent *event, Bool 
next, Bool class_only)
                        break;
                }
        }
-       if (keymap)
-               XFreeModifiermap(keymap);
-
-       if (hasModifier) {
 
+       if (hasModifier)
                XUngrabKeyboard(dpy, CurrentTime);
-       }
 
        if (swpanel)
                wSwitchPanelDestroy(swpanel);
-- 
1.8.4.rc3


-- 
To unsubscribe, send mail to wmaker-dev-unsubscr...@lists.windowmaker.org.

Reply via email to