Translate bindsym bindings upon ISO_Next_Group

With commit c738b2e454 we changed i3 so
that the default keybindings can be used when ISO_Next_Group is enabled,
but bindings which explicitly use Mode_switch have precedence. This
behavior required the use of bindcode instead of bindsym.

With this commit, when switching from group 1 to group 2 using
ISO_Next_Group, i3 will re-translate all keybindings (looking at column
2/3, regardless of whether the keybinding itself specifies Mode_switch)
and re-grab them.

That way, the keybinding “bindsym $mod+x nop foo” will work when
pressing $mod+x without Mode_switch and when pressing the corresponding
$mod+x (different key) with Mode_switch. A binding such as “bindsym
Mode_switch+$mod+x nop bar” will still have precedence.

The intention here is to make bindsym keybindings work well with dual
keyboard layouts (such as {dvorak, us} or {us, ru}), so that users can
switch between groups and still have their (logical) keybindings behave
the same way.

fixes #1775
This commit is contained in:
Michael Stapelberg
2015-08-06 09:32:22 +02:00
parent fed05ef876
commit 0fb784f5cb
2 changed files with 9 additions and 13 deletions

View File

@ -1361,14 +1361,10 @@ void handle_event(int type, xcb_generic_event_t *event) {
if (xkb_current_group == state->group)
return;
xkb_current_group = state->group;
if (state->group == XCB_XKB_GROUP_1) {
DLOG("Mode_switch disabled\n");
ungrab_all_keys(conn);
grab_all_keys(conn, false);
} else {
DLOG("Mode_switch enabled\n");
grab_all_keys(conn, true);
}
DLOG("Mode_switch %s\n", (xkb_current_group == XCB_XKB_GROUP_1 ? "disabled" : "enabled"));
ungrab_all_keys(conn);
translate_keysyms();
grab_all_keys(conn, (xkb_current_group == XCB_XKB_GROUP_2));
}
return;