[Xorg-commit] xc/programs/Xserver/hw/xwin win.h,1.1.4.1.2.4,1.1.4.1.2.5 winkeybd.c,1.1.4.1.2.3,1.1.4.1.2.4 winkeybd.h,1.1,1.1.6.1 winwndproc.c,1.1.4.1.2.2,1.1.4.1.2.3

Harold L Hunt II xorg-commit at pdx.freedesktop.org
Wed Dec 24 23:17:30 EET 2003


Committed by: harold

Update of /cvs/xorg/xc/programs/Xserver/hw/xwin
In directory pdx:/tmp/cvs-serv29134

Modified Files:
      Tag: CYGWIN
	win.h winkeybd.c winkeybd.h winwndproc.c 
Log Message:
Attempt to fix handling of AltGr when TweakUI is enabled.  Remove the dead code that was wrapped with WIN_NEW_KEYBOARD_SUPPORT.

Index: win.h
===================================================================
RCS file: /cvs/xorg/xc/programs/Xserver/hw/xwin/win.h,v
retrieving revision 1.1.4.1.2.4
retrieving revision 1.1.4.1.2.5
diff -u -d -r1.1.4.1.2.4 -r1.1.4.1.2.5
--- win.h	21 Dec 2003 07:26:10 -0000	1.1.4.1.2.4
+++ win.h	24 Dec 2003 21:17:27 -0000	1.1.4.1.2.5
@@ -49,7 +49,6 @@
  */
 #define WIN_NATIVE_GDI_SUPPORT			YES
 #define WIN_LAYER_SUPPORT			NO
-#define WIN_NEW_KEYBOARD_SUPPORT		NO
 #define WIN_EMULATE_PSEUDO_SUPPORT		YES
 #define WIN_UPDATE_STATS			NO
 
@@ -350,19 +349,6 @@
 } winPrivCmapRec, *winPrivCmapPtr;
 
 
-#if WIN_NEW_KEYBOARD_SUPPORT
-/*
- * Keyboard event structure
- */
-
-typedef struct
-{
-  DWORD			dwXKeycodes[WIN_MAX_KEYS_PER_KEY];
-  DWORD			dwReleaseModifiers;
-} winKeyEventsRec, *winKeyEventsPtr;
-
-#endif /* WIN_NEW_KEYBOARD_SUPPORT */
-
 /*
  * Screen information structure that we need before privates are available
  * in the server startup sequence.
@@ -961,13 +947,8 @@
  * winkeybd.c
  */
 
-#if WIN_NEW_KEYBOARD_SUPPORT
-winKeyEventsRec
-winTranslateKey (DWORD dwVirtualKey, DWORD dwKeyData);
-#else
 void
 winTranslateKey (WPARAM wParam, LPARAM lParam, int *piScanCode);
-#endif
 
 void
 winGetKeyMappings (KeySymsPtr pKeySyms, CARD8 *pModMap);
@@ -997,11 +978,6 @@
 void
 winSendKeyEvent (DWORD dwKey, Bool fDown);
 
-#if WIN_NEW_KEYBOARD_SUPPORT
-void
-winProcessKeyEvent (DWORD dwVirtKey, DWORD dwKeyData);
-#endif
-
 
 /*
  * winlayer.c

Index: winkeybd.c
===================================================================
RCS file: /cvs/xorg/xc/programs/Xserver/hw/xwin/winkeybd.c,v
retrieving revision 1.1.4.1.2.3
retrieving revision 1.1.4.1.2.4
diff -u -d -r1.1.4.1.2.3 -r1.1.4.1.2.4
--- winkeybd.c	18 Dec 2003 20:17:58 -0000	1.1.4.1.2.3
+++ winkeybd.c	24 Dec 2003 21:17:27 -0000	1.1.4.1.2.4
@@ -48,173 +48,6 @@
 /* Stored to get internal mode key states.  Must be read-only.  */
 static unsigned short const *g_winInternalModeKeyStatesPtr = NULL;
 
