gri3-wm/include
Michael Stapelberg bf3cd41b5d Use libxkbcommon for translating keysyms, support all XKB groups.
fixes #1835

This commit improves the translation of keysyms to keycodes by loading
keymaps using libxkbcommon-x11 and using libxkbcommon for figuring out
the keymap, depending on each keybinding’s modifiers. This way, the
upper layers of complex layouts are now usable with i3’s bindsym
directive, such as de_neo’s layer 3 and higher.

Furthermore, the commit generalizes the handling of different XKB
groups. We formerly had support only for two separate groups, the
default group 1, and group 2. While Mode_switch is only one way to
switch to group 2, we called the binding option Mode_switch. With this
commit, the new names Group1, Group2 (an alias for Mode_switch), Group3
and Group4 are introduced for configuring bindings. This is only useful
for advanced keyboard layouts, such as people loading two keyboard
layouts and switching between them (us, ru seems to be a popular
combination).

When grabbing keys, one can only specify the modifier mask, but not an
XKB state mask (or value), so we still dynamically unbind and re-bind
keys whenever the XKB group changes.

The commit was manually tested using the following i3 config:

    bindsym Group4+n nop heya from group 4
    bindsym Group3+n nop heya from group 3
    bindsym Group2+n nop heya from group 2
    bindsym n nop heya
    bindsym shift+N nop explicit shift binding
    bindsym shift+r nop implicit shift binding
    bindcode Group2+38 nop fallback overwritten in group 2 only
    bindcode 38 nop fallback

…with the following layout:

    setxkbmap -layout "us,ua,ru,de" -variant ",winkeys,,neo" \
      -option "grp:shift_caps_toggle,grp_led:scroll" \
      -model pc104 -rules evdev

By default (xkb group 1, us layout), pressing “n” will result in the
“heya” message appearing. Pressing “a” will result in the “fallback”
message appearing. “j” is not triggered.

By pressing Shift+CapsLock you switch to the next group (xkb group 2, ua
layout). Pressing “a” will result in the “fallback overwritten in group
2 only” message, pressing “n” will still result in “heya”. “j” is not
triggered.

In the next group (xkb group 3, ru layout), pressing “a” will result in
the “fallback” message again, pressing “n” will result in “heya”,
“j” is not triggered.

In the last group (xkb group 4, de_neo layout), pressing “a” will still
result in “fallback”, pressing “n” will result in “heya”, pressing “j”
will result in “heya from group 4”.

Pressing shift+n results in “explicit shift binding”, pressing shift+r
results in “implicit shift binding”. This ensures that keysym
translation falls back to looking at non-shift keys (“r” can be used
instead of ”R”) and that the order of keybindings doesn’t play a role
(“bindsym n” does not override “bindsym shift+n”, even though it’s
specified earlier in the config).

The fallback behavior ensures use-cases such as ticket #1775 are still
covered.

