[WIN32K]
authorRafal Harabien <rafalh@reactos.org>
Sat, 8 Oct 2011 23:33:26 +0000 (23:33 +0000)
committerRafal Harabien <rafalh@reactos.org>
Sat, 8 Oct 2011 23:33:26 +0000 (23:33 +0000)
- Rename gKeyStateTable to gafAsyncKeyState: it's a proper name
- Fix accelerators regression

svn path=/trunk/; revision=54058

reactos/subsystems/win32/win32k/include/input.h
reactos/subsystems/win32/win32k/ntuser/accelerator.c
reactos/subsystems/win32/win32k/ntuser/input.c
reactos/subsystems/win32/win32k/ntuser/keyboard.c
reactos/subsystems/win32/win32k/ntuser/msgqueue.c

index 36d7f23..9eac220 100644 (file)
@@ -56,4 +56,4 @@ VOID FASTCALL DoTheScreenSaver(VOID);
 
 extern HANDLE ghKeyboardDevice;
 extern PTHREADINFO ptiRawInput;
-extern BYTE gKeyStateTable[0x100];
+extern BYTE gafAsyncKeyState[0x100];
index 03e5fa8..1e20a83 100644 (file)
@@ -110,7 +110,7 @@ co_IntTranslateAccelerator(
                                    &MenuItem,
                                    NULL);
        if (nPos != (UINT)-1)
-           hSubMenu = MenuItem->hSubMenu;
+           hSubMenu = SubMenu->head.h;
        else
            hMenu = NULL;
    }
@@ -129,7 +129,7 @@ co_IntTranslateAccelerator(
                                        &MenuItem,
                                        NULL);
            if (nPos != (UINT)-1)
-               hSubMenu = MenuItem->hSubMenu;
+               hSubMenu = SubMenu->head.h;
            else
                hMenu = NULL;
        }
