xkbcommon / libxkbcommon

keymap handling library for toolkits and window systems
https://xkbcommon.org
Other
286 stars 125 forks source link

Using my custom keyboard layouts doesn't work as expected when using `grp:alt_space_toggle` or `grp:win_space_toggle` #479

Closed rempas closed 7 months ago

rempas commented 7 months ago

I am using two custom keyboard layouts, rempas and rempas_el. While they are normally recognized and work, the problem is that, when using either the grp:alt_space_toggle or grp:win_space_toggle options, the Shift+Space keybind (that generates a backspace), doesn't work and now just generates a space. The option grp:lalt_lshift_toggle works so I know it's a problem with these two options (and maybe more?) specifically.

It is also worth mentioning that I tried in Hyprland (Wayland) and Openbox (X11) and both have the exact same behavior, so I know it's a problem with the library itself.

wismill commented 7 months ago

It’s not an issue with xkbcommon nor XKB: your mapping

key <SPCE> { [ space,          BackSpace                                   ] };

is simply incompatible with e.g. grp:alt_space_toggle:

key <SPCE> {[  space,  ISO_Next_Group  ], type[group1] = "PC_ALT_LEVEL2" };

because they both modify the space key but with a different key type (TWO_LEVEL vs PC_ALT_LEVEL2). You need to create a custom key type to make this work, or you should not use the space bar for group switching. You can also use third-party software such as keyd, kanata or kmonad to remap the space key.

rempas commented 6 months ago

@wismill For some reason, I completely missed the reply (I'm blind sometimes...) and I accidentally found it now. I just wanted to say, thank you for the reply! I will use grp:ctrl_alt_toggle which is good enough! Have a beautiful day!

wismill commented 6 months ago

@rempas You’re welcome.

I will use grp:ctrl_alt_toggle which is good enough!

Be aware that it may not act as expected: see issue 420 for further details.

rempas commented 6 months ago

@rempas You’re welcome.

I will use grp:ctrl_alt_toggle which is good enough!

Be aware that it may not act as expected: see issue 420 for further details.

Thank you for the information! Based on my understanding, when the window manager sees "Ctrl+Alt" (in my case), it will use it to change the layout, even if these aren't the only keys pressed and there is another key. That means that keybindings who depend on it won't work, as the window manager will ignore them and just change the layout (as if you only had pressed the identifier combination). So, it can be made to not just stop at "Ctrl+Alt" but wait to see if there is another key pressed before these identifiers are let up. That would be cool and the right behavior.

For me, my personal choice of "Ctrl+Alt" does not interfere with any other keybinds that I have set, so I'm fine. But in any case, thank you so much for thinking about informing me! You are very kind, and I love kind people who care about others! :heart:

Sorry if that is too much, I do like speaking when I find a chance. Hope I didn't bother you a lot 😅