Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

x11: Keep level when the keysym is undefined but not the action #590

Merged
merged 1 commit into from
Jan 11, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changes/api/+fix-x11-action-only-handling.bugfix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
x11: Do not drop a level when the keysym is undefined but not the action.
11 changes: 9 additions & 2 deletions src/x11/keymap.c
Original file line number Diff line number Diff line change
Expand Up @@ -478,8 +478,9 @@ get_sym_maps(struct xkb_keymap *keymap, xcb_connection_t *conn,
xcb_keysym_t wire_keysym = *syms_iter;

assert(key->groups[group].type != NULL);
if (level < key->groups[group].type->num_levels &&
wire_keysym != XKB_KEY_NoSymbol) {
if (level < key->groups[group].type->num_levels) {
/* Do not discard the keysym yet if it is NoSymbol, because
* there may be an action set */
key->groups[group].levels[level].num_syms = 1;
key->groups[group].levels[level].s.sym = wire_keysym;
}
Expand Down Expand Up @@ -532,6 +533,12 @@ get_actions(struct xkb_keymap *keymap, xcb_connection_t *conn,
union xkb_action *action = &key->groups[group].levels[level].a.action;

translate_action(action, wire_action);
/* If the action and the keysym are both undefined,
* discard them */
if (action->type == ACTION_TYPE_NONE &&
key->groups[group].levels[level].s.sym == XKB_KEY_NoSymbol) {
key->groups[group].levels[level].num_syms = 0;
}
}

xcb_xkb_action_next(&acts_iter);
Expand Down
5 changes: 5 additions & 0 deletions test/data/keymaps/host.xkb
Original file line number Diff line number Diff line change
Expand Up @@ -1657,6 +1657,11 @@ xkb_symbols "pc_us_pt_2_us_3_inet(evdev)_group(shift_caps_toggle)_compose(ralt)"
key <I244> { [ XF86Battery ] };
key <I245> { [ XF86Bluetooth ] };
key <I246> { [ XF86WLAN ] };
key <I247> {
repeat= Yes,
symbols[Group1]= [ NoSymbol ],
actions[Group1]= [ SetMods(modifiers=Shift) ]
};
modifier_map Shift { <LFSH>, <RTSH> };
modifier_map Lock { <CAPS> };
modifier_map Control { <LCTL>, <RCTL> };
Expand Down
Loading