GdkWin32: Fix keyboard state for WinPointer input
authorLuca Bacci <luca.bacci982@gmail.com>
Wed, 21 Jun 2023 14:14:56 +0000 (16:14 +0200)
committerLuca Bacci <luca.bacci982@gmail.com>
Wed, 21 Jun 2023 14:18:01 +0000 (16:18 +0200)
The dwKeyStates field of the POINTER_INFO structure
is always set to 0, no matter what. Use GetKeyState
instead.

Forward-port of !4327 to GTK4

gdk/win32/gdkinput-winpointer.c

index 078274345340bb91713123e54be3122cb1b33663..1a9e6bbff528ec45e2bba1d5a2091ed37a254814 100644 (file)
@@ -271,9 +271,10 @@ winpointer_make_event (GdkDeviceWinpointer *device,
   y /= impl->surface_scale;
 
   state = 0;
-  if (info->dwKeyStates & POINTER_MOD_CTRL)
+  /* Note that info->dwKeyStates is not reliable, use GetKeyState() */
+  if (GetKeyState (VK_CONTROL) < 0)
     state |= GDK_CONTROL_MASK;
-  if (info->dwKeyStates & POINTER_MOD_SHIFT)
+  if (GetKeyState (VK_SHIFT) < 0)
     state |= GDK_SHIFT_MASK;
   if (GetKeyState (VK_MENU) < 0)
     state |= GDK_ALT_MASK;