ReactOS  0.4.14-dev-342-gdc047f9
hotkey.c File Reference
#include <win32k.h>
Include dependency graph for hotkey.c:

Go to the source code of this file.

Functions

 DBG_DEFAULT_CHANNEL (UserHotkey)
 
VOID FASTCALL StartDebugHotKeys (VOID)
 
static UINT FASTCALL IntGetModifiers (PBYTE pKeyState)
 
VOID FASTCALL UnregisterWindowHotKeys (PWND pWnd)
 
VOID FASTCALL UnregisterThreadHotKeys (PTHREADINFO pti)
 
static PHOT_KEY FASTCALL IsHotKey (UINT fsModifiers, WORD wVk)
 
BOOL NTAPI co_UserProcessHotKeys (WORD wVk, BOOL bIsDown)
 
UINT FASTCALL DefWndGetHotKey (PWND pWnd)
 
INT FASTCALL DefWndSetHotKey (PWND pWnd, WPARAM wParam)
 
BOOL FASTCALL UserRegisterHotKey (PWND pWnd, int id, UINT fsModifiers, UINT vk)
 
BOOL FASTCALL UserUnregisterHotKey (PWND pWnd, int id)
 
BOOL APIENTRY NtUserRegisterHotKey (HWND hWnd, int id, UINT fsModifiers, UINT vk)
 
BOOL APIENTRY NtUserUnregisterHotKey (HWND hWnd, int id)
 

Variables

PHOT_KEY gphkFirst = NULL
 
UINT gfsModOnlyCandidate
 

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 
282  pWnd = gpqForeground->spwndFocus;
283  }
284 
285  if (pWnd)
286  {
287  // pWnd->head.rpdesk->pDeskInfo->spwndShell needs testing.
288  if (pWnd == ValidateHwndNoErr(InputWindowStation->ShellWindow) && pHotKey->id == SC_TASKLIST)
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 }
BYTE gafAsyncKeyState[256 *2/8]
Definition: keyboard.c:13
PUSER_MESSAGE_QUEUE gpqForeground
Definition: focus.c:12
#define IDHK_SNAP_DOWN
Definition: hotkey.h:23
static UINT FASTCALL IntGetModifiers(PBYTE pKeyState)
Definition: hotkey.c:66
BOOL FASTCALL UserPostMessage(HWND Wnd, UINT Msg, WPARAM wParam, LPARAM lParam)
Definition: message.c:1181
#define TRUE
Definition: types.h:120
PWND FASTCALL ValidateHwndNoErr(HWND hWnd)
Definition: window.c:96
Definition: hotkey.h:3
#define IDHK_SHIFTF12
Definition: hotkey.h:15
#define WM_HOTKEY
Definition: winuser.h:1861
PWINSTATION_OBJECT InputWindowStation
Definition: winsta.c:21
#define PWND_BOTTOM
Definition: ntuser.h:731
#define VK_LWIN
Definition: winuser.h:2210
#define VK_MENU
Definition: winuser.h:2179
#define SC_TASKLIST
Definition: winuser.h:2574
PWND pWnd
Definition: hotkey.h:6
#define IDHK_SNAP_RIGHT
Definition: hotkey.h:21
unsigned int BOOL
Definition: ntddk_ex.h:94
BOOL FASTCALL UserPostThreadMessage(PTHREADINFO pti, UINT Msg, WPARAM wParam, LPARAM lParam)
Definition: message.c:1144
#define VK_SHIFT
Definition: winuser.h:2177
#define MAKELONG(a, b)
Definition: typedefs.h:248
smooth NULL
Definition: ftsmooth.c:416
#define WM_KEYDOWN
Definition: winuser.h:1697
HWND FASTCALL UserGetForegroundWindow(VOID)
Definition: focus.c:1303
#define UserHMGetHandle(obj)
Definition: ntuser.h:208
#define TRACE(s)
Definition: solgame.cpp:4
static PHOT_KEY FASTCALL IsHotKey(UINT fsModifiers, WORD wVk)
Definition: hotkey.c:151
#define IDHK_SNAP_UP
Definition: hotkey.h:22
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#define IDHK_F12
Definition: hotkey.h:14
#define VK_RWIN
Definition: winuser.h:2211
#define ERR(fmt,...)
Definition: debug.h:109
Definition: ntuser.h:657
UINT gfsModOnlyCandidate
Definition: hotkey.c:39
#define IDHK_SNAP_LEFT
Definition: hotkey.h:20
PTHREADINFO pti
Definition: hotkey.h:5
unsigned int UINT
Definition: ndis.h:50
VOID co_IntShellHookNotify(WPARAM Message, WPARAM wParam, LPARAM lParam)
Definition: desktop.c:1656
#define VK_CONTROL
Definition: winuser.h:2178
INT id
Definition: hotkey.h:9
#define IDHK_WINKEY
Definition: hotkey.h:16
#define WM_SYSCOMMAND
Definition: winuser.h:1723
HANDLE ShellWindow
Definition: winsta.h:20

