problems with the alt button and window switching

Rizsanyi Zsolt rizsanyi at myrealbox.com
Fri Mar 29 11:15:00 CST 2002


Hi!

If I change the window with keyboard (eg with ALT-TAB), then when I switch 
back to the wine window wine still thinks that the ALT button is depressed.
I happens, because the key event of pressing ALT arrives to the wine window 
before the switch. And I see in the console (with --debugmsg +key) the next 
lines:
trace:key:X11DRV_KeyEvent state = 10
trace:key:X11DRV_KeyEvent KeyPress : keysym=FFE9 (Alt_L), ascii chars=0 / 0 / 
''
trace:key:X11DRV_KeyEvent keycode 0x40 converted to vkey 0x12
trace:key:X11DRV_KeyEvent bScan = 0x38.
trace:key:queue_kbd_event  wParam=0012, lParam=20380001, InputKeyState=81
trace:key:TranslateMessage (WM_SYSKEYDOWN, 0012, 20380001)
trace:key:TranslateMessage Translating key VK_MENU (0012), scancode 38
trace:key:X11DRV_ToUnicode (0012, 2038) : faked state = 10
trace:key:X11DRV_ToUnicode ToUnicode about to return 0 with char bbc6
trace:key:queue_kbd_event  wParam=0012, lParam=c0000001, InputKeyState=1

That is the key state has been changed. And when I return to the wine window 
(by keyboard or mouse) it acts like if the ALT button were depressed.

The solution is that the key states should be reset when the wine gets back 
the focus or loses the focus. 
That is more exactly in windows/winpos.c in the function 
WINPOS_SetActiveWindow when the hWnd is NULL !
That is the case when switching from a wine window to an non-wine window.

So I have found the place :), just I dont know whats the preferred way to 
reset all the key states to not pressed.
I have added the next few lines:
--- oldwinpos.c Fri Mar 29 16:54:59 2002
+++ winpos.c    Fri Mar 29 16:55:08 2002
@@ -1217,6 +1217,12 @@
     if ((wndPtr = WIN_FindWndPtr(hWnd)))
         hWnd = wndPtr->hwndSelf;  /* make it a full handle */

+    /* reset key states when switching to a non-wine window */
+    if (hWnd == 0)
+    {
+        InputKeyStateTable[VK_MENU] &= ~0x80;
+        goto CLEANUP_END;
+    }
+
     /* paranoid checks */
     if( hWnd == GetDesktopWindow() || (bRet = (hWnd == hwndActive)) )
        goto CLEANUP_END;

And now my problem is fixed. But I have experienced the same problem with the 
Control button (altough it is harder to reproduce). So maybe all the key 
states should be reset.

So I would like to have this patch or something similar in wine.

Best regards
Zsolt Rizsanyi




More information about the wine-devel mailing list