2 * ReactOS W32 Subsystem
3 * Copyright (C) 2003 ReactOS Team
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 * COPYRIGHT: See COPYING in the top level directory
21 * PROJECT: ReactOS kernel
22 * PURPOSE: HotKey support
23 * FILE: subsys/win32k/ntuser/hotkey.c
24 * PROGRAMER: Eric Kohl
26 * 02-11-2003 EK Created
33 FIXME: Hotkey notifications are triggered by keyboard input (physical or programatically)
34 and since only desktops on WinSta0 can recieve input in seems very wrong to allow
35 windows/threads on destops not belonging to WinSta0 to set hotkeys (recieve notifications).
41 /* INCLUDES ******************************************************************/
48 /* GLOBALS *******************************************************************/
50 LIST_ENTRY gHotkeyList
;
52 /* FUNCTIONS *****************************************************************/
57 InitializeListHead(&gHotkeyList
);
59 return STATUS_SUCCESS
;
68 return STATUS_SUCCESS
;
74 GetHotKey (UINT fsModifiers
,
76 struct _ETHREAD
**Thread
,
80 PHOT_KEY_ITEM HotKeyItem
;
82 LIST_FOR_EACH(HotKeyItem
, &gHotkeyList
, HOT_KEY_ITEM
, ListEntry
)
84 if (HotKeyItem
->fsModifiers
== fsModifiers
&&
88 *Thread
= HotKeyItem
->Thread
;
91 *hWnd
= HotKeyItem
->hWnd
;
105 UnregisterWindowHotKeys(PWND Window
)
107 PHOT_KEY_ITEM HotKeyItem
, tmp
;
109 LIST_FOR_EACH_SAFE(HotKeyItem
, tmp
, &gHotkeyList
, HOT_KEY_ITEM
, ListEntry
)
111 if (HotKeyItem
->hWnd
== Window
->head
.h
)
113 RemoveEntryList (&HotKeyItem
->ListEntry
);
114 ExFreePool (HotKeyItem
);
122 UnregisterThreadHotKeys(struct _ETHREAD
*Thread
)
124 PHOT_KEY_ITEM HotKeyItem
, tmp
;
126 LIST_FOR_EACH_SAFE(HotKeyItem
, tmp
, &gHotkeyList
, HOT_KEY_ITEM
, ListEntry
)
128 if (HotKeyItem
->Thread
== Thread
)
130 RemoveEntryList (&HotKeyItem
->ListEntry
);
131 ExFreePool (HotKeyItem
);
140 IsHotKey (UINT fsModifiers
, UINT vk
)
142 PHOT_KEY_ITEM HotKeyItem
;
144 LIST_FOR_EACH(HotKeyItem
, &gHotkeyList
, HOT_KEY_ITEM
, ListEntry
)
146 if (HotKeyItem
->fsModifiers
== fsModifiers
&& HotKeyItem
->vk
== vk
)
157 /* SYSCALLS *****************************************************************/
161 NtUserRegisterHotKey(HWND hWnd
,
166 PHOT_KEY_ITEM HotKeyItem
;
168 PETHREAD HotKeyThread
;
169 DECLARE_RETURN(BOOL
);
171 DPRINT("Enter NtUserRegisterHotKey\n");
172 UserEnterExclusive();
176 HotKeyThread
= PsGetCurrentThread();
180 if(!(Window
= UserGetWindowObject(hWnd
)))
184 HotKeyThread
= Window
->head
.pti
->pEThread
;
187 /* Check for existing hotkey */
188 if (IsHotKey (fsModifiers
, vk
))
193 HotKeyItem
= ExAllocatePoolWithTag (PagedPool
, sizeof(HOT_KEY_ITEM
), TAG_HOTKEY
);
194 if (HotKeyItem
== NULL
)
199 HotKeyItem
->Thread
= HotKeyThread
;
200 HotKeyItem
->hWnd
= hWnd
;
202 HotKeyItem
->fsModifiers
= fsModifiers
;
205 InsertHeadList (&gHotkeyList
, &HotKeyItem
->ListEntry
);
210 DPRINT("Leave NtUserRegisterHotKey, ret=%i\n",_ret_
);
217 NtUserUnregisterHotKey(HWND hWnd
, int id
)
219 PHOT_KEY_ITEM HotKeyItem
;
221 DECLARE_RETURN(BOOL
);
223 DPRINT("Enter NtUserUnregisterHotKey\n");
224 UserEnterExclusive();
226 if(!(Window
= UserGetWindowObject(hWnd
)))
231 LIST_FOR_EACH(HotKeyItem
, &gHotkeyList
, HOT_KEY_ITEM
, ListEntry
)
233 if (HotKeyItem
->hWnd
== hWnd
&& HotKeyItem
->id
== id
)
235 RemoveEntryList (&HotKeyItem
->ListEntry
);
236 ExFreePool (HotKeyItem
);
245 DPRINT("Leave NtUserUnregisterHotKey, ret=%i\n",_ret_
);