ReactOS 0.4.16-dev-92-g0c2cdca
hotkey.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  _HOT_KEY
 

Macros

#define IDHK_F12   -5
 
#define IDHK_SHIFTF12   -6
 
#define IDHK_WINKEY   -7
 
#define IDHK_REACTOS   -8
 
#define IDHK_SNAP_LEFT   -10
 
#define IDHK_SNAP_RIGHT   -11
 
#define IDHK_SNAP_UP   -12
 
#define IDHK_SNAP_DOWN   -13
 

Typedefs

typedef struct _HOT_KEY HOT_KEY
 
typedef struct _HOT_KEYPHOT_KEY
 

Functions

VOID FASTCALL UnregisterWindowHotKeys (PWND Window)
 
VOID FASTCALL UnregisterThreadHotKeys (PTHREADINFO pti)
 
BOOL NTAPI co_UserProcessHotKeys (WORD wVk, BOOL bIsDown)
 
UINT FASTCALL DefWndGetHotKey (PWND pWnd)
 
INT FASTCALL DefWndSetHotKey (PWND pWnd, WPARAM wParam)
 
VOID FASTCALL StartDebugHotKeys (VOID)
 
BOOL FASTCALL UserRegisterHotKey (PWND pWnd, int id, UINT fsModifiers, UINT vk)
 
BOOL FASTCALL UserUnregisterHotKey (PWND pWnd, int id)
 

Macro Definition Documentation

◆ IDHK_F12

#define IDHK_F12   -5

Definition at line 14 of file hotkey.h.

◆ IDHK_REACTOS

#define IDHK_REACTOS   -8

Definition at line 17 of file hotkey.h.

◆ IDHK_SHIFTF12

#define IDHK_SHIFTF12   -6

Definition at line 15 of file hotkey.h.

◆ IDHK_SNAP_DOWN

#define IDHK_SNAP_DOWN   -13

Definition at line 23 of file hotkey.h.

◆ IDHK_SNAP_LEFT

#define IDHK_SNAP_LEFT   -10

Definition at line 20 of file hotkey.h.

◆ IDHK_SNAP_RIGHT

#define IDHK_SNAP_RIGHT   -11

Definition at line 21 of file hotkey.h.

◆ IDHK_SNAP_UP

#define IDHK_SNAP_UP   -12

Definition at line 22 of file hotkey.h.

◆ IDHK_WINKEY

#define IDHK_WINKEY   -7

Definition at line 16 of file hotkey.h.

Typedef Documentation

◆ HOT_KEY

◆ PHOT_KEY

Function Documentation

◆ co_UserProcessHotKeys()

BOOL NTAPI co_UserProcessHotKeys ( WORD  wVk,
BOOL  bIsDown 
)

Definition at line 177 of file hotkey.c.

