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.
21 * COPYRIGHT: See COPYING in the top level directory
22 * PROJECT: ReactOS kernel
23 * PURPOSE: HotKey support
24 * FILE: subsys/win32k/ntuser/hotkey.c
25 * PROGRAMER: Eric Kohl
27 * 02-11-2003 EK Created
34 FIXME: Hotkey notifications are triggered by keyboard input (physical or programatically)
35 and since only desktops on WinSta0 can recieve input in seems very wrong to allow
36 windows/threads on destops not belonging to WinSta0 to set hotkeys (recieve notifications).
42 /* INCLUDES ******************************************************************/
49 /* GLOBALS *******************************************************************/
51 LIST_ENTRY gHotkeyList
;
53 /* FUNCTIONS *****************************************************************/
58 InitializeListHead(&gHotkeyList
);
60 return STATUS_SUCCESS
;
69 return STATUS_SUCCESS
;
75 GetHotKey (UINT fsModifiers
,
77 struct _ETHREAD
**Thread
,
81 PHOT_KEY_ITEM HotKeyItem
;
83 LIST_FOR_EACH(HotKeyItem
, &gHotkeyList
, HOT_KEY_ITEM
, ListEntry
)
85 if (HotKeyItem
->fsModifiers
== fsModifiers
&&
89 *Thread
= HotKeyItem
->Thread
;
92 *hWnd
= HotKeyItem
->hWnd
;
106 UnregisterWindowHotKeys(PWINDOW_OBJECT Window
)
108 PHOT_KEY_ITEM HotKeyItem
, tmp
;
110 LIST_FOR_EACH_SAFE(HotKeyItem
, tmp
, &gHotkeyList
, HOT_KEY_ITEM
, ListEntry
)
112 if (HotKeyItem
->hWnd
== Window
->hSelf
)
114 RemoveEntryList (&HotKeyItem
->ListEntry
);
115 ExFreePool (HotKeyItem
);
123 UnregisterThreadHotKeys(struct _ETHREAD
*Thread
)
125 PHOT_KEY_ITEM HotKeyItem
, tmp
;
127 LIST_FOR_EACH_SAFE(HotKeyItem
, tmp
, &gHotkeyList
, HOT_KEY_ITEM
, ListEntry
)
129 if (HotKeyItem
->Thread
== Thread
)
131 RemoveEntryList (&HotKeyItem
->ListEntry
);
132 ExFreePool (HotKeyItem
);
141 IsHotKey (UINT fsModifiers
, UINT vk
)
143 PHOT_KEY_ITEM HotKeyItem
;
145 LIST_FOR_EACH(HotKeyItem
, &gHotkeyList
, HOT_KEY_ITEM
, ListEntry
)
147 if (HotKeyItem
->fsModifiers
== fsModifiers
&& HotKeyItem
->vk
== vk
)
158 /* SYSCALLS *****************************************************************/
162 NtUserRegisterHotKey(HWND hWnd
,
167 PHOT_KEY_ITEM HotKeyItem
;
168 PWINDOW_OBJECT Window
;
169 PETHREAD HotKeyThread
;
170 DECLARE_RETURN(BOOL
);
172 DPRINT("Enter NtUserRegisterHotKey\n");
173 UserEnterExclusive();
177 HotKeyThread
= PsGetCurrentThread();
181 if(!(Window
= UserGetWindowObject(hWnd
)))
185 HotKeyThread
= Window
->OwnerThread
;
188 /* Check for existing hotkey */
189 if (IsHotKey (fsModifiers
, vk
))
194 HotKeyItem
= ExAllocatePoolWithTag (PagedPool
, sizeof(HOT_KEY_ITEM
), TAG_HOTKEY
);
195 if (HotKeyItem
== NULL
)
200 HotKeyItem
->Thread
= HotKeyThread
;
201 HotKeyItem
->hWnd
= hWnd
;
203 HotKeyItem
->fsModifiers
= fsModifiers
;
206 InsertHeadList (&gHotkeyList
, &HotKeyItem
->ListEntry
);
211 DPRINT("Leave NtUserRegisterHotKey, ret=%i\n",_ret_
);
218 NtUserUnregisterHotKey(HWND hWnd
, int id
)
220 PHOT_KEY_ITEM HotKeyItem
;
221 PWINDOW_OBJECT Window
;
222 DECLARE_RETURN(BOOL
);
224 DPRINT("Enter NtUserUnregisterHotKey\n");
225 UserEnterExclusive();
227 if(!(Window
= UserGetWindowObject(hWnd
)))
232 LIST_FOR_EACH(HotKeyItem
, &gHotkeyList
, HOT_KEY_ITEM
, ListEntry
)
234 if (HotKeyItem
->hWnd
== hWnd
&& HotKeyItem
->id
== id
)
236 RemoveEntryList (&HotKeyItem
->ListEntry
);
237 ExFreePool (HotKeyItem
);
246 DPRINT("Leave NtUserUnregisterHotKey, ret=%i\n",_ret_
);