Skip to content

gdkevents: Don't ignore modifiers that are not currently active

Simon McVittie requested to merge wip/smcv/shifted-shortcuts into main

The X11 backend can mark modifiers like Shift as consumed even if they aren't actually active, which seems to be something to do with making shortcuts like <Control><Shift>plus and <Control>plus work as intended regardless of whether the plus symbol is obtained by pressing Shift and a key (like +/= on American, British or French keyboards) or not (like */+ on German keyboards).

However, this can go badly wrong when the modifier is not pressed. For example, terminals normally have separate bindings for <Control>c (send SIGINT) and <Control><Shift>c (copy). If we disregard the consumed modifiers completely, when the X11 backend marks Shift as consumed, pressing Ctrl+c would send SIGINT and copy to the clipboard, which is not what was intended.

By masking out the members of consumed that are not in state, we get the same interpretation for X11 and Wayland, and ensure that keyboard shortcuts that explicitly mention Shift can only be triggered while holding Shift. It continues to be possible to trigger keyboard shortcuts that do not explicitly mention Shift (such as <Control>plus) while holding Shift, if the backend reports Shift as having been consumed in order to generate the plus keysym.

Resolves: #5095 (closed)
Bug-Debian: https://bugs.debian.org/1016927

Edited by Simon McVittie

Merge request reports