-#if WIN_NEW_KEYBOARD_SUPPORT
-
-const unsigned int MaxKeysPerKey = 4;
-
-void
-winProcessKeyEvent (DWORD dwVirtualKey, DWORD dwKeyData)
-{
-  Bool			fDown = ((dwKeyData & 0x80000000) == 0);
-  winKeyEventsRec	kerEvent;
-  int			i;
-
-  /* Get the key events */
-  kerEvent = winTranslateKey (dwVirtualKey, dwKeyData);
-
-  if (kerEvent.dwReleaseModifiers & WIN_MOD_LCONTROL)
-    winSendKeyEvent (XK_Control_L, FALSE);
-  if (kerEvent.dwReleaseModifiers & WIN_MOD_RCONTROL)
-    winSendKeyEvent (XK_Control_R, FALSE);
-  if (kerEvent.dwReleaseModifiers & WIN_MOD_LALT)
-    winSendKeyEvent (XK_Alt_L, FALSE);
-  if (kerEvent.dwReleaseModifiers & WIN_MOD_RALT)
-    winSendKeyEvent (XK_Alt_R, FALSE);
-  
-  for (i = 0; kerEvent.dwXKeycodes[i] != XK_VoidSymbol; ++i)
-    winSendKeyEvent (kerEvent.dwXKeycodes[i], fDown);
-  
-  if (kerEvent.dwReleaseModifiers & WIN_MOD_LCONTROL)
-    winSendKeyEvent (XK_Control_L, FALSE);
-  if (kerEvent.dwReleaseModifiers & WIN_MOD_RCONTROL)
-    winSendKeyEvent (XK_Control_R, TRUE);
-  if (kerEvent.dwReleaseModifiers & WIN_MOD_LALT)
-    winSendKeyEvent (XK_Alt_L, FALSE);
-  if (kerEvent.dwReleaseModifiers & WIN_MOD_RALT)
-    winSendKeyEvent (XK_Alt_R, TRUE);
-  
-}
-
-
-winKeyEventsRec
-winTranslateKey (DWORD dwVirtualKey, DWORD dwKeyData)
-{
-  winKeyEventsRec	kerEvents;
-  Bool			fExtended = ((HIWORD (dwKeyData) & KF_EXTENDED) != 0);
-  int			i;
-  DWORD			dwNumEvents = 0;
-  BYTE			bKeyboardState[256];
-  int			iReturn;
-  unsigned char		cAscii[4];
-
-  /* Remap extended modifiers to the right version of that key.  */
-  if (fExtended)
-    {
-      switch (dwVirtualKey)
-	{
-	case VK_MENU:
-	  dwVirtualKey = VK_RMENU;
-	  break;
-
-	case VK_CONTROL:
-	  dwVirtualKey = VK_RCONTROL;
-	  break;
-	}
-    }
-
-  /* Initialize the modifiers to release flag */
-  kerEvents.dwReleaseModifiers = 0;
-   
-  /* Look up the current virtual key code in the translation table */
-  for (i = 0; i < g_winKeymapEntries; ++i)
-    {
-      /* Did we find a mapping? */
-      if (winKeymap[i].dwVirtualKey == dwVirtualKey)
-	{
-	  /* Mapping found, we have at least one event now */
-	  kerEvents.dwXKeycodes[dwNumEvents] = winKeymap[i].dwXKey;
-	  break;
-	}
-    }
-
-  
-  /* Break out early, if we found the key in the translation table */
-  if (dwNumEvents != 0)
-    {
-      /* Terminate the last of the key events with a void symbol */
-      kerEvents.dwXKeycodes[dwNumEvents] = XK_VoidSymbol;
-      return kerEvents;
-    }
-  
-  /* Get the state of all keyboard keys */
-  GetKeyboardState (bKeyboardState);
-
-  /* Try to convert the key to ASCII */
-  iReturn = ToAscii (dwVirtualKey, 0, bKeyboardState, (WORD *) cAscii, 0);
-  
-  /*
-   * Left Control and Alt pressed, combined with a valid result
-   * from ToAscii means that we have found the Windows version of AltGr.
-   */
-  if ((bKeyboardState[VK_MENU] & 0x80) && (bKeyboardState[VK_CONTROL] & 0x80)
-      && (iReturn >= 1)
-      && (((cAscii[0] >= 32) && (cAscii[0] <= 126))
-	  || (cAscii[0] >= 160)))
-    {
-      /* These three calls will return 0 on Windows 95/98/Me */
-      if ((GetKeyState (VK_LCONTROL) & KF_UP))
-	kerEvents.dwReleaseModifiers |= WIN_MOD_LCONTROL;
-      if ((GetKeyState (VK_LMENU) & KF_UP))
-	kerEvents.dwReleaseModifiers |= WIN_MOD_LALT;
-      if ((GetKeyState (VK_RMENU) & KF_UP))
-	kerEvents.dwReleaseModifiers |= WIN_MOD_RALT;
-
-      /* Windows 95/98/Me handling - pop all of them */
-      if (kerEvents.dwReleaseModifiers == 0)
-	kerEvents.dwReleaseModifiers
-	  = WIN_MOD_LCONTROL | WIN_MOD_LALT | WIN_MOD_RALT;
-
-      /* Copy the string of character events */
-      for (i = 0; i < iReturn; ++i)
-	kerEvents.dwXKeycodes[dwNumEvents++] = cAscii[i];
-    }
-
-  /* Handle non Ctrl+Alt cases*/
-  if (dwNumEvents == 0)
-    {
-      bKeyboardState[VK_CONTROL] = 0;
-      bKeyboardState[VK_LCONTROL] = 0;
-      bKeyboardState[VK_RCONTROL] = 0;
-      
-      iReturn = ToAscii (dwVirtualKey, 0, bKeyboardState, (WORD *)cAscii, 0);
-      if (iReturn < 0)
-	{
-	  switch (cAscii[0])
-	    {
-	    case '`':
-	      kerEvents.dwXKeycodes[dwNumEvents++] = XK_dead_grave;
-	      break;
-	      
-	    case '\'':
-	      kerEvents.dwXKeycodes[dwNumEvents++] = XK_dead_acute;
-	      break;
-	      
-	    case '~':
-	      kerEvents.dwXKeycodes[dwNumEvents++] = XK_dead_tilde;
-	      break;
-	      
-	    case '^':
-	      kerEvents.dwXKeycodes[dwNumEvents++] = XK_dead_circumflex;
-	      break;
-	    }
-	}
-      
-      /* Send what we've got if its a printable character */
-      if (iReturn >= 1)
-	for (i = 0; i < iReturn; ++i)
-	  kerEvents.dwXKeycodes[dwNumEvents++] = cAscii[i];
-    }
-
-  
-  /* Terminate the last of the key events with a void symbol */
-  kerEvents.dwXKeycodes[dwNumEvents] = XK_VoidSymbol;
-  return kerEvents;
-}
-
-
-#else /* WIN_NEW_KEYBOARD_SUPPORT */
-
-
 /* 
  * Translate a Windows WM_[SYS]KEY(UP/DOWN) message
  * into an ASCII scan code.
@@ -239,8 +72,6 @@
     *piScanCode = LOBYTE (HIWORD (lParam));
 }
 
-#endif /* WIN_NEW_KEYBOARD_SUPPORT */
-
 
 /*
  * We call this function from winKeybdProc when we are
@@ -290,7 +121,6 @@
 	  pModMap[i] = AltMask;
 	  break;
 
-#if !WIN_NEW_KEYBOARD_SUPPORT
 	case XK_Num_Lock:
 	  pModMap[i] = NumLockMask;
 	  break;
@@ -304,7 +134,6 @@
 	case XK_Kana_Shift:
 	  pModMap[i] = KanaMask;
 	  break;
-#endif
 
 	/* alternate toggle for multinational support */
 	case XK_Mode_switch:
