Skip to content

Emit key release signal after kbd modifier update

Change when the key release event signal is emitted relative to when the keyboard modifier state is updated. Prior to the change, the key event signal was always emitted before the modifer state was updated regardless of whether the event was a key press or a key release. With this commit the modifier state is still updated after a key press signal is emitted (no change from previous behavior), but it is updated before a key release signal is sent.

Prior to this commit, if a key signal subscriber received a signal for a modifier key press and queried the modifier state at that point, the returned state would not take the pressed key into account. This seems reasonable. However, when the same key was released the queried modifer state would still include a modifier for the corresponding key. In other words the behavior is "asymetrical", this commit makes things consistent, i.e. the queried modifier no longer factors in the pressed or released modifier key. Note: other currently active modifiers continue to behave as before.


I've tested this with a modified version of Sway that logs key events (in handle_key_event) and their corresponding modifiers (from the struct key_info after calling update_keyboard_state). Before this commit, pressing and releasing the Super_L key resulted in a Super_L key press event with no modifiers and a Super_L key release event with modifiers set to 64 (i.e. WLR_MODIFIER_LOGO). With this commit I'm getting the expected behavior, i.e. modifiers is 0 when Super_L is released in the example given above. Beyond this change I haven't noticed any change in the behavior of my Sway.

I have not tested this modified wlroots with any non-Sway WMs so it is entirely possible that I'm missing something glaringly obvious.

The behavior prior to this commit was interfering with changes I'm trying to make in Sway. I'm guessing that behavior could also turn out to be a problem for other wlroot-using projects.

Merge request reports