GDK_SUPER_MASK is not set on Super key press events on Wayland / wlroots
When handling a key press event for something like "Super+/", the GDK_SUPER_MASK bit is not set on Sway; only the GDK_MOD4_MASK bit is. This is different from the documented behavior, which I could reproduce using X11 with Xwayland.
Steps to reproduce
-
Download the following script: https://paste.sr.ht/~schnouki/9f76166c5287de6a1e7d3d3f1537fe2fbd511d5e (sorry, didn't try to do it in C; if needed please let me know and I'll do what I can)
-
Run it under Sway, hit "Super+/": on the console, the following output appears:
$ ./gtk-events.py event.keyval=65515 event.string='' event.state=<flags 0 of type Gdk.ModifierType> event.keyval=47 event.string='/' event.state=<flags GDK_MOD4_MASK of type Gdk.ModifierType>
First event is the Super_L key on its own, 2nd one is Super+/. There's
GDK_MOD4_MASK
in the modifiers, but noGDK_SUPER_MASK
. -
Run the same script under Xwayland and do the same thing:
$ WAYLAND_DISPLAY="" XDG_SEAT="" ./gtk-events.py event.keyval=65515 event.string='' event.state=<flags 0 of type Gdk.ModifierType> event.keyval=47 event.string='/' event.state=<flags GDK_MOD4_MASK | GDK_SUPER_MASK of type Gdk.ModifierType>
This time the
GDK_SUPER_MASK
is set.
Current behavior
The GDK_SUPER_MASK
bit is not set on key press events when Super is pressed, only GDK_MOD4_MASK
is.
Expected outcome
The GDK_SUPER_MASK
bit should be set too.
Version information
- GTK 3.24.33 (from the Arch repo)
- Arch Linux
- Sway 1.7, wlroots 0.15.1, xorg-xwayland 22.1.1
Additional information
This was found while trying to understand a bug in recent Git versions of Emacs: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=55362. It used to work because Emacs didn't rely on GDK modifier flags and re-implemented a similar mechanism, which was recently removed.