From c5ea41e87698a868e7280a52af0bd7da2968e2b1 Mon Sep 17 00:00:00 2001 From: Yannis Drougas Date: Wed, 9 Apr 2025 08:26:59 +0100 Subject: [PATCH] Add overrideInhibition to keyboard.keybind --- docs/labwc-config.5.scd | 8 +++++++- include/config/keybind.h | 1 + src/config/rcxml.c | 3 +++ src/input/keyboard.c | 6 ++++-- 4 files changed, 15 insertions(+), 3 deletions(-) diff --git a/docs/labwc-config.5.scd b/docs/labwc-config.5.scd index 061e57ad..ac94d54c 100644 --- a/docs/labwc-config.5.scd +++ b/docs/labwc-config.5.scd @@ -760,7 +760,8 @@ References: Stores the keyboard layout either globally or per window and restores it when switching back to the window. Default is global. -** +** Define a *key* binding in the format *modifier-key*, where supported modifiers are: - S (shift) @@ -808,6 +809,11 @@ References: *allowWhenLocked* [yes|no] Make this keybind work even if the screen is locked. Default is no. + *overrideInhibition* [yes|no] + Make this keybind work even if the view inhibits keybinds. Default is no. + This can be used to prevent W-Tab and similar keybinds from being + delivered to Virtual Machines, VNC clients or nested compositors. + *onRelease* [yes|no] When yes, fires the keybind action when the key or key combination is released, rather than first pressed. This is useful to diff --git a/include/config/keybind.h b/include/config/keybind.h index e3c9e21b..d02de387 100644 --- a/include/config/keybind.h +++ b/include/config/keybind.h @@ -23,6 +23,7 @@ struct keybind { struct wl_list actions; /* struct action.link */ struct wl_list link; /* struct rcxml.keybinds */ bool on_release; + bool override_inhibition; }; /** diff --git a/src/config/rcxml.c b/src/config/rcxml.c index 9884d15e..20c236b4 100644 --- a/src/config/rcxml.c +++ b/src/config/rcxml.c @@ -602,6 +602,7 @@ fill_keybind(xmlNode *node) lab_xml_get_bool(node, "onRelease", &keybind->on_release); lab_xml_get_bool(node, "layoutDependent", &keybind->use_syms_only); lab_xml_get_bool(node, "allowWhenLocked", &keybind->allow_when_locked); + lab_xml_get_bool(node, "overrideInhibition", &keybind->override_inhibition); append_parsed_actions(node, &keybind->actions); } @@ -1706,6 +1707,8 @@ deduplicate_key_bindings(void) wl_list_remove(¤t->link); keybind_destroy(current); cleared++; + } else if (actions_contain_toggle_keybinds(¤t->actions)) { + current->override_inhibition = true; } } if (replaced) { diff --git a/src/input/keyboard.c b/src/input/keyboard.c index 9d8e840d..98be5d11 100644 --- a/src/input/keyboard.c +++ b/src/input/keyboard.c @@ -203,8 +203,10 @@ match_keybinding_for_sym(uint32_t modifiers, if (modifiers ^ keybind->modifiers) { continue; } - if (view_inhibits_actions(server.active_view, &keybind->actions)) { - continue; + if (!(keybind->override_inhibition)) { + if (view_inhibits_actions(server.active_view, &keybind->actions)) { + continue; + } } if (sym == XKB_KEY_NoSymbol) { /* Use keycodes */