[PATCH 12/13] Cygwin/X: Fix the keyboard mode key synchronization

Jon TURNEY jon.turney at dronecode.org.uk
Wed Jan 7 12:04:07 PST 2009


Fix the code which generates fake keypresses when an X window gains focus to
bring the X servers idea of the state of these mode keys in to sync with any
changes which might have taken place whilst unfocused.

With MPX changes, the place the server stores the current mode key state has
changed, appears they are now only held on the virtual core keyboard.

Signed-off-by: Jon TURNEY <jon.turney at dronecode.org.uk>
---
 hw/xwin/winkeybd.c |   15 ++++-----------
 1 files changed, 4 insertions(+), 11 deletions(-)

diff --git a/hw/xwin/winkeybd.c b/hw/xwin/winkeybd.c
index 24a7b43..0c07c2f 100644
--- a/hw/xwin/winkeybd.c
+++ b/hw/xwin/winkeybd.c
@@ -49,10 +49,6 @@
 
 static Bool g_winKeyState[NUM_KEYCODES];
 
-/* Stored to get internal mode key states.  Must be read-only.  */
-static unsigned short const *g_winInternalModeKeyStatesPtr = NULL;
-
-
 /*
  * Local prototypes
  */
@@ -209,7 +205,6 @@ winKeybdBell (int iPercent, DeviceIntPtr pDeviceInt,
 static void
 winKeybdCtrl (DeviceIntPtr pDevice, KeybdCtrl *pCtrl)
 {
-  g_winInternalModeKeyStatesPtr = &(pDevice->key->state);
 }
 
 
@@ -297,19 +292,15 @@ winKeybdProc (DeviceIntPtr pDeviceInt, int iState)
             }
         }
 #endif
-
-      g_winInternalModeKeyStatesPtr = &(pDeviceInt->key->state);
       break;
       
     case DEVICE_ON: 
       pDevice->on = TRUE;
-      g_winInternalModeKeyStatesPtr = &(pDeviceInt->key->state);
       break;
 
     case DEVICE_CLOSE:
     case DEVICE_OFF: 
       pDevice->on = FALSE;
-      g_winInternalModeKeyStatesPtr = NULL;
       break;
     }
 
@@ -371,7 +362,7 @@ winRestoreModeKeyStates ()
   unsigned short	internalKeyStates;
 
   /* X server is being initialized */
-  if (!g_winInternalModeKeyStatesPtr)
+  if (!inputInfo.keyboard)
     return;
 
   /* Only process events if the rootwindow is mapped. The keyboard events
@@ -384,7 +375,9 @@ winRestoreModeKeyStates ()
     mieqProcessInputEvents ();
   
   /* Read the mode key states of our X server */
-  internalKeyStates = *g_winInternalModeKeyStatesPtr;
+  /* (stored in the virtual core keyboard) */
+  internalKeyStates = inputInfo.keyboard->key->state;
+  winDebug("winRestoreModeKeyStates: state %d\n", internalKeyStates);
 
   /* 
    * NOTE: The C XOR operator, ^, will not work here because it is
-- 
1.6.0.4




More information about the xorg mailing list