Gate Wayland modifier autodiscovery behind an environment variable

This commit is contained in:
Ravi R Kiran 2021-08-17 21:46:09 -05:00
parent 1b88a68b55
commit 75df0cbcf5
3 changed files with 13 additions and 4 deletions

View File

@ -64,6 +64,13 @@ Variables that influence kitty behavior
Same as :envvar:`VISUAL`. Used if :envvar:`VISUAL` is not set. Same as :envvar:`VISUAL`. Used if :envvar:`VISUAL` is not set.
.. envvar:: KITTY_WAYLAND_DETECT_MODIFIERS
When set to a non-empty value, kitty attempts to autodiscover XKB
modifiers under Wayland. It is possible for the autodiscovery to
fail; the default Wayland XKB mappings are used in this case.
Variables that kitty sets when running child programs Variables that kitty sets when running child programs
.. envvar:: LANG .. envvar:: LANG

View File

@ -145,8 +145,8 @@ Modifiers
This protocol supports six modifier keys, :kbd:`shift, alt, ctrl, super, hyper This protocol supports six modifier keys, :kbd:`shift, alt, ctrl, super, hyper
and meta` as well as :kbd:`num_lock and caps_lock`. Here :kbd:`super` is either and meta` as well as :kbd:`num_lock and caps_lock`. Here :kbd:`super` is either
the *Windows/Linux* key or the *Cmd* key on mac keyboards. :kbd:`hyper` and the *Windows/Linux* key or the *Cmd* key on mac keyboards. :kbd:`hyper` and
:kbd:`meta` are typically present only on X11 based systems with special XKB :kbd:`meta` are typically present only on X11/Wayland based systems with
rules. Modifiers are encoded as a bit field with:: special XKB rules. Modifiers are encoded as a bit field with::
shift 0b1 (1) shift 0b1 (1)
alt 0b10 (2) alt 0b10 (2)

6
glfw/xkb_glfw.c vendored
View File

@ -515,15 +515,17 @@ static int local_modifier_mapping(_GLFWXKBData *xkb) {
} }
} }
if ( algorithm.failed )
debug( "Wayland modifier autodetection algorithm failed; using defaults\n" );
return !algorithm.failed; return !algorithm.failed;
} }
static void static void
glfw_xkb_update_masks(_GLFWXKBData *xkb) { glfw_xkb_update_masks(_GLFWXKBData *xkb) {
// Should find better solution under Wayland // Should find better solution under Wayland
// See https://github.com/kovidgoyal/kitty/pull/3430 for discussion // See https://github.com/kovidgoyal/kitty/pull/3943 for discussion
if ( !local_modifier_mapping( xkb ) ) { if ( getenv( "KITTY_WAYLAND_DETECT_MODIFIERS" ) == NULL || !local_modifier_mapping( xkb ) ) {
#define S( a ) xkb->a##Idx = XKB_MOD_INVALID; xkb->a##Mask = 0 #define S( a ) xkb->a##Idx = XKB_MOD_INVALID; xkb->a##Mask = 0
S(hyper); S(meta); S(hyper); S(meta);
#undef S #undef S