Subject: bug#57825: 29.0.50; Superkey handling regression in pgtk

From: Po Lu <[email-masked]>
Date: Mon, 19 Sep 2022 15:57:58 +0800

Lars Ingebrigtsen <[email-masked]> writes:

> Can't we check what compositor we're running under?

No, that is not really easy to do.

Kwin and Mutter apparently work correctly with GTK, but as I found out
earlier, the real problem lies in libxkbcommon, which is not working the
way XKB is supposed to, thus confusing GTK.

XKB_MOD_NAME_LOGO is not supposed to exist.  Instead, there should be
XKB_MOD_NAME_SUPER, defined to "Super".

Unfortunately, the libxkbcommon API is already set in stone, so the
easiest fix on the GTK side would be this:

diff --git a/gdk/wayland/gdkkeys-wayland.c b/gdk/wayland/gdkkeys-wayland.c
index 35ac9e8..c104b5a 100644
--- a/gdk/wayland/gdkkeys-wayland.c
+++ b/gdk/wayland/gdkkeys-wayland.c
@@ -254,7 +254,8 @@ get_xkb_modifiers (struct xkb_keymap *xkb_keymap,
   if (state & GDK_ALT_MASK)
     mods |= 1 << xkb_keymap_mod_get_index (xkb_keymap, XKB_MOD_NAME_ALT);
   if (state & GDK_SUPER_MASK)
-    mods |= 1 << xkb_keymap_mod_get_index (xkb_keymap, "Super");
+    mods |= (1 << xkb_keymap_mod_get_index (xkb_keymap, "Super")
+	     | 1 << xkb_keymap_mod_get_index (xkb_keymap, XKB_MOD_NAME_LOGO));
   if (state & GDK_HYPER_MASK)
     mods |= 1 << xkb_keymap_mod_get_index (xkb_keymap, "Hyper");
   if (state & GDK_META_MASK)
@@ -277,6 +278,8 @@ get_gdk_modifiers (struct xkb_keymap *xkb_keymap,
     state |= GDK_CONTROL_MASK;
   if (mods & (1 << xkb_keymap_mod_get_index (xkb_keymap, XKB_MOD_NAME_ALT)))
     state |= GDK_ALT_MASK;
+  if (mods & (1 << xkb_keymap_mod_get_index (xkb_keymap, XKB_MOD_NAME_LOGO)))
+    state |= GDK_SUPER_MASK;
   if (mods & (1 << xkb_keymap_mod_get_index (xkb_keymap, "Super")))
     state |= GDK_SUPER_MASK;
   if (mods & (1 << xkb_keymap_mod_get_index (xkb_keymap, "Hyper")))