Referenced by ProcessKeyEvent().

◆ DBG_DEFAULT_CHANNEL()

DBG_DEFAULT_CHANNEL ( UserHotkey  )

◆ 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 IDHK_REACTOS
Definition: hotkey.h:17
UINT fsModifiers
Definition: hotkey.h:7
Definition: hotkey.h:3
#define WARN(fmt,...)
Definition: debug.h:111
PWND pWnd
Definition: hotkey.h:6
#define MAKELONG(a, b)
Definition: typedefs.h:248
UINT vk
Definition: hotkey.h:8
struct _HOT_KEY * pNext
Definition: hotkey.h:10
PHOT_KEY gphkFirst
Definition: hotkey.c:38
INT id
Definition: hotkey.h:9

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 }
#define IDHK_REACTOS
Definition: hotkey.h:17
UINT fsModifiers
Definition: hotkey.h:7
Definition: hotkey.h:3
#define WARN(fmt,...)
Definition: debug.h:111
#define VK_TAB
Definition: winuser.h:2174
#define WS_CHILD
Definition: pedump.c:617
#define VK_ESCAPE
Definition: winuser.h:2189
int32_t INT
Definition: typedefs.h:56
WPARAM wParam
Definition: combotst.c:138
PWND pWnd
Definition: hotkey.h:6
smooth NULL
Definition: ftsmooth.c:416
UINT vk
Definition: hotkey.h:8
struct _HOT_KEY * pNext
Definition: hotkey.h:10
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
PHOT_KEY gphkFirst
Definition: hotkey.c:38
PTHREADINFO pti
Definition: hotkey.h:5
unsigned int UINT
Definition: ndis.h:50
#define VK_SPACE
Definition: winuser.h:2194
INT id
Definition: hotkey.h:9
#define HIWORD(l)
Definition: typedefs.h:246
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1099
#define LOWORD(l)
Definition: pedump.c:82
#define USERTAG_HOTKEY
Definition: tags.h:237
DWORD style
Definition: ntuser.h:670

Referenced by IntDefWindowProc().

◆ IntGetModifiers()

static UINT FASTCALL IntGetModifiers ( PBYTE  pKeyState)
static

Definition at line 66 of file hotkey.c.

67 {
68  UINT fModifiers = 0;
69 
70  if (IS_KEY_DOWN(pKeyState, VK_SHIFT))
71  fModifiers |= MOD_SHIFT;
72 
73  if (IS_KEY_DOWN(pKeyState, VK_CONTROL))
74  fModifiers |= MOD_CONTROL;
75 
76  if (IS_KEY_DOWN(pKeyState, VK_MENU))
77  fModifiers |= MOD_ALT;
78 
79  if (IS_KEY_DOWN(pKeyState, VK_LWIN) || IS_KEY_DOWN(pKeyState, VK_RWIN))
80  fModifiers |= MOD_WIN;
81 
82  return fModifiers;
83 }
#define VK_LWIN
Definition: winuser.h:2210
#define VK_MENU
Definition: winuser.h:2179
#define VK_SHIFT
Definition: winuser.h:2177
#define VK_RWIN
Definition: winuser.h:2211
#define MOD_ALT
Definition: imm.h:311
#define MOD_CONTROL
Definition: imm.h:312
#define MOD_SHIFT
Definition: imm.h:313
unsigned int UINT
Definition: ndis.h:50
#define VK_CONTROL
Definition: winuser.h:2178
#define IS_KEY_DOWN(ks, vk)
Definition: input.h:98
#define MOD_WIN
Definition: winuser.h:2619

