]> git.sur5r.net Git - i3/i3/blobdiff - src/bindings.c
Bugfix: set group mask 1 by default, correctly compare modifiers
[i3/i3] / src / bindings.c
index b5f3190146a78382131bf40ea15ebdb94a5b12c5..7ea087e6191179014ca66a4a9983676c9bf645c5 100644 (file)
@@ -166,15 +166,23 @@ static Binding *get_binding(i3_event_state_mask_t state_filtered, bool is_releas
     }
 
     TAILQ_FOREACH(bind, bindings, bindings) {
+        bool state_matches;
+        if ((bind->event_state_mask & 0xFFFF) == 0) {
+            /* Verify no modifiers are pressed. A bitwise AND would lead to
+             * false positives, see issue #2002. */
+            state_matches = (state_filtered == bind->event_state_mask);
+        } else {
+            state_matches = ((state_filtered & bind->event_state_mask) == bind->event_state_mask);
+        }
+
         DLOG("binding with event_state_mask 0x%x, state_filtered 0x%x, match: %s\n",
-             bind->event_state_mask, state_filtered,
-             ((state_filtered & bind->event_state_mask) == bind->event_state_mask) ? "yes" : "no");
+             bind->event_state_mask, state_filtered, (state_matches ? "yes" : "no"));
         /* First compare the state_filtered (unless this is a
          * B_UPON_KEYRELEASE_IGNORE_MODS binding and this is a KeyRelease
          * event) */
         if (bind->input_type != input_type)
             continue;
-        if ((state_filtered & bind->event_state_mask) != bind->event_state_mask &&
+        if (!state_matches &&
             (bind->release != B_UPON_KEYRELEASE_IGNORE_MODS ||
              !is_release))
             continue;
@@ -413,6 +421,7 @@ void translate_keysyms(void) {
     }
 
     xkb_state_unref(dummy_state);
+    xkb_state_unref(dummy_state_no_shift);
 
     if (has_errors) {
         start_config_error_nagbar(current_configpath, true);