178{
179 UINT fModifiers;
180 PHOT_KEY pHotKey;
181 PWND pWnd;
182 BOOL DoNotPostMsg = FALSE;
183 BOOL IsModifier = FALSE;
184
185 if (wVk == VK_SHIFT || wVk == VK_CONTROL || wVk == VK_MENU ||
186 wVk == VK_LWIN || wVk == VK_RWIN)
187 {
188 /* Remember that this was a modifier */
189 IsModifier = TRUE;
190 }
191
192 fModifiers = IntGetModifiers(gafAsyncKeyState);
193
194 if (bIsDown)
195 {
196 if (IsModifier)
197 {
198 /* Modifier key down -- no hotkey trigger, but remember this */
199 gfsModOnlyCandidate = fModifiers;
200 return FALSE;
201 }
202 else
203 {
204 /* Regular key down -- check for hotkey, and reset mod candidates */
205 pHotKey = IsHotKey(fModifiers, wVk);
207 }
208 }
209 else
210 {
211 if (IsModifier)
212 {
213 /* Modifier key up -- modifier-only keys are triggered here */
214 pHotKey = IsHotKey(gfsModOnlyCandidate, 0);
216 }
217 else
218 {
219 /* Regular key up -- no hotkey, but reset mod-only candidates */
221 return FALSE;
222 }
223 }
224
225 if (pHotKey)
226 {
227 TRACE("Hot key pressed (pWnd %p, id %d)\n", pHotKey->pWnd, pHotKey->id);
228
229 /* FIXME: See comment about "UserDebuggerHotKey" on top of this file. */
230 if (pHotKey->id == IDHK_SHIFTF12 || pHotKey->id == IDHK_F12)
231 {
232 if (bIsDown)
233 {
234 ERR("Hot key pressed for Debug Activation! ShiftF12 = %d or F12 = %d\n",pHotKey->id == IDHK_SHIFTF12 , pHotKey->id == IDHK_F12);
235 //DoNotPostMsg = co_ActivateDebugger(); // FIXME
236 }
237 return DoNotPostMsg;
238 }
239
240 /* WIN and F12 keys are not hardcoded here. See comments on top of this file. */
241 if (pHotKey->id == IDHK_WINKEY)
242 {
243 ASSERT(!bIsDown);
245 if (pWnd)
246 {
247 TRACE("System Hot key Id %d Key %u\n", pHotKey->id, wVk );
249 co_IntShellHookNotify(HSHELL_TASKMAN, 0, 0);
250 return FALSE;
251 }
252 }
253
254 if (pHotKey->id == IDHK_SNAP_LEFT ||
255 pHotKey->id == IDHK_SNAP_RIGHT ||
256 pHotKey->id == IDHK_SNAP_UP ||
257 pHotKey->id == IDHK_SNAP_DOWN)
258 {
259 HWND topWnd = UserGetForegroundWindow();
260 if (topWnd)
261 {
262 UserPostMessage(topWnd, WM_KEYDOWN, wVk, 0);
263 }
264 return TRUE;
265 }
266
267 if (!pHotKey->pWnd)
268 {
269 TRACE("UPTM Hot key Id %d Key %u\n", pHotKey->id, wVk );
270 UserPostThreadMessage(pHotKey->pti, WM_HOTKEY, pHotKey->id, MAKELONG(fModifiers, wVk));
271 //ptiLastInput = pHotKey->pti;
272 return TRUE; /* Don't send any message */
273 }
274 else
275 {
276 pWnd = pHotKey->pWnd;
277 if (pWnd == PWND_BOTTOM)
278 {
279 if (gpqForeground == NULL)
280 return FALSE;
281
283 }
284
285 if (pWnd)
286 {
287 // pWnd->head.rpdesk->pDeskInfo->spwndShell needs testing.
289 {
291 co_IntShellHookNotify(HSHELL_TASKMAN, 0, 0);
292 }
293 else
294 {
295 TRACE("UPM Hot key Id %d Key %u\n", pHotKey->id, wVk );
296 UserPostMessage(UserHMGetHandle(pWnd), WM_HOTKEY, pHotKey->id, MAKELONG(fModifiers, wVk));
297 }
298 //ptiLastInput = pWnd->head.pti;
299 return TRUE; /* Don't send any message */
300 }
301 }
302 }
303 return FALSE;
304}
#define ERR(fmt,...)
Definition: precomp.h:57
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define ValidateHwndNoErr(hwnd)
Definition: precomp.h:84
unsigned int BOOL
Definition: ntddk_ex.h:94
PUSER_MESSAGE_QUEUE gpqForeground
Definition: focus.c:13
HWND FASTCALL UserGetForegroundWindow(VOID)
Definition: focus.c:1424
#define IDHK_SNAP_LEFT
Definition: hotkey.h:20
#define IDHK_WINKEY
Definition: hotkey.h:16
#define IDHK_SNAP_UP
Definition: hotkey.h:22
#define IDHK_F12
Definition: hotkey.h:14
#define IDHK_SNAP_DOWN
Definition: hotkey.h:23
#define IDHK_SNAP_RIGHT
Definition: hotkey.h:21
#define IDHK_SHIFTF12
Definition: hotkey.h:15
#define UserHMGetHandle(obj)
Definition: ntuser.h:230
#define PWND_BOTTOM
Definition: ntuser.h:769
#define ASSERT(a)
Definition: mode.c:44
unsigned int UINT
Definition: ndis.h:50
PWINSTATION_OBJECT InputWindowStation
Definition: winsta.c:21
#define TRACE(s)
Definition: solgame.cpp:4
Definition: hotkey.h:4
PTHREADINFO pti
Definition: hotkey.h:5
INT id
Definition: hotkey.h:9
PWND pWnd
Definition: hotkey.h:6
HANDLE ShellWindow
Definition: winsta.h:43
Definition: ntuser.h:694
#define MAKELONG(a, b)
Definition: typedefs.h:249
VOID co_IntShellHookNotify(WPARAM Message, WPARAM wParam, LPARAM lParam)
Definition: desktop.c:1709
static PHOT_KEY FASTCALL IsHotKey(UINT fsModifiers, WORD wVk)
Definition: hotkey.c:151
UINT gfsModOnlyCandidate
Definition: hotkey.c:39
static UINT FASTCALL IntGetModifiers(PBYTE pKeyState)
Definition: hotkey.c:66
BYTE gafAsyncKeyState[256 *2/8]
Definition: keyboard.c:13
BOOL FASTCALL UserPostMessage(HWND Wnd, UINT Msg, WPARAM wParam, LPARAM lParam)
Definition: message.c:1395
BOOL FASTCALL UserPostThreadMessage(PTHREADINFO pti, UINT Msg, WPARAM wParam, LPARAM lParam)
Definition: message.c:1358
#define WM_SYSCOMMAND
Definition: winuser.h:1744
#define VK_CONTROL
Definition: winuser.h:2206
#define SC_TASKLIST
Definition: winuser.h:2602
#define VK_LWIN
Definition: winuser.h:2238
#define WM_HOTKEY
Definition: winuser.h:1882
#define VK_SHIFT
Definition: winuser.h:2205
#define WM_KEYDOWN
Definition: winuser.h:1718
#define VK_RWIN
Definition: winuser.h:2239
#define VK_MENU
Definition: winuser.h:2207

