ReactOS  0.4.15-dev-4569-g032c50f
focus.c
Go to the documentation of this file.
1 /*
2  * COPYRIGHT: See COPYING in the top level directory
3  * PROJECT: ReactOS Win32k subsystem
4  * PURPOSE: Focus functions
5  * FILE: win32ss/user/ntuser/focus.c
6  * PROGRAMER: ReactOS Team
7  */
8 
9 #include <win32k.h>
10 #include <ddk/immdev.h>
11 DBG_DEFAULT_CHANNEL(UserFocus);
12 
17 ULONG guSFWLockCount = 0; // Rule #8, No menus are active. So should be zero.
20 
21 /*
22  Check locking of a process or one or more menus are active.
23 */
26 {
27  return (gppiLockSFW || guSFWLockCount);
28 }
29 
30 /*
31  Get capture window via foreground Queue.
32 */
35 {
36  PUSER_MESSAGE_QUEUE ForegroundQueue = IntGetFocusMessageQueue();
37  return ( ForegroundQueue ? (ForegroundQueue->spwndCapture ? UserHMGetHandle(ForegroundQueue->spwndCapture) : 0) : 0);
38 }
39 
42 {
43  PTHREADINFO pti;
44  PUSER_MESSAGE_QUEUE ThreadQueue;
45 
47  ThreadQueue = pti->MessageQueue;
48  if (!ThreadQueue)
49  return NULL;
50  return ThreadQueue->spwndFocus ? UserHMGetHandle(ThreadQueue->spwndFocus) : 0;
51 }
52 
54 {
55  RECTL rclAnd, rclMonitor, rclWindow;
57 
58  if (!Window || !(Window->style & WS_VISIBLE) || (Window->style & WS_CHILD) ||
59  (Window->ExStyle & WS_EX_TOOLWINDOW) || !IntGetWindowRect(Window, &rclWindow))
60  {
61  return FALSE;
62  }
63 
65  if (!pMonitor)
66  {
67  RECTL_vSetRect(&rclMonitor, 0, 0,
69  }
70  else
71  {
72  rclMonitor = *(LPRECTL)&pMonitor->rcMonitor;
73  }
74 
75  RECTL_bIntersectRect(&rclAnd, &rclMonitor, &rclWindow);
76  return RtlEqualMemory(&rclAnd, &rclMonitor, sizeof(RECTL));
77 }
78 
80 {
81  HWND hWnd;
82 
85 
87  return FALSE;
88 
90  if (ghwndOldFullscreen != hWnd)
91  {
94  }
95  return TRUE;
96 }
97 
100 {
102  return;
103 
104  if ( Window->spwndParent == UserGetDesktopWindow() &&
105  (!(Window->ExStyle & WS_EX_TOOLWINDOW) ||
106  (Window->ExStyle & WS_EX_APPWINDOW)))
107  {
108  // FIXME lParam; The value is TRUE if the window is in full-screen mode, or FALSE otherwise.
109  co_IntShellHookNotify(HSHELL_WINDOWACTIVATED, (WPARAM) UserHMGetHandle(Window), FALSE);
110  }
111  else
112  {
113  co_IntShellHookNotify(HSHELL_WINDOWACTIVATED, 0, FALSE);
114  }
115 }
116 
119 {
120  USER_REFERENCE_ENTRY RefPrev;
121  PWND WndPrev;
122  BOOL Ret = TRUE;
123  LPARAM lParam = hWnd ? (LPARAM)hWnd : 0;
124 
125  if (hWndPrev && (WndPrev = ValidateHwndNoErr(hWndPrev)))
126  {
127  UserRefObjectCo(WndPrev, &RefPrev);
128 
129  if (co_IntSendMessage(hWndPrev, WM_NCACTIVATE, FALSE, lParam))
130  {
131  co_IntSendMessage(hWndPrev, WM_ACTIVATE,
132  MAKEWPARAM(WA_INACTIVE, (WndPrev->style & WS_MINIMIZE) != 0),
133  (LPARAM)hWnd);
134 
135  if (WndPrev && Clear)
136  WndPrev->state &= ~(WNDS_ACTIVEFRAME|WNDS_HASCAPTION);
137  }
138  else
139  {
140  ERR("Application is keeping itself Active to prevent the change!\n");
141  Ret = FALSE;
142  }
143 
144  UserDerefObjectCo(WndPrev);
145  }
146  return Ret;
147 }
148 
149 // Win: xxxFocusSetInputContext
150 VOID IntFocusSetInputContext(PWND pWnd, BOOL bActivate, BOOL bCallback)
151 {
152  PTHREADINFO pti;
153  PWND pImeWnd;
155  HWND hImeWnd;
156  WPARAM wParam;
157  LPARAM lParam;
158 
159  if (!pWnd || !pWnd->pcls || IS_WND_IMELIKE(pWnd))
160  return;
161 
162  pti = pWnd->head.pti;
163  if (!pti || (pti->TIF_flags & TIF_INCLEANUP))
164  return;
165 
166  pImeWnd = pti->spwndDefaultIme;
167  if (!pImeWnd)
168  return;
169 
170  UserRefObjectCo(pImeWnd, &Ref);
171 
172  hImeWnd = UserHMGetHandle(pImeWnd);
173  wParam = (bActivate ? IMS_IMEACTIVATE : IMS_IMEDEACTIVATE);
174  lParam = (LPARAM)UserHMGetHandle(pWnd);
175 
176  if (bCallback)
178  else
180 
181  UserDerefObjectCo(pImeWnd);
182 }
183 
184 //
185 // Deactivating the foreground message queue.
186 //
187 // Release Active, Capture and Focus Windows associated with this message queue.
188 //
189 // Win: xxxDeactivate
192 {
194  PTHREADINFO ptiPrev;
195  PWND pwndPrev;
196  BOOL InAAPM = FALSE;
198 
199  if ( !pti->MessageQueue->spwndActive )
200  {
201  TRACE("IDAW E : Nothing to do, Active is NULL! pti 0x%p tid 0x%p\n",pti,tid);
202  return TRUE;
203  }
204 
205  TRACE("IDAW : pti 0x%p tid 0x%p\n",pti,tid);
206 
207  if (ptiCurrent != pti)
208  {
210  IntReferenceThreadInfo(ptiCurrent);
211  }
212 
213  if (!(pti->TIF_flags & TIF_INACTIVATEAPPMSG) )
214  {
216  InAAPM = TRUE;
217  }
218 
219  //
220  // Check for Capture and release it.
221  //
222  if ( pti->MessageQueue->spwndCapture )
223  {
224  MSG msg;
225  PWND pwndCapture = pti->MessageQueue->spwndCapture;
226 
227  UserRefObjectCo(pwndCapture, &Ref);
228  co_IntSendMessage(UserHMGetHandle(pwndCapture), WM_CANCELMODE, 0, 0);
229  UserDerefObjectCo(pwndCapture);
230 
231  /* Generate mouse move message */
232  msg.message = WM_MOUSEMOVE;
233  msg.wParam = UserGetMouseButtonsState();
234  msg.lParam = MAKELPARAM(gpsi->ptCursor.x, gpsi->ptCursor.y);
235  msg.pt = gpsi->ptCursor;
237  }
238 
239  //
240  // Check for Active and release it.
241  //
242  if ( pti->MessageQueue->spwndActive )
243  {
244  pwndPrev = pti->MessageQueue->spwndActive;
245  ptiPrev = pwndPrev->head.pti;
246 
248  {
249  if (InAAPM) pti->TIF_flags &= ~TIF_INACTIVATEAPPMSG;
250  if (ptiCurrent != pti)
251  {
253  IntDereferenceThreadInfo(ptiCurrent);
254  }
255  return FALSE;
256  }
257 
258  if ( pti->MessageQueue->spwndActive == pwndPrev )
259  {
260  pti->MessageQueue->spwndActivePrev = pwndPrev;
261  pti->MessageQueue->spwndActive = NULL;
262  }
263 
264  if (ptiPrev->TIF_flags & TIF_INCLEANUP) ptiPrev = NULL;
265  }
266  else
267  {
268  ptiPrev = pti;
269  pwndPrev = (PWND)-1; // Avoid zero Active window.
270  }
271 
272  if ( ptiPrev )
273  {
274  HANDLE OldTID = PsGetThreadId(ptiPrev->pEThread);
275  PWND cWindow;
276  HWND *List, *phWnd;
277 
279  if ( List )
280  {
281  if ( OldTID )
282  {
283  for (phWnd = List; *phWnd; ++phWnd)
284  {
285  cWindow = ValidateHwndNoErr(*phWnd);
286  if ( cWindow && cWindow->head.pti == ptiPrev )
287  { // FALSE if the window is being deactivated,
288  // ThreadId that owns the window being activated.
289  //ERR("IDW : WM_ACTIVATEAPP(0) hwnd %p tid Old %p New %p\n",UserHMGetHandle(cWindow),OldTID,tid);
290  UserRefObjectCo(cWindow, &Ref);
292  UserDerefObjectCo(cWindow);
293  }
294  }
295  }
297  }
298  }
299 
300  //
301  // Now check for a change (Bounce), if Active same as previous window, release it too.
302  //
303  if ( pti->MessageQueue->spwndActive == pwndPrev )
304  {
306  {
307  if (InAAPM) pti->TIF_flags &= ~TIF_INACTIVATEAPPMSG;
308  if (ptiCurrent != pti)
309  {
311  IntDereferenceThreadInfo(ptiCurrent);
312  }
313  return FALSE;
314  }
315 
316  if ( pti->MessageQueue->spwndActive == pwndPrev )
317  {
318  pti->MessageQueue->spwndActivePrev = pwndPrev;
319  pti->MessageQueue->spwndActive = NULL;
320  }
321  }
322 
323  //
324  // Check for Focus and release it.
325  //
326  if ( pti->MessageQueue->spwndFocus )
327  {
328  PWND pwndFocus = pti->MessageQueue->spwndFocus;
329 
330  //
331  // Fix win.c:test_SetForegroundWindow:SetActiveWindow(0)!
332  //
333  pti->MessageQueue->spwndFocus = NULL; // Null out Focus.
334 
335  UserRefObjectCo(pwndFocus, &Ref);
337  if (IS_IMM_MODE())
338  {
339  IntFocusSetInputContext(pwndFocus, FALSE, FALSE);
340  }
341  UserDerefObjectCo(pwndFocus);
342  }
343 
344  if (InAAPM) pti->TIF_flags &= ~TIF_INACTIVATEAPPMSG;
345  if (ptiCurrent != pti)
346  {
348  IntDereferenceThreadInfo(ptiCurrent);
349  }
350  return TRUE;
351 }
352 
353 //
354 // Activating another threads foreground window after a switch.
355 //
358 {
361 
362  if (Wnd)
363  {
364  Wnd = VerifyWnd(Wnd);
365 
366  if (!Wnd) return;
367 
368  UserRefObjectCo(Wnd, &Ref);
369 
370  if (!gpqForeground)
371  {
372  // No foreground queue set.
373  co_IntSetForegroundMessageQueue( Wnd, pti, (BOOL)Type, 0);
374  }
375  else
376  {
377  // Same Active and Wnd.
378  if ( pmq->spwndActive == Wnd )
379  {
380  WPARAM wParam = (Wnd->head.pti->MessageQueue == gpqForeground);
381 
383 
384  if (wParam)
385  {
386  UpdateShellHook(Wnd);
387 
389  }
390  }
391  else // Not the same, set the active Wnd.
392  {
394  }
395  }
396  UserDerefObjectCo(Wnd);
397  }
398  else // Handle no Wnd!
399  {
400  if ( tid && // TID,
401  pmq->spwndActive && // Active WND not zero,
402  gpqForeground == pmq ) // Same message queues.
403  {
404  Wnd = pmq->spwndActive; // Use active window from current queue.
405 
406  UserRefObjectCo(Wnd, &Ref);
407 
409 
410  UpdateShellHook(Wnd);
411 
413 
414  UserDerefObjectCo(Wnd);
415  }
416  else if (gpqForeground != pmq)
417  {
418  // Not the same message queue so clear flags for foreground switching.
420  pti->ppi->W32PF_flags &= ~W32PF_ALLOWFOREGROUNDACTIVATE;
421  }
422  }
423 }
424 
427 {
428  PWND spwndOwner;
429  if (VerifyWnd(Window))
430  { // Set last active for window and it's owner.
431  spwndOwner = Window;
432  while (spwndOwner->spwndOwner)
433  {
434  spwndOwner = spwndOwner->spwndOwner;
435  }
436  spwndOwner->spwndLastActive = Window;
437  return TRUE;
438  }
439  ERR("MakeWindowActive Failed!\n");
440  return FALSE;
441 }
442 
444 co_IntSendActivateMessages(PWND WindowPrev, PWND Window, BOOL MouseActivate, BOOL Async)
445 {
446  USER_REFERENCE_ENTRY Ref, RefPrev, RefCall;
447  HANDLE OldTID, NewTID;
448  PTHREADINFO pti, ptiOld, ptiNew;
449  BOOL InAAPM = FALSE;
450 
451  //ERR("SendActivateMessages\n");
452 
454 
455  if (Window)
456  {
457  UserRefObjectCo(Window, &Ref);
458 
459  if (WindowPrev) UserRefObjectCo(WindowPrev, &RefPrev);
460 
461  pti->MessageQueue->QF_flags &= ~QF_EVENTDEACTIVATEREMOVED;
462 
463  /* Send palette messages */
464  if (gpsi->PUSIFlags & PUSIF_PALETTEDISPLAY &&
465  //co_IntPostOrSendMessage(UserHMGetHandle(Window), WM_QUERYNEWPALETTE, 0, 0))
467  {
471  0);
472  }
474  if (!(Window->style & WS_CHILD))
475  {
477 
478  while (pwndTemp && !(pwndTemp->style & WS_VISIBLE)) pwndTemp = pwndTemp->spwndNext;
479 
480  if (Window != pwndTemp || (WindowPrev && !IntIsWindowVisible(WindowPrev)))
481  {
482  if (!Async || pti->MessageQueue == gpqForeground)
483  {
485  if (Window == pwndTemp) flags |= SWP_NOACTIVATE;
486  //ERR("co_IntSendActivateMessages SetWindowPos! Async %d pti Q == FGQ %d\n",Async,pti->MessageQueue == gpqForeground);
488  }
489  }
490  }
493  if (Window->spwndPrev)
494  {
495  HWND *phwndTopLevel, *phwndCurrent;
496  PWND pwndCurrent, pwndDesktop;
497 
498  pwndDesktop = co_GetDesktopWindow(Window);//UserGetDesktopWindow();
499  if (Window->spwndParent == pwndDesktop )
500  {
501  phwndTopLevel = IntWinListChildren(pwndDesktop);
502  phwndCurrent = phwndTopLevel;
503  while(*phwndCurrent)
504  {
505  pwndCurrent = UserGetWindowObject(*phwndCurrent);
506 
507  if (pwndCurrent && pwndCurrent->spwndOwner == Window )
508  {
510  }
511  phwndCurrent++;
512  }
513  ExFreePoolWithTag(phwndTopLevel, USERTAG_WINDOWLIST);
514  }
515  }
517  }
518 
519  OldTID = WindowPrev ? IntGetWndThreadId(WindowPrev) : NULL;
520  NewTID = Window ? IntGetWndThreadId(Window) : NULL;
521  ptiOld = WindowPrev ? WindowPrev->head.pti : NULL;
522  ptiNew = Window ? Window->head.pti : NULL;
523 
524  //ERR("SendActivateMessage Old -> %x, New -> %x\n", OldTID, NewTID);
525 
526  if (!(pti->TIF_flags & TIF_INACTIVATEAPPMSG) &&
527  (OldTID != NewTID) )
528  {
529  PWND cWindow;
530  HWND *List, *phWnd;
531 
533  if ( List )
534  {
535  if ( OldTID )
536  {
537  ptiOld->TIF_flags |= TIF_INACTIVATEAPPMSG;
538  // Note: Do not set pci flags, this does crash!
539  for (phWnd = List; *phWnd; ++phWnd)
540  {
541  cWindow = ValidateHwndNoErr(*phWnd);
542  if (cWindow && cWindow->head.pti == ptiOld)
543  { // FALSE if the window is being deactivated,
544  // ThreadId that owns the window being activated.
545  //ERR("SAM : WM_ACTIVATEAPP(0) tid Old %p New %p\n",OldTID,NewTID);
546  UserRefObjectCo(cWindow, &RefCall);
547  co_IntSendMessage(*phWnd, WM_ACTIVATEAPP, FALSE, (LPARAM)NewTID);
548  UserDerefObjectCo(cWindow);
549  }
550  }
551  ptiOld->TIF_flags &= ~TIF_INACTIVATEAPPMSG;
552  }
553  if ( NewTID )
554  {
555  InAAPM = TRUE;
558  for (phWnd = List; *phWnd; ++phWnd)
559  {
560  cWindow = ValidateHwndNoErr(*phWnd);
561  if (cWindow && cWindow->head.pti == ptiNew)
562  { // TRUE if the window is being activated,
563  // ThreadId that owns the window being deactivated.
564  //ERR("SAM : WM_ACTIVATEAPP(1) hwnd %p tid New %p Old %p\n",UserHMGetHandle(cWindow),NewTID,OldTID);
565  UserRefObjectCo(cWindow, &RefCall);
566  co_IntSendMessage(*phWnd, WM_ACTIVATEAPP, TRUE, (LPARAM)OldTID);
567  UserDerefObjectCo(cWindow);
568  }
569  }
570  }
572  }
573  }
574 
575  if (Window)
576  {
577  if (WindowPrev)
578  UserDerefObjectCo(WindowPrev); // Now allow the previous window to die.
579 
580  if (Window->state & WNDS_ACTIVEFRAME)
581  { // If already active frame do not allow NCPaint.
582  //ERR("SendActivateMessage Is Active Frame!\n");
583  Window->state |= WNDS_NONCPAINT;
584  }
585 
586  if (Window->style & WS_MINIMIZE)
587  {
588  TRACE("Widow was minimized\n");
589  }
590 
592 
596  0);
597 
599  WM_ACTIVATE,
600  MAKEWPARAM(MouseActivate ? WA_CLICKACTIVE : WA_ACTIVE, (Window->style & WS_MINIMIZE) != 0),
601  (LPARAM)(WindowPrev ? UserHMGetHandle(WindowPrev) : 0));
602 
603  if (Window->style & WS_VISIBLE)
605 
606  Window->state &= ~WNDS_NONCPAINT;
607 
609  }
610  return InAAPM;
611 }
612 
613 // Win: xxxSendFocusMessages
616 {
617  PWND pWndPrev;
618  PUSER_MESSAGE_QUEUE ThreadQueue = pti->MessageQueue; // Queue can change...
619  HWND hwndPrev;
621 
622  ThreadQueue->QF_flags &= ~QF_FOCUSNULLSINCEACTIVE;
623  if (!pWnd && ThreadQueue->spwndActive)
624  {
625  ThreadQueue->QF_flags |= QF_FOCUSNULLSINCEACTIVE;
626  }
627 
628  pWndPrev = ThreadQueue->spwndFocus;
629  if (pWndPrev)
630  UserRefObjectCo(pWndPrev, &Ref);
631 
632  /* check if the specified window can be set in the input data of a given queue */
633  if (!pWnd || ThreadQueue == pWnd->head.pti->MessageQueue)
634  /* set the current thread focus window */
635  ThreadQueue->spwndFocus = pWnd;
636 
637  if (pWnd)
638  {
639  if (pWndPrev)
640  {
642  if (IS_IMM_MODE())
643  {
644  IntFocusSetInputContext(pWndPrev, FALSE, FALSE);
645  }
646  }
647  if (ThreadQueue->spwndFocus == pWnd)
648  {
649  if (IS_IMM_MODE())
650  {
652  }
653 
654  IntNotifyWinEvent(EVENT_OBJECT_FOCUS, pWnd, OBJID_CLIENT, CHILDID_SELF, 0);
655 
656  hwndPrev = (pWndPrev ? UserHMGetHandle(pWndPrev) : NULL);
657  co_IntSendMessage(UserHMGetHandle(pWnd), WM_SETFOCUS, (WPARAM)hwndPrev, 0);
658  }
659  }
660  else
661  {
662  if (pWndPrev)
663  {
664  IntNotifyWinEvent(EVENT_OBJECT_FOCUS, NULL, OBJID_CLIENT, CHILDID_SELF, 0);
665 
667  if (IS_IMM_MODE())
668  {
669  IntFocusSetInputContext(pWndPrev, FALSE, FALSE);
670  }
671  }
672  }
673 
674  if (pWndPrev)
675  UserDerefObjectCo(pWndPrev);
676 }
677 
680 {
683  BOOL Ret = FALSE;
684 
686  while (Entry != &pti->PostedMessagesListHead)
687  {
688  // Scan posted queue messages to see if we received async messages.
690  Entry = Entry->Flink;
691 
692  if (Message->dwQEvent == EventLast)
693  {
694  //ERR("Event D/SAW: Last Activate/Deactivate %d\n", EventLast);
695  return Ret;
696  }
697 
698  if (Message->dwQEvent == Event)
699  {
700  //ERR("Event D/SAW: Found one in the Post Msg Queue! Activate/Deactivate %d\n", Event);
701  ClearMsgBitsMask(pti, Message->QS_Flags);
703  Ret = TRUE;
704  }
705  }
706  return Ret;
707 }
708 
711 {
712  BOOL Ret;
713  PPROCESSINFO ppi = pti->ppi;
714 
715  Ret = !!(pti->TIF_flags & TIF_ALLOWFOREGROUNDACTIVATE);
716  if (Ret)
717  {
719  }
720  else
721  Ret = !!(ppi->W32PF_flags & W32PF_ALLOWFOREGROUNDACTIVATE);
722 
723  if (Ret)
724  ppi->W32PF_flags &= ~W32PF_ALLOWFOREGROUNDACTIVATE;
725  //ERR("ToggleFGActivate is %d\n",Ret);
726  return Ret;
727 }
728 
731 {
732  // Not allowed if one or more,,
733  if (!ToggleFGActivate(pti) || // bits not set,
734  pti->rpdesk != gpdeskInputDesktop || // not current Desktop,
735  pti->MessageQueue == gpqForeground || // if already the queue foreground,
736  IsFGLocked() || // foreground is locked,
737  Wnd->ExStyle & WS_EX_NOACTIVATE ) // or,,, does not become the foreground window when the user clicks it.
738  {
739  return FALSE;
740  }
741  //ERR("IsAllowedFGActive is TRUE\n");
742  return TRUE;
743 }
744 
745 /*
746  Can the system force foreground from one or more conditions.
747  */
750 {
751  if (!ptiLastInput ||
752  ptiLastInput->ppi == ppi ||
753  !gptiForeground ||
754  gptiForeground->ppi == ppi ||
756  gppiInputProvider == ppi ||
758  ) return TRUE;
759  //ERR("CanForceFG is FALSE\n");
760  return FALSE;
761 }
762 
763 //
764 // Switching out foreground message queues.
765 //
768  _In_opt_ PWND Wnd,
769  _In_ PTHREADINFO pti,
770  _In_ BOOL MouseActivate,
771  _In_ DWORD Type )
772 {
773  PTHREADINFO ptiChg, ptiPrev;
774  PUSER_MESSAGE_QUEUE pumq, pumqChg, pumqPrev;
775  BOOL Removed, Ret = TRUE;
776 
777  if (Wnd && !VerifyWnd(Wnd))
778  {
779  return FALSE;
780  }
781 
783  ptiPrev = NULL;
784  else
785  ptiPrev = gptiForeground;
786 
787  if (Wnd)
788  {
789  ptiChg = Wnd->head.pti;
790  IntSetFocusMessageQueue(Wnd->head.pti->MessageQueue);
791  gptiForeground = Wnd->head.pti;
792  //ERR("Set Foreground pti 0x%p Q 0x%p hWnd 0x%p\n",Wnd->head.pti, Wnd->head.pti->MessageQueue,Wnd->head.h);
793  }
794  else
795  {
796  ptiChg = NULL;
799  //ERR("Set Foreground pti 0x0 Q 0x0 hWnd 0x0\n");
800  }
801 
802  //
803  // Process the changing out of the message queues.
804  //
806  {
807  pumqPrev = NULL;
808  if ( ptiPrev && !(ptiPrev->TIF_flags & TIF_INCLEANUP) )
809  {
810  pumqPrev = ptiPrev->MessageQueue;
811  }
812 
813  pumq = pti ? pti->MessageQueue : NULL;
814 
815  // Deactivate the previous message queue.
816  if (pumqPrev)
817  {
818  if ( pumq != pumqPrev )
819  {
820  MSG Msg;
821  HWND hWndPrev = pumqPrev->spwndActive ? UserHMGetHandle(pumqPrev->spwndActive) : NULL;
822  HANDLE tid = gptiForeground ? PsGetThreadId(gptiForeground->pEThread) : NULL; // TID from changing Window PTI.
823 
824  Msg.message = WM_ASYNC_SETACTIVEWINDOW;
825  Msg.hwnd = hWndPrev;
826  Msg.wParam = (WPARAM)pumqPrev->spwndActive;
827  Msg.lParam = 0;
828  Msg.time = 0;
829  //ERR("SFWAMQ : DAW P pti 0x%p tid 0x%p hWndPrev 0x%p\n",ptiPrev,tid,hWndPrev);
831  }
832  }
833 
834  pumqChg = NULL;
835  if ( ptiChg && !(ptiChg->TIF_flags & TIF_INCLEANUP) )
836  {
837  pumqChg = ptiChg->MessageQueue;
838  }
839 
840  pumq = pti ? pti->MessageQueue : NULL;
841 
842  // Activate changing message queue.
843  if (pumqChg)
844  {
845  /*
846  Henri Verbeet,
847  What happens is that we get the WM_WINE_SETACTIVEWINDOW message sent by the
848  other thread after we already changed the foreground window back to our own
849  window.
850  */
851  //ERR("SFWAMQ : 1\n");
853 
854  if (pumqChg != pumq)
855  {
856  MSG Msg;
857  HWND hWnd = Wnd ? UserHMGetHandle(Wnd) : NULL;
858  HANDLE tid = ptiPrev ? PsGetThreadId(ptiPrev->pEThread) : NULL;
859 
860  if (Removed) pumqChg->QF_flags |= QF_EVENTDEACTIVATEREMOVED;
861 
862  Msg.message = WM_ASYNC_SETACTIVEWINDOW;
863  Msg.hwnd = hWnd;
864  Msg.wParam = (WPARAM)Wnd;
865  Msg.lParam = (LPARAM)tid;
866  Msg.time = 0;
867  //ERR("SFWAMQ : SAW P pti 0x%p tid 0x%p hWnd 0x%p\n",ptiChg,tid,hWnd);
868  MsqPostMessage(ptiChg, &Msg, FALSE, QS_EVENT, POSTEVENT_SAW, (LONG_PTR)Type|MouseActivate);
869  }
870  else // Current message queue same as changed message queue.
871  {
872  if (pumq->spwndActive == Wnd)
873  {
875 
876  UpdateShellHook(Wnd);
877 
879  }
880  else
881  {
882  //ERR("SFWAMQ : SAW I pti 0x%p hWnd 0x%p\n",ptiChg,Wnd->head.h);
883  Ret = co_IntSetActiveWindow(Wnd, MouseActivate, TRUE/*Type*/, FALSE);
884  //if (!Ret) ERR("SFWAMQ : ISAW : return error\n");
885  return Ret;
886  }
887  }
888  }
889 
890  // Handle same message queue after switch out.
891  pumqPrev = NULL;
892  if ( ptiPrev && !(ptiPrev->TIF_flags & TIF_INCLEANUP) )
893  {
894  pumqPrev = ptiPrev->MessageQueue;
895  }
896  pumq = pti ? pti->MessageQueue : NULL;
897 
898  if ( pumqPrev && pumq == pumqPrev )
899  {
900  HANDLE tid = Wnd ? PsGetThreadId(Wnd->head.pti->pEThread) : NULL;
901  //ERR("SFWAMQ : DAW I pti 0x%p tid 0x%p hWnd 0x%p\n",ptiPrev,tid,Wnd ? Wnd->head.h : 0);
902  IntDeactivateWindow(pti, tid);
903  }
904  }
905  return Ret;
906 }
907 
908 /*
909  MSDN:
910  The system restricts which processes can set the foreground window. A process
911  can set the foreground window only if one of the following conditions is true:
912 
913  * The process is the foreground process.
914  * The process was started by the foreground process.
915  * The process received the last input event.
916  * There is no foreground process.
917  * The foreground process is being debugged.
918  * The foreground is not locked (see LockSetForegroundWindow).
919  * The foreground lock time-out has expired (see SPI_GETFOREGROUNDLOCKTIMEOUT in SystemParametersInfo).
920  * No menus are active.
921 */
922 static
925  _In_opt_ PWND Wnd,
926  _In_ BOOL MouseActivate,
927  _In_ BOOL bFlash )
928 {
929  HWND hWnd = Wnd ? UserHMGetHandle(Wnd) : NULL;
930  PUSER_MESSAGE_QUEUE PrevForegroundQueue;
931  PTHREADINFO pti;
932  BOOL Ret = FALSE;
933 
934  if (Wnd) ASSERT_REFS_CO(Wnd);
935 
936  TRACE("SetForegroundAndFocusWindow(%x, %s)\n", hWnd, (MouseActivate ? "TRUE" : "FALSE"));
937 
938  PrevForegroundQueue = IntGetFocusMessageQueue(); // Use this active desktop.
940 
941  if (Wnd && PrevForegroundQueue)
942  { // Same Window Q as foreground just do active.
943  if (Wnd->head.pti->MessageQueue == PrevForegroundQueue)
944  {
945  //ERR("Same Window Q as foreground just do active.\n");
946  if (pti->MessageQueue == PrevForegroundQueue)
947  { // Same WQ and TQ go active.
948  //ERR("Same WQ and TQ go active.\n");
949  Ret = IntUserSetActiveWindow(Wnd, MouseActivate, TRUE, FALSE);
950  }
951  else if (Wnd->head.pti->MessageQueue->spwndActive == Wnd)
952  { // Same WQ and it is active.
953  //ERR("Same WQ and it is active.\n");
954  Ret = TRUE;
955  }
956  else
957  { // Same WQ as FG but not the same TQ send active.
958  //ERR("Same WQ as FG but not the same TQ send active.\n");
959  MSG Msg;
960  PTHREADINFO ptiNew = Wnd->head.pti;
961 
962  Msg.message = WM_ASYNC_SETACTIVEWINDOW;
963  Msg.hwnd = hWnd;
964  Msg.wParam = (WPARAM)Wnd;
965  Msg.lParam = 0;
966  Msg.time = 0;
967  //ERR("SFAFW 1 : SAW P pti 0x%p hWnd 0x%p\n",ptiNew,hWnd);
968  MsqPostMessage(ptiNew, &Msg, FALSE, QS_EVENT, POSTEVENT_SAW, (LONG_PTR)MouseActivate);
969 
970  Ret = TRUE;
971  }
972  return Ret;
973  }
974  }
975 
976  if ( (( !IsFGLocked() || pti->ppi == gppiInputProvider ) &&
978  pti->ppi == ppiScrnSaver
979  )
980  {
981 
982  ToggleFGActivate(pti);
983 
984  return co_IntSetForegroundMessageQueue( Wnd, pti, MouseActivate, 0 );
985  }
986 
987  if (!Wnd) return FALSE; // No window, always return FALSE.
988 
990 
991  if (pti->MessageQueue == Wnd->head.pti->MessageQueue)
992  {
993  //ERR("Same PQ and WQ go active.\n");
994  Ret = IntUserSetActiveWindow(Wnd, MouseActivate, TRUE, FALSE);
995  //if (!Ret) ERR("ISFAFW : IUSAW : return error\n");
996  }
997  else if (Wnd->head.pti->MessageQueue->spwndActive == Wnd)
998  {
999  TRACE("Same Active and Wnd.\n"); // Leave this for now.
1000  }
1001  else
1002  {
1003  //ERR("Activate Not same PQ and WQ and Wnd.\n");
1005  MSG Msg;
1006  PTHREADINFO ptiNew = Wnd->head.pti;
1007 
1008  Msg.message = WM_ASYNC_SETACTIVEWINDOW;
1009  Msg.hwnd = hWnd;
1010  Msg.wParam = (WPARAM)Wnd;
1011  Msg.lParam = 0;
1012  Msg.time = 0;
1013  //ERR("SFAFW 2 : SAW P pti 0x%p hWnd 0x%p\n",ptiNew,hWnd);
1014  MsqPostMessage(ptiNew, &Msg, FALSE, QS_EVENT, POSTEVENT_SAW, (LONG_PTR)MouseActivate);
1015  }
1016  // Always return FALSE.
1017  return FALSE;
1018 }
1019 
1020 //
1021 // Set the Active Window.
1022 //
1023 BOOL FASTCALL
1025  _In_ PWND Wnd,
1026  _In_ BOOL bMouse,
1027  _In_ BOOL bFocus,
1028  _In_ BOOL Async )
1029 {
1030  PTHREADINFO pti;
1031  PUSER_MESSAGE_QUEUE ThreadQueue;
1032  PWND pWndChg, WndPrev; // State changes.
1033  HWND hWndPrev;
1034  HWND hWnd = 0;
1035  BOOL InAAPM;
1036  CBTACTIVATESTRUCT cbt;
1037 
1038  //ERR("co_IntSetActiveWindow 1\n");
1039 
1041  ThreadQueue = pti->MessageQueue;
1042  ASSERT(ThreadQueue != 0);
1043 
1044  hWndPrev = ThreadQueue->spwndActive ? UserHMGetHandle(ThreadQueue->spwndActive) : NULL;
1045 
1046  pWndChg = ThreadQueue->spwndActive; // Keep to notify of a preemptive switch.
1047 
1048  if ( !Wnd || Wnd == UserGetDesktopWindow() )
1049  {
1050  //ERR("ISAW : NULL %p\n",Wnd);
1051  return FALSE;
1052  }
1053 
1054  ASSERT_REFS_CO(Wnd);
1055  hWnd = UserHMGetHandle(Wnd);
1056  //ERR("co_IntSetActiveWindow 2 hWnd 0x%p\n",hWnd);
1057 
1058  /* check if the specified window can be set in the input data of a given queue */
1059  if ( ThreadQueue != Wnd->head.pti->MessageQueue )
1060  {
1061  //ERR("ISAW : Must have the same Message Queue\n");
1062  return FALSE;
1063  }
1064 
1065  if (!VerifyWnd(Wnd))
1066  {
1067  //ERR("ISAW : Window is in Destroy!\n");
1068  return FALSE;
1069  }
1070 
1071  if ( Wnd == pWndChg )
1072  {
1073  //ERR("ISAW : Nothing to do\n");
1074  return TRUE; // Fix CORE-8780 and CORE-11979. See CORE-11324 for breakage.
1075  }
1076 
1077  if ( Wnd->state & WNDS_BEINGACTIVATED ) return TRUE;
1078 
1079  /* Call CBT hook chain */
1080  cbt.fMouse = bMouse;
1081  cbt.hWndActive = hWndPrev;
1083  {
1084  ERR("SetActiveWindow: WH_CBT Call Hook return!\n");
1085  return FALSE;
1086  }
1087 
1088  ThreadQueue->QF_flags &= ~QF_EVENTDEACTIVATEREMOVED;
1089 
1090  if ( ThreadQueue->spwndActive && ThreadQueue->spwndActive->state & WNDS_DESTROYED )
1091  ThreadQueue->spwndActive = NULL;
1092  else
1093  ThreadQueue->spwndActivePrev = ThreadQueue->spwndActive;
1094 
1095  WndPrev = ThreadQueue->spwndActive; // Keep to save changing active.
1096 
1097  if (WndPrev)
1098  {
1099  if (ThreadQueue == gpqForeground) gpqForegroundPrev = ThreadQueue;
1100  if (!co_IntSendDeactivateMessages(UserHMGetHandle(WndPrev), hWnd, TRUE)) return FALSE;
1101  }
1102 
1103  WndPrev = ThreadQueue->spwndActive; // Again keep to save changing active.
1104 
1105  // While in calling message proc or hook:
1106  // Fail if a preemptive switch was made, current active not made previous,
1107  // focus window is dead or no longer the same thread queue.
1108  if ( ThreadQueue->spwndActivePrev != ThreadQueue->spwndActive ||
1109  pWndChg != WndPrev ||
1110  (Wnd && !VerifyWnd(Wnd)) ||
1111  ThreadQueue != pti->MessageQueue )
1112  {
1113  ERR("SetActiveWindow: Summary ERROR, active state changed!\n");
1114  return FALSE;
1115  }
1116 
1117  if (!WndPrev) ThreadQueue->QF_flags &= ~QF_FOCUSNULLSINCEACTIVE;
1118 
1119  /* set the current thread active window */
1120  ThreadQueue->spwndActive = Wnd;
1121 
1122  // Set state flag to prevent recursions.
1123  Wnd->state |= WNDS_BEINGACTIVATED;
1124 
1125  IntNotifyWinEvent(EVENT_SYSTEM_FOREGROUND, Wnd, OBJID_WINDOW, CHILDID_SELF, WEF_SETBYWNDPTI);
1126 
1127  // Clear out activate EVENT messages.
1129 
1130  WndPrev = VerifyWnd(ThreadQueue->spwndActivePrev); // Now should be set but verify it again.
1131 
1132  InAAPM = co_IntSendActivateMessages(WndPrev, Wnd, bMouse, Async);
1133 
1134  /* now change focus if necessary */
1136  if (bFocus && !(ThreadQueue->QF_flags & QF_FOCUSNULLSINCEACTIVE))
1137  {
1138  /* Do not change focus if the window is no longer active */
1139  if (pti->MessageQueue->spwndActive != IntGetNonChildAncestor(pti->MessageQueue->spwndFocus))
1140  {
1141  PWND pWndSend = pti->MessageQueue->spwndActive;
1142  // Clear focus if the active window is minimized.
1143  if (pWndSend && pti->MessageQueue->spwndActive->style & WS_MINIMIZE) pWndSend = NULL;
1144  // Send focus messages and if so, set the focus.
1145  IntSendFocusMessages( pti, pWndSend);
1146  }
1147  }
1149  if (InAAPM)
1150  {
1152  }
1153 
1154  // Checked in MENU_TrackMenu
1155  ThreadQueue->QF_flags |= QF_ACTIVATIONCHANGE;
1156 
1157  //ERR("co_IntSetActiveWindow Exit\n");
1158  Wnd->state &= ~WNDS_BEINGACTIVATED;
1159  return (ThreadQueue->spwndActive == Wnd);
1160 }
1161 
1162 //
1163 // Set the Active Window.
1164 //
1165 // Window is not optional!
1166 //
1167 BOOL FASTCALL
1169  _In_ PWND Wnd,
1170  _In_ BOOL bMouse,
1171  _In_ BOOL bFocus,
1172  _In_ BOOL Async)
1173 {
1174  PTHREADINFO pti;
1175  PUSER_MESSAGE_QUEUE ThreadQueue;
1176 
1177  //ERR("IntUserSetActiveWindow 1\n");
1178  ASSERT_REFS_CO(Wnd);
1179  if ((Wnd->style & (WS_POPUP|WS_CHILD)) == WS_CHILD) return FALSE;
1180  //ERR("IntUserSetActiveWindow 1a hWnd 0x%p\n",UserHMGetHandle(Wnd));
1181 
1182  //ERR("IntUserSetActiveWindow 2\n");
1184  ThreadQueue = pti->MessageQueue;
1185  ASSERT(ThreadQueue != 0);
1186 
1187  while (Wnd)
1188  {
1189  BOOL Ret, DoFG, AllowFG;
1190 
1191  if (ThreadQueue == Wnd->head.pti->MessageQueue)
1192  {
1193  if (IsAllowedFGActive(pti, Wnd))
1194  {
1195  DoFG = TRUE;
1196  }
1197  else
1198  {
1199  //ERR("IntUserSetActiveWindow 3 Go Out!\n");
1200  break;
1201  }
1202  AllowFG = !pti->cVisWindows; // Nothing is visable.
1203  //ERR("IntUserSetActiveWindow 3a DoFG = %d AllowFG = %d\n",DoFG,AllowFG);
1204  }
1205  else //if (ThreadQueue != Wnd->head.pti->MessageQueue)
1206  {
1207  //PUSER_MESSAGE_QUEUE ForegroundQueue = IntGetFocusMessageQueue();
1208  // Rule 1 & 4, We are foreground so set this FG window or NULL foreground....
1209  if (!gpqForeground || gpqForeground == ThreadQueue)
1210  {
1211  DoFG = TRUE;
1212  }
1213  else
1214  DoFG = FALSE;
1215  if (DoFG)
1216  {
1218  AllowFG = TRUE;
1219  else
1220  AllowFG = FALSE;
1221  }
1222  else
1223  AllowFG = FALSE;
1224  //ERR("IntUserSetActiveWindow 3b DoFG = %d AllowFG = %d\n",DoFG,AllowFG);
1225  }
1226  Ret = FALSE;
1227  if (DoFG)
1228  {
1230  //ERR("IntUserSetActiveWindow 3c FG set\n");
1231  Ret = co_IntSetForegroundAndFocusWindow(Wnd, bMouse, TRUE);
1232  if (AllowFG)
1233  {
1235  }
1236  else
1237  {
1239  }
1240  }
1241  return Ret;
1242  }
1243 
1244  return co_IntSetActiveWindow(Wnd, bMouse, bFocus, Async);
1245 }
1246 
1247 BOOL FASTCALL
1249 {
1250  TRACE("Mouse Active\n");
1252 }
1253 
1254 BOOL FASTCALL
1256 {
1258 
1259  if (Wnd)
1260  {
1261  if ((Wnd->style & (WS_POPUP|WS_CHILD)) == WS_CHILD) return FALSE;
1262 
1263  return IntUserSetActiveWindow(Wnd, FALSE, TRUE, FALSE);
1264  }
1265  /*
1266  Yes your eye are not deceiving you~!
1267 
1268  First part of wines Win.c test_SetActiveWindow:
1269 
1270  flush_events( TRUE );
1271  ShowWindow(hwnd, SW_HIDE);
1272  SetFocus(0);
1273  SetActiveWindow(0);
1274  check_wnd_state(0, 0, 0, 0); <-- This should pass if ShowWindow does it's job!!! As of 10/28/2012 it does!
1275 
1276  Now Handle wines Msg.c test_SetActiveWindow( 0 )...
1277  */
1278  TRACE("USAW: Previous active window\n");
1279  if ( gpqForegroundPrev &&
1284  {
1285  TRACE("USAW:PAW hwnd %p\n",Wnd?Wnd->head.h:NULL);
1286  return IntUserSetActiveWindow(Wnd, FALSE, TRUE, FALSE);
1287  }
1288 
1289  // Activate anyone but the active window.
1290  if ( pti->MessageQueue->spwndActive &&
1291  (Wnd = VerifyWnd(pti->MessageQueue->spwndActive)) != NULL )
1292  {
1293  //ERR("USAW:AOWM hwnd %p\n",Wnd?Wnd->head.h:NULL);
1294  if (!ActivateOtherWindowMin(Wnd))
1295  {
1296  // Okay, now go find someone else to play with!
1297  //ERR("USAW: Going to WPAOW\n");
1299  }
1300  return TRUE;
1301  }
1302 
1303  TRACE("USAW: Nothing\n");
1304  return FALSE;
1305 }
1306 
1307 // Win: PWND xxxSetFocus(Window)
1308 HWND FASTCALL
1310 {
1311  HWND hWndPrev = 0;
1312  PWND pwndTop;
1313  PTHREADINFO pti;
1314  PUSER_MESSAGE_QUEUE ThreadQueue;
1315 
1316  if (Window)
1318 
1320  ThreadQueue = pti->MessageQueue;
1321  ASSERT(ThreadQueue != 0);
1322 
1323  TRACE("Enter SetFocus hWnd 0x%p pti 0x%p\n",Window ? UserHMGetHandle(Window) : 0, pti );
1324 
1325  hWndPrev = ThreadQueue->spwndFocus ? UserHMGetHandle(ThreadQueue->spwndFocus) : 0;
1326 
1327  if (Window != 0)
1328  {
1329  if (hWndPrev == UserHMGetHandle(Window))
1330  {
1331  return hWndPrev ? (IntIsWindow(hWndPrev) ? hWndPrev : 0) : 0; /* Nothing to do */
1332  }
1333 
1334  if (Window->head.pti->MessageQueue != ThreadQueue)
1335  {
1336  ERR("SetFocus Must have the same Q!\n");
1337  return 0;
1338  }
1339 
1340  /* Check if we can set the focus to this window */
1342  for (pwndTop = Window; pwndTop; pwndTop = pwndTop->spwndParent)
1343  {
1344  if (pwndTop->style & (WS_MINIMIZED|WS_DISABLED)) return 0;
1345  if ((pwndTop->style & (WS_POPUP|WS_CHILD)) != WS_CHILD) break;
1346  if (pwndTop->spwndParent == NULL) break;
1347  }
1349  if (co_HOOK_CallHooks( WH_CBT, HCBT_SETFOCUS, (WPARAM)Window->head.h, (LPARAM)hWndPrev))
1350  {
1351  ERR("SetFocus 1 WH_CBT Call Hook return!\n");
1352  return 0;
1353  }
1354 
1355  /* Activate pwndTop if needed. */
1356  if (pwndTop != ThreadQueue->spwndActive)
1357  {
1358  PUSER_MESSAGE_QUEUE ForegroundQueue = IntGetFocusMessageQueue(); // Keep it based on desktop.
1359  if (ThreadQueue != ForegroundQueue && IsAllowedFGActive(pti, pwndTop)) // Rule 2 & 3.
1360  {
1361  //ERR("SetFocus: Set Foreground!\n");
1362  if (!(pwndTop->style & WS_VISIBLE))
1363  {
1364  pti->ppi->W32PF_flags |= W32PF_ALLOWFOREGROUNDACTIVATE;
1365  }
1367  {
1368  ERR("SetFocus: Set Foreground and Focus Failed!\n");
1369  return 0;
1370  }
1371  }
1372 
1373  /* Set Active when it is needed. */
1374  if (pwndTop != ThreadQueue->spwndActive)
1375  {
1376  //ERR("SetFocus: Set Active! %p\n",pwndTop?UserHMGetHandle(pwndTop):0);
1377  if (!co_IntSetActiveWindow(pwndTop, FALSE, FALSE, FALSE))
1378  {
1379  ERR("SetFocus: Set Active Failed!\n");
1380  return 0;
1381  }
1382  }
1383 
1384  /* Abort if window destroyed */
1385  if (Window->state2 & WNDS2_INDESTROY) return 0;
1386  /* Do not change focus if the window is no longer active */
1387  if (pwndTop != ThreadQueue->spwndActive)
1388  {
1389  ERR("SetFocus: Top window did not go active!\n");
1390  return 0;
1391  }
1392  }
1393 
1394  // Check again! SetActiveWindow could have set the focus via WM_ACTIVATE.
1395  hWndPrev = ThreadQueue->spwndFocus ? UserHMGetHandle(ThreadQueue->spwndFocus) : 0;
1396 
1398 
1399  TRACE("Focus: %p -> %p\n", hWndPrev, Window->head.h);
1400  }
1401  else /* NULL hwnd passed in */
1402  {
1403  if (co_HOOK_CallHooks( WH_CBT, HCBT_SETFOCUS, (WPARAM)0, (LPARAM)hWndPrev))
1404  {
1405  ERR("SetFocus: 2 WH_CBT Call Hook return!\n");
1406  return 0;
1407  }
1408  //ERR("SetFocus: Set Focus NULL\n");
1409  /* set the current thread focus window null */
1410  IntSendFocusMessages( pti, NULL);
1411  }
1412  return hWndPrev ? (IntIsWindow(hWndPrev) ? hWndPrev : 0) : 0;
1413 }
1414 
1415 HWND FASTCALL
1417 {
1418  PUSER_MESSAGE_QUEUE ForegroundQueue;
1419 
1420  ForegroundQueue = IntGetFocusMessageQueue();
1421  return( ForegroundQueue ? (ForegroundQueue->spwndActive ? UserHMGetHandle(ForegroundQueue->spwndActive) : 0) : 0);
1422 }
1423 
1425 {
1426  PTHREADINFO pti;
1427  PUSER_MESSAGE_QUEUE ThreadQueue;
1428 
1430  ThreadQueue = pti->MessageQueue;
1431  return( ThreadQueue ? (ThreadQueue->spwndActive ? UserHMGetHandle(ThreadQueue->spwndActive) : 0) : 0);
1432 }
1433 
1434 HWND APIENTRY
1436 {
1437  PTHREADINFO pti;
1438  PUSER_MESSAGE_QUEUE ThreadQueue;
1440 
1441  TRACE("Enter IntGetCapture\n");
1442 
1444  ThreadQueue = pti->MessageQueue;
1445  RETURN( ThreadQueue ? (ThreadQueue->spwndCapture ? UserHMGetHandle(ThreadQueue->spwndCapture) : 0) : 0);
1446 
1447 CLEANUP:
1448  TRACE("Leave IntGetCapture, ret=%p\n", _ret_);
1449  END_CLEANUP;
1450 }
1451 
1452 HWND FASTCALL
1454 {
1455  PTHREADINFO pti;
1456  PUSER_MESSAGE_QUEUE ThreadQueue;
1457  PWND pWnd, Window = NULL;
1458  HWND hWndPrev;
1459 
1461  ThreadQueue = pti->MessageQueue;
1462 
1463  if (ThreadQueue->QF_flags & QF_CAPTURELOCKED)
1464  return NULL;
1465 
1466  if (hWnd && (Window = UserGetWindowObject(hWnd)))
1467  {
1468  if (Window->head.pti->MessageQueue != ThreadQueue)
1469  {
1470  ERR("Window Thread does not match Current!\n");
1471  return NULL;
1472  }
1473  }
1474 
1475  hWndPrev = MsqSetStateWindow(pti, MSQ_STATE_CAPTURE, hWnd);
1476 
1477  if (hWndPrev)
1478  {
1479  pWnd = UserGetWindowObject(hWndPrev);
1480  if (pWnd)
1481  IntNotifyWinEvent(EVENT_SYSTEM_CAPTUREEND, pWnd, OBJID_WINDOW, CHILDID_SELF, WEF_SETBYWNDPTI);
1482  }
1483 
1484  if (Window)
1485  IntNotifyWinEvent(EVENT_SYSTEM_CAPTURESTART, Window, OBJID_WINDOW, CHILDID_SELF, WEF_SETBYWNDPTI);
1486 
1487  //
1488  // Only send the message if we have a previous Window!
1489  // Fix msg_menu tracking popup menu and win test_capture_4!!!!
1490  //
1491  if (hWndPrev)
1492  {
1493  if (ThreadQueue->MenuOwner && Window) ThreadQueue->QF_flags |= QF_CAPTURELOCKED;
1494 
1496 
1497  ThreadQueue->QF_flags &= ~QF_CAPTURELOCKED;
1498  }
1499 
1500  if (hWnd == NULL) // Release mode.
1501  {
1502  MOUSEINPUT mi;
1504  /* Also remove other windows if not capturing anymore */
1508  /* Somebody may have missed some mouse movements */
1509  mi.dx = 0;
1510  mi.dy = 0;
1511  mi.mouseData = 0;
1513  mi.time = 0;
1514  mi.dwExtraInfo = 0;
1516  }
1517  return hWndPrev;
1518 }
1519 
1520 /*
1521  API Call
1522 */
1523 BOOL
1524 FASTCALL
1526 {
1527  PTHREADINFO pti;
1528  PUSER_MESSAGE_QUEUE ThreadQueue;
1529 
1531  ThreadQueue = pti->MessageQueue;
1532 
1533  // Can not release inside WM_CAPTURECHANGED!!
1534  if (ThreadQueue->QF_flags & QF_CAPTURELOCKED) return FALSE;
1535 
1537 
1538  return TRUE;
1539 }
1540 
1541 /*
1542  API Call
1543 */
1544 BOOL FASTCALL
1546 {
1548 
1550 }
1551 
1552 /*
1553  API Call
1554 */
1555 BOOL FASTCALL
1557 {
1559 
1561 }
1562 
1563 /*
1564  API Call
1565 */
1566 BOOL FASTCALL
1568 {
1569  ULONG Err = ERROR_ACCESS_DENIED;
1571  switch (uLockCode)
1572  {
1573  case LSFW_LOCK:
1574  if ( CanForceFG(ppi) && !gppiLockSFW )
1575  {
1576  gppiLockSFW = ppi;
1577  return TRUE;
1578  }
1579  break;
1580  case LSFW_UNLOCK:
1581  if ( gppiLockSFW == ppi)
1582  {
1583  gppiLockSFW = NULL;
1584  return TRUE;
1585  }
1586  break;
1587  default:
1589  }
1590  EngSetLastError(Err);
1591  return FALSE;
1592 }
1593 
1594 /*
1595  API Call
1596 */
1597 BOOL FASTCALL
1599 {
1600  PPROCESSINFO ppi, ppiCur;
1602 
1603  ppi = NULL;
1604  if (dwProcessId != ASFW_ANY)
1605  {
1607  {
1609  return FALSE;
1610  }
1612  if (!ppi)
1613  {
1615  return FALSE;
1616  }
1617  }
1619  if (!CanForceFG(ppiCur))
1620  {
1623  return FALSE;
1624  }
1625  if (dwProcessId == ASFW_ANY)
1626  { // All processes will be enabled to set the foreground window.
1627  //ERR("ptiLastInput is CLEARED!!\n");
1628  ptiLastInput = NULL;
1629  }
1630  else
1631  { // Rule #3, last input event in force.
1632  ERR("ptiLastInput is SET!!\n");
1633  //ptiLastInput = ppi->ptiList; // See CORE-6384 & CORE-7030.
1635  }
1636  return TRUE;
1637 }
1638 
1639 /*
1640  * @implemented
1641  */
1642 HWND APIENTRY
1644 {
1646 
1647  TRACE("Enter NtUserGetForegroundWindow\n");
1649 
1651 
1652 CLEANUP:
1653  TRACE("Leave NtUserGetForegroundWindow, ret=%p\n",_ret_);
1654  UserLeave();
1655  END_CLEANUP;
1656 }
1657 
1658 HWND APIENTRY
1660 {
1662  HWND hWndPrev;
1663  PWND Window;
1665 
1666  TRACE("Enter NtUserSetActiveWindow(%p)\n", hWnd);
1668 
1669  Window = NULL;
1670  if (hWnd)
1671  {
1672  if (!(Window = UserGetWindowObject(hWnd)))
1673  {
1674  ERR("NtUserSetActiveWindow: Invalid handle 0x%p!\n",hWnd);
1675  RETURN( NULL);
1676  }
1677  }
1678 
1679  if (!Window ||
1680  Window->head.pti->MessageQueue == gptiCurrent->MessageQueue)
1681  {
1682  hWndPrev = gptiCurrent->MessageQueue->spwndActive ? UserHMGetHandle(gptiCurrent->MessageQueue->spwndActive) : NULL;
1683  if (Window) UserRefObjectCo(Window, &Ref);
1686  RETURN( hWndPrev ? (IntIsWindow(hWndPrev) ? hWndPrev : 0) : 0 );
1687  }
1688  RETURN( NULL);
1689 
1690 CLEANUP:
1691  TRACE("Leave NtUserSetActiveWindow, ret=%p\n",_ret_);
1692  UserLeave();
1693  END_CLEANUP;
1694 }
1695 
1696 /*
1697  * @implemented
1698  */
1699 HWND APIENTRY
1701 {
1703 
1704  TRACE("Enter NtUserSetCapture(%p)\n", hWnd);
1706 
1708 
1709 CLEANUP:
1710  TRACE("Leave NtUserSetCapture, ret=%p\n", _ret_);
1711  UserLeave();
1712  END_CLEANUP;
1713 }
1714 
1715 /*
1716  * @implemented
1717  */
1718 HWND APIENTRY
1720 {
1721  PWND Window;
1724  HWND ret;
1725 
1726  TRACE("Enter NtUserSetFocus(%p)\n", hWnd);
1728 
1729  if (hWnd)
1730  {
1731  if (!(Window = UserGetWindowObject(hWnd)))
1732  {
1733  ERR("NtUserSetFocus: Invalid handle 0x%p!\n",hWnd);
1734  RETURN(NULL);
1735  }
1736 
1737  UserRefObjectCo(Window, &Ref);
1740 
1741  RETURN(ret);
1742  }
1743  else
1744  {
1745  RETURN( co_UserSetFocus(0));
1746  }
1747 
1748 CLEANUP:
1749  TRACE("Leave NtUserSetFocus, ret=%p\n",_ret_);
1750  UserLeave();
1751  END_CLEANUP;
1752 }
1753 
1754 /* EOF */
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
PUSER_MESSAGE_QUEUE gpqForeground
Definition: focus.c:13
#define WS_DISABLED
Definition: pedump.c:621
#define MSQ_STATE_MOVESIZE
Definition: ntuser.h:3670
PTHREADINFO gptiForeground
Definition: focus.c:15
DWORD ExStyle
Definition: ntuser.h:683
PPROCESSINFO ppiScrnSaver
Definition: main.c:30
VOID FASTCALL co_MsqInsertMouseMessage(MSG *Msg, DWORD flags, ULONG_PTR dwExtraInfo, BOOL Hook)
Definition: msgqueue.c:580
#define MAKEWPARAM(l, h)
Definition: winuser.h:3989
HWND FASTCALL IntGetThreadFocusWindow(VOID)
Definition: focus.c:41
#define CLEANUP
Definition: ntuser.h:5
BOOL FASTCALL co_IntSetActiveWindow(_In_ PWND Wnd, _In_ BOOL bMouse, _In_ BOOL bFocus, _In_ BOOL Async)
Definition: focus.c:1024
BOOL NTAPI UserSendMouseInput(MOUSEINPUT *pMouseInput, BOOL bInjected)
Definition: mouse.c:168
#define _In_opt_
Definition: ms_sal.h:309
VOID IntFocusSetInputContext(PWND pWnd, BOOL bActivate, BOOL bCallback)
Definition: focus.c:150
struct _Entry Entry
Definition: kefuncs.h:629
HWND FASTCALL co_UserSetFocus(PWND Window)
Definition: focus.c:1309
BOOL FASTCALL FindRemoveEventMsg(PTHREADINFO pti, DWORD Event, DWORD EventLast)
Definition: focus.c:679
#define QF_FOCUSNULLSINCEACTIVE
Definition: msgqueue.h:105
#define QF_EVENTDEACTIVATEREMOVED
Definition: msgqueue.h:107
#define WNDS2_BOTTOMMOST
Definition: ntuser.h:629
BOOL FASTCALL IntReleaseCapture(VOID)
Definition: focus.c:1525
VOID FASTCALL IntSendFocusMessages(PTHREADINFO pti, PWND pWnd)
Definition: focus.c:615
BOOL FASTCALL IntUserSetActiveWindow(_In_ PWND Wnd, _In_ BOOL bMouse, _In_ BOOL bFocus, _In_ BOOL Async)
Definition: focus.c:1168
PDESKTOP gpdeskInputDesktop
Definition: desktop.c:35
#define TRUE
Definition: types.h:120
HWND FASTCALL UserGetActiveWindow(VOID)
Definition: focus.c:1424
#define IMS_IMEACTIVATE
Definition: immdev.h:28
#define POSTEVENT_NONE
Definition: msgqueue.h:126
#define ASSERT_REFS_CO(_obj_)
Definition: userfuncs.h:14
BOOL FASTCALL IsFGLocked(VOID)
Definition: focus.c:25
PVOID NTAPI PsGetProcessWin32Process(PEPROCESS Process)
Definition: process.c:1193
FLONG TIF_flags
Definition: win32.h:96
TW_UINT32 TW_UINT16 TW_UINT16 MSG
Definition: twain.h:1827
VOID FASTCALL IntNotifyWinEvent(DWORD Event, PWND pWnd, LONG idObject, LONG idChild, DWORD flags)
Definition: event.c:179
#define MAKELPARAM(l, h)
Definition: winuser.h:3988
PVOID NTAPI PsGetCurrentThreadWin32Thread(VOID)
Definition: thread.c:805
BOOLEAN FASTCALL co_WinPosSetWindowPos(PWND Window, HWND WndInsertAfter, INT x, INT y, INT cx, INT cy, UINT flags)
Definition: winpos.c:1721
struct @1591 Msg[]
#define WM_CAPTURECHANGED
Definition: winuser.h:1795
BOOL FASTCALL UserSendNotifyMessage(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
Definition: message.c:2037
PSERVERINFO gpsi
Definition: imm.c:17
#define OBJID_WINDOW
Definition: winable.h:15
HWND hWnd
Definition: settings.c:17
static __inline VOID UserRefObjectCo(PVOID obj, PUSER_REFERENCE_ENTRY UserReferenceEntry)
Definition: object.h:27
BOOL FASTCALL UserSetActiveWindow(_In_opt_ PWND Wnd)
Definition: focus.c:1255
HWND ghwndOldFullscreen
Definition: focus.c:19
#define HWND_TOP
Definition: winuser.h:1197
BOOL FASTCALL IntIsWindowFullscreen(PWND Window)
Definition: focus.c:53
static MONITORINFO mi
Definition: win.c:7338
DBG_DEFAULT_CHANNEL(UserFocus)
UINT_PTR WPARAM
Definition: windef.h:207
#define WS_CHILD
Definition: pedump.c:617
#define HCBT_SETFOCUS
Definition: winuser.h:64
HWND APIENTRY NtUserSetActiveWindow(HWND hWnd)
Definition: focus.c:1659
HWND FASTCALL IntGetCaptureWindow(VOID)
Definition: focus.c:34
VOID FASTCALL co_WinPosActivateOtherWindow(PWND Wnd)
Definition: winpos.c:395
#define FASTCALL
Definition: nt_native.h:50
#define TIF_SYSTEMTHREAD
Definition: ntuser.h:256
#define WS_EX_TOOLWINDOW
Definition: winuser.h:404
PUSER_MESSAGE_QUEUE FASTCALL IntGetFocusMessageQueue(VOID)
Definition: desktop.c:1310
struct _DESKTOP * rpdesk
Definition: win32.h:93
#define W32PF_SETFOREGROUNDALLOWED
Definition: win32.h:20
WPARAM wParam
Definition: combotst.c:138
WORD FASTCALL UserGetMouseButtonsState(VOID)
Definition: mouse.c:22
PPROCESSINFO gppiLockSFW
Definition: focus.c:16
#define RETURN(x)
#define WNDS_BEINGACTIVATED
Definition: ntuser.h:608
PPROCESSINFO ppi
Definition: win32.h:89
VOID FASTCALL MsqDestroyMessage(PUSER_MESSAGE Message)
Definition: msgqueue.c:748
#define SM_CXSCREEN
Definition: winuser.h:953
Definition: window.c:28
#define W32PF_ALLOWFOREGROUNDACTIVATE
Definition: win32.h:12
#define IMS_IMEDEACTIVATE
Definition: immdev.h:29
#define FALSE
Definition: types.h:117
#define WM_NCACTIVATE
Definition: winuser.h:1675
#define TIF_CSRSSTHREAD
Definition: ntuser.h:257
#define ERROR_ACCESS_DENIED
Definition: compat.h:97
#define WS_MINIMIZE
Definition: pedump.c:622
unsigned int BOOL
Definition: ntddk_ex.h:94
static __inline VOID UserDerefObjectCo(PVOID obj)
Definition: object.h:40
#define QF_CAPTURELOCKED
Definition: msgqueue.h:111
BOOL FASTCALL co_IntMouseActivateWindow(PWND Wnd)
Definition: focus.c:1248
#define CHILDID_SELF
Definition: winable.h:14
struct _WND * spwndOwner
Definition: ntuser.h:694
THRDESKHEAD head
Definition: ntuser.h:674
Definition: object.h:3
PPROCESSINFO gppiInputProvider
Definition: ntuser.c:16
ULONG guSFWLockCount
Definition: focus.c:17
#define _In_
Definition: ms_sal.h:308
LONG_PTR LPARAM
Definition: windef.h:208
PWND FASTCALL co_GetDesktopWindow(PWND pWnd)
Definition: desktop.c:1369
struct _WND * spwndDefaultIme
Definition: win32.h:132
#define WH_CBT
Definition: winuser.h:35
PTHREADINFO gptiCurrent
Definition: ntuser.c:15
PTHREADINFO ptiLastInput
Definition: focus.c:18
#define WS_EX_NOACTIVATE
Definition: winuser.h:395
struct _WND * spwndNext
Definition: ntuser.h:690
#define WEF_SETBYWNDPTI
Definition: ntuser.h:227
#define WM_PALETTEISCHANGING
Definition: winuser.h:1863
VOID FASTCALL IntActivateWindow(PWND Wnd, PTHREADINFO pti, HANDLE tid, DWORD Type)
Definition: focus.c:357
#define WM_IME_SYSTEM
Definition: undocuser.h:59
HWND APIENTRY NtUserSetFocus(HWND hWnd)
Definition: focus.c:1719
PWND FASTCALL UserGetWindowObject(HWND hWnd)
Definition: window.c:126
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
struct _RECTL * LPRECTL
HWND FASTCALL UserGetForegroundWindow(VOID)
Definition: focus.c:1416
HWND APIENTRY NtUserGetForegroundWindow(VOID)
Definition: focus.c:1643
#define TIF_ALLOWFOREGROUNDACTIVATE
Definition: ntuser.h:259
BOOL FASTCALL IntCheckFullscreen(PWND Window)
Definition: focus.c:79
#define IntReferenceThreadInfo(pti)
Definition: win32.h:167
BOOL FASTCALL co_IntSendDeactivateMessages(HWND hWndPrev, HWND hWnd, BOOL Clear)
Definition: focus.c:118
LONG NTAPI UserGetSystemMetrics(ULONG Index)
Definition: metric.c:194
#define WS_MINIMIZED
Definition: undocuser.h:18
static BOOL FASTCALL co_IntSetForegroundAndFocusWindow(_In_opt_ PWND Wnd, _In_ BOOL MouseActivate, _In_ BOOL bFlash)
Definition: focus.c:924
VOID FASTCALL UserEnterExclusive(VOID)
Definition: ntuser.c:249
#define UserHMGetHandle(obj)
Definition: ntuser.h:222
#define WM_QUERYNEWPALETTE
Definition: winuser.h:1865
struct _LIST_ENTRY * Flink
Definition: typedefs.h:121
#define OBJID_CLIENT
Definition: winable.h:19
#define SM_CYSCREEN
Definition: winuser.h:954
HWND FASTCALL MsqSetStateWindow(PTHREADINFO pti, ULONG Type, HWND hWnd)
Definition: msgqueue.c:2551
#define TRACE(s)
Definition: solgame.cpp:4
HWND FASTCALL co_UserSetCapture(HWND hWnd)
Definition: focus.c:1453
#define WM_KILLFOCUS
Definition: winuser.h:1601
VOID FASTCALL ClearMsgBitsMask(PTHREADINFO pti, UINT MessageBits)
Definition: msgqueue.c:445
BOOL FASTCALL co_IntMakeWindowActive(PWND Window)
Definition: focus.c:426
#define ASSERT(a)
Definition: mode.c:44
NTSYSAPI ULONG NTAPI RtlEqualMemory(CONST VOID *Source1, CONST VOID *Source2, ULONG Length)
HWND APIENTRY NtUserSetCapture(HWND hWnd)
Definition: focus.c:1700
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define SWP_NOACTIVATE
Definition: winuser.h:1232
#define TIF_INACTIVATEAPPMSG
Definition: ntuser.h:263
#define UlongToHandle(ul)
Definition: basetsd.h:97
#define ValidateHwndNoErr(hwnd)
Definition: precomp.h:84
#define WA_ACTIVE
Definition: winuser.h:2603
BOOL FASTCALL IntLockSetForegroundWindow(UINT uLockCode)
Definition: focus.c:1567
#define ObDereferenceObject
Definition: obfuncs.h:203
BOOL FASTCALL RECTL_bIntersectRect(_Out_ RECTL *prclDst, _In_ const RECTL *prcl1, _In_ const RECTL *prcl2)
Definition: rect.c:55
#define QS_EVENT
Definition: undocuser.h:96
Type
Definition: Type.h:6
unsigned long DWORD
Definition: ntddk_ex.h:95
#define DECLARE_RETURN(type)
Definition: ntuser.h:3
#define WA_CLICKACTIVE
Definition: winuser.h:2604
VOID FASTCALL MsqPostMessage(PTHREADINFO pti, MSG *Msg, BOOLEAN HardwareMessage, DWORD MessageBits, DWORD dwQEvent, LONG_PTR ExtraInfo)
Definition: msgqueue.c:1337
BOOL FASTCALL IntIsWindow(HWND hWnd)
Definition: window.c:180
int Window
Definition: x11stubs.h:26
GLbitfield flags
Definition: glext.h:7161
CHAR Message[80]
Definition: alive.c:5
LRESULT APIENTRY co_HOOK_CallHooks(INT HookId, INT Code, WPARAM wParam, LPARAM lParam)
Definition: hook.c:1103
BOOL FASTCALL co_IntSetForegroundMessageQueue(_In_opt_ PWND Wnd, _In_ PTHREADINFO pti, _In_ BOOL MouseActivate, _In_ DWORD Type)
Definition: focus.c:767
PWND FASTCALL UserGetDesktopWindow(VOID)
Definition: desktop.c:1389
NTSTATUS NTAPI PsLookupProcessByProcessId(IN HANDLE ProcessId, OUT PEPROCESS *Process)
Definition: process.c:919
int ret
BOOL FASTCALL IntIsWindowVisible(PWND Wnd)
Definition: window.c:193
BOOL FASTCALL co_IntSendActivateMessages(PWND WindowPrev, PWND Window, BOOL MouseActivate, BOOL Async)
Definition: focus.c:444
LRESULT FASTCALL co_IntSendMessage(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
Definition: message.c:1446
_In_ LPWSTR _Out_ PHANDLE _In_ struct _MONITOR * pMonitor
Definition: winsplp.h:772
#define IS_IMM_MODE()
Definition: precomp.h:117
_Must_inspect_result_ _In_ WDFCMRESLIST List
Definition: wdfresource.h:550
#define WM_CANCELMODE
Definition: winuser.h:1622
HWND *FASTCALL IntWinListChildren(PWND Window)
Definition: window.c:278
#define WNDS_ACTIVEFRAME
Definition: ntuser.h:594
Definition: typedefs.h:119
HANDLE NTAPI PsGetThreadId(IN PETHREAD Thread)
Definition: thread.c:705
HWND APIENTRY IntGetCapture(VOID)
Definition: focus.c:1435
BOOL FASTCALL ActivateOtherWindowMin(PWND Wnd)
Definition: winpos.c:284
#define SWP_NOSIZE
Definition: winuser.h:1235
#define ERR(fmt,...)
Definition: debug.h:110
Definition: ntuser.h:672
struct _USER_MESSAGE_QUEUE * MessageQueue
Definition: win32.h:90
VOID FASTCALL UserLeave(VOID)
Definition: ntuser.c:258
FORCEINLINE VOID RECTL_vSetRect(_Out_ RECTL *prcl, _In_ LONG left, _In_ LONG top, _In_ LONG right, _In_ LONG bottom)
Definition: rect.h:5
BOOL FASTCALL ToggleFGActivate(PTHREADINFO pti)
Definition: focus.c:710
VOID FASTCALL IntSetFocusMessageQueue(PUSER_MESSAGE_QUEUE NewQueue)
Definition: desktop.c:1322
struct _WND * PWND
#define WM_ACTIVATEAPP
Definition: winuser.h:1619
#define WM_ACTIVATE
Definition: winuser.h:1599
#define MSQ_STATE_CAPTURE
Definition: ntuser.h:3666
LIST_ENTRY PostedMessagesListHead
Definition: win32.h:138
struct _WND * spwndLastActive
Definition: ntuser.h:718
#define IntGetWndThreadId(WndObj)
Definition: window.h:34
#define QF_ACTIVATIONCHANGE
Definition: msgqueue.h:100
#define MOUSEEVENTF_MOVE
Definition: winuser.h:1173
DWORD state
Definition: ntuser.h:680
__int3264 LONG_PTR
Definition: mstsclib_h.h:276
#define WS_POPUP
Definition: pedump.c:616
unsigned int UINT
Definition: ndis.h:50
#define WM_MOUSEMOVE
Definition: winuser.h:1762
#define NULL
Definition: types.h:112
PVOID NTAPI PsGetCurrentProcessWin32Process(VOID)
Definition: process.c:1183
#define WNDS_NONCPAINT
Definition: ntuser.h:596
VOID co_IntShellHookNotify(WPARAM Message, WPARAM wParam, LPARAM lParam)
Definition: desktop.c:1695
#define POSTEVENT_DAW
Definition: msgqueue.h:123
DWORD dwFlags
Definition: winuser.h:3767
#define HSHELL_RUDEAPPACTIVATED
Definition: winuser.h:1268
#define msg(x)
Definition: auth_time.c:54
PMONITOR NTAPI UserGetPrimaryMonitor(VOID)
Definition: monitor.c:102
PWND FASTCALL IntGetNonChildAncestor(PWND pWnd)
Definition: window.c:346
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
Definition: fsrtlfuncs.h:219
#define IS_WND_IMELIKE(pWnd)
Definition: window.h:111
#define PUSIF_PALETTEDISPLAY
Definition: ntuser.h:972
BOOL FASTCALL CanForceFG(PPROCESSINFO ppi)
Definition: focus.c:749
PUSER_MESSAGE_QUEUE gpqForegroundPrev
Definition: focus.c:14
UINT cVisWindows
Definition: win32.h:142
struct _WND * spwndParent
Definition: ntuser.h:692
BOOL FASTCALL IntAllowSetForegroundWindow(DWORD dwProcessId)
Definition: focus.c:1598
BOOL FASTCALL IntDeactivateWindow(PTHREADINFO pti, HANDLE tid)
Definition: focus.c:191
unsigned int ULONG
Definition: retypes.h:1
DWORD state2
Definition: ntuser.h:681
#define HCBT_ACTIVATE
Definition: winuser.h:60
#define SWP_NOMOVE
Definition: winuser.h:1234
#define WA_INACTIVE
Definition: winuser.h:2602
BOOL FASTCALL co_IntSetForegroundWindowMouse(PWND Window)
Definition: focus.c:1556
Definition: fbtusb.h:86
#define WS_EX_APPWINDOW
Definition: winuser.h:383
void Clear(USHORT Window)
Definition: hardware.c:684
#define WM_SETFOCUS
Definition: winuser.h:1600
PWND FASTCALL VerifyWnd(PWND pWnd)
Definition: window.c:86
#define USERTAG_WINDOWLIST
Definition: tags.h:298
BOOL FASTCALL IsAllowedFGActive(PTHREADINFO pti, PWND Wnd)
Definition: focus.c:730
BOOL FASTCALL co_IntSetForegroundWindow(PWND Window)
Definition: focus.c:1545
struct _WND * spwndChild
Definition: ntuser.h:693
#define WS_VISIBLE
Definition: pedump.c:620
#define MSQ_STATE_MENUOWNER
Definition: ntuser.h:3669
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1099
#define HWND_BROADCAST
Definition: winuser.h:1194
#define IntDereferenceThreadInfo(pti)
Definition: win32.h:172
#define WNDS_DESTROYED
Definition: ntuser.h:619
#define POSTEVENT_SAW
Definition: msgqueue.h:124
static TfClientId tid
LPARAM lParam
Definition: combotst.c:139
VOID FASTCALL UpdateShellHook(PWND Window)
Definition: focus.c:99
#define TIF_INCLEANUP
Definition: ntuser.h:254
ENGAPI VOID APIENTRY EngSetLastError(_In_ ULONG iError)
Definition: error.c:28
base of all file and directory entries
Definition: entries.h:82
#define WNDS_HASCAPTION
Definition: ntuser.h:591
#define APIENTRY
Definition: api.h:79
#define END_CLEANUP
Definition: ntuser.h:6
#define WNDS2_INDESTROY
Definition: ntuser.h:631
LRESULT FASTCALL co_IntSendMessageWithCallBack(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam, SENDASYNCPROC CompletionCallback, ULONG_PTR CompletionCallbackContext, ULONG_PTR *uResult)
Definition: message.c:1732
PCLS pcls
Definition: ntuser.h:699
DWORD style
Definition: ntuser.h:685
BOOL FASTCALL IntGetWindowRect(PWND Wnd, RECTL *Rect)
Definition: winpos.c:120