@@ -469,7 +298,6 @@
 void
 winInitializeModeKeyStates (void)
 {
-#if !WIN_NEW_KEYBOARD_SUPPORT
   /* Restore NumLock */
   if (GetKeyState (VK_NUMLOCK) & 0x0001)
     {
@@ -497,7 +325,6 @@
       winSendKeyEvent (KEY_HKTG, TRUE);
       winSendKeyEvent (KEY_HKTG, FALSE);
     }
-#endif
 }
 
 
@@ -510,9 +337,8 @@
 void
 winRestoreModeKeyStates ()
 {
-#if !WIN_NEW_KEYBOARD_SUPPORT
   DWORD			dwKeyState;
-  unsigned short internalKeyStates;
+  unsigned short	internalKeyStates;
 
   /* X server is being initialized */
   if (!g_winInternalModeKeyStatesPtr)
@@ -561,11 +387,9 @@
       winSendKeyEvent (KEY_HKTG, TRUE);
       winSendKeyEvent (KEY_HKTG, FALSE);
     }
-#endif
 }
 
 
-#if !WIN_NEW_KEYBOARD_SUPPORT
 /*
  * Look for the lovely fake Control_L press/release generated by Windows
  * when AltGr is pressed/released on a non-U.S. keyboard.
@@ -596,6 +420,21 @@
 			     WM_KEYDOWN, WM_KEYDOWN,
 			     PM_NOREMOVE);
 
+      /*
+       * Try again if the first call fails.
+       * NOTE: This usually happens when TweakUI is enabled.
+       */
+      if (!fReturn)
+	{
+	  /* Voodoo to make sure that the Alt_R message has posted */
+	  Sleep (0);
+
+	  /* Look for fake Ctrl_L preceeding an Alt_R press. */
+	  fReturn = PeekMessage (&msgNext, NULL,
+				 WM_KEYDOWN, WM_KEYDOWN,
+				 PM_NOREMOVE);
+	}
+
       /* Is next press an Alt_R with the same timestamp? */
       if (fReturn && msgNext.wParam == VK_MENU
 	  && msgNext.time == lTime
@@ -628,6 +467,21 @@
 			     WM_KEYUP, WM_SYSKEYUP, 
 			     PM_NOREMOVE);
 
