Improve support for keyboard group switching

Dmitry Timoshkov dmitry at baikal.ru
Thu Sep 27 04:26:50 CDT 2001


Hello.

Here is a slightly modified patch to improve support for keyboard
group switching.

Changelog:
    Dmitry Timoshkov <dmitry at codeweavers.com>
    Remove a hack for keyboard group switching.
    Always save/restore correct keyboard group index.
    Explicitly ignore the keyboard group switching events.

diff -u cvs/hq/wine/include/winuser.h wine/include/winuser.h
--- cvs/hq/wine/include/winuser.h	Sun Sep 23 14:40:10 2001
+++ wine/include/winuser.h	Thu Sep 27 17:31:37 2001
@@ -2109,7 +2109,6 @@
   /* keybd_event flags */
 #define KEYEVENTF_EXTENDEDKEY        0x0001
 #define KEYEVENTF_KEYUP              0x0002
-#define KEYEVENTF_WINE_FORCEEXTENDED 0x8000
 
   /* mouse_event flags */
 #define MOUSEEVENTF_MOVE        0x0001
diff -u cvs/hq/wine/windows/input.c wine/windows/input.c
--- cvs/hq/wine/windows/input.c	Thu Sep 20 13:19:38 2001
+++ wine/windows/input.c	Thu Sep 27 17:44:32 2001
@@ -123,9 +123,8 @@
 
     if (ki->dwFlags & KEYEVENTF_KEYUP )
     {
-        BOOL sysKey = ((InputKeyStateTable[VK_MENU] & 0x80) &&
-                       !(InputKeyStateTable[VK_CONTROL] & 0x80) &&
-                       !(ki->dwFlags & KEYEVENTF_WINE_FORCEEXTENDED)); /* for Alt from AltGr */
+        BOOL sysKey = (InputKeyStateTable[VK_MENU] & 0x80) &&
+                      !(InputKeyStateTable[VK_CONTROL] & 0x80);
         InputKeyStateTable[ki->wVk] &= ~0x80;
         keylp.lp1.previous = 1;
         keylp.lp1.transition = 1;
diff -u cvs/hq/wine/windows/x11drv/keyboard.c wine/windows/x11drv/keyboard.c
--- cvs/hq/wine/windows/x11drv/keyboard.c	Thu Sep 20 13:19:40 2001
+++ wine/windows/x11drv/keyboard.c	Thu Sep 27 18:00:34 2001
@@ -618,7 +618,7 @@
     return keyc2vkey[e->keycode];
 }
 
-static BOOL NumState=FALSE, CapsState=FALSE, AltGrState=FALSE;
+static BOOL NumState=FALSE, CapsState=FALSE;
 
 /**********************************************************************
  *		KEYBOARD_GenerateMsg
@@ -735,7 +735,6 @@
     KeySym keysym;
     WORD vkey = 0, bScan;
     DWORD dwFlags;
-    static BOOL force_extended = FALSE; /* hack for AltGr translation */
     int ascii_chars;
 
     DWORD event_time = event->time - X11DRV_server_startticks;
@@ -746,6 +745,13 @@
 
     ascii_chars = TSXLookupString(event, Str, sizeof(Str), &keysym, NULL);
 
+    /* Ignore some unwanted events */
+    if (keysym == XK_ISO_Prev_Group || keysym == XK_ISO_Next_Group)
+    {
+	TRACE("Ignoring %s keyboard event\n", TSXKeysymToString(keysym));
+	return;
+    }
+
     TRACE_(key)("state = %X\n", event->state);
 
     /* If XKB extensions is used, the state mask for AltGr will used the group
@@ -757,27 +763,7 @@
        predefined group index and find it dynamically
 
        Ref: X Keyboard Extension: Library specification (section 14.1.1 and 17.1.1) */
-    if ( AltGrState && (event->state & 0x6000) )
-        AltGrMask = event->state & 0x6000;
-
-    if (keysym == XK_Mode_switch)
-	{
-	TRACE_(key)("Alt Gr key event received\n");
-	event->keycode = kcControl; /* Simulate Control */
-	X11DRV_KEYBOARD_HandleEvent( event, x, y );
-
-	event->keycode = kcAlt; /* Simulate Alt */
-	force_extended = TRUE;
-	X11DRV_KEYBOARD_HandleEvent( event, x, y );
-	force_extended = FALSE;
-    
-    /* Here we save the pressed/released state of the AltGr key, to be able to 
-       identify the group index associated with AltGr on the next key pressed *
-       see comment above. */
-    AltGrState = (event->type == KeyPress) ? TRUE : FALSE;
-    
-	return;
-	}
+    AltGrMask = event->state & 0x6000;
 
     Str[ascii_chars] = '\0';
     if (TRACE_ON(key)){
@@ -792,7 +778,6 @@
     }
 
     vkey = EVENT_event_to_vkey(event);
-    if (force_extended) vkey |= 0x100;
 
     TRACE_(key)("keycode 0x%x converted to vkey 0x%x\n",
                 event->keycode, vkey);
@@ -834,7 +819,6 @@
 	dwFlags = 0;
 	if ( event->type == KeyRelease ) dwFlags |= KEYEVENTF_KEYUP;
 	if ( vkey & 0x100 )              dwFlags |= KEYEVENTF_EXTENDEDKEY;
-	if ( force_extended )            dwFlags |= KEYEVENTF_WINE_FORCEEXTENDED;
 
         KEYBOARD_SendEvent( vkey & 0xff, bScan, dwFlags, x, y, event_time );
     }
@@ -1527,14 +1511,13 @@
     if (lpKeyState[VK_CAPITAL] & 0x01)
 	e.state |= LockMask;
     if (lpKeyState[VK_CONTROL] & 0x80)
-    {
-	if (lpKeyState[VK_MENU] & 0x80)
-	    e.state |= AltGrMask;
-	else
-	    e.state |= ControlMask;
-    }
+	e.state |= ControlMask;
     if (lpKeyState[VK_NUMLOCK] & 0x01)
 	e.state |= NumLockMask;
+
+    /* Restore saved AltGr state */
+    e.state |= AltGrMask;
+
     TRACE_(key)("(%04X, %04X) : faked state = %X\n",
 		virtKey, scanCode, e.state);
     /* We exit on the first keycode found, to speed up the thing. */






More information about the wine-patches mailing list