0b8a68efc847e74a46b4240d7b8f6ca7e71e97bd
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 *****************************************************************/
59 InitializeListHead(&gHotkeyList
);
61 return STATUS_SUCCESS
;
70 return STATUS_SUCCESS
;
76 GetHotKey (UINT fsModifiers
,
78 struct _ETHREAD
**Thread
,
82 PHOT_KEY_ITEM HotKeyItem
;
84 LIST_FOR_EACH(HotKeyItem
, &gHotkeyList
, HOT_KEY_ITEM
, ListEntry
)
86 if (HotKeyItem
->fsModifiers
== fsModifiers
&&
90 *Thread
= HotKeyItem
->Thread
;
93 *hWnd
= HotKeyItem
->hWnd
;
107 UnregisterWindowHotKeys(PWND Window
)
109 PHOT_KEY_ITEM HotKeyItem
, tmp
;
111 LIST_FOR_EACH_SAFE(HotKeyItem
, tmp
, &gHotkeyList
, HOT_KEY_ITEM
, ListEntry
)
113 if (HotKeyItem
->hWnd
== Window
->head
.h
)
115 RemoveEntryList (&HotKeyItem
->ListEntry
);
116 ExFreePool (HotKeyItem
);
124 UnregisterThreadHotKeys(struct _ETHREAD
*Thread
)
126 PHOT_KEY_ITEM HotKeyItem
, tmp
;
128 LIST_FOR_EACH_SAFE(HotKeyItem
, tmp
, &gHotkeyList
, HOT_KEY_ITEM
, ListEntry
)
130 if (HotKeyItem
->Thread
== Thread
)
132 RemoveEntryList (&HotKeyItem
->ListEntry
);
133 ExFreePool (HotKeyItem
);
142 IsHotKey (UINT fsModifiers
, UINT vk
)
144 PHOT_KEY_ITEM HotKeyItem
;
146 LIST_FOR_EACH(HotKeyItem
, &gHotkeyList
, HOT_KEY_ITEM
, ListEntry
)
148 if (HotKeyItem
->fsModifiers
== fsModifiers
&& HotKeyItem
->vk
== vk
)
159 /* SYSCALLS *****************************************************************/
163 NtUserRegisterHotKey(HWND hWnd
,
168 PHOT_KEY_ITEM HotKeyItem
;
170 PETHREAD HotKeyThread
;
171 DECLARE_RETURN(BOOL
);
173 DPRINT("Enter NtUserRegisterHotKey\n");
174 UserEnterExclusive();
178 HotKeyThread
= PsGetCurrentThread();
182 if(!(Window
= UserGetWindowObject(hWnd
)))
186 HotKeyThread
= Window
->head
.pti
->pEThread
;
189 /* Check for existing hotkey */
190 if (IsHotKey (fsModifiers
, vk
))
195 HotKeyItem
= ExAllocatePoolWithTag (PagedPool
, sizeof(HOT_KEY_ITEM
), TAG_HOTKEY
);
196 if (HotKeyItem
== NULL
)
201 HotKeyItem
->Thread
= HotKeyThread
;
202 HotKeyItem
->hWnd
= hWnd
;
204 HotKeyItem
->fsModifiers
= fsModifiers
;
207 InsertHeadList (&gHotkeyList
, &HotKeyItem
->ListEntry
);
212 DPRINT("Leave NtUserRegisterHotKey, ret=%i\n",_ret_
);
219 NtUserUnregisterHotKey(HWND hWnd
, int id
)
221 PHOT_KEY_ITEM HotKeyItem
;
223 DECLARE_RETURN(BOOL
);
225 DPRINT("Enter NtUserUnregisterHotKey\n");
226 UserEnterExclusive();
228 if(!(Window
= UserGetWindowObject(hWnd
)))
233 LIST_FOR_EACH(HotKeyItem
, &gHotkeyList
, HOT_KEY_ITEM
, ListEntry
)
235 if (HotKeyItem
->hWnd
== hWnd
&& HotKeyItem
->id
== id
)
237 RemoveEntryList (&HotKeyItem
->ListEntry
);
238 ExFreePool (HotKeyItem
);
247 DPRINT("Leave NtUserUnregisterHotKey, ret=%i\n",_ret_
);