Referenced by ProcessKeyEvent().

◆ DefWndGetHotKey()

UINT FASTCALL DefWndGetHotKey ( PWND  pWnd)

Definition at line 313 of file hotkey.c.

314{
315 PHOT_KEY pHotKey = gphkFirst;
316
317 WARN("DefWndGetHotKey\n");
318
319 while (pHotKey)
320 {
321 if (pHotKey->pWnd == pWnd && pHotKey->id == IDHK_REACTOS)
322 {
323 /* We have found it */
324 return MAKELONG(pHotKey->vk, pHotKey->fsModifiers);
325 }
326
327 /* Move to the next entry */
328 pHotKey = pHotKey->pNext;
329 }
330
331 return 0;
332}
#define WARN(fmt,...)
Definition: precomp.h:61
#define IDHK_REACTOS
Definition: hotkey.h:17
UINT fsModifiers
Definition: hotkey.h:7
struct _HOT_KEY * pNext
Definition: hotkey.h:10
UINT vk
Definition: hotkey.h:8
PHOT_KEY gphkFirst
Definition: hotkey.c:38

Referenced by IntDefWindowProc().

◆ DefWndSetHotKey()

INT FASTCALL DefWndSetHotKey ( PWND  pWnd,
WPARAM  wParam 
)

Definition at line 340 of file hotkey.c.

