x11drv: One more fix for "stuck" ctrl, shift & alt.

Vitaliy Margolen wine-patch at kievinfo.com
Tue Feb 21 23:30:39 CST 2006


ChangeLog:
x11drv: One more fix for "stuck" ctrl, shift & alt.

DInput needs scan code with each event - make sure we send one.
Also don't loose key state change events in mouse.c

I tested this with Keyboard DInput sample from DXSDK. It clearly showed
that we are loosing these events when focus is being changed.

 dlls/x11drv/keyboard.c |   10 +++++-----
 dlls/x11drv/mouse.c    |    6 ++++--
 dlls/x11drv/x11drv.h   |    2 ++
 3 files changed, 11 insertions(+), 7 deletions(-)
-------------- next part --------------
a770e96814de75ac27aca89e8c4dd7946f123a4d
diff --git a/dlls/x11drv/keyboard.c b/dlls/x11drv/keyboard.c
index 78ff47c..f01a692 100644
--- a/dlls/x11drv/keyboard.c
+++ b/dlls/x11drv/keyboard.c
@@ -1239,7 +1239,7 @@ static void KEYBOARD_GenerateMsg( WORD v
  * Updates internal state for <vkey>, depending on key <state> under X
  *
  */
-inline static void KEYBOARD_UpdateOneState ( int vkey, int state, DWORD time )
+inline void KEYBOARD_UpdateOneState ( int vkey, int scan, int state, DWORD time )
 {
     /* Do something if internal table state != X state for keycode */
     if (((key_state_table[vkey] & 0x80)!=0) != state)
@@ -1248,7 +1248,7 @@ inline static void KEYBOARD_UpdateOneSta
               vkey, key_state_table[vkey]);
 
         /* Fake key being pressed inside wine */
-        X11DRV_send_keyboard_input( vkey, 0, state? 0 : KEYEVENTF_KEYUP, time, 0, 0 );
+        X11DRV_send_keyboard_input( vkey, scan, state? 0 : KEYEVENTF_KEYUP, time, 0, 0 );
 
         TRACE("State after %#.2x\n",key_state_table[vkey]);
     }
@@ -1283,9 +1283,9 @@ void X11DRV_KeymapNotify( HWND hwnd, XEv
             }
         }
     }
-    KEYBOARD_UpdateOneState( VK_MENU, alt, time );
-    KEYBOARD_UpdateOneState( VK_CONTROL, control, time );
-    KEYBOARD_UpdateOneState( VK_SHIFT, shift, time );
+    KEYBOARD_UpdateOneState( VK_MENU, 0x38, alt, time );
+    KEYBOARD_UpdateOneState( VK_CONTROL, 0x1d, control, time );
+    KEYBOARD_UpdateOneState( VK_SHIFT, 0x2a, shift, time );
 }
 
 /***********************************************************************
diff --git a/dlls/x11drv/mouse.c b/dlls/x11drv/mouse.c
index f2123c0..f1bbf20 100644
--- a/dlls/x11drv/mouse.c
+++ b/dlls/x11drv/mouse.c
@@ -112,8 +112,10 @@ static inline void update_button_state( 
  */
 static inline void update_key_state( unsigned int state )
 {
-    key_state_table[VK_SHIFT]   = (state & ShiftMask   ? 0x80 : 0);
-    key_state_table[VK_CONTROL] = (state & ControlMask ? 0x80 : 0);
+    DWORD time = GetCurrentTime();
+
+    KEYBOARD_UpdateOneState( VK_SHIFT,   0x2a, (state & ShiftMask)   != 0, time );
+    KEYBOARD_UpdateOneState( VK_CONTROL, 0x1d, (state & ControlMask) != 0, time );
 }
 
 
diff --git a/dlls/x11drv/x11drv.h b/dlls/x11drv/x11drv.h
index 0339fad..d9a2ec8 100644
--- a/dlls/x11drv/x11drv.h
+++ b/dlls/x11drv/x11drv.h
@@ -673,6 +673,8 @@ extern void X11DRV_send_keyboard_input( 
 extern void X11DRV_send_mouse_input( HWND hwnd, DWORD flags, DWORD x, DWORD y,
                                      DWORD data, DWORD time, DWORD extra_info, UINT injected_flags );
 
+extern void KEYBOARD_UpdateOneState ( int vkey, int scan, int state, DWORD time );
+
 typedef int (*x11drv_error_callback)( Display *display, XErrorEvent *event, void *arg );
 
 extern void X11DRV_expect_error( Display *display, x11drv_error_callback callback, void *arg );


More information about the wine-patches mailing list