+      /*
+       * Try again if the first call fails.
+       * NOTE: This usually happens when TweakUI is enabled.
+       */
+      if (!fReturn)
+	{
+	  /* Voodoo to make sure that the Alt_R message has posted */
+	  Sleep (0);
+
+	  /* Look for fake Ctrl_L release preceeding an Alt_R release. */
+	  fReturn = PeekMessage (&msgNext, NULL,
+				 WM_KEYUP, WM_SYSKEYUP, 
+				 PM_NOREMOVE);
+	}
+
       /* Is next press an Alt_R with the same timestamp? */
       if (fReturn
 	  && (msgNext.message == WM_KEYUP
@@ -648,7 +502,6 @@
   /* Not a fake control left press/release */
   return FALSE;
 }
-#endif /* WIN_NEW_KEYBOARD_SUPPORT */
 
 
 /*
@@ -658,7 +511,6 @@
 void
 winKeybdReleaseKeys ()
 {
-#if !WIN_NEW_KEYBOARD_SUPPORT
   int				i;
 
   /* Verify that the mi input system has been initialized */
@@ -675,7 +527,6 @@
       /* Reset pressed flag for keys */
       g_winKeyState[i] = FALSE;
     }
-#endif
 }
 
 

Index: winkeybd.h
===================================================================
RCS file: /cvs/xorg/xc/programs/Xserver/hw/xwin/winkeybd.h,v
retrieving revision 1.1
retrieving revision 1.1.6.1
diff -u -d -r1.1 -r1.1.6.1
--- winkeybd.h	14 Nov 2003 16:48:56 -0000	1.1
+++ winkeybd.h	24 Dec 2003 21:17:27 -0000	1.1.6.1
@@ -1,3 +1,6 @@
+#if !defined(WINKEYBD_H)
+#define WINKEYBD_H
+
 /*
  *Copyright (C) 1994-2000 The XFree86 Project, Inc. All Rights Reserved.
  *
@@ -42,97 +45,6 @@
  */
 #include "../xfree86/common/xf86Keymap.h"
 