341{
342 UINT fsModifiers, vk;
343 PHOT_KEY pHotKey, *pLink;
344 INT iRet = 1;
345
346 WARN("DefWndSetHotKey wParam 0x%x\n", wParam);
347
348 // A hot key cannot be associated with a child window.
349 if (pWnd->style & WS_CHILD)
350 return 0;
351
352 // VK_ESCAPE, VK_SPACE, and VK_TAB are invalid hot keys.
353 if (LOWORD(wParam) == VK_ESCAPE ||
354 LOWORD(wParam) == VK_SPACE ||
355 LOWORD(wParam) == VK_TAB)
356 {
357 return -1;
358 }
359
360 vk = LOWORD(wParam);
361 fsModifiers = HIWORD(wParam);
362
363 if (wParam)
364 {
365 pHotKey = gphkFirst;
366 while (pHotKey)
367 {
368 if (pHotKey->fsModifiers == fsModifiers &&
369 pHotKey->vk == vk &&
370 pHotKey->id == IDHK_REACTOS)
371 {
372 if (pHotKey->pWnd != pWnd)
373 iRet = 2; // Another window already has the same hot key.
374 break;
375 }
376
377 /* Move to the next entry */
378 pHotKey = pHotKey->pNext;
379 }
380 }
381
382 pHotKey = gphkFirst;
383 pLink = &gphkFirst;
384 while (pHotKey)
385 {
386 if (pHotKey->pWnd == pWnd &&
387 pHotKey->id == IDHK_REACTOS)
388 {
389 /* This window has already hotkey registered */
390 break;
391 }
392
393 /* Move to the next entry */
394 pLink = &pHotKey->pNext;
395 pHotKey = pHotKey->pNext;
396 }
397
398 if (wParam)
399 {
400 if (!pHotKey)
401 {
402 /* Create new hotkey */
404 if (pHotKey == NULL)
405 return 0;
406
407 pHotKey->pWnd = pWnd;
408 pHotKey->id = IDHK_REACTOS; // Don't care, these hot keys are unrelated to the hot keys set by RegisterHotKey
409 pHotKey->pNext = gphkFirst;
410 gphkFirst = pHotKey;
411 }
412
413 /* A window can only have one hot key. If the window already has a
414 hot key associated with it, the new hot key replaces the old one. */
415 pHotKey->pti = NULL;
416 pHotKey->fsModifiers = fsModifiers;
417 pHotKey->vk = vk;
418 }
419 else if (pHotKey)
420 {
421 /* Remove hotkey */
422 *pLink = pHotKey->pNext;
424 }
425
426 return iRet;
427}
WPARAM wParam
Definition: combotst.c:138
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
#define PagedPool
Definition: env_spec_w32.h:308
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1109
WORD vk
Definition: input.c:77
#define LOWORD(l)
Definition: pedump.c:82
#define WS_CHILD
Definition: pedump.c:617
DWORD style
Definition: ntuser.h:706
int32_t INT
Definition: typedefs.h:58
#define HIWORD(l)
Definition: typedefs.h:247
#define USERTAG_HOTKEY
Definition: tags.h:238
#define VK_TAB
Definition: winuser.h:2202
#define VK_SPACE
Definition: winuser.h:2222
#define VK_ESCAPE
Definition: winuser.h:2217

Referenced by IntDefWindowProc().

◆ StartDebugHotKeys()

VOID FASTCALL StartDebugHotKeys ( VOID  )

Definition at line 44 of file hotkey.c.

45{
46 UINT vk = VK_F12;
50 {
52 }
55 TRACE("Start up the debugger hotkeys!! If you see this you enabled debugprints. Congrats!\n");
56}
#define MOD_SHIFT
Definition: imm.h:186
#define ENHANCED_KEYBOARD(Id)
Definition: ntddkbd.h:105
KEYBOARD_ID KeyboardIdentifier
Definition: ntddkbd.h:124
BOOL FASTCALL UserRegisterHotKey(PWND pWnd, int id, UINT fsModifiers, UINT vk)
Definition: hotkey.c:431
BOOL FASTCALL UserUnregisterHotKey(PWND pWnd, int id)
Definition: hotkey.c:479
KEYBOARD_ATTRIBUTES gKeyboardInfo
Definition: keyboard.c:17
#define VK_F12
Definition: winuser.h:2269
#define VK_SUBTRACT
Definition: winuser.h:2255

Referenced by RawInputThreadMain().

◆ UnregisterThreadHotKeys()

VOID FASTCALL UnregisterThreadHotKeys ( PTHREADINFO  pti)

Definition at line 121 of file hotkey.c.

