[Win32ss]

- Fix up hot keys. Finding out that the wine test_hotkey is brain damaged and even breaks XP.

svn path=/trunk/; revision=60659
This commit is contained in:
James Tabor 2013-10-14 06:19:48 +00:00
parent 8109301ade
commit f4b05f11b2
13 changed files with 289 additions and 168 deletions

View file

@ -74,4 +74,6 @@ list(APPEND SOURCE
vtxfmt.c vtxfmt.c
) )
add_library(mesa_main STATIC ${SOURCE}) add_library(mesa_main STATIC ${SOURCE})
allow_warnings(mesa_main)

View file

@ -27,4 +27,6 @@ list(APPEND SOURCE
s_zoom.c s_zoom.c
) )
add_library(mesa_swrast STATIC ${SOURCE}) add_library(mesa_swrast STATIC ${SOURCE})
allow_warnings(mesa_swrast)

View file

@ -233,7 +233,7 @@ IntDefWindowProc(
return (LRESULT) DefWndControlColor((HDC)wParam, HIWORD(lParam)); return (LRESULT) DefWndControlColor((HDC)wParam, HIWORD(lParam));
case WM_GETHOTKEY: case WM_GETHOTKEY:
return DefWndGetHotKey(UserHMGetHandle(Wnd)); return DefWndGetHotKey(Wnd);
case WM_SETHOTKEY: case WM_SETHOTKEY:
return DefWndSetHotKey(Wnd, wParam); return DefWndSetHotKey(Wnd, wParam);

View file

@ -2,7 +2,7 @@
* COPYRIGHT: See COPYING in the top level directory * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS Win32k subsystem * PROJECT: ReactOS Win32k subsystem
* PURPOSE: HotKey support * PURPOSE: HotKey support
* FILE: subsystems/win32/win32k/ntuser/hotkey.c * FILE: win32ss/user/ntuser/hotkey.c
* PROGRAMER: Eric Kohl * PROGRAMER: Eric Kohl
*/ */
@ -30,17 +30,31 @@ DBG_DEFAULT_CHANNEL(UserHotkey);
* By default the key is VK-F12 on a 101-key keyboard, and is VK_SUBTRACT * By default the key is VK-F12 on a 101-key keyboard, and is VK_SUBTRACT
* (hyphen / substract sign) on a 82-key keyboard. * (hyphen / substract sign) on a 82-key keyboard.
*/ */
/* thread hwnd modifiers vk id next */ /* pti pwnd modifiers vk id next */
// HOT_KEY hkF12 = {NULL, NULL, 0, VK_F12, IDHK_F12, NULL}; // HOT_KEY hkF12 = {NULL, 1, 0, VK_F12, IDHK_F12, NULL};
// HOT_KEY hkShiftF12 = {NULL, NULL, MOD_SHIFT, VK_F12, IDHK_SHIFTF12, &hkF12}; // HOT_KEY hkShiftF12 = {NULL, 1, MOD_SHIFT, VK_F12, IDHK_SHIFTF12, &hkF12};
// HOT_KEY hkWinKey = {NULL, NULL, MOD_WIN, 0, IDHK_WINKEY, &hkShiftF12}; // HOT_KEY hkWinKey = {NULL, 1, MOD_WIN, 0, IDHK_WINKEY, &hkShiftF12};
HOT_KEY hkWinKey = {NULL, NULL, MOD_WIN, 0, IDHK_WINKEY, NULL};
PHOT_KEY gphkFirst = &hkWinKey; PHOT_KEY gphkFirst = NULL;
BOOL bWinHotkeyActive = FALSE; BOOL bWinHotkeyActive = FALSE;
/* FUNCTIONS *****************************************************************/ /* FUNCTIONS *****************************************************************/
VOID FASTCALL
StartDebugHotKeys(VOID)
{
UINT vk = VK_F12;
UserUnregisterHotKey(PWND_BOTTOM, IDHK_F12);
UserUnregisterHotKey(PWND_BOTTOM, IDHK_SHIFTF12);
if (!ENHANCED_KEYBOARD(gKeyboardInfo.KeyboardIdentifier))
{
vk = VK_SUBTRACT;
}
UserRegisterHotKey(PWND_BOTTOM, IDHK_SHIFTF12, MOD_SHIFT, vk);
UserRegisterHotKey(PWND_BOTTOM, IDHK_F12, 0, vk);
ERR("Start up the debugger hotkeys!! Should see this once!\n");
}
/* /*
* IntGetModifiers * IntGetModifiers
* *
@ -77,7 +91,6 @@ VOID FASTCALL
UnregisterWindowHotKeys(PWND pWnd) UnregisterWindowHotKeys(PWND pWnd)
{ {
PHOT_KEY pHotKey = gphkFirst, phkNext, *pLink = &gphkFirst; PHOT_KEY pHotKey = gphkFirst, phkNext, *pLink = &gphkFirst;
HWND hWnd = pWnd->head.h;
while (pHotKey) while (pHotKey)
{ {
@ -85,7 +98,7 @@ UnregisterWindowHotKeys(PWND pWnd)
phkNext = pHotKey->pNext; phkNext = pHotKey->pNext;
/* Should we delete this hotkey? */ /* Should we delete this hotkey? */
if (pHotKey->hWnd == hWnd) if (pHotKey->pWnd == pWnd)
{ {
/* Update next ptr for previous hotkey and free memory */ /* Update next ptr for previous hotkey and free memory */
*pLink = phkNext; *pLink = phkNext;
@ -105,7 +118,7 @@ UnregisterWindowHotKeys(PWND pWnd)
* Removes hotkeys registered by specified thread on its cleanup * Removes hotkeys registered by specified thread on its cleanup
*/ */
VOID FASTCALL VOID FASTCALL
UnregisterThreadHotKeys(struct _ETHREAD *pThread) UnregisterThreadHotKeys(PTHREADINFO pti)
{ {
PHOT_KEY pHotKey = gphkFirst, phkNext, *pLink = &gphkFirst; PHOT_KEY pHotKey = gphkFirst, phkNext, *pLink = &gphkFirst;
@ -115,7 +128,7 @@ UnregisterThreadHotKeys(struct _ETHREAD *pThread)
phkNext = pHotKey->pNext; phkNext = pHotKey->pNext;
/* Should we delete this hotkey? */ /* Should we delete this hotkey? */
if (pHotKey->pThread == pThread) if (pHotKey->pti == pti)
{ {
/* Update next ptr for previous hotkey and free memory */ /* Update next ptr for previous hotkey and free memory */
*pLink = phkNext; *pLink = phkNext;
@ -165,6 +178,8 @@ co_UserProcessHotKeys(WORD wVk, BOOL bIsDown)
{ {
UINT fModifiers; UINT fModifiers;
PHOT_KEY pHotKey; PHOT_KEY pHotKey;
PWND pWnd;
BOOL DoNotPostMsg = FALSE;
if (wVk == VK_SHIFT || wVk == VK_CONTROL || wVk == VK_MENU || if (wVk == VK_SHIFT || wVk == VK_CONTROL || wVk == VK_MENU ||
wVk == VK_LWIN || wVk == VK_RWIN) wVk == VK_LWIN || wVk == VK_RWIN)
@ -173,59 +188,84 @@ co_UserProcessHotKeys(WORD wVk, BOOL bIsDown)
wVk = 0; wVk = 0;
} }
/* Check if it is a hotkey */
fModifiers = IntGetModifiers(gafAsyncKeyState); fModifiers = IntGetModifiers(gafAsyncKeyState);
/* Check if it is a hotkey */
pHotKey = IsHotKey(fModifiers, wVk); pHotKey = IsHotKey(fModifiers, wVk);
if (pHotKey) if (pHotKey)
{ {
TRACE("Hot key Found\n");
/* FIXME: See comment about "UserDebuggerHotKey" on top of this file. */
if (pHotKey->id == IDHK_SHIFTF12 || pHotKey->id == IDHK_F12)
{
if (bIsDown)
{
ERR("Hot key pressed for Debug Activation! ShiftF12 = %d or F12 = %d\n",pHotKey->id == IDHK_SHIFTF12 , pHotKey->id == IDHK_F12);
//DoNotPostMsg = co_ActivateDebugger(); // FIXME
}
return DoNotPostMsg;
}
/* Process hotkey if it is key up event */ /* Process hotkey if it is key up event */
if (!bIsDown) if (!bIsDown)
{ {
TRACE("Hot key pressed (hWnd %p, id %d)\n", pHotKey->hWnd, pHotKey->id); TRACE("Hot key pressed (pWnd %p, id %d)\n", pHotKey->pWnd, pHotKey->id);
/* WIN and F12 keys are hardcoded here. See comments on top of this file. */ /* WIN and F12 keys are not hardcoded here. See comments on top of this file. */
if (pHotKey == &hkWinKey) if (pHotKey->id == IDHK_WINKEY && bWinHotkeyActive == TRUE)
{ {
if(bWinHotkeyActive == TRUE) pWnd = ValidateHwndNoErr(InputWindowStation->ShellWindow);
if (pWnd)
{ {
UserPostMessage(InputWindowStation->ShellWindow, WM_SYSCOMMAND, SC_TASKLIST, 0); TRACE("System Hot key Id %d Key %d\n",pHotKey->id, wVk );
bWinHotkeyActive = FALSE; UserPostMessage(UserHMGetHandle(pWnd), WM_SYSCOMMAND, SC_TASKLIST, 0);
//ptiLastInput = pWnd->head.pti;
bWinHotkeyActive = FALSE;
return TRUE;
} }
} }
#if 0 /* FIXME: See comment about "UserDebuggerHotKey" on top of this file. */
else if (pHotKey == &hkF12 || pHotKey == &hkShiftF12) if (!pHotKey->pWnd)
{ {
//co_ActivateDebugger(); // FIXME TRACE("UPTM Hot key Id %d Key %d\n",pHotKey->id, wVk );
} UserPostThreadMessage(pHotKey->pti, WM_HOTKEY, pHotKey->id, MAKELONG(fModifiers, wVk));
#endif //ptiLastInput = pHotKey->pti;
else if (pHotKey->id == IDHK_REACTOS && !pHotKey->pThread) // FIXME: Those hotkeys doesn't depend on RegisterHotKey
{
UserPostMessage(pHotKey->hWnd, WM_SYSCOMMAND, SC_HOTKEY, (LPARAM)pHotKey->hWnd);
} }
else else
{ {
/* If a hotkey with the WIN modifier was activated, do not treat the release of the WIN key as a hotkey*/ if (pHotKey->pWnd == PWND_BOTTOM)
if((pHotKey->fsModifiers & MOD_WIN) != 0) {
bWinHotkeyActive = FALSE; if (gpqForeground != NULL)
{
MsqPostHotKeyMessage(pHotKey->pThread, pWnd = gpqForeground->spwndFocus;
pHotKey->hWnd, }
(WPARAM)pHotKey->id, else
MAKELPARAM((WORD)fModifiers, wVk)); return FALSE;
}
else
{
pWnd = pHotKey->pWnd;
}
if (pWnd)
{
if (pWnd == pWnd->head.rpdesk->pDeskInfo->spwndShell && pHotKey->id == SC_TASKLIST)
{
ERR("Sending to shell window w/o IDHK_WINKEY..\n");
UserPostMessage(UserHMGetHandle(pWnd), WM_SYSCOMMAND, SC_TASKLIST, 0);
}
else
{
UserPostMessage(UserHMGetHandle(pWnd), WM_HOTKEY, pHotKey->id, MAKELONG(fModifiers, wVk));
}
//ptiLastInput = pWnd->head.pti;
}
} }
return TRUE; /* Don't send any message */
} }
else else /* The user pressed the win key */
{ if (pHotKey->id == IDHK_WINKEY) bWinHotkeyActive = TRUE;
if (pHotKey == &hkWinKey)
{
/* The user pressed the win key */
bWinHotkeyActive = TRUE;
}
}
return TRUE; /* Don't send any message */
} }
return FALSE; return FALSE;
} }
@ -236,7 +276,7 @@ co_UserProcessHotKeys(WORD wVk, BOOL bIsDown)
* GetHotKey message support * GetHotKey message support
*/ */
UINT FASTCALL UINT FASTCALL
DefWndGetHotKey(HWND hWnd) DefWndGetHotKey(PWND pWnd)
{ {
PHOT_KEY pHotKey = gphkFirst; PHOT_KEY pHotKey = gphkFirst;
@ -244,7 +284,7 @@ DefWndGetHotKey(HWND hWnd)
while (pHotKey) while (pHotKey)
{ {
if (pHotKey->hWnd == hWnd && pHotKey->id == IDHK_REACTOS) if (pHotKey->pWnd == pWnd && pHotKey->id == IDHK_REACTOS)
{ {
/* We have found it */ /* We have found it */
return MAKELONG(pHotKey->vk, pHotKey->fsModifiers); return MAKELONG(pHotKey->vk, pHotKey->fsModifiers);
@ -267,7 +307,6 @@ DefWndSetHotKey(PWND pWnd, WPARAM wParam)
{ {
UINT fsModifiers, vk; UINT fsModifiers, vk;
PHOT_KEY pHotKey, *pLink; PHOT_KEY pHotKey, *pLink;
HWND hWnd;
INT iRet = 1; INT iRet = 1;
WARN("DefWndSetHotKey wParam 0x%x\n", wParam); WARN("DefWndSetHotKey wParam 0x%x\n", wParam);
@ -286,7 +325,6 @@ DefWndSetHotKey(PWND pWnd, WPARAM wParam)
vk = LOWORD(wParam); vk = LOWORD(wParam);
fsModifiers = HIWORD(wParam); fsModifiers = HIWORD(wParam);
hWnd = UserHMGetHandle(pWnd);
if (wParam) if (wParam)
{ {
@ -297,7 +335,7 @@ DefWndSetHotKey(PWND pWnd, WPARAM wParam)
pHotKey->vk == vk && pHotKey->vk == vk &&
pHotKey->id == IDHK_REACTOS) pHotKey->id == IDHK_REACTOS)
{ {
if (pHotKey->hWnd != hWnd) if (pHotKey->pWnd != pWnd)
iRet = 2; // Another window already has the same hot key. iRet = 2; // Another window already has the same hot key.
break; break;
} }
@ -311,7 +349,7 @@ DefWndSetHotKey(PWND pWnd, WPARAM wParam)
pLink = &gphkFirst; pLink = &gphkFirst;
while (pHotKey) while (pHotKey)
{ {
if (pHotKey->hWnd == hWnd && if (pHotKey->pWnd == pWnd &&
pHotKey->id == IDHK_REACTOS) pHotKey->id == IDHK_REACTOS)
{ {
/* This window has already hotkey registered */ /* This window has already hotkey registered */
@ -332,7 +370,7 @@ DefWndSetHotKey(PWND pWnd, WPARAM wParam)
if (pHotKey == NULL) if (pHotKey == NULL)
return 0; return 0;
pHotKey->hWnd = hWnd; pHotKey->pWnd = pWnd;
pHotKey->id = IDHK_REACTOS; // Don't care, these hot keys are unrelated to the hot keys set by RegisterHotKey pHotKey->id = IDHK_REACTOS; // Don't care, these hot keys are unrelated to the hot keys set by RegisterHotKey
pHotKey->pNext = gphkFirst; pHotKey->pNext = gphkFirst;
gphkFirst = pHotKey; gphkFirst = pHotKey;
@ -340,7 +378,7 @@ DefWndSetHotKey(PWND pWnd, WPARAM wParam)
/* A window can only have one hot key. If the window already has a /* A window can only have one hot key. If the window already has a
hot key associated with it, the new hot key replaces the old one. */ hot key associated with it, the new hot key replaces the old one. */
pHotKey->pThread = NULL; pHotKey->pti = NULL;
pHotKey->fsModifiers = fsModifiers; pHotKey->fsModifiers = fsModifiers;
pHotKey->vk = vk; pHotKey->vk = vk;
} }
@ -354,6 +392,85 @@ DefWndSetHotKey(PWND pWnd, WPARAM wParam)
return iRet; return iRet;
} }
BOOL FASTCALL
UserRegisterHotKey(PWND pWnd,
int id,
UINT fsModifiers,
UINT vk)
{
PHOT_KEY pHotKey;
PTHREADINFO pHotKeyThread;
/* Find hotkey thread */
if (pWnd == NULL || pWnd == PWND_BOTTOM)
{
pHotKeyThread = PsGetCurrentThreadWin32Thread();
}
else
{
pHotKeyThread = pWnd->head.pti;
}
/* Check for existing hotkey */
if (IsHotKey(fsModifiers, vk))
{
EngSetLastError(ERROR_HOTKEY_ALREADY_REGISTERED);
WARN("Hotkey already exists\n");
return FALSE;
}
/* Create new hotkey */
pHotKey = ExAllocatePoolWithTag(PagedPool, sizeof(HOT_KEY), USERTAG_HOTKEY);
if (pHotKey == NULL)
{
EngSetLastError(ERROR_NOT_ENOUGH_MEMORY);
return FALSE;
}
pHotKey->pti = pHotKeyThread;
pHotKey->pWnd = pWnd;
pHotKey->fsModifiers = fsModifiers;
pHotKey->vk = vk;
pHotKey->id = id;
/* Insert hotkey to the global list */
pHotKey->pNext = gphkFirst;
gphkFirst = pHotKey;
return TRUE;
}
BOOL FASTCALL
UserUnregisterHotKey(PWND pWnd, int id)
{
PHOT_KEY pHotKey = gphkFirst, phkNext, *pLink = &gphkFirst;
BOOL bRet = FALSE;
while (pHotKey)
{
/* Save next ptr for later use */
phkNext = pHotKey->pNext;
/* Should we delete this hotkey? */
if (pHotKey->pWnd == pWnd && pHotKey->id == id)
{
/* Update next ptr for previous hotkey and free memory */
*pLink = phkNext;
ExFreePoolWithTag(pHotKey, USERTAG_HOTKEY);
bRet = TRUE;
}
else /* This hotkey will stay, use its next ptr */
pLink = &pHotKey->pNext;
/* Move to the next entry */
pHotKey = phkNext;
}
return bRet;
}
/* SYSCALLS *****************************************************************/ /* SYSCALLS *****************************************************************/
@ -364,8 +481,8 @@ NtUserRegisterHotKey(HWND hWnd,
UINT vk) UINT vk)
{ {
PHOT_KEY pHotKey; PHOT_KEY pHotKey;
PWND pWnd; PWND pWnd = NULL;
PETHREAD pHotKeyThread; PTHREADINFO pHotKeyThread;
BOOL bRet = FALSE; BOOL bRet = FALSE;
TRACE("Enter NtUserRegisterHotKey\n"); TRACE("Enter NtUserRegisterHotKey\n");
@ -382,7 +499,7 @@ NtUserRegisterHotKey(HWND hWnd,
/* Find hotkey thread */ /* Find hotkey thread */
if (hWnd == NULL) if (hWnd == NULL)
{ {
pHotKeyThread = PsGetCurrentThread(); pHotKeyThread = gptiCurrent;
} }
else else
{ {
@ -390,7 +507,14 @@ NtUserRegisterHotKey(HWND hWnd,
if (!pWnd) if (!pWnd)
goto cleanup; goto cleanup;
pHotKeyThread = pWnd->head.pti->pEThread; pHotKeyThread = pWnd->head.pti;
/* Fix wine msg "Window on another thread" test_hotkey */
if (pWnd->head.pti != gptiCurrent)
{
WARN("Must be from the same Thread.\n");
goto cleanup;
}
} }
/* Check for existing hotkey */ /* Check for existing hotkey */
@ -409,8 +533,8 @@ NtUserRegisterHotKey(HWND hWnd,
goto cleanup; goto cleanup;
} }
pHotKey->pThread = pHotKeyThread; pHotKey->pti = pHotKeyThread;
pHotKey->hWnd = hWnd; pHotKey->pWnd = pWnd;
pHotKey->fsModifiers = fsModifiers; pHotKey->fsModifiers = fsModifiers;
pHotKey->vk = vk; pHotKey->vk = vk;
pHotKey->id = id; pHotKey->id = id;
@ -433,12 +557,13 @@ NtUserUnregisterHotKey(HWND hWnd, int id)
{ {
PHOT_KEY pHotKey = gphkFirst, phkNext, *pLink = &gphkFirst; PHOT_KEY pHotKey = gphkFirst, phkNext, *pLink = &gphkFirst;
BOOL bRet = FALSE; BOOL bRet = FALSE;
PWND pWnd;
TRACE("Enter NtUserUnregisterHotKey\n"); TRACE("Enter NtUserUnregisterHotKey\n");
UserEnterExclusive(); UserEnterExclusive();
/* Fail if given window is invalid */ /* Fail if given window is invalid */
if (hWnd && !UserGetWindowObject(hWnd)) if (hWnd && !(pWnd = UserGetWindowObject(hWnd)))
goto cleanup; goto cleanup;
while (pHotKey) while (pHotKey)
@ -447,7 +572,7 @@ NtUserUnregisterHotKey(HWND hWnd, int id)
phkNext = pHotKey->pNext; phkNext = pHotKey->pNext;
/* Should we delete this hotkey? */ /* Should we delete this hotkey? */
if (pHotKey->hWnd == hWnd && pHotKey->id == id) if (pHotKey->pWnd == pWnd && pHotKey->id == id)
{ {
/* Update next ptr for previous hotkey and free memory */ /* Update next ptr for previous hotkey and free memory */
*pLink = phkNext; *pLink = phkNext;

View file

@ -2,8 +2,8 @@
typedef struct _HOT_KEY typedef struct _HOT_KEY
{ {
struct _ETHREAD *pThread; PTHREADINFO pti;
HWND hWnd; PWND pWnd;
UINT fsModifiers; UINT fsModifiers;
UINT vk; UINT vk;
INT id; INT id;
@ -17,9 +17,12 @@ typedef struct _HOT_KEY
#define IDHK_REACTOS -8 #define IDHK_REACTOS -8
VOID FASTCALL UnregisterWindowHotKeys(PWND Window); VOID FASTCALL UnregisterWindowHotKeys(PWND Window);
VOID FASTCALL UnregisterThreadHotKeys(struct _ETHREAD *pThread); VOID FASTCALL UnregisterThreadHotKeys(PTHREADINFO pti);
BOOL NTAPI co_UserProcessHotKeys(WORD wVk, BOOL bIsDown); BOOL NTAPI co_UserProcessHotKeys(WORD wVk, BOOL bIsDown);
UINT FASTCALL DefWndGetHotKey(HWND hwnd); UINT FASTCALL DefWndGetHotKey(PWND pWnd);
INT FASTCALL DefWndSetHotKey(PWND pWnd, WPARAM wParam); INT FASTCALL DefWndSetHotKey(PWND pWnd, WPARAM wParam);
VOID FASTCALL StartDebugHotKeys(VOID);
BOOL FASTCALL UserRegisterHotKey(PWND pWnd,int id,UINT fsModifiers,UINT vk);
BOOL FASTCALL UserUnregisterHotKey(PWND pWnd, int id);
/* EOF */ /* EOF */

View file

@ -13,12 +13,10 @@ DBG_DEFAULT_CHANNEL(UserInput);
/* GLOBALS *******************************************************************/ /* GLOBALS *******************************************************************/
PTHREADINFO ptiRawInput; PTHREADINFO ptiRawInput;
PTHREADINFO ptiKeyboard;
PTHREADINFO ptiMouse;
PKTIMER MasterTimer = NULL; PKTIMER MasterTimer = NULL;
PATTACHINFO gpai = NULL; PATTACHINFO gpai = NULL;
INT paiCount = 0; INT paiCount = 0;
HANDLE ghKeyboardDevice; HANDLE ghKeyboardDevice = NULL;
static DWORD LastInputTick = 0; static DWORD LastInputTick = 0;
static HANDLE ghMouseDevice; static HANDLE ghMouseDevice;
@ -131,7 +129,7 @@ RawInputThreadMain()
{ {
NTSTATUS MouStatus = STATUS_UNSUCCESSFUL, KbdStatus = STATUS_UNSUCCESSFUL, Status; NTSTATUS MouStatus = STATUS_UNSUCCESSFUL, KbdStatus = STATUS_UNSUCCESSFUL, Status;
IO_STATUS_BLOCK MouIosb, KbdIosb; IO_STATUS_BLOCK MouIosb, KbdIosb;
PFILE_OBJECT pKbdDevice, pMouDevice; PFILE_OBJECT pKbdDevice = NULL, pMouDevice = NULL;
LARGE_INTEGER ByteOffset; LARGE_INTEGER ByteOffset;
//LARGE_INTEGER WaitTimeout; //LARGE_INTEGER WaitTimeout;
PVOID WaitObjects[3], pSignaledObject = NULL; PVOID WaitObjects[3], pSignaledObject = NULL;
@ -175,6 +173,14 @@ RawInputThreadMain()
{ {
++cMaxWaitObjects; ++cMaxWaitObjects;
TRACE("Keyboard connected!\n"); TRACE("Keyboard connected!\n");
// Get and load keyboard attributes.
UserInitKeyboard(ghKeyboardDevice);
UserEnterExclusive();
// Register the Window hotkey.
UserRegisterHotKey(PWND_BOTTOM, IDHK_WINKEY, MOD_WIN, 0);
// Register the debug hotkeys.
StartDebugHotKeys();
UserLeave();
} }
} }

View file

@ -99,4 +99,4 @@ extern BYTE gafAsyncKeyState[256 * 2 / 8]; // 2 bits per key
extern PKL gspklBaseLayout; extern PKL gspklBaseLayout;
extern KEYBOARD_ATTRIBUTES gKeyboardInfo;

View file

@ -2,7 +2,7 @@
* COPYRIGHT: See COPYING in the top level directory * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
* PURPOSE: Keyboard functions * PURPOSE: Keyboard functions
* FILE: subsystems/win32/win32k/ntuser/keyboard.c * FILE: win32ss/user/ntuser/keyboard.c
* PROGRAMERS: Casper S. Hornstrup (chorns@users.sourceforge.net) * PROGRAMERS: Casper S. Hornstrup (chorns@users.sourceforge.net)
* Rafal Harabien (rafalh@reactos.org) * Rafal Harabien (rafalh@reactos.org)
*/ */
@ -14,6 +14,7 @@ BYTE gafAsyncKeyState[256 * 2 / 8]; // 2 bits per key
static BYTE gafAsyncKeyStateRecentDown[256 / 8]; // 1 bit per key static BYTE gafAsyncKeyStateRecentDown[256 / 8]; // 1 bit per key
static PKEYBOARD_INDICATOR_TRANSLATION gpKeyboardIndicatorTrans = NULL; static PKEYBOARD_INDICATOR_TRANSLATION gpKeyboardIndicatorTrans = NULL;
static KEYBOARD_INDICATOR_PARAMETERS gIndicators = {0, 0}; static KEYBOARD_INDICATOR_PARAMETERS gIndicators = {0, 0};
KEYBOARD_ATTRIBUTES gKeyboardInfo;
/* FUNCTIONS *****************************************************************/ /* FUNCTIONS *****************************************************************/
@ -29,6 +30,10 @@ InitKeyboardImpl(VOID)
{ {
RtlZeroMemory(&gafAsyncKeyState, sizeof(gafAsyncKeyState)); RtlZeroMemory(&gafAsyncKeyState, sizeof(gafAsyncKeyState));
RtlZeroMemory(&gafAsyncKeyStateRecentDown, sizeof(gafAsyncKeyStateRecentDown)); RtlZeroMemory(&gafAsyncKeyStateRecentDown, sizeof(gafAsyncKeyStateRecentDown));
// Clear and set default information.
RtlZeroMemory(&gKeyboardInfo, sizeof(gKeyboardInfo));
gKeyboardInfo.KeyboardIdentifier.Type = 4; /* AT-101 */
gKeyboardInfo.NumberOfFunctionKeys = 12; /* We're doing an 101 for now, so return 12 F-keys */
return STATUS_SUCCESS; return STATUS_SUCCESS;
} }
@ -38,7 +43,7 @@ InitKeyboardImpl(VOID)
* Asks the keyboard driver to send a small table that shows which * Asks the keyboard driver to send a small table that shows which
* lights should connect with which scancodes * lights should connect with which scancodes
*/ */
static //static
NTSTATUS APIENTRY NTSTATUS APIENTRY
IntKeyboardGetIndicatorTrans(HANDLE hKeyboardDevice, IntKeyboardGetIndicatorTrans(HANDLE hKeyboardDevice,
PKEYBOARD_INDICATOR_TRANSLATION *ppIndicatorTrans) PKEYBOARD_INDICATOR_TRANSLATION *ppIndicatorTrans)
@ -159,7 +164,7 @@ UserInitKeyboard(HANDLE hKeyboardDevice)
{ {
NTSTATUS Status; NTSTATUS Status;
IO_STATUS_BLOCK Block; IO_STATUS_BLOCK Block;
/*
IntKeyboardGetIndicatorTrans(hKeyboardDevice, &gpKeyboardIndicatorTrans); IntKeyboardGetIndicatorTrans(hKeyboardDevice, &gpKeyboardIndicatorTrans);
Status = NtDeviceIoControlFile(hKeyboardDevice, Status = NtDeviceIoControlFile(hKeyboardDevice,
@ -175,13 +180,31 @@ UserInitKeyboard(HANDLE hKeyboardDevice)
{ {
WARN("NtDeviceIoControlFile() failed, ignored\n"); WARN("NtDeviceIoControlFile() failed, ignored\n");
} }
SET_KEY_LOCKED(gafAsyncKeyState, VK_CAPITAL, SET_KEY_LOCKED(gafAsyncKeyState, VK_CAPITAL,
gIndicators.LedFlags & KEYBOARD_CAPS_LOCK_ON); gIndicators.LedFlags & KEYBOARD_CAPS_LOCK_ON);
SET_KEY_LOCKED(gafAsyncKeyState, VK_NUMLOCK, SET_KEY_LOCKED(gafAsyncKeyState, VK_NUMLOCK,
gIndicators.LedFlags & KEYBOARD_NUM_LOCK_ON); gIndicators.LedFlags & KEYBOARD_NUM_LOCK_ON);
SET_KEY_LOCKED(gafAsyncKeyState, VK_SCROLL, SET_KEY_LOCKED(gafAsyncKeyState, VK_SCROLL,
gIndicators.LedFlags & KEYBOARD_SCROLL_LOCK_ON); gIndicators.LedFlags & KEYBOARD_SCROLL_LOCK_ON);
*/
// FIXME: Need device driver to work! HID support more than one!!!!
Status = NtDeviceIoControlFile(hKeyboardDevice,
NULL,
NULL,
NULL,
&Block,
IOCTL_KEYBOARD_QUERY_ATTRIBUTES,
NULL, 0,
&gKeyboardInfo, sizeof(gKeyboardInfo));
if (!NT_SUCCESS(Status))
{
ERR("NtDeviceIoControlFile() failed, ignored\n");
}
ERR("Keyboard type %d, subtype %d and number of func keys %d\n",
gKeyboardInfo.KeyboardIdentifier.Type,
gKeyboardInfo.KeyboardIdentifier.Subtype,
gKeyboardInfo.NumberOfFunctionKeys);
} }
/* /*
@ -798,8 +821,10 @@ ProcessKeyEvent(WORD wVk, WORD wScanCode, DWORD dwFlags, BOOL bInjected, DWORD d
/* Check if this is a hotkey */ /* Check if this is a hotkey */
if (co_UserProcessHotKeys(wSimpleVk, bIsDown)) if (co_UserProcessHotKeys(wSimpleVk, bIsDown))
{
TRACE("HotKey Processed\n");
bPostMsg = FALSE; bPostMsg = FALSE;
}
wFixedVk = IntFixVk(wSimpleVk, bExt); /* LSHIFT + EXT = RSHIFT */ wFixedVk = IntFixVk(wSimpleVk, bExt); /* LSHIFT + EXT = RSHIFT */
if (wSimpleVk == VK_SHIFT) /* shift can't be extended */ if (wSimpleVk == VK_SHIFT) /* shift can't be extended */
bExt = FALSE; bExt = FALSE;
@ -1459,11 +1484,11 @@ UserGetKeyboardType(
switch (dwTypeFlag) switch (dwTypeFlag)
{ {
case 0: /* Keyboard type */ case 0: /* Keyboard type */
return 4; /* AT-101 */ return (DWORD)gKeyboardInfo.KeyboardIdentifier.Type;
case 1: /* Keyboard Subtype */ case 1: /* Keyboard Subtype */
return 0; /* There are no defined subtypes */ return (DWORD)gKeyboardInfo.KeyboardIdentifier.Subtype;
case 2: /* Number of F-keys */ case 2: /* Number of F-keys */
return 12; /* We're doing an 101 for now, so return 12 F-keys */ return (DWORD)gKeyboardInfo.NumberOfFunctionKeys;
default: default:
ERR("Unknown type!\n"); ERR("Unknown type!\n");
return 0; /* Note: we don't have to set last error here */ return 0; /* Note: we don't have to set last error here */

View file

@ -544,7 +544,7 @@ UserDestroyThreadInfo(struct _ETHREAD *Thread)
EVENT_DestroyThreadEvents(Thread); EVENT_DestroyThreadEvents(Thread);
DestroyTimersForThread(ptiCurrent); DestroyTimersForThread(ptiCurrent);
KeSetEvent(ptiCurrent->pEventQueueServer, IO_NO_INCREMENT, FALSE); KeSetEvent(ptiCurrent->pEventQueueServer, IO_NO_INCREMENT, FALSE);
UnregisterThreadHotKeys(Thread); UnregisterThreadHotKeys(ptiCurrent);
/* /*
if (IsListEmpty(&ptiCurrent->WindowListHead)) if (IsListEmpty(&ptiCurrent->WindowListHead))
{ {

View file

@ -1058,53 +1058,29 @@ co_IntGetPeekMessage( PMSG pMsg,
} }
BOOL FASTCALL BOOL FASTCALL
UserPostThreadMessage( DWORD idThread, UserPostThreadMessage( PTHREADINFO pti,
UINT Msg, UINT Msg,
WPARAM wParam, WPARAM wParam,
LPARAM lParam ) LPARAM lParam )
{ {
MSG Message; MSG Message;
PETHREAD peThread;
PTHREADINFO pThread;
LARGE_INTEGER LargeTickCount; LARGE_INTEGER LargeTickCount;
NTSTATUS Status;
if (is_pointer_message(Msg)) if (is_pointer_message(Msg))
{ {
EngSetLastError(ERROR_MESSAGE_SYNC_ONLY ); EngSetLastError(ERROR_MESSAGE_SYNC_ONLY );
return FALSE; return FALSE;
} }
Message.hwnd = NULL;
Message.message = Msg;
Message.wParam = wParam;
Message.lParam = lParam;
Message.pt = gpsi->ptCursor;
Status = PsLookupThreadByThreadId((HANDLE)idThread,&peThread); KeQueryTickCount(&LargeTickCount);
Message.time = MsqCalculateMessageTime(&LargeTickCount);
if( Status == STATUS_SUCCESS ) MsqPostMessage(pti, &Message, FALSE, QS_POSTMESSAGE, 0);
{ return TRUE;
pThread = (PTHREADINFO)peThread->Tcb.Win32Thread;
if( !pThread ||
!pThread->MessageQueue ||
(pThread->TIF_flags & TIF_INCLEANUP))
{
ObDereferenceObject( peThread );
return FALSE;
}
Message.hwnd = NULL;
Message.message = Msg;
Message.wParam = wParam;
Message.lParam = lParam;
Message.pt = gpsi->ptCursor;
KeQueryTickCount(&LargeTickCount);
Message.time = MsqCalculateMessageTime(&LargeTickCount);
MsqPostMessage(pThread, &Message, FALSE, QS_POSTMESSAGE, 0);
ObDereferenceObject( peThread );
return TRUE;
}
else
{
SetLastNtError( Status );
}
return FALSE;
} }
BOOL FASTCALL BOOL FASTCALL
@ -1157,7 +1133,8 @@ UserPostMessage( HWND Wnd,
if (!Wnd) if (!Wnd)
{ {
return UserPostThreadMessage( PtrToInt(PsGetCurrentThreadId()), pti = PsGetCurrentThreadWin32Thread();
return UserPostThreadMessage( pti,
Msg, Msg,
wParam, wParam,
lParam); lParam);
@ -1983,13 +1960,33 @@ NtUserPostThreadMessage(DWORD idThread,
LPARAM lParam) LPARAM lParam)
{ {
BOOL ret; BOOL ret;
PETHREAD peThread;
PTHREADINFO pThread;
NTSTATUS Status;
UserEnterExclusive(); UserEnterExclusive();
ret = UserPostThreadMessage( idThread, Msg, wParam, lParam); Status = PsLookupThreadByThreadId((HANDLE)idThread,&peThread);
if ( Status == STATUS_SUCCESS )
{
pThread = (PTHREADINFO)peThread->Tcb.Win32Thread;
if( !pThread ||
!pThread->MessageQueue ||
(pThread->TIF_flags & TIF_INCLEANUP))
{
ObDereferenceObject( peThread );
goto exit;
}
ret = UserPostThreadMessage( pThread, Msg, wParam, lParam);
ObDereferenceObject( peThread );
}
else
{
SetLastNtError( Status );
}
exit:
UserLeave(); UserLeave();
return ret; return ret;
} }

View file

@ -638,54 +638,6 @@ co_MsqInsertMouseMessage(MSG* Msg, DWORD flags, ULONG_PTR dwExtraInfo, BOOL Hook
} }
} }
VOID FASTCALL
MsqPostHotKeyMessage(PVOID Thread, HWND hWnd, WPARAM wParam, LPARAM lParam)
{
PWND Window;
PTHREADINFO Win32Thread;
MSG Mesg;
LARGE_INTEGER LargeTickCount;
NTSTATUS Status;
INT id;
DWORD Type;
Status = ObReferenceObjectByPointer (Thread,
THREAD_ALL_ACCESS,
PsThreadType,
KernelMode);
if (!NT_SUCCESS(Status))
return;
Win32Thread = ((PETHREAD)Thread)->Tcb.Win32Thread;
if (Win32Thread == NULL || Win32Thread->MessageQueue == NULL)
{
ObDereferenceObject ((PETHREAD)Thread);
return;
}
Window = IntGetWindowObject(hWnd);
if (!Window)
{
ObDereferenceObject ((PETHREAD)Thread);
return;
}
id = wParam; // Check for hot keys unrelated to the hot keys set by RegisterHotKey.
Mesg.hwnd = hWnd;
Mesg.message = id != IDHK_REACTOS ? WM_HOTKEY : WM_SYSCOMMAND;
Mesg.wParam = id != IDHK_REACTOS ? wParam : SC_HOTKEY;
Mesg.lParam = id != IDHK_REACTOS ? lParam : (LPARAM)hWnd;
Type = id != IDHK_REACTOS ? QS_HOTKEY : QS_POSTMESSAGE;
KeQueryTickCount(&LargeTickCount);
Mesg.time = MsqCalculateMessageTime(&LargeTickCount);
Mesg.pt = gpsi->ptCursor;
MsqPostMessage(Window->head.pti, &Mesg, FALSE, Type, 0);
UserDereferenceObject(Window);
ObDereferenceObject (Thread);
}
PUSER_MESSAGE FASTCALL PUSER_MESSAGE FASTCALL
MsqCreateMessage(LPMSG Msg) MsqCreateMessage(LPMSG Msg)
{ {
@ -1251,6 +1203,7 @@ MsqPostMessage(PTHREADINFO pti,
&Message->ListEntry); &Message->ListEntry);
} }
if (Msg->message == WM_HOTKEY) MessageBits |= QS_HOTKEY; // Justin Case, just set it.
Message->dwQEvent = dwQEvent; Message->dwQEvent = dwQEvent;
Message->QS_Flags = MessageBits; Message->QS_Flags = MessageBits;
//Message->pti = pti; Fixed in ATI changes. See CORE-6551 //Message->pti = pti; Fixed in ATI changes. See CORE-6551

View file

@ -198,7 +198,6 @@ co_MsqSendMessageAsync(PTHREADINFO ptiReceiver,
LRESULT FASTCALL IntDispatchMessage(MSG* Msg); LRESULT FASTCALL IntDispatchMessage(MSG* Msg);
BOOL FASTCALL IntTranslateKbdMessage(LPMSG lpMsg, UINT flags); BOOL FASTCALL IntTranslateKbdMessage(LPMSG lpMsg, UINT flags);
VOID FASTCALL MsqPostHotKeyMessage(PVOID Thread, HWND hWnd, WPARAM wParam, LPARAM lParam);
VOID FASTCALL co_MsqInsertMouseMessage(MSG* Msg, DWORD flags, ULONG_PTR dwExtraInfo, BOOL Hook); VOID FASTCALL co_MsqInsertMouseMessage(MSG* Msg, DWORD flags, ULONG_PTR dwExtraInfo, BOOL Hook);
BOOL FASTCALL MsqIsClkLck(LPMSG Msg, BOOL Remove); BOOL FASTCALL MsqIsClkLck(LPMSG Msg, BOOL Remove);
BOOL FASTCALL MsqIsDblClk(LPMSG Msg, BOOL Remove); BOOL FASTCALL MsqIsDblClk(LPMSG Msg, BOOL Remove);
@ -274,5 +273,10 @@ co_IntGetPeekMessage( PMSG pMsg,
UINT MsgFilterMax, UINT MsgFilterMax,
UINT RemoveMsg, UINT RemoveMsg,
BOOL bGMSG ); BOOL bGMSG );
BOOL FASTCALL
UserPostThreadMessage( PTHREADINFO pti,
UINT Msg,
WPARAM wParam,
LPARAM lParam );
/* EOF */ /* EOF */

View file

@ -804,6 +804,10 @@ DefWndHandleSysCommand(HWND hWnd, WPARAM wParam, LPARAM lParam)
} }
break; break;
case SC_TASKLIST:
WinExec( "taskman.exe", SW_SHOWNORMAL );
break;
case SC_SCREENSAVE: case SC_SCREENSAVE:
NtUserMessageCall( hWnd, WM_SYSCOMMAND, wParam, lParam, (ULONG_PTR)&lResult, FNID_DEFWINDOWPROC, FALSE); NtUserMessageCall( hWnd, WM_SYSCOMMAND, wParam, lParam, (ULONG_PTR)&lResult, FNID_DEFWINDOWPROC, FALSE);
break; break;