-
-#if WIN_NEW_KEYBOARD_SUPPORT
-
-/* Define the keymap structure */
-typedef struct
-{
-  DWORD		dwVirtualKey;
-  DWORD		dwXKey;
-} winKeymappingRec, *winKeymappingPtr;
-
-static const winKeymappingRec 
-winKeymap[] = {
-	{VK_BACK,		XK_BackSpace},
-	{VK_TAB,		XK_Tab},
-	{VK_CLEAR,		XK_Clear},
-	{VK_RETURN,		XK_Return},
-	{VK_LSHIFT,		XK_Shift_L},
-	{VK_RSHIFT,		XK_Shift_R},
-	{VK_SHIFT,		XK_Shift_L},
-	{VK_LCONTROL,		XK_Control_L},
-	{VK_RCONTROL,		XK_Control_R},
-	{VK_CONTROL,		XK_Control_L},
-	{VK_LMENU,		XK_Alt_L},
-	{VK_RMENU,		XK_Alt_R},
-	{VK_MENU,		XK_Alt_L},
-	{VK_PAUSE,		XK_Pause},
-	{VK_CAPITAL,		XK_Caps_Lock},
-	{VK_ESCAPE,		XK_Escape},
-	{VK_SPACE,		XK_space},
-	{VK_PRIOR,		XK_Page_Up},
-	{VK_NEXT,		XK_Page_Down},
-	{VK_END,		XK_End},
-	{VK_HOME,		XK_Home},
-	{VK_LEFT,		XK_Left},
-	{VK_UP,			XK_Up},
-	{VK_RIGHT,		XK_Right},
-	{VK_DOWN,		XK_Down},
-	{VK_SELECT,		XK_Select},
-	{VK_EXECUTE,		XK_Execute},
-	{VK_SNAPSHOT,		XK_Print},
-	{VK_INSERT,		XK_Insert},
-	{VK_DELETE,		XK_Delete},
-	{VK_HELP,		XK_Help},
-	{VK_NUMPAD0,		XK_KP_0},
-	{VK_NUMPAD1,		XK_KP_1},
-	{VK_NUMPAD2,		XK_KP_2},
-	{VK_NUMPAD3,		XK_KP_3},
-	{VK_NUMPAD4,		XK_KP_4},
-	{VK_NUMPAD5,		XK_KP_5},
-	{VK_NUMPAD6,		XK_KP_6},
-	{VK_NUMPAD7,		XK_KP_7},
-	{VK_NUMPAD8,		XK_KP_8},
-	{VK_NUMPAD9,		XK_KP_9},
-	{VK_MULTIPLY,		XK_KP_Multiply},
-	{VK_ADD,		XK_KP_Add},
-	{VK_SEPARATOR,		XK_KP_Separator},   // often comma
-	{VK_SUBTRACT,		XK_KP_Subtract},
-	{VK_DECIMAL,		XK_KP_Decimal},
-	{VK_DIVIDE,		XK_KP_Divide},
-	{VK_F1,			XK_F1},
-	{VK_F2,			XK_F2},
-	{VK_F3,			XK_F3},
-	{VK_F4,			XK_F4},
-	{VK_F5,			XK_F5},
-	{VK_F6,			XK_F6},
-	{VK_F7,			XK_F7},
-	{VK_F8,			XK_F8},
-	{VK_F9,			XK_F9},
-	{VK_F10,		XK_F10},
-	{VK_F11,		XK_F11},
-	{VK_F12,		XK_F12},
-	{VK_F13,		XK_F13},
-	{VK_F14,		XK_F14},
-	{VK_F15,		XK_F15},
-	{VK_F16,		XK_F16},
-	{VK_F17,		XK_F17},
-	{VK_F18,		XK_F18},
-	{VK_F19,		XK_F19},
-	{VK_F20,		XK_F20},
-	{VK_F21,		XK_F21},
-	{VK_F22,		XK_F22},
-	{VK_F23,		XK_F23},
-	{VK_F24,		XK_F24},
-	{VK_NUMLOCK,		XK_Num_Lock},
-	{VK_SCROLL,		XK_Scroll_Lock}
-};
-
-static int g_winKeymapEntries = sizeof (winKeymap) / sizeof (winKeymappingRec);
-
-#else /* WIN_NEW_KEYBOARD_SUPPORT */
-
 #define		WIN_KEYMAP_COLS		3
 
 const int
@@ -395,4 +307,5 @@
   /* 254 */	0,		0,		0,
   /* 255 */	0,		0,		0
 };
-#endif /* WIN_NEW_KEYBOARD_SUPPORT */
+
+#endif /* WINKEYBD_H */

Index: winwndproc.c
===================================================================
RCS file: /cvs/xorg/xc/programs/Xserver/hw/xwin/winwndproc.c,v
retrieving revision 1.1.4.1.2.2
retrieving revision 1.1.4.1.2.3
diff -u -d -r1.1.4.1.2.2 -r1.1.4.1.2.3
--- winwndproc.c	9 Dec 2003 01:37:16 -0000	1.1.4.1.2.2
+++ winwndproc.c	24 Dec 2003 21:17:27 -0000	1.1.4.1.2.3
@@ -846,26 +846,6 @@
       winKeybdReleaseKeys ();
       return 0;
 
-#if WIN_NEW_KEYBOARD_SUPPORT
-    case WM_SYSKEYDOWN:
-    case WM_KEYDOWN:
-    case WM_SYSKEYUP:
-    case WM_KEYUP:
-      if (s_pScreenPriv == NULL || s_pScreenInfo->fIgnoreInput)
-	break;
-
-      /* Don't process keys if we are not active */
-      if (!s_pScreenPriv->fActive)
-	return 0;
-
-      winProcessKeyEvent ((DWORD)wParam, (DWORD) lParam);
-      return 0;
-
-    case WM_DEADCHAR:
-    case WM_SYSDEADCHAR:
-      return 0;
-
-#else /* WIN_NEW_KEYBOARD_SUPPORT */
     case WM_SYSKEYDOWN:
     case WM_KEYDOWN:
       if (s_pScreenPriv == NULL || s_pScreenInfo->fIgnoreInput)
@@ -955,7 +935,6 @@
       winTranslateKey (wParam, lParam, &iScanCode);
       winSendKeyEvent (iScanCode, FALSE);
       return 0;
-#endif /* WIN_NEW_KEYBOARD_SUPPORT */
 
     case WM_HOTKEY:
       if (s_pScreenPriv == NULL)





More information about the xorg-commit mailing list