*
*/
void grab_all_keys(xcb_connection_t *conn, bool bind_mode_switch);
+
+/**
+ * Returns a pointer to the keyboard Binding with the specified modifiers and
+ * keycode or NULL if no such binding exists.
+ *
+ */
+Binding *get_keyboard_binding(uint16_t modifiers, bool key_release, xcb_keycode_t keycode);
*
*/void update_barconfig();
-/**
- * Returns a pointer to the Binding with the specified modifiers and keycode
- * or NULL if no such binding exists.
- *
- */
-Binding *get_binding(uint16_t modifiers, bool key_release, xcb_keycode_t keycode);
-
/**
* Kills the configerror i3-nagbar process, if any.
*
grab_keycode_for_binding(conn, bind, *walk++);
}
}
+
+/*
+ * Returns a pointer to the keyboard Binding with the specified modifiers and
+ * keycode or NULL if no such binding exists.
+ *
+ */
+Binding *get_keyboard_binding(uint16_t modifiers, bool key_release, xcb_keycode_t keycode) {
+ Binding *bind;
+
+ if (!key_release) {
+ /* On a KeyPress event, we first reset all
+ * B_UPON_KEYRELEASE_IGNORE_MODS bindings back to B_UPON_KEYRELEASE */
+ TAILQ_FOREACH(bind, bindings, bindings) {
+ if (bind->input_type != B_KEYBOARD)
+ continue;
+ if (bind->release == B_UPON_KEYRELEASE_IGNORE_MODS)
+ bind->release = B_UPON_KEYRELEASE;
+ }
+ }
+
+ TAILQ_FOREACH(bind, bindings, bindings) {
+ /* First compare the modifiers (unless this is a
+ * B_UPON_KEYRELEASE_IGNORE_MODS binding and this is a KeyRelease
+ * event) */
+ if (bind->input_type != B_KEYBOARD)
+ continue;
+ if (bind->mods != modifiers &&
+ (bind->release != B_UPON_KEYRELEASE_IGNORE_MODS ||
+ !key_release))
+ continue;
+
+ /* If a symbol was specified by the user, we need to look in
+ * the array of translated keycodes for the event’s keycode */
+ if (bind->symbol != NULL) {
+ if (memmem(bind->translated_to,
+ bind->number_keycodes * sizeof(xcb_keycode_t),
+ &keycode, sizeof(xcb_keycode_t)) == NULL)
+ continue;
+ } else {
+ /* This case is easier: The user specified a keycode */
+ if (bind->keycode != keycode)
+ continue;
+ }
+
+ /* If this keybinding is a KeyRelease binding, it matches the key which
+ * the user pressed. We therefore mark it as
+ * B_UPON_KEYRELEASE_IGNORE_MODS for later, so that the user can
+ * release the modifiers before the actual key and the KeyRelease will
+ * still be matched. */
+ if (bind->release == B_UPON_KEYRELEASE && !key_release)
+ bind->release = B_UPON_KEYRELEASE_IGNORE_MODS;
+
+ /* Check if the binding is for a KeyPress or a KeyRelease event */
+ if ((bind->release == B_UPON_KEYPRESS && key_release) ||
+ (bind->release >= B_UPON_KEYRELEASE && !key_release))
+ continue;
+
+ break;
+ }
+
+ return (bind == TAILQ_END(bindings) ? NULL : bind);
+}
xcb_ungrab_key(conn, XCB_GRAB_ANY, root, XCB_BUTTON_MASK_ANY);
}
-/*
- * Returns a pointer to the Binding with the specified modifiers and keycode
- * or NULL if no such binding exists.
- *
- */
-Binding *get_binding(uint16_t modifiers, bool key_release, xcb_keycode_t keycode) {
- Binding *bind;
-
- if (!key_release) {
- /* On a KeyPress event, we first reset all
- * B_UPON_KEYRELEASE_IGNORE_MODS bindings back to B_UPON_KEYRELEASE */
- TAILQ_FOREACH(bind, bindings, bindings) {
- if (bind->release == B_UPON_KEYRELEASE_IGNORE_MODS)
- bind->release = B_UPON_KEYRELEASE;
- }
- }
-
- TAILQ_FOREACH(bind, bindings, bindings) {
- /* First compare the modifiers (unless this is a
- * B_UPON_KEYRELEASE_IGNORE_MODS binding and this is a KeyRelease
- * event) */
- if (bind->mods != modifiers &&
- (bind->release != B_UPON_KEYRELEASE_IGNORE_MODS ||
- !key_release))
- continue;
-
- /* If a symbol was specified by the user, we need to look in
- * the array of translated keycodes for the event’s keycode */
- if (bind->symbol != NULL) {
- if (memmem(bind->translated_to,
- bind->number_keycodes * sizeof(xcb_keycode_t),
- &keycode, sizeof(xcb_keycode_t)) == NULL)
- continue;
- } else {
- /* This case is easier: The user specified a keycode */
- if (bind->keycode != keycode)
- continue;
- }
-
- /* If this keybinding is a KeyRelease binding, it matches the key which
- * the user pressed. We therefore mark it as
- * B_UPON_KEYRELEASE_IGNORE_MODS for later, so that the user can
- * release the modifiers before the actual key and the KeyRelease will
- * still be matched. */
- if (bind->release == B_UPON_KEYRELEASE && !key_release)
- bind->release = B_UPON_KEYRELEASE_IGNORE_MODS;
-
- /* Check if the binding is for a KeyPress or a KeyRelease event */
- if ((bind->release == B_UPON_KEYPRESS && key_release) ||
- (bind->release >= B_UPON_KEYRELEASE && !key_release))
- continue;
-
- break;
- }
-
- return (bind == TAILQ_END(bindings) ? NULL : bind);
-}
-
/*
* Translates keysymbols to keycodes for all bindings which use keysyms.
*
DLOG("(checked mode_switch, state %d)\n", state_filtered);
/* Find the binding */
- Binding *bind = get_binding(state_filtered, key_release, event->detail);
+ Binding *bind = get_keyboard_binding(state_filtered, key_release, event->detail);
/* No match? Then the user has Mode_switch enabled but does not have a
* specific keybinding. Fall back to the default keybindings (without
if (bind == NULL) {
state_filtered &= ~(BIND_MODE_SWITCH);
DLOG("no match, new state_filtered = %d\n", state_filtered);
- if ((bind = get_binding(state_filtered, key_release, event->detail)) == NULL) {
+ if ((bind = get_keyboard_binding(state_filtered, key_release, event->detail)) == NULL) {
/* This is not a real error since we can have release and
* non-release keybindings. On a KeyPress event for which there is
* only a !release-binding, but no release-binding, the