@@ -138,7 +138,7 @@ co_IntTranslateAccelerator(
    /* If this is a menu item, there is no capturing enabled and
       window is not disabled, send WM_INITMENU */
    if (hMenu && !IntGetCaptureWindow())
-   {                                               
+   {
        co_IntSendMessage(hWnd, WM_INITMENU, (WPARAM)hMenu, 0L);
        if (hSubMenu)
        {
@@ -154,7 +154,7 @@ co_IntTranslateAccelerator(
       - this is window menu and window is minimized */
    if (!(Window->style & WS_DISABLED) &&
        !(hMenu && IntGetMenuState(hMenu, pAccel->cmd, MF_BYCOMMAND) & (MF_DISABLED|MF_GRAYED)) &&
-       !(hMenu && hMenu == (HMENU)Window->IDMenu && !(Window->style & WS_MINIMIZED)))
+       !(hMenu && hMenu == (HMENU)Window->IDMenu && (Window->style & WS_MINIMIZED)))
    {
        /* If this is system menu item, send WM_SYSCOMMAND, otherwise send WM_COMMAND */
        if (hMenu && hMenu == Window->SystemMenu)
@@ -426,8 +426,7 @@ NtUserTranslateAccelerator(
    {
       if (co_IntTranslateAccelerator(Window, &Message, &Accel->Table[i]))
       {
-         TRACE("NtUserTranslateAccelerator returns 1\n");
-         RETURN( 1);
+          RETURN( 1);
       }
 
       /* Undocumented feature... */
@@ -441,7 +440,7 @@ CLEANUP:
    if (Window) UserDerefObjectCo(Window);
    if (Accel) UserDerefObjectCo(Accel);
 
-   TRACE("NtUserTranslateAccelerator returns 0\n");
+   TRACE("NtUserTranslateAccelerator returns %d\n", _ret_);
    UserLeave();
    END_CLEANUP;
 }
index 0842e22..1f57219 100644 (file)
@@ -10,7 +10,6 @@
 #include <win32k.h>
 DBG_DEFAULT_CHANNEL(UserInput);
 
-extern BYTE gKeyStateTable[];
 extern NTSTATUS Win32kInitWin32Thread(PETHREAD Thread);
 extern PPROCESSINFO ppiScrnSaver;
 
@@ -684,12 +683,12 @@ IntMouseInput(MOUSEINPUT *mi, BOOL Injected)
     Msg.lParam = MAKELPARAM(MousePos.x, MousePos.y);
     Msg.pt = MousePos;
 
-    if (gKeyStateTable[VK_SHIFT] & KS_DOWN_BIT)
+    if (gafAsyncKeyState[VK_SHIFT] & KS_DOWN_BIT)
     {
         Msg.wParam |= MK_SHIFT;
     }
 
-    if (gKeyStateTable[VK_CONTROL] & KS_DOWN_BIT)
+    if (gafAsyncKeyState[VK_CONTROL] & KS_DOWN_BIT)
     {
         Msg.wParam |= MK_CONTROL;
     }
@@ -700,7 +699,7 @@ IntMouseInput(MOUSEINPUT *mi, BOOL Injected)
     }
     if(mi->dwFlags & MOUSEEVENTF_LEFTDOWN)
     {
-        gKeyStateTable[VK_LBUTTON] |= KS_DOWN_BIT;
+        gafAsyncKeyState[VK_LBUTTON] |= KS_DOWN_BIT;
         Msg.message = SwapBtnMsg[0][SwapButtons];
         CurInfo->ButtonsDown |= SwapBtn[SwapButtons];
         Msg.wParam |= CurInfo->ButtonsDown;
@@ -708,7 +707,7 @@ IntMouseInput(MOUSEINPUT *mi, BOOL Injected)
     }
     else if(mi->dwFlags & MOUSEEVENTF_LEFTUP)
     {
-        gKeyStateTable[VK_LBUTTON] &= ~KS_DOWN_BIT;
+        gafAsyncKeyState[VK_LBUTTON] &= ~KS_DOWN_BIT;
         Msg.message = SwapBtnMsg[1][SwapButtons];
         CurInfo->ButtonsDown &= ~SwapBtn[SwapButtons];
         Msg.wParam |= CurInfo->ButtonsDown;
@@ -716,7 +715,7 @@ IntMouseInput(MOUSEINPUT *mi, BOOL Injected)
     }
     if(mi->dwFlags & MOUSEEVENTF_MIDDLEDOWN)
     {
-        gKeyStateTable[VK_MBUTTON] |= KS_DOWN_BIT;
+        gafAsyncKeyState[VK_MBUTTON] |= KS_DOWN_BIT;
         Msg.message = WM_MBUTTONDOWN;
         CurInfo->ButtonsDown |= MK_MBUTTON;
         Msg.wParam |= CurInfo->ButtonsDown;
@@ -724,7 +723,7 @@ IntMouseInput(MOUSEINPUT *mi, BOOL Injected)
     }
     else if(mi->dwFlags & MOUSEEVENTF_MIDDLEUP)
     {
-        gKeyStateTable[VK_MBUTTON] &= ~KS_DOWN_BIT;
+        gafAsyncKeyState[VK_MBUTTON] &= ~KS_DOWN_BIT;
         Msg.message = WM_MBUTTONUP;
         CurInfo->ButtonsDown &= ~MK_MBUTTON;
         Msg.wParam |= CurInfo->ButtonsDown;
@@ -732,7 +731,7 @@ IntMouseInput(MOUSEINPUT *mi, BOOL Injected)
     }
     if(mi->dwFlags & MOUSEEVENTF_RIGHTDOWN)
     {
-        gKeyStateTable[VK_RBUTTON] |= KS_DOWN_BIT;
+        gafAsyncKeyState[VK_RBUTTON] |= KS_DOWN_BIT;
         Msg.message = SwapBtnMsg[0][!SwapButtons];
         CurInfo->ButtonsDown |= SwapBtn[!SwapButtons];
         Msg.wParam |= CurInfo->ButtonsDown;
@@ -740,7 +739,7 @@ IntMouseInput(MOUSEINPUT *mi, BOOL Injected)
     }
     else if(mi->dwFlags & MOUSEEVENTF_RIGHTUP)
     {
-        gKeyStateTable[VK_RBUTTON] &= ~KS_DOWN_BIT;
+        gafAsyncKeyState[VK_RBUTTON] &= ~KS_DOWN_BIT;
         Msg.message = SwapBtnMsg[1][!SwapButtons];
         CurInfo->ButtonsDown &= ~SwapBtn[!SwapButtons];
         Msg.wParam |= CurInfo->ButtonsDown;
@@ -759,14 +758,14 @@ IntMouseInput(MOUSEINPUT *mi, BOOL Injected)
         Msg.message = WM_XBUTTONDOWN;
         if(mi->mouseData & XBUTTON1)
         {
-            gKeyStateTable[VK_XBUTTON1] |= KS_DOWN_BIT;
+            gafAsyncKeyState[VK_XBUTTON1] |= KS_DOWN_BIT;
             CurInfo->ButtonsDown |= MK_XBUTTON1;
             Msg.wParam = MAKEWPARAM(CurInfo->ButtonsDown, XBUTTON1);
             co_MsqInsertMouseMessage(&Msg, Injected, mi->dwExtraInfo, TRUE);
         }
         if(mi->mouseData & XBUTTON2)
         {
-            gKeyStateTable[VK_XBUTTON2] |= KS_DOWN_BIT;
+            gafAsyncKeyState[VK_XBUTTON2] |= KS_DOWN_BIT;
             CurInfo->ButtonsDown |= MK_XBUTTON2;
             Msg.wParam = MAKEWPARAM(CurInfo->ButtonsDown, XBUTTON2);
             co_MsqInsertMouseMessage(&Msg, Injected, mi->dwExtraInfo, TRUE);
@@ -777,14 +776,14 @@ IntMouseInput(MOUSEINPUT *mi, BOOL Injected)
         Msg.message = WM_XBUTTONUP;
         if(mi->mouseData & XBUTTON1)
         {
-            gKeyStateTable[VK_XBUTTON1] &= ~KS_DOWN_BIT;
+            gafAsyncKeyState[VK_XBUTTON1] &= ~KS_DOWN_BIT;
             CurInfo->ButtonsDown &= ~MK_XBUTTON1;
             Msg.wParam = MAKEWPARAM(CurInfo->ButtonsDown, XBUTTON1);
             co_MsqInsertMouseMessage(&Msg, Injected, mi->dwExtraInfo, TRUE);
         }
         if(mi->mouseData & XBUTTON2)
         {
-            gKeyStateTable[VK_XBUTTON2] &= ~KS_DOWN_BIT;
+            gafAsyncKeyState[VK_XBUTTON2] &= ~KS_DOWN_BIT;
             CurInfo->ButtonsDown &= ~MK_XBUTTON2;
             Msg.wParam = MAKEWPARAM(CurInfo->ButtonsDown, XBUTTON2);
             co_MsqInsertMouseMessage(&Msg, Injected, mi->dwExtraInfo, TRUE);
index 4c4077e..e02bccd 100644 (file)
@@ -10,7 +10,7 @@
 #include <win32k.h>
 DBG_DEFAULT_CHANNEL(UserKbd);
 
-BYTE gKeyStateTable[0x100];
+BYTE gafAsyncKeyState[0x100];
 static PKEYBOARD_INDICATOR_TRANSLATION gpKeyboardIndicatorTrans = NULL;
 
 /* FUNCTIONS *****************************************************************/
@@ -25,7 +25,7 @@ NTSTATUS
 NTAPI
 InitKeyboardImpl(VOID)
 {
-    RtlZeroMemory(&gKeyStateTable, sizeof(gKeyStateTable));
+    RtlZeroMemory(&gafAsyncKeyState, sizeof(gafAsyncKeyState));
     return STATUS_SUCCESS;
 }
 
@@ -636,9 +636,9 @@ IntGetAsyncKeyState(DWORD dwKey)
 
     if (dwKey < 0x100)
     {
-        if (gKeyStateTable[dwKey] & KS_DOWN_BIT)
+        if (gafAsyncKeyState[dwKey] & KS_DOWN_BIT)
             dwRet |= 0xFFFF8000; // If down, windows returns 0xFFFF8000.
-        if (gKeyStateTable[dwKey] & KS_LOCK_BIT)
+        if (gafAsyncKeyState[dwKey] & KS_LOCK_BIT)
             dwRet |= 0x1;
     }
     else
@@ -783,20 +783,20 @@ UserSendKeyboardInput(KEYBDINPUT *pKbdInput, BOOL bInjected)
         /* Get virtual key without shifts (VK_(L|R)* -> VK_*) */
         wSimpleVk = IntSimplifyVk(wVk);
         wVkOtherSide = IntGetVkOtherSide(wVk);
-        PrevKeyState = gKeyStateTable[wSimpleVk];
+        PrevKeyState = gafAsyncKeyState[wSimpleVk];
 
         /* Update global keyboard state. Begin from lock bit */
         if (!bKeyUp && !(PrevKeyState & KS_DOWN_BIT))
-            gKeyStateTable[wVk] ^= KS_LOCK_BIT;
+            gafAsyncKeyState[wVk] ^= KS_LOCK_BIT;
 
         /* Update down bit */
         if (bKeyUp)
-            gKeyStateTable[wVk] &= ~KS_DOWN_BIT;
+            gafAsyncKeyState[wVk] &= ~KS_DOWN_BIT;
         else
-            gKeyStateTable[wVk] |= KS_DOWN_BIT;
+            gafAsyncKeyState[wVk] |= KS_DOWN_BIT;
 
         /* Update key without shifts */
-        gKeyStateTable[wSimpleVk] = gKeyStateTable[wVk] | gKeyStateTable[wVkOtherSide];
+        gafAsyncKeyState[wSimpleVk] = gafAsyncKeyState[wVk] | gafAsyncKeyState[wVkOtherSide];
 
         if (!bKeyUp)
         {
@@ -806,7 +806,7 @@ UserSendKeyboardInput(KEYBDINPUT *pKbdInput, BOOL bInjected)
             if (gpKeyboardIndicatorTrans)
                 IntKeyboardUpdateLeds(ghKeyboardDevice,
                                       wScanCode,
-                                      gKeyStateTable[wSimpleVk] & KS_LOCK_BIT,
+                                      gafAsyncKeyState[wSimpleVk] & KS_LOCK_BIT,
                                       gpKeyboardIndicatorTrans);
         }
 
@@ -818,12 +818,12 @@ UserSendKeyboardInput(KEYBDINPUT *pKbdInput, BOOL bInjected)
         {
             if (wVk == VK_LWIN || wVk == VK_RWIN)
                 IntKeyboardSendWinKeyMsg();
-            else if(wSimpleVk == VK_MENU && !(gKeyStateTable[VK_CONTROL] & KS_DOWN_BIT))
+            else if(wSimpleVk == VK_MENU && !(gafAsyncKeyState[VK_CONTROL] & KS_DOWN_BIT))
                 co_IntKeyboardSendAltKeyMsg();
         }
 
         /* Check if it is a hotkey */
-        fModifiers = IntGetModifiers(gKeyStateTable);
+        fModifiers = IntGetModifiers(gafAsyncKeyState);
         if (GetHotKey(fModifiers, wSimpleVk, &Thread, &hWnd, &HotkeyId))
         {
             if (!bKeyUp)
@@ -848,8 +848,8 @@ UserSendKeyboardInput(KEYBDINPUT *pKbdInput, BOOL bInjected)
         wSysKey = (pKbdTbl->fLocaleFlags & KLLF_ALTGR) ? VK_LMENU : VK_MENU;
         if (wVk == VK_F10 ||
             //uVkNoShift == VK_MENU || // FIXME: If only LALT is pressed WM_SYSKEYUP is generated instead of WM_KEYUP
-            ((gKeyStateTable[wSysKey] & KS_DOWN_BIT) && // FIXME
-            !(gKeyStateTable[VK_CONTROL] & KS_DOWN_BIT)))
+            ((gafAsyncKeyState[wSysKey] & KS_DOWN_BIT) && // FIXME
+            !(gafAsyncKeyState[VK_CONTROL] & KS_DOWN_BIT)))
         {
             if (bKeyUp)
                 Msg.message = WM_SYSKEYUP;
@@ -870,7 +870,7 @@ UserSendKeyboardInput(KEYBDINPUT *pKbdInput, BOOL bInjected)
         {
             if (bExt)
                 Msg.lParam |= LP_EXT_BIT;
-            if (gKeyStateTable[VK_MENU] & KS_DOWN_BIT)
+            if (gafAsyncKeyState[VK_MENU] & KS_DOWN_BIT)
                 Msg.lParam |= LP_CONTEXT_BIT;
             if (PrevKeyState & KS_DOWN_BIT)
                 Msg.lParam |= LP_PREV_STATE_BIT;
@@ -947,7 +947,7 @@ UserProcessKeyboardInput(
         KEYBDINPUT KbdInput;
 
         /* Support numlock */
-        if ((wVk & KBDNUMPAD) && (gKeyStateTable[VK_NUMLOCK] & KS_LOCK_BIT))
+        if ((wVk & KBDNUMPAD) && (gafAsyncKeyState[VK_NUMLOCK] & KS_LOCK_BIT))
         {
             wVk = IntTranslateNumpadKey(wVk & 0xFF);
         }
@@ -1451,19 +1451,19 @@ UserGetMouseButtonsState(VOID)
 
     if (gpsi->aiSysMet[SM_SWAPBUTTON])
     {
-        if (gKeyStateTable[VK_RBUTTON] & KS_DOWN_BIT) ret |= MK_LBUTTON;
-        if (gKeyStateTable[VK_LBUTTON] & KS_DOWN_BIT) ret |= MK_RBUTTON;
+        if (gafAsyncKeyState[VK_RBUTTON] & KS_DOWN_BIT) ret |= MK_LBUTTON;
+        if (gafAsyncKeyState[VK_LBUTTON] & KS_DOWN_BIT) ret |= MK_RBUTTON;
     }
     else
     {
-        if (gKeyStateTable[VK_LBUTTON] & KS_DOWN_BIT) ret |= MK_LBUTTON;
-        if (gKeyStateTable[VK_RBUTTON] & KS_DOWN_BIT) ret |= MK_RBUTTON;
+        if (gafAsyncKeyState[VK_LBUTTON] & KS_DOWN_BIT) ret |= MK_LBUTTON;
+        if (gafAsyncKeyState[VK_RBUTTON] & KS_DOWN_BIT) ret |= MK_RBUTTON;
     }
-    if (gKeyStateTable[VK_MBUTTON]  & KS_DOWN_BIT) ret |= MK_MBUTTON;
-    if (gKeyStateTable[VK_SHIFT]    & KS_DOWN_BIT) ret |= MK_SHIFT;
-    if (gKeyStateTable[VK_CONTROL]  & KS_DOWN_BIT) ret |= MK_CONTROL;
-    if (gKeyStateTable[VK_XBUTTON1] & KS_DOWN_BIT) ret |= MK_XBUTTON1;
-    if (gKeyStateTable[VK_XBUTTON2] & KS_DOWN_BIT) ret |= MK_XBUTTON2;
+    if (gafAsyncKeyState[VK_MBUTTON]  & KS_DOWN_BIT) ret |= MK_MBUTTON;
+    if (gafAsyncKeyState[VK_SHIFT]    & KS_DOWN_BIT) ret |= MK_SHIFT;
+    if (gafAsyncKeyState[VK_CONTROL]  & KS_DOWN_BIT) ret |= MK_CONTROL;
+    if (gafAsyncKeyState[VK_XBUTTON1] & KS_DOWN_BIT) ret |= MK_XBUTTON1;
+    if (gafAsyncKeyState[VK_XBUTTON2] & KS_DOWN_BIT) ret |= MK_XBUTTON2;
     return ret;
 }
 
index a3a1254..ead730c 100644 (file)
@@ -1930,7 +1930,7 @@ MsqInitializeMessageQueue(struct _ETHREAD *Thread, PUSER_MESSAGE_QUEUE MessageQu
    MessageQueue->NewMessagesHandle = NULL;
    MessageQueue->ShowingCursor = 0;
    MessageQueue->CursorObject = NULL;
-   RtlCopyMemory(MessageQueue->KeyState, gKeyStateTable, sizeof(gKeyStateTable));
+   RtlCopyMemory(MessageQueue->KeyState, gafAsyncKeyState, sizeof(gafAsyncKeyState));
 
    Status = ZwCreateEvent(&MessageQueue->NewMessagesHandle, EVENT_ALL_ACCESS,
                           NULL, SynchronizationEvent, FALSE);