Only binding keys when the X server is in the corresponding XKB group
ensures use-cases such as ticket #585 are still covered.
2015-08-26 09:56:42 +02:00
..
i3 Update copyright notices and get rid of ranges 2015-04-20 17:50:21 -04:00
all.h Update copyright notices and get rid of ranges 2015-04-20 17:50:21 -04:00
assignments.h Update copyright notices and get rid of ranges 2015-04-20 17:50:21 -04:00
atoms.xmacro Set the _NET_WM_STATE_HIDDEN atom on windows that are currently not visible due to being in the non-focused tab of a stacked or tabbed container. 2015-04-21 09:14:22 +02:00
bindings.h Use libxkbcommon for translating keysyms, support all XKB groups. 2015-08-26 09:56:42 +02:00
click.h Update copyright notices and get rid of ranges 2015-04-20 17:50:21 -04:00
cmdparse.h Update copyright notices and get rid of ranges 2015-04-20 17:50:21 -04:00
commands.h Added command directive 'title_format'. 2015-06-29 09:13:31 +02:00
commands_parser.h Update copyright notices and get rid of ranges 2015-04-20 17:50:21 -04:00
con.h Added 'con_is_hidden' to check whether a given container is visible to the user assuming its workspace is visible. 2015-04-21 09:13:48 +02:00
config.h Configurable tray padding. 2015-06-28 00:14:37 +02:00
config_directives.h Use libxkbcommon for translating keysyms, support all XKB groups. 2015-08-26 09:56:42 +02:00
config_parser.h Update copyright notices and get rid of ranges 2015-04-20 17:50:21 -04:00
data.h Use libxkbcommon for translating keysyms, support all XKB groups. 2015-08-26 09:56:42 +02:00
debug.h Update copyright notices and get rid of ranges 2015-04-20 17:50:21 -04:00
display_version.h Update copyright notices and get rid of ranges 2015-04-20 17:50:21 -04:00
ewmh.h Update copyright notices and get rid of ranges 2015-04-20 17:50:21 -04:00
fake_outputs.h Update copyright notices and get rid of ranges 2015-04-20 17:50:21 -04:00
floating.h Implemented new command 'move [window|container] [to] position mouse|cursor|pointer 2015-05-12 17:46:06 -04:00
handlers.h Update copyright notices and get rid of ranges 2015-04-20 17:50:21 -04:00
i3.h Update copyright notices and get rid of ranges 2015-04-20 17:50:21 -04:00
ipc.h Update copyright notices and get rid of ranges 2015-04-20 17:50:21 -04:00
key_press.h Update copyright notices and get rid of ranges 2015-04-20 17:50:21 -04:00
libi3.h Merge pull request #1816 from tcreech/tcreech-for-illumos 2015-08-04 00:10:06 -07:00
load_layout.h Update copyright notices and get rid of ranges 2015-04-20 17:50:21 -04:00
log.h Update copyright notices and get rid of ranges 2015-04-20 17:50:21 -04:00
main.h Update copyright notices and get rid of ranges 2015-04-20 17:50:21 -04:00
manage.h Update copyright notices and get rid of ranges 2015-04-20 17:50:21 -04:00
match.h Update copyright notices and get rid of ranges 2015-04-20 17:50:21 -04:00
move.h Update copyright notices and get rid of ranges 2015-04-20 17:50:21 -04:00
output.h Update copyright notices and get rid of ranges 2015-04-20 17:50:21 -04:00
queue.h clang-format-3.5 **/*.h **/*.c 2014-06-19 11:20:32 +02:00
randr.h Update copyright notices and get rid of ranges 2015-04-20 17:50:21 -04:00
regex.h Update copyright notices and get rid of ranges 2015-04-20 17:50:21 -04:00
render.h Update copyright notices and get rid of ranges 2015-04-20 17:50:21 -04:00
resize.h Update copyright notices and get rid of ranges 2015-04-20 17:50:21 -04:00
restore_layout.h Update copyright notices and get rid of ranges 2015-04-20 17:50:21 -04:00
scratchpad.h Update copyright notices and get rid of ranges 2015-04-20 17:50:21 -04:00
sd-daemon.h clang-format-3.5 **/*.h **/*.c 2014-06-19 11:20:32 +02:00
shmlog.h Update copyright notices and get rid of ranges 2015-04-20 17:50:21 -04:00
sighandler.h Update copyright notices and get rid of ranges 2015-04-20 17:50:21 -04:00
startup.h Update copyright notices and get rid of ranges 2015-04-20 17:50:21 -04:00
tree.h Update copyright notices and get rid of ranges 2015-04-20 17:50:21 -04:00
util.h Update copyright notices and get rid of ranges 2015-04-20 17:50:21 -04:00
window.h Merge pull request #1665 from Airblader/feature-1658 2015-04-21 08:42:16 +02:00
workspace.h Update copyright notices and get rid of ranges 2015-04-20 17:50:21 -04:00
x.h Update copyright notices and get rid of ranges 2015-04-20 17:50:21 -04:00
xcb.h Merge pull request #1665 from Airblader/feature-1658 2015-04-21 08:42:16 +02:00
xcb_compat.h Update copyright notices and get rid of ranges 2015-04-20 17:50:21 -04:00
xcursor.h Update copyright notices and get rid of ranges 2015-04-20 17:50:21 -04:00
xinerama.h Update copyright notices and get rid of ranges 2015-04-20 17:50:21 -04:00
yajl_utils.h Update copyright notices and get rid of ranges 2015-04-20 17:50:21 -04:00