- Support for window-less hotkeys.

- Send hotkeys even if there's no focus window.

svn path=/trunk/; revision=9488
This commit is contained in:
Filip Navara 2004-05-25 15:52:45 +00:00
parent e58206820b
commit 6368fbd7a8
2 changed files with 51 additions and 49 deletions

View file

@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
/* $Id: hotkey.c,v 1.9 2004/05/10 17:07:18 weiden Exp $ /* $Id: hotkey.c,v 1.10 2004/05/25 15:52:44 navaraf Exp $
* *
* COPYRIGHT: See COPYING in the top level directory * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
@ -210,20 +210,30 @@ NtUserRegisterHotKey(HWND hWnd,
PHOT_KEY_ITEM HotKeyItem; PHOT_KEY_ITEM HotKeyItem;
PWINDOW_OBJECT Window; PWINDOW_OBJECT Window;
PWINSTATION_OBJECT WinStaObject = NULL; PWINSTATION_OBJECT WinStaObject = NULL;
PETHREAD HotKeyThread;
Window = IntGetWindowObject(hWnd); if (hWnd == NULL)
if(!Window)
{ {
SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE); HotKeyThread = PsGetCurrentThread();
return FALSE;
} }
else
{
Window = IntGetWindowObject(hWnd);
if(!Window)
{
SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE);
return FALSE;
}
HotKeyThread = Window->OwnerThread;
IntReleaseWindowObject(Window);
}
if(Window->OwnerThread->ThreadsProcess && Window->OwnerThread->ThreadsProcess->Win32Process) if(HotKeyThread->ThreadsProcess && HotKeyThread->ThreadsProcess->Win32Process)
WinStaObject = Window->OwnerThread->ThreadsProcess->Win32Process->WindowStation; WinStaObject = HotKeyThread->ThreadsProcess->Win32Process->WindowStation;
if(!WinStaObject) if(!WinStaObject)
{ {
IntReleaseWindowObject(Window);
return FALSE; return FALSE;
} }
@ -233,7 +243,6 @@ NtUserRegisterHotKey(HWND hWnd,
if (IsHotKey (WinStaObject, fsModifiers, vk)) if (IsHotKey (WinStaObject, fsModifiers, vk))
{ {
IntUnLockHotKeys(WinStaObject); IntUnLockHotKeys(WinStaObject);
IntReleaseWindowObject(Window);
return FALSE; return FALSE;
} }
@ -241,11 +250,10 @@ NtUserRegisterHotKey(HWND hWnd,
if (HotKeyItem == NULL) if (HotKeyItem == NULL)
{ {
IntUnLockHotKeys(WinStaObject); IntUnLockHotKeys(WinStaObject);
IntReleaseWindowObject(Window);
return FALSE; return FALSE;
} }
HotKeyItem->Thread = PsGetCurrentThread(); HotKeyItem->Thread = HotKeyThread;
HotKeyItem->hWnd = hWnd; HotKeyItem->hWnd = hWnd;
HotKeyItem->id = id; HotKeyItem->id = id;
HotKeyItem->fsModifiers = fsModifiers; HotKeyItem->fsModifiers = fsModifiers;
@ -256,7 +264,6 @@ NtUserRegisterHotKey(HWND hWnd,
IntUnLockHotKeys(WinStaObject); IntUnLockHotKeys(WinStaObject);
IntReleaseWindowObject(Window);
return TRUE; return TRUE;
} }

View file

@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
/* $Id: input.c,v 1.33 2004/05/14 23:57:32 weiden Exp $ /* $Id: input.c,v 1.34 2004/05/25 15:52:45 navaraf Exp $
* *
* COPYRIGHT: See COPYING in the top level directory * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
@ -30,12 +30,8 @@
/* INCLUDES ******************************************************************/ /* INCLUDES ******************************************************************/
#include <w32k.h> #include <w32k.h>
#include <rosrtl/string.h> #include <rosrtl/string.h>
#define NDEBUG
#include <debug.h>
/* GLOBALS *******************************************************************/ /* GLOBALS *******************************************************************/
#define ENABLEMOUSEGDICALLBACK 1 #define ENABLEMOUSEGDICALLBACK 1
@ -238,14 +234,24 @@ KeyboardThreadMain(PVOID StartContext)
lParam |= (1 << 29); lParam |= (1 << 29);
} }
if(KeyEvent.bKeyDown && (fsModifiers & MOD_ALT)) if (GetHotKey(InputWindowStation,
msg.message = WM_SYSKEYDOWN; fsModifiers,
else if(KeyEvent.bKeyDown) KeyEvent.wVirtualKeyCode,
msg.message = WM_KEYDOWN; &Thread,
else if(fsModifiers & MOD_ALT) &hWnd,
msg.message = WM_SYSKEYUP; &id))
else {
msg.message = WM_KEYUP; if (KeyEvent.bKeyDown)
{
DPRINT("Hot key pressed (hWnd %lx, id %d)\n", hWnd, id);
MsqPostHotKeyMessage (Thread,
hWnd,
(WPARAM)id,
MAKELPARAM((WORD)fsModifiers,
(WORD)msg.wParam));
}
continue;
}
/* Find the target thread whose locale is in effect */ /* Find the target thread whose locale is in effect */
if (!IntGetScreenDC()) if (!IntGetScreenDC())
@ -259,6 +265,15 @@ KeyboardThreadMain(PVOID StartContext)
if (!FocusQueue) continue; if (!FocusQueue) continue;
if(KeyEvent.bKeyDown && (fsModifiers & MOD_ALT))
msg.message = WM_SYSKEYDOWN;
else if(KeyEvent.bKeyDown)
msg.message = WM_KEYDOWN;
else if(fsModifiers & MOD_ALT)
msg.message = WM_SYSKEYUP;
else
msg.message = WM_KEYUP;
msg.wParam = KeyEvent.wVirtualKeyCode; msg.wParam = KeyEvent.wVirtualKeyCode;
msg.lParam = lParam; msg.lParam = lParam;
msg.hwnd = FocusQueue->FocusWindow; msg.hwnd = FocusQueue->FocusWindow;
@ -274,30 +289,10 @@ KeyboardThreadMain(PVOID StartContext)
else else
continue; continue;
if (GetHotKey(InputWindowStation, /*
fsModifiers, * Post a keyboard message.
msg.wParam, */
&Thread, MsqPostKeyboardMessage(msg.message,msg.wParam,msg.lParam);
&hWnd,
&id))
{
if (KeyEvent.bKeyDown)
{
DPRINT("Hot key pressed (hWnd %lx, id %d)\n", hWnd, id);
MsqPostHotKeyMessage (Thread,
hWnd,
(WPARAM)id,
MAKELPARAM((WORD)fsModifiers,
(WORD)msg.wParam));
}
}
else
{
/*
* Post a keyboard message.
*/
MsqPostKeyboardMessage(msg.message,msg.wParam,msg.lParam);
}
} }
DPRINT( "KeyboardInput Thread Stopped...\n" ); DPRINT( "KeyboardInput Thread Stopped...\n" );
} }