Referenced by co_UserProcessHotKeys().

◆ IsHotKey()

static PHOT_KEY FASTCALL IsHotKey ( UINT  fsModifiers,
WORD  wVk 
)
static

Definition at line 151 of file hotkey.c.

152 {
153  PHOT_KEY pHotKey = gphkFirst;
154 
155  while (pHotKey)
156  {
157  if (pHotKey->fsModifiers == fsModifiers &&
158  pHotKey->vk == wVk)
159  {
160  /* We have found it */
161  return pHotKey;
162  }
163 
164  /* Move to the next entry */
165  pHotKey = pHotKey->pNext;
166  }
167 
168  return NULL;
169 }
UINT fsModifiers
Definition: hotkey.h:7
Definition: hotkey.h:3
smooth NULL
Definition: ftsmooth.c:416
UINT vk
Definition: hotkey.h:8
struct _HOT_KEY * pNext
Definition: hotkey.h:10
PHOT_KEY gphkFirst
Definition: hotkey.c:38

Referenced by co_UserProcessHotKeys(), NtUserRegisterHotKey(), and UserRegisterHotKey().

◆ NtUserRegisterHotKey()

BOOL APIENTRY NtUserRegisterHotKey ( HWND  hWnd,
int  id,
UINT  fsModifiers,
UINT  vk 
)

Definition at line 512 of file hotkey.c.

516 {
517  PHOT_KEY pHotKey;
518  PWND pWnd = NULL;
519  PTHREADINFO pHotKeyThread;
520  BOOL bRet = FALSE;
521 
522  TRACE("Enter NtUserRegisterHotKey\n");
523 
524  if (fsModifiers & ~(MOD_ALT|MOD_CONTROL|MOD_SHIFT|MOD_WIN)) // FIXME: Does Win2k3 support MOD_NOREPEAT?
525  {
526  WARN("Invalid modifiers: %x\n", fsModifiers);
528  return 0;
529  }
530 
532 
533  /* Find hotkey thread */
534  if (hWnd == NULL)
535  {
536  pHotKeyThread = gptiCurrent;
537  }
538  else
539  {
540  pWnd = UserGetWindowObject(hWnd);
541  if (!pWnd)
542  goto cleanup;
543 
544  pHotKeyThread = pWnd->head.pti;
545 
546  /* Fix wine msg "Window on another thread" test_hotkey */
547  if (pWnd->head.pti != gptiCurrent)
548  {
550  WARN("Must be from the same Thread.\n");
551  goto cleanup;
552  }
553  }
554 
555  /* Check for existing hotkey */
556  if (IsHotKey(fsModifiers, vk))
557  {
559  WARN("Hotkey already exists\n");
560  goto cleanup;
561  }
562 
563  /* Create new hotkey */
565  if (pHotKey == NULL)
566  {
568  goto cleanup;
569  }
570 
571  pHotKey->pti = pHotKeyThread;
572  pHotKey->pWnd = pWnd;
573  pHotKey->fsModifiers = fsModifiers;
574  pHotKey->vk = vk;
575  pHotKey->id = id;
576 
577  /* Insert hotkey to the global list */
578  pHotKey->pNext = gphkFirst;
579  gphkFirst = pHotKey;
580 
581  bRet = TRUE;
582 
583 cleanup:
584  TRACE("Leave NtUserRegisterHotKey, ret=%i\n", bRet);
585  UserLeave();
586  return bRet;
587 }
#define TRUE
Definition: types.h:120
UINT fsModifiers
Definition: hotkey.h:7
Definition: hotkey.h:3
#define WARN(fmt,...)
Definition: debug.h:111
HWND hWnd
Definition: settings.c:17
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
PWND pWnd
Definition: hotkey.h:6
unsigned int BOOL
Definition: ntddk_ex.h:94
THRDESKHEAD head
Definition: ntuser.h:659
smooth NULL
Definition: ftsmooth.c:416
#define ERROR_WINDOW_OF_OTHER_THREAD
Definition: winerror.h:889
PTHREADINFO gptiCurrent
Definition: ntuser.c:15
UINT vk
Definition: hotkey.h:8
PWND FASTCALL UserGetWindowObject(HWND hWnd)
Definition: window.c:103
#define ERROR_HOTKEY_ALREADY_REGISTERED
Definition: winerror.h:890
VOID FASTCALL UserEnterExclusive(VOID)
Definition: ntuser.c:247
#define TRACE(s)
Definition: solgame.cpp:4
static PHOT_KEY FASTCALL IsHotKey(UINT fsModifiers, WORD wVk)
Definition: hotkey.c:151
struct _HOT_KEY * pNext
Definition: hotkey.h:10
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
PHOT_KEY gphkFirst
Definition: hotkey.c:38
Definition: ntuser.h:657
VOID FASTCALL UserLeave(VOID)
Definition: ntuser.c:255
#define MOD_ALT
Definition: imm.h:311
#define MOD_CONTROL
Definition: imm.h:312
#define MOD_SHIFT
Definition: imm.h:313
PTHREADINFO pti
Definition: hotkey.h:5
INT id
Definition: hotkey.h:9
GLenum GLuint id
Definition: glext.h:5579
char * cleanup(char *str)
Definition: wpickclick.c:99
#define MOD_WIN
Definition: winuser.h:2619
#define ERROR_INVALID_FLAGS
Definition: winerror.h:583
#define USERTAG_HOTKEY
Definition: tags.h:237
ENGAPI VOID APIENTRY EngSetLastError(_In_ ULONG iError)
Definition: error.c:27

