gdkkeys-win32: Also ignore Ctrl + Shift (etc.)
authorPhilip Zander <philip.zander@gmail.com>
Tue, 8 Feb 2022 19:33:42 +0000 (20:33 +0100)
committerLuca Bacci <luca.bacci982@gmail.com>
Wed, 9 Feb 2022 09:43:07 +0000 (10:43 +0100)
Some Windows keymaps have bogus mappings for the Ctrl modifier. !4423 attempted
to fix this by ignoring the Ctrl layer, but that was not enough. We also need to
ignore combinations of Ctrl with other modifiers, i.e. Ctrl + Shift. For example,
Ctrl + Shift + 6 is mapped to the character 0x1E on a US keyboard (but it should
be treated as Ctrl + ^). Basically, always ignore Ctrl unless it is used in
conjunction with Alt, i.e. as part of AltGr.

Related issue: #4667

gdk/win32/gdkkeys-win32-impl.c

index 51ed1f63815b2935e457d01275173501d72b8f4e..f3d42481b4aae1d65d80e7f12c0c45c301a0d61c 100644 (file)
@@ -340,11 +340,12 @@ vk_to_char_fuzzy (GdkWin32KeymapLayoutInfo *info,
           if (candidate_modbits & ~mod_bits)
             continue;
 
-          /* Some keys have bogus mappings for the control key, e.g.
-           * Ctrl + Backspace = Delete, or Ctrl + [ = 0x1B. These are
-           * never used on Windows, so we ignore them.
+          /* Some keys have bogus mappings for the control key, e.g.  Ctrl +
+           * Backspace = Delete, Ctrl + [ = 0x1B or even  Ctrl + Shift + 6 =
+           * 0x1E on a US keyboard. So we have to ignore all cases of
+           * Ctrl that aren't part of AltGr.
            */
-          if (candidate_modbits == KBDCTRL)
+          if ((candidate_modbits & KBDCTRL) && !(candidate_modbits & KBDALT))
             continue;
 
           c = entry->wch[level];