2003-11-02 16:33:51 +00:00
|
|
|
/*
|
|
|
|
* ReactOS W32 Subsystem
|
|
|
|
* Copyright (C) 2003 ReactOS Team
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
2009-10-27 10:34:16 +00:00
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
2003-11-02 16:33:51 +00:00
|
|
|
*/
|
2010-01-12 05:25:22 +00:00
|
|
|
/*
|
2003-11-02 16:33:51 +00:00
|
|
|
* COPYRIGHT: See COPYING in the top level directory
|
|
|
|
* PROJECT: ReactOS kernel
|
|
|
|
* PURPOSE: HotKey support
|
|
|
|
* FILE: subsys/win32k/ntuser/hotkey.c
|
|
|
|
* PROGRAMER: Eric Kohl
|
|
|
|
* REVISION HISTORY:
|
|
|
|
* 02-11-2003 EK Created
|
|
|
|
*/
|
|
|
|
|
2005-09-18 23:06:15 +00:00
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
|
|
FIXME: Hotkey notifications are triggered by keyboard input (physical or programatically)
|
|
|
|
and since only desktops on WinSta0 can recieve input in seems very wrong to allow
|
|
|
|
windows/threads on destops not belonging to WinSta0 to set hotkeys (recieve notifications).
|
|
|
|
|
|
|
|
-Gunnar
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
2003-11-02 16:33:51 +00:00
|
|
|
/* INCLUDES ******************************************************************/
|
|
|
|
|
2010-04-26 13:58:46 +00:00
|
|
|
#include <win32k.h>
|
2003-11-02 16:33:51 +00:00
|
|
|
|
|
|
|
#define NDEBUG
|
|
|
|
#include <debug.h>
|
|
|
|
|
|
|
|
/* GLOBALS *******************************************************************/
|
|
|
|
|
2005-09-18 23:06:15 +00:00
|
|
|
LIST_ENTRY gHotkeyList;
|
|
|
|
|
2003-11-02 16:33:51 +00:00
|
|
|
/* FUNCTIONS *****************************************************************/
|
|
|
|
|
2003-11-03 18:52:21 +00:00
|
|
|
NTSTATUS FASTCALL
|
2009-08-24 20:09:58 +00:00
|
|
|
InitHotkeyImpl(VOID)
|
2003-11-03 18:52:21 +00:00
|
|
|
{
|
2005-09-18 23:06:15 +00:00
|
|
|
InitializeListHead(&gHotkeyList);
|
2003-11-03 18:52:21 +00:00
|
|
|
|
2005-09-07 21:25:42 +00:00
|
|
|
return STATUS_SUCCESS;
|
2003-11-03 18:52:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-09-18 23:06:15 +00:00
|
|
|
#if 0 //not used
|
2003-11-03 18:52:21 +00:00
|
|
|
NTSTATUS FASTCALL
|
2009-08-24 20:09:58 +00:00
|
|
|
CleanupHotKeys(VOID)
|
2003-11-03 18:52:21 +00:00
|
|
|
{
|
|
|
|
|
2005-09-07 21:25:42 +00:00
|
|
|
return STATUS_SUCCESS;
|
2003-11-03 18:52:21 +00:00
|
|
|
}
|
2005-09-18 23:06:15 +00:00
|
|
|
#endif
|
2003-11-03 18:52:21 +00:00
|
|
|
|
|
|
|
|
2005-09-18 23:06:15 +00:00
|
|
|
BOOL FASTCALL
|
|
|
|
GetHotKey (UINT fsModifiers,
|
2005-09-07 21:25:42 +00:00
|
|
|
UINT vk,
|
|
|
|
struct _ETHREAD **Thread,
|
|
|
|
HWND *hWnd,
|
|
|
|
int *id)
|
2003-11-03 18:52:21 +00:00
|
|
|
{
|
2005-09-07 21:25:42 +00:00
|
|
|
PHOT_KEY_ITEM HotKeyItem;
|
2005-05-08 02:11:54 +00:00
|
|
|
|
2005-09-18 23:06:15 +00:00
|
|
|
LIST_FOR_EACH(HotKeyItem, &gHotkeyList, HOT_KEY_ITEM, ListEntry)
|
2005-09-07 21:25:42 +00:00
|
|
|
{
|
2003-11-03 18:52:21 +00:00
|
|
|
if (HotKeyItem->fsModifiers == fsModifiers &&
|
2005-09-07 21:25:42 +00:00
|
|
|
HotKeyItem->vk == vk)
|
|
|
|
{
|
|
|
|
if (Thread != NULL)
|
|
|
|
*Thread = HotKeyItem->Thread;
|
2003-11-03 18:52:21 +00:00
|
|
|
|
2005-09-07 21:25:42 +00:00
|
|
|
if (hWnd != NULL)
|
|
|
|
*hWnd = HotKeyItem->hWnd;
|
2003-11-03 18:52:21 +00:00
|
|
|
|
2005-09-07 21:25:42 +00:00
|
|
|
if (id != NULL)
|
|
|
|
*id = HotKeyItem->id;
|
2003-11-03 18:52:21 +00:00
|
|
|
|
2005-09-07 21:25:42 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
}
|
2003-11-03 18:52:21 +00:00
|
|
|
|
2005-09-07 21:25:42 +00:00
|
|
|
return FALSE;
|
2003-11-03 18:52:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-09-18 23:06:15 +00:00
|
|
|
VOID FASTCALL
|
2010-10-11 03:41:41 +00:00
|
|
|
UnregisterWindowHotKeys(PWND Window)
|
2003-11-03 18:52:21 +00:00
|
|
|
{
|
2005-09-18 23:06:15 +00:00
|
|
|
PHOT_KEY_ITEM HotKeyItem, tmp;
|
2007-10-19 23:21:45 +00:00
|
|
|
|
2005-09-18 23:06:15 +00:00
|
|
|
LIST_FOR_EACH_SAFE(HotKeyItem, tmp, &gHotkeyList, HOT_KEY_ITEM, ListEntry)
|
2005-09-07 21:25:42 +00:00
|
|
|
{
|
2010-10-11 03:41:41 +00:00
|
|
|
if (HotKeyItem->hWnd == Window->head.h)
|
2005-09-07 21:25:42 +00:00
|
|
|
{
|
|
|
|
RemoveEntryList (&HotKeyItem->ListEntry);
|
|
|
|
ExFreePool (HotKeyItem);
|
|
|
|
}
|
|
|
|
}
|
2003-11-03 18:52:21 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-09-18 23:06:15 +00:00
|
|
|
VOID FASTCALL
|
2003-11-03 18:52:21 +00:00
|
|
|
UnregisterThreadHotKeys(struct _ETHREAD *Thread)
|
|
|
|
{
|
2005-09-18 23:06:15 +00:00
|
|
|
PHOT_KEY_ITEM HotKeyItem, tmp;
|
2005-05-08 02:11:54 +00:00
|
|
|
|
2007-10-19 23:21:45 +00:00
|
|
|
LIST_FOR_EACH_SAFE(HotKeyItem, tmp, &gHotkeyList, HOT_KEY_ITEM, ListEntry)
|
2005-09-07 21:25:42 +00:00
|
|
|
{
|
2003-11-03 18:52:21 +00:00
|
|
|
if (HotKeyItem->Thread == Thread)
|
2005-09-07 21:25:42 +00:00
|
|
|
{
|
|
|
|
RemoveEntryList (&HotKeyItem->ListEntry);
|
|
|
|
ExFreePool (HotKeyItem);
|
|
|
|
}
|
|
|
|
}
|
2003-11-03 18:52:21 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-10-19 23:21:45 +00:00
|
|
|
static
|
2005-09-18 23:06:15 +00:00
|
|
|
BOOL FASTCALL
|
|
|
|
IsHotKey (UINT fsModifiers, UINT vk)
|
2003-11-03 18:52:21 +00:00
|
|
|
{
|
2005-09-07 21:25:42 +00:00
|
|
|
PHOT_KEY_ITEM HotKeyItem;
|
2003-11-03 18:52:21 +00:00
|
|
|
|
2005-09-18 23:06:15 +00:00
|
|
|
LIST_FOR_EACH(HotKeyItem, &gHotkeyList, HOT_KEY_ITEM, ListEntry)
|
2005-09-07 21:25:42 +00:00
|
|
|
{
|
2005-09-18 23:06:15 +00:00
|
|
|
if (HotKeyItem->fsModifiers == fsModifiers && HotKeyItem->vk == vk)
|
2005-09-07 21:25:42 +00:00
|
|
|
{
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
}
|
2003-11-03 18:52:21 +00:00
|
|
|
|
2005-09-07 21:25:42 +00:00
|
|
|
return FALSE;
|
2003-11-03 18:52:21 +00:00
|
|
|
}
|
|
|
|
|
2003-11-02 16:33:51 +00:00
|
|
|
|
2005-09-19 00:02:39 +00:00
|
|
|
|
|
|
|
/* SYSCALLS *****************************************************************/
|
|
|
|
|
|
|
|
|
2008-11-29 22:48:58 +00:00
|
|
|
BOOL APIENTRY
|
2003-11-02 16:33:51 +00:00
|
|
|
NtUserRegisterHotKey(HWND hWnd,
|
2005-09-07 21:25:42 +00:00
|
|
|
int id,
|
|
|
|
UINT fsModifiers,
|
|
|
|
UINT vk)
|
2003-11-02 16:33:51 +00:00
|
|
|
{
|
2005-09-07 21:25:42 +00:00
|
|
|
PHOT_KEY_ITEM HotKeyItem;
|
2010-10-11 03:41:41 +00:00
|
|
|
PWND Window;
|
2005-09-07 21:25:42 +00:00
|
|
|
PETHREAD HotKeyThread;
|
|
|
|
DECLARE_RETURN(BOOL);
|
|
|
|
|
|
|
|
DPRINT("Enter NtUserRegisterHotKey\n");
|
|
|
|
UserEnterExclusive();
|
|
|
|
|
|
|
|
if (hWnd == NULL)
|
|
|
|
{
|
|
|
|
HotKeyThread = PsGetCurrentThread();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2005-09-08 16:18:51 +00:00
|
|
|
if(!(Window = UserGetWindowObject(hWnd)))
|
2005-09-07 21:25:42 +00:00
|
|
|
{
|
|
|
|
RETURN( FALSE);
|
|
|
|
}
|
2010-10-11 03:41:41 +00:00
|
|
|
HotKeyThread = Window->head.pti->pEThread;
|
2005-09-07 21:25:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Check for existing hotkey */
|
2005-09-18 23:06:15 +00:00
|
|
|
if (IsHotKey (fsModifiers, vk))
|
2005-09-07 21:25:42 +00:00
|
|
|
{
|
|
|
|
RETURN( FALSE);
|
|
|
|
}
|
2003-11-03 18:52:21 +00:00
|
|
|
|
2005-09-07 21:25:42 +00:00
|
|
|
HotKeyItem = ExAllocatePoolWithTag (PagedPool, sizeof(HOT_KEY_ITEM), TAG_HOTKEY);
|
|
|
|
if (HotKeyItem == NULL)
|
|
|
|
{
|
2005-09-05 21:19:23 +00:00
|
|
|
RETURN( FALSE);
|
2005-09-07 21:25:42 +00:00
|
|
|
}
|
2003-11-03 18:52:21 +00:00
|
|
|
|
2005-09-07 21:25:42 +00:00
|
|
|
HotKeyItem->Thread = HotKeyThread;
|
|
|
|
HotKeyItem->hWnd = hWnd;
|
|
|
|
HotKeyItem->id = id;
|
|
|
|
HotKeyItem->fsModifiers = fsModifiers;
|
|
|
|
HotKeyItem->vk = vk;
|
2003-11-03 18:52:21 +00:00
|
|
|
|
2005-09-18 23:06:15 +00:00
|
|
|
InsertHeadList (&gHotkeyList, &HotKeyItem->ListEntry);
|
2003-11-03 18:52:21 +00:00
|
|
|
|
2005-09-07 21:25:42 +00:00
|
|
|
RETURN( TRUE);
|
2005-05-08 02:11:54 +00:00
|
|
|
|
2005-09-05 21:19:23 +00:00
|
|
|
CLEANUP:
|
2005-09-07 21:25:42 +00:00
|
|
|
DPRINT("Leave NtUserRegisterHotKey, ret=%i\n",_ret_);
|
|
|
|
UserLeave();
|
|
|
|
END_CLEANUP;
|
2003-11-02 16:33:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-11-29 22:48:58 +00:00
|
|
|
BOOL APIENTRY
|
2005-09-18 23:06:15 +00:00
|
|
|
NtUserUnregisterHotKey(HWND hWnd, int id)
|
2003-11-02 16:33:51 +00:00
|
|
|
{
|
2005-09-07 21:25:42 +00:00
|
|
|
PHOT_KEY_ITEM HotKeyItem;
|
2010-10-11 03:41:41 +00:00
|
|
|
PWND Window;
|
2005-09-07 21:25:42 +00:00
|
|
|
DECLARE_RETURN(BOOL);
|
|
|
|
|
|
|
|
DPRINT("Enter NtUserUnregisterHotKey\n");
|
|
|
|
UserEnterExclusive();
|
|
|
|
|
2005-09-08 16:18:51 +00:00
|
|
|
if(!(Window = UserGetWindowObject(hWnd)))
|
2005-09-07 21:25:42 +00:00
|
|
|
{
|
|
|
|
RETURN( FALSE);
|
|
|
|
}
|
|
|
|
|
2005-09-18 23:06:15 +00:00
|
|
|
LIST_FOR_EACH(HotKeyItem, &gHotkeyList, HOT_KEY_ITEM, ListEntry)
|
2005-09-07 21:25:42 +00:00
|
|
|
{
|
2005-09-18 23:06:15 +00:00
|
|
|
if (HotKeyItem->hWnd == hWnd && HotKeyItem->id == id)
|
2005-09-07 21:25:42 +00:00
|
|
|
{
|
|
|
|
RemoveEntryList (&HotKeyItem->ListEntry);
|
|
|
|
ExFreePool (HotKeyItem);
|
2005-05-08 02:11:54 +00:00
|
|
|
|
2005-09-07 21:25:42 +00:00
|
|
|
RETURN( TRUE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
RETURN( FALSE);
|
2005-05-08 02:11:54 +00:00
|
|
|
|
2005-09-05 21:19:23 +00:00
|
|
|
CLEANUP:
|
2005-09-07 21:25:42 +00:00
|
|
|
DPRINT("Leave NtUserUnregisterHotKey, ret=%i\n",_ret_);
|
|
|
|
UserLeave();
|
|
|
|
END_CLEANUP;
|
2003-11-02 16:33:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* EOF */
|