Referenced by RegisterHotKey().

◆ NtUserUnregisterHotKey()

BOOL APIENTRY NtUserUnregisterHotKey ( HWND  hWnd,
int  id 
)

Definition at line 591 of file hotkey.c.

592 {
593  PHOT_KEY pHotKey = gphkFirst, phkNext, *pLink = &gphkFirst;
594  BOOL bRet = FALSE;
595  PWND pWnd = NULL;
596 
597  TRACE("Enter NtUserUnregisterHotKey\n");
599 
600  /* Fail if given window is invalid */
601  if (hWnd && !(pWnd = UserGetWindowObject(hWnd)))
602  goto cleanup;
603 
604  while (pHotKey)
605  {
606  /* Save next ptr for later use */
607  phkNext = pHotKey->pNext;
608 
609  /* Should we delete this hotkey? */
610  if (pHotKey->pWnd == pWnd && pHotKey->id == id)
611  {
612  /* Update next ptr for previous hotkey and free memory */
613  *pLink = phkNext;
615 
616  bRet = TRUE;
617  }
618  else /* This hotkey will stay, use its next ptr */
619  pLink = &pHotKey->pNext;
620 
621  /* Move to the next entry */
622  pHotKey = phkNext;
623  }
624 
625 cleanup:
626  TRACE("Leave NtUserUnregisterHotKey, ret=%i\n", bRet);
627  UserLeave();
628  return bRet;
629 }
#define TRUE
Definition: types.h:120
Definition: hotkey.h:3
HWND hWnd
Definition: settings.c:17
PWND pWnd
Definition: hotkey.h:6
unsigned int BOOL
Definition: ntddk_ex.h:94
smooth NULL
Definition: ftsmooth.c:416
PWND FASTCALL UserGetWindowObject(HWND hWnd)
Definition: window.c:103
VOID FASTCALL UserEnterExclusive(VOID)
Definition: ntuser.c:247
#define TRACE(s)
Definition: solgame.cpp:4
struct _HOT_KEY * pNext
Definition: hotkey.h:10
PHOT_KEY gphkFirst
Definition: hotkey.c:38
Definition: ntuser.h:657
VOID FASTCALL UserLeave(VOID)
Definition: ntuser.c:255
INT id
Definition: hotkey.h:9
char * cleanup(char *str)
Definition: wpickclick.c:99
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1099
#define USERTAG_HOTKEY
Definition: tags.h:237

◆ StartDebugHotKeys()

VOID FASTCALL StartDebugHotKeys ( VOID  )

