Fixes for several keyboard layout related issues

Dmitry Timoshkov dmitry at baikal.ru
Fri Apr 16 00:04:07 CDT 2004


Hello,

this patch fixes several keyboard layout related issues
reported by a user running Wine on a remote Sun workstation.

Changelog:
    Dmitry Timoshkov <dmitry at codeweavers.com>
    - start assigning custom VK codes from VK_OEM_8 since this
    code already presents in the layout tables
    - search the layout tables only if XLookupString returned
    non zero number of characters for a keysym, otherwise that's
    a non character key
    - avoid inserting VK_OEM_x codes into unassigned positions
    since these codes might already be in the layout table, thus
    creating a conflict

--- cvs/hq/wine/dlls/x11drv/keyboard.c	Thu Apr 15 02:06:08 2004
+++ wine/dlls/x11drv/keyboard.c	Fri Apr 16 04:51:36 2004
@@ -1371,12 +1371,15 @@ void X11DRV_InitKeyboard( BYTE *key_stat
     e2.display = display;
     e2.state = 0;
 
-    OEMvkey = VK_OEM_7; /* next is available.  */
+    OEMvkey = VK_OEM_8; /* next is available.  */
     for (keyc = min_keycode; keyc <= max_keycode; keyc++)
     {
+        char buf[30];
+        int have_chars;
+
         keysym = 0;
         e2.keycode = (KeyCode)keyc;
-        XLookupString(&e2, NULL, 0, &keysym, NULL);
+        have_chars = XLookupString(&e2, buf, sizeof(buf), &keysym, NULL);
         vkey = 0; scan = 0;
         if (keysym)  /* otherwise, keycode not used */
         {
@@ -1389,7 +1392,7 @@ void X11DRV_InitKeyboard( BYTE *key_stat
             } else if (keysym == 0x20) {                 /* Spacebar */
 	        vkey = VK_SPACE;
 		scan = 0x39;
-	    } else {
+	    } else if (have_chars) {
 	      /* we seem to need to search the layout-dependent scancodes */
 	      int maxlen=0,maxval=-1,ok;
 	      for (i=0; i<syms; i++) {
@@ -1427,7 +1430,9 @@ void X11DRV_InitKeyboard( BYTE *key_stat
 		vkey = (*lvkey)[maxval];
 	      }
 	    }
-
+#if 0 /* this breaks VK_OEM_x VKeys in some layout tables by inserting
+       * a VK code into a not appropriate place.
+       */
             /* find a suitable layout-dependent VK code */
 	    /* (most Winelib apps ought to be able to work without layout tables!) */
             for (i = 0; (i < keysyms_per_keycode) && (!vkey); i++)
@@ -1457,7 +1462,7 @@ void X11DRV_InitKeyboard( BYTE *key_stat
 		case '+':             vkey = VK_OEM_PLUS; break;
 		}
 	    }
-
+#endif
             if (!vkey)
             {
                 /* Others keys: let's assign OEM virtual key codes in the allowed range,
@@ -1490,6 +1495,7 @@ void X11DRV_InitKeyboard( BYTE *key_stat
                 }
             }
         }
+        TRACE("keycode %04x => vkey %04x\n", e2.keycode, vkey);
         keyc2vkey[e2.keycode] = vkey;
         keyc2scan[e2.keycode] = scan;
     } /* for */






More information about the wine-patches mailing list