]> Dogcows Code - chaz/openbox/blobdiff - openbox/actions/cyclewindows.c
get the modifier mask for a modifier key that is pressed/released more accurately...
[chaz/openbox] / openbox / actions / cyclewindows.c
index d1112242d6f1f7c74c495551e3623361507b97a3..6d852fdf8418ceafa65cc1cd06595e1f8d103074 100644 (file)
@@ -5,6 +5,7 @@
 #include "openbox/focus_cycle.h"
 #include "openbox/openbox.h"
 #include "gettext.h"
+#include "obt/keyboard.h"
 
 typedef struct {
     gboolean linear;
@@ -42,6 +43,7 @@ static void     free_func(gpointer options);
 static gboolean run_func(ObActionsData *data, gpointer options);
 static gboolean i_input_func(guint initial_state,
                              XEvent *e,
+                             ObtIC *ic,
                              gpointer options,
                              gboolean *used);
 static void     i_cancel_func(gpointer options);
@@ -63,7 +65,7 @@ static gpointer setup_func(xmlNodePtr node,
     xmlNodePtr n;
     Options *o;
 
-    o = g_new0(Options, 1);
+    o = g_slice_new0(Options);
     o->bar = TRUE;
     o->dialog_mode = OB_FOCUS_CYCLE_POPUP_MODE_LIST;
 
@@ -142,7 +144,7 @@ static void free_func(gpointer options)
         o->actions = g_slist_delete_link(o->actions, o->actions);
     }
 
-    g_free(o);
+    g_slice_free(Options, o);
 }
 
 static gboolean run_func(ObActionsData *data, gpointer options)
@@ -168,31 +170,39 @@ static gboolean run_func(ObActionsData *data, gpointer options)
 
 static gboolean i_input_func(guint initial_state,
                              XEvent *e,
+                             ObtIC *ic,
                              gpointer options,
                              gboolean *used)
 {
     Options *o = options;
+    guint mods;
+
+    mods = obt_keyboard_only_modmasks(e->xkey.state);
+    if (e->type == KeyRelease) {
+        /* remove from the state the mask of the modifier key being
+           released, if it is a modifier key being released that is */
+        mods &= ~obt_keyboard_keyevent_to_modmask(e);
+    }
 
     if (e->type == KeyPress) {
+        KeySym sym = obt_keyboard_keypress_to_keysym(e);
+
         /* Escape cancels no matter what */
-        if (ob_keycode_match(e->xkey.keycode, OB_KEY_ESCAPE)) {
+        if (sym == XK_Escape) {
             o->cancel = TRUE;
             o->state = e->xkey.state;
             return FALSE;
         }
 
         /* There were no modifiers and they pressed enter */
-        else if (ob_keycode_match(e->xkey.keycode, OB_KEY_RETURN) &&
-                 !initial_state)
-        {
+        else if (sym == XK_Return && !initial_state) {
             o->cancel = FALSE;
             o->state = e->xkey.state;
             return FALSE;
         }
     }
     /* They released the modifiers */
-    else if (e->type == KeyRelease && initial_state &&
-             (e->xkey.state & initial_state) == 0)
+    else if (e->type == KeyRelease && initial_state && !(mods & initial_state))
     {
         o->cancel = FALSE;
         o->state = e->xkey.state;
This page took 0.024551 seconds and 4 git commands to generate.