Definition at line 44 of file hotkey.c.

45 {
46  UINT vk = VK_F12;
50  {
51  vk = VK_SUBTRACT;
52  }
55  TRACE("Start up the debugger hotkeys!! If you see this you eneabled debugprints. Congrats!\n");
56 }
#define VK_SUBTRACT
Definition: winuser.h:2227
#define ENHANCED_KEYBOARD(Id)
Definition: ntddkbd.h:105
#define IDHK_SHIFTF12
Definition: hotkey.h:15
#define PWND_BOTTOM
Definition: ntuser.h:731
#define TRACE(s)
Definition: solgame.cpp:4
#define VK_F12
Definition: winuser.h:2241
#define IDHK_F12
Definition: hotkey.h:14
KEYBOARD_ID KeyboardIdentifier
Definition: ntddkbd.h:124
BOOL FASTCALL UserRegisterHotKey(PWND pWnd, int id, UINT fsModifiers, UINT vk)
Definition: hotkey.c:431
#define MOD_SHIFT
Definition: imm.h:313
unsigned int UINT
Definition: ndis.h:50
KEYBOARD_ATTRIBUTES gKeyboardInfo
Definition: keyboard.c:17
BOOL FASTCALL UserUnregisterHotKey(PWND pWnd, int id)
Definition: hotkey.c:479

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 }
Definition: hotkey.h:3
struct _HOT_KEY * pNext
Definition: hotkey.h:10
PHOT_KEY gphkFirst
Definition: hotkey.c:38
PTHREADINFO pti
Definition: hotkey.h:5
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1099
#define USERTAG_HOTKEY
Definition: tags.h:237

Referenced by ExitThreadCallback().

◆ UnregisterWindowHotKeys()

VOID FASTCALL UnregisterWindowHotKeys ( PWND  pWnd)

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 }
Definition: hotkey.h:3
PWND pWnd
Definition: hotkey.h:6
struct _HOT_KEY * pNext
Definition: hotkey.h:10
PHOT_KEY gphkFirst
Definition: hotkey.c:38
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1099
#define USERTAG_HOTKEY
Definition: tags.h:237

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 TRUE
Definition: types.h:120
UINT fsModifiers
Definition: hotkey.h:7
Definition: hotkey.h:3
#define PWND_BOTTOM
Definition: ntuser.h:731
#define WARN(fmt,...)
Definition: debug.h:111
PVOID NTAPI PsGetCurrentThreadWin32Thread(VOID)
Definition: thread.c:805
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
PWND pWnd
Definition: hotkey.h:6
THRDESKHEAD head
Definition: ntuser.h:659
smooth NULL
Definition: ftsmooth.c:416
UINT vk
Definition: hotkey.h:8
#define ERROR_HOTKEY_ALREADY_REGISTERED
Definition: winerror.h:890
static PHOT_KEY FASTCALL IsHotKey(UINT fsModifiers, WORD wVk)
Definition: hotkey.c:151
struct _HOT_KEY * pNext
Definition: hotkey.h:10
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
PHOT_KEY gphkFirst
Definition: hotkey.c:38
PTHREADINFO pti
Definition: hotkey.h:5
INT id
Definition: hotkey.h:9
GLenum GLuint id
Definition: glext.h:5579
#define USERTAG_HOTKEY
Definition: tags.h:237
ENGAPI VOID APIENTRY EngSetLastError(_In_ ULONG iError)
Definition: error.c:27

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 }
#define TRUE
Definition: types.h:120
Definition: hotkey.h:3
PWND pWnd
Definition: hotkey.h:6
unsigned int BOOL
Definition: ntddk_ex.h:94
struct _HOT_KEY * pNext
Definition: hotkey.h:10
PHOT_KEY gphkFirst
Definition: hotkey.c:38
INT id
Definition: hotkey.h:9
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1099
#define USERTAG_HOTKEY
Definition: tags.h:237

Referenced by StartDebugHotKeys().

Variable Documentation

◆ gfsModOnlyCandidate

UINT gfsModOnlyCandidate

Definition at line 39 of file hotkey.c.

Referenced by co_UserProcessHotKeys().

◆ gphkFirst