Skip to content

Commit

Permalink
Strip modifier keys of modifiers.
Browse files Browse the repository at this point in the history
For some reason modifiers are applied to modifier keys being held down when a mode is loaded.
I suspect this is a problem with xcb -- I haven't been able to find another culprit yet.
This strips modifiers of modifier keys. I don't see this breaking anything since modifiers
with modifier keys isn't normally applied and is nonesense from the beginning.

This partially fixes #5288. It doesn't fully fix the issue since B_UPON_KEYRELEASE_IGNORE_MODS
can't be applied to a key release binding that didn't get a keypress, so the order that keys are
released when the bindsym is made between modes matters when it shouldn't.

I'm not sure what exactly the fix for that would be-- and it seems like it'd be a much bigger change
than this, and that it would have to deserve it's own commit.
  • Loading branch information
slyshot committed Jan 21, 2023
1 parent 8d64937 commit 88a62e5
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/bindings.c
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,25 @@ Binding *get_binding_from_xcb_event(xcb_generic_event_t *event) {
/* Remove the CapsLock bit */
i3_event_state_mask_t state_filtered = event_state & ~XCB_MOD_MASK_LOCK;
DLOG("(removed capslock, state = 0x%x)\n", state_filtered);
/* Strip modifier keys of modifiers. Needed for keyrelease events between modes */
struct xkb_state *dummy_state = xkb_state_new(xkb_keymap);
xkb_keysym_t event_sym = xkb_state_key_get_one_sym(dummy_state,event_detail);
xkb_state_unref(dummy_state);
switch(event_sym) {
case XKB_KEY_Meta_L:
case XKB_KEY_Meta_R:
case XKB_KEY_Alt_L:
case XKB_KEY_Alt_R:
case XKB_KEY_Super_L:
case XKB_KEY_Super_R:
case XKB_KEY_Control_L:
case XKB_KEY_Control_R:
case XKB_KEY_Hyper_R:
case XKB_KEY_Hyper_L:
state_filtered = state_filtered & 0xFF00;
break;
}

/* Transform the keyboard_group from bit 13 and bit 14 into an
* i3_xkb_group_mask_t, so that get_binding() can just bitwise AND the
* configured bindings against |state_filtered|.
Expand Down

0 comments on commit 88a62e5

Please sign in to comment.