122{
123 PHOT_KEY pHotKey = gphkFirst, phkNext, *pLink = &gphkFirst;
124
125 while (pHotKey)
126 {
127 /* Save next ptr for later use */
128 phkNext = pHotKey->pNext;
129
130 /* Should we delete this hotkey? */
131 if (pHotKey->pti == pti)
132 {
133 /* Update next ptr for previous hotkey and free memory */
134 *pLink = phkNext;
136 }
137 else /* This hotkey will stay, use its next ptr */
138 pLink = &pHotKey->pNext;
139
140 /* Move to the next entry */
141 pHotKey = phkNext;
142 }
143}

Referenced by ExitThreadCallback().

◆ UnregisterWindowHotKeys()

VOID FASTCALL UnregisterWindowHotKeys ( PWND  Window)

Definition at line 91 of file hotkey.c.

92{
93 PHOT_KEY pHotKey = gphkFirst, phkNext, *pLink = &gphkFirst;
94
95 while (pHotKey)
96 {
97 /* Save next ptr for later use */
98 phkNext = pHotKey->pNext;
99
100 /* Should we delete this hotkey? */
101 if (pHotKey->pWnd == pWnd)
102 {
103 /* Update next ptr for previous hotkey and free memory */
104 *pLink = phkNext;
106 }
107 else /* This hotkey will stay, use its next ptr */
108 pLink = &pHotKey->pNext;
109
110 /* Move to the next entry */
111 pHotKey = phkNext;
112 }
113}

Referenced by co_UserFreeWindow().

◆ UserRegisterHotKey()

BOOL FASTCALL UserRegisterHotKey ( PWND  pWnd,
int  id,
UINT  fsModifiers,
UINT  vk 
)

Definition at line 431 of file hotkey.c.

435{
436 PHOT_KEY pHotKey;
437 PTHREADINFO pHotKeyThread;
438
439 /* Find hotkey thread */
440 if (pWnd == NULL || pWnd == PWND_BOTTOM)
441 {
442 pHotKeyThread = PsGetCurrentThreadWin32Thread();
443 }
444 else
445 {
446 pHotKeyThread = pWnd->head.pti;
447 }
448
449 /* Check for existing hotkey */
450 if (IsHotKey(fsModifiers, vk))
451 {
453 WARN("Hotkey already exists\n");
454 return FALSE;
455 }
456
457 /* Create new hotkey */
459 if (pHotKey == NULL)
460 {
462 return FALSE;
463 }
464
465 pHotKey->pti = pHotKeyThread;
466 pHotKey->pWnd = pWnd;
467 pHotKey->fsModifiers = fsModifiers;
468 pHotKey->vk = vk;
469 pHotKey->id = id;
470
471 /* Insert hotkey to the global list */
472 pHotKey->pNext = gphkFirst;
473 gphkFirst = pHotKey;
474
475 return TRUE;
476}
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
GLuint id
Definition: glext.h:5910
PVOID NTAPI PsGetCurrentThreadWin32Thread(VOID)
Definition: thread.c:805
THRDESKHEAD head
Definition: ntuser.h:695
ENGAPI VOID APIENTRY EngSetLastError(_In_ ULONG iError)
Definition: error.c:22
#define ERROR_HOTKEY_ALREADY_REGISTERED
Definition: winerror.h:890

Referenced by NtUserSetShellWindowEx(), RawInputThreadMain(), and StartDebugHotKeys().

◆ UserUnregisterHotKey()

BOOL FASTCALL UserUnregisterHotKey ( PWND  pWnd,
int  id 
)

Definition at line 479 of file hotkey.c.

480{
481 PHOT_KEY pHotKey = gphkFirst, phkNext, *pLink = &gphkFirst;
482 BOOL bRet = FALSE;
483
484 while (pHotKey)
485 {
486 /* Save next ptr for later use */
487 phkNext = pHotKey->pNext;
488
489 /* Should we delete this hotkey? */
490 if (pHotKey->pWnd == pWnd && pHotKey->id == id)
491 {
492 /* Update next ptr for previous hotkey and free memory */
493 *pLink = phkNext;
495
496 bRet = TRUE;
497 }
498 else /* This hotkey will stay, use its next ptr */
499 pLink = &pHotKey->pNext;
500
501 /* Move to the next entry */
502 pHotKey = phkNext;
503 }
504 return bRet;
505}

Referenced by StartDebugHotKeys().