2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS Win32k subsystem
4 * PURPOSE: Focus functions
5 * FILE: subsystems/win32/win32k/ntuser/focus.c
6 * PROGRAMER: ReactOS Team
10 DBG_DEFAULT_CHANNEL(UserFocus
);
12 PUSER_MESSAGE_QUEUE gpqForeground
= NULL
;
13 PUSER_MESSAGE_QUEUE gpqForegroundPrev
= NULL
;
14 PTHREADINFO gptiForeground
= NULL
;
15 PPROCESSINFO gppiLockSFW
= NULL
;
16 ULONG guSFWLockCount
= 0; // Rule #8, No menus are active. So should be zero.
17 PTHREADINFO ptiLastInput
= NULL
;
20 Check locking of a process or one or more menus are active.
25 return (gppiLockSFW
|| guSFWLockCount
);
29 IntGetCaptureWindow(VOID
)
31 PUSER_MESSAGE_QUEUE ForegroundQueue
= IntGetFocusMessageQueue();
32 return ForegroundQueue
!= NULL
? ForegroundQueue
->CaptureWindow
: 0;
36 IntGetThreadFocusWindow(VOID
)
39 PUSER_MESSAGE_QUEUE ThreadQueue
;
41 pti
= PsGetCurrentThreadWin32Thread();
42 ThreadQueue
= pti
->MessageQueue
;
45 return ThreadQueue
->spwndFocus
? UserHMGetHandle(ThreadQueue
->spwndFocus
) : 0;
49 co_IntSendDeactivateMessages(HWND hWndPrev
, HWND hWnd
)
53 if (hWndPrev
&& (WndPrev
= UserGetWindowObject(hWndPrev
)))
55 co_IntSendMessageNoWait(hWndPrev
, WM_NCACTIVATE
, FALSE
, 0);
56 co_IntSendMessageNoWait(hWndPrev
, WM_ACTIVATE
,
57 MAKEWPARAM(WA_INACTIVE
, WndPrev
->style
& WS_MINIMIZE
),
63 co_IntMakeWindowActive(PWND Window
)
67 { // Set last active for window and it's owner.
68 Window
->spwndLastActive
= Window
;
69 spwndOwner
= Window
->spwndOwner
;
72 spwndOwner
->spwndLastActive
= Window
;
73 spwndOwner
= spwndOwner
->spwndOwner
;
77 ERR("MakeWindowActive Failed!\n");
82 co_IntSendActivateMessages(HWND hWndPrev
, HWND hWnd
, BOOL MouseActivate
)
84 USER_REFERENCE_ENTRY Ref
, RefPrev
;
85 PWND Window
, WindowPrev
= NULL
;
86 HANDLE OldTID
, NewTID
;
87 PTHREADINFO ptiOld
, ptiNew
;
89 if ((Window
= UserGetWindowObject(hWnd
)))
91 UserRefObjectCo(Window
, &Ref
);
93 WindowPrev
= UserGetWindowObject(hWndPrev
);
95 if (WindowPrev
) UserRefObjectCo(WindowPrev
, &RefPrev
);
97 /* Send palette messages */
98 if (gpsi
->PUSIFlags
& PUSIF_PALETTEDISPLAY
&&
99 co_IntPostOrSendMessage(hWnd
, WM_QUERYNEWPALETTE
, 0, 0))
101 UserSendNotifyMessage( HWND_BROADCAST
,
102 WM_PALETTEISCHANGING
,
107 if (Window
->spwndPrev
!= NULL
)
108 co_WinPosSetWindowPos(Window
, HWND_TOP
, 0, 0, 0, 0,
109 SWP_NOSIZE
| SWP_NOMOVE
);
111 if (!Window
->spwndOwner
&& !IntGetParent(Window
))
113 co_IntShellHookNotify(HSHELL_WINDOWACTIVATED
, (LPARAM
) hWnd
);
118 Window
->state
|= WNDS_ACTIVEFRAME
;
120 if (Window
->style
& WS_MINIMIZE
)
122 TRACE("Widow was minimized\n");
127 WindowPrev
->state
&= ~WNDS_ACTIVEFRAME
;
129 OldTID
= WindowPrev
? IntGetWndThreadId(WindowPrev
) : NULL
;
130 NewTID
= Window
? IntGetWndThreadId(Window
) : NULL
;
131 ptiOld
= WindowPrev
? WindowPrev
->head
.pti
: NULL
;
132 ptiNew
= Window
? Window
->head
.pti
: NULL
;
134 TRACE("SendActiveMessage Old -> %x, New -> %x\n", OldTID
, NewTID
);
136 if (OldTID
!= NewTID
)
141 List
= IntWinListChildren(UserGetWindowObject(IntGetDesktopWindow()));
146 for (phWnd
= List
; *phWnd
; ++phWnd
)
148 cWindow
= UserGetWindowObject(*phWnd
);
149 if (cWindow
&& cWindow
->head
.pti
== ptiOld
)
150 { // FALSE if the window is being deactivated,
151 // ThreadId that owns the window being activated.
152 co_IntSendMessageNoWait(*phWnd
, WM_ACTIVATEAPP
, FALSE
, (LPARAM
)NewTID
);
158 for (phWnd
= List
; *phWnd
; ++phWnd
)
160 cWindow
= UserGetWindowObject(*phWnd
);
161 if (cWindow
&& cWindow
->head
.pti
== ptiNew
)
162 { // TRUE if the window is being activated,
163 // ThreadId that owns the window being deactivated.
164 co_IntSendMessageNoWait(*phWnd
, WM_ACTIVATEAPP
, TRUE
, (LPARAM
)OldTID
);
172 UserDerefObjectCo(WindowPrev
); // Now allow the previous window to die.
174 UserDerefObjectCo(Window
);
176 /* FIXME: IntIsWindow */
177 co_IntSendMessageNoWait(hWnd
, WM_NCACTIVATE
, (WPARAM
)(hWnd
== UserGetForegroundWindow()), 0);
178 /* FIXME: WA_CLICKACTIVE */
179 co_IntSendMessageNoWait(hWnd
, WM_ACTIVATE
,
180 MAKEWPARAM(MouseActivate
? WA_CLICKACTIVE
: WA_ACTIVE
,
181 Window
->style
& WS_MINIMIZE
),
187 co_IntSendKillFocusMessages(HWND hWndPrev
, HWND hWnd
)
191 IntNotifyWinEvent(EVENT_OBJECT_FOCUS
, NULL
, OBJID_CLIENT
, CHILDID_SELF
, 0);
192 co_IntPostOrSendMessage(hWndPrev
, WM_KILLFOCUS
, (WPARAM
)hWnd
, 0);
197 co_IntSendSetFocusMessages(HWND hWndPrev
, HWND hWnd
)
201 PWND pWnd
= UserGetWindowObject(hWnd
);
204 IntNotifyWinEvent(EVENT_OBJECT_FOCUS
, pWnd
, OBJID_CLIENT
, CHILDID_SELF
, 0);
205 co_IntPostOrSendMessage(hWnd
, WM_SETFOCUS
, (WPARAM
)hWndPrev
, 0);
211 IntFindChildWindowToOwner(PWND Root
, PWND Owner
)
214 PWND Child
, OwnerWnd
;
216 for(Child
= Root
->spwndChild
; Child
; Child
= Child
->spwndNext
)
218 OwnerWnd
= Child
->spwndOwner
;
222 if(OwnerWnd
== Owner
)
233 Can the system force foreground from one or more conditions.
236 CanForceFG(PPROCESSINFO ppi
)
239 ptiLastInput
->ppi
== ppi
||
241 gptiForeground
->ppi
== ppi
||
242 ppi
->W32PF_flags
& (W32PF_ALLOWFOREGROUNDACTIVATE
| W32PF_SETFOREGROUNDALLOWED
) ||
243 gppiInputProvider
== ppi
||
251 The system restricts which processes can set the foreground window. A process
252 can set the foreground window only if one of the following conditions is true:
254 * The process is the foreground process.
255 * The process was started by the foreground process.
256 * The process received the last input event.
257 * There is no foreground process.
258 * The foreground process is being debugged.
259 * The foreground is not locked (see LockSetForegroundWindow).
260 * The foreground lock time-out has expired (see SPI_GETFOREGROUNDLOCKTIMEOUT in SystemParametersInfo).
261 * No menus are active.
265 co_IntSetForegroundAndFocusWindow(PWND Wnd
, BOOL MouseActivate
)
267 HWND hWnd
= UserHMGetHandle(Wnd
);
268 HWND hWndPrev
= NULL
;
269 PUSER_MESSAGE_QUEUE PrevForegroundQueue
;
271 BOOL fgRet
= FALSE
, Ret
= FALSE
;
275 TRACE("SetForegroundAndFocusWindow(%x, %x, %s)\n", hWnd
, MouseActivate
? "TRUE" : "FALSE");
277 PrevForegroundQueue
= IntGetFocusMessageQueue(); // Use this active desktop.
278 pti
= PsGetCurrentThreadWin32Thread();
280 if (PrevForegroundQueue
)
281 { // Same Window Q as foreground just do active.
282 if (Wnd
&& Wnd
->head
.pti
->MessageQueue
== PrevForegroundQueue
)
284 if (pti
->MessageQueue
== PrevForegroundQueue
)
285 { // Same WQ and TQ go active.
286 Ret
= co_IntSetActiveWindow(Wnd
, NULL
, MouseActivate
, TRUE
);
288 else if (Wnd
->head
.pti
->MessageQueue
->spwndActive
== Wnd
)
289 { // Same WQ and it is active.
293 { // Same WQ as FG but not the same TQ send active.
294 co_IntSendMessageNoWait(hWnd
, WM_ASYNC_SETACTIVEWINDOW
, (WPARAM
)Wnd
, (LPARAM
)MouseActivate
);
300 hWndPrev
= PrevForegroundQueue
->spwndActive
? UserHMGetHandle(PrevForegroundQueue
->spwndActive
) : 0;
303 if ( (( !IsFGLocked() || pti
->ppi
== gppiInputProvider
) &&
304 ( CanForceFG(pti
->ppi
) || pti
->TIF_flags
& (TIF_SYSTEMTHREAD
|TIF_CSRSSTHREAD
|TIF_ALLOWFOREGROUNDACTIVATE
) )) ||
305 pti
->ppi
== ppiScrnSaver
308 IntSetFocusMessageQueue(Wnd
->head
.pti
->MessageQueue
);
309 gptiForeground
= Wnd
->head
.pti
;
313 Fix FG Bounce with regedit but breaks test_SFW todos:
315 What happens is that we get the WM_WINE_SETACTIVEWINDOW message sent by the
316 other thread after we already changed the foreground window back to our own
319 if (hWndPrev
!= hWnd
)
321 if (PrevForegroundQueue
&&
323 Wnd
->head
.pti
->MessageQueue
!= PrevForegroundQueue
&&
324 PrevForegroundQueue
->spwndActive
)
326 //ERR("SFGW: Send NULL to 0x%x\n",hWndPrev);
327 if (pti
->MessageQueue
== PrevForegroundQueue
)
329 //ERR("SFGW: TI same as Prev TI\n");
330 co_IntSetActiveWindow(NULL
, NULL
, FALSE
, TRUE
);
333 co_IntSendMessageNoWait(hWndPrev
, WM_ASYNC_SETACTIVEWINDOW
, 0, 0 );
337 if (pti
->MessageQueue
== Wnd
->head
.pti
->MessageQueue
)
339 Ret
= co_IntSetActiveWindow(Wnd
, NULL
, MouseActivate
, TRUE
);
341 else if (Wnd
->head
.pti
->MessageQueue
->spwndActive
== Wnd
)
347 co_IntSendMessageNoWait(hWnd
, WM_ASYNC_SETACTIVEWINDOW
, (WPARAM
)Wnd
, (LPARAM
)MouseActivate
);
355 co_IntMouseActivateWindow(PWND Wnd
)
359 USER_REFERENCE_ENTRY Ref
;
363 if (Wnd
->style
& WS_DISABLED
)
367 PWND DesktopWindow
= UserGetWindowObject(IntGetDesktopWindow());
370 Top
= IntFindChildWindowToOwner(DesktopWindow
, Wnd
);
371 if ((TopWnd
= UserGetWindowObject(Top
)))
373 UserRefObjectCo(TopWnd
, &Ref
);
374 Ret
= co_IntMouseActivateWindow(TopWnd
);
375 UserDerefObjectCo(TopWnd
);
383 TopWindow
= UserGetAncestor(Wnd
, GA_ROOT
);
384 if (!TopWindow
) return FALSE
;
386 /* TMN: Check return valud from this function? */
387 UserRefObjectCo(TopWindow
, &Ref
);
389 co_IntSetForegroundAndFocusWindow(TopWindow
, TRUE
);
391 UserDerefObjectCo(TopWindow
);
397 co_IntSetActiveWindow(PWND Wnd OPTIONAL
, HWND
* Prev
, BOOL bMouse
, BOOL bFocus
)
400 PUSER_MESSAGE_QUEUE ThreadQueue
;
403 CBTACTIVATESTRUCT cbt
;
408 hWnd
= UserHMGetHandle(Wnd
);
411 pti
= PsGetCurrentThreadWin32Thread();
412 ThreadQueue
= pti
->MessageQueue
;
413 ASSERT(ThreadQueue
!= 0);
415 hWndPrev
= ThreadQueue
->spwndActive
? UserHMGetHandle(ThreadQueue
->spwndActive
) : NULL
;
416 if (Prev
) *Prev
= hWndPrev
;
417 if (hWndPrev
== hWnd
) return TRUE
;
421 if (ThreadQueue
!= Wnd
->head
.pti
->MessageQueue
)
423 PUSER_MESSAGE_QUEUE ForegroundQueue
= IntGetFocusMessageQueue();
424 // Rule 1 & 4, We are foreground so set this FG window or NULL foreground....
425 if (!ForegroundQueue
|| ForegroundQueue
== ThreadQueue
)
427 return co_IntSetForegroundAndFocusWindow(Wnd
, bMouse
);
431 if (Wnd
->state
& WNDS_BEINGACTIVATED
) return TRUE
;
434 /* Call CBT hook chain */
436 cbt
.hWndActive
= hWndPrev
;
437 if (co_HOOK_CallHooks( WH_CBT
, HCBT_ACTIVATE
, (WPARAM
)hWnd
, (LPARAM
)&cbt
))
439 ERR("SetActiveWindow WH_CBT Call Hook return!\n");
443 co_IntSendDeactivateMessages(hWndPrev
, hWnd
);
445 if (Wnd
) Wnd
->state
|= WNDS_BEINGACTIVATED
;
447 IntNotifyWinEvent(EVENT_SYSTEM_FOREGROUND
, Wnd
, OBJID_WINDOW
, CHILDID_SELF
, WEF_SETBYWNDPTI
);
449 /* check if the specified window can be set in the input data of a given queue */
450 if ( !Wnd
|| ThreadQueue
== Wnd
->head
.pti
->MessageQueue
)
452 /* set the current thread active window */
453 if (!Wnd
|| co_IntMakeWindowActive(Wnd
))
455 ThreadQueue
->spwndActivePrev
= ThreadQueue
->spwndActive
;
456 ThreadQueue
->spwndActive
= Wnd
;
460 co_IntSendActivateMessages(hWndPrev
, hWnd
, bMouse
);
462 /* now change focus if necessary */
465 /* Do not change focus if the window is no longer active */
466 if (ThreadQueue
->spwndActive
== Wnd
)
468 if (!ThreadQueue
->spwndFocus
||
470 UserGetAncestor(ThreadQueue
->spwndFocus
, GA_ROOT
) != Wnd
)
472 co_UserSetFocus(Wnd
);
477 if (Wnd
) Wnd
->state
&= ~WNDS_BEINGACTIVATED
;
482 co_UserSetFocus(PWND Window
)
487 PUSER_MESSAGE_QUEUE ThreadQueue
;
490 ASSERT_REFS_CO(Window
);
492 pti
= PsGetCurrentThreadWin32Thread();
493 ThreadQueue
= pti
->MessageQueue
;
494 ASSERT(ThreadQueue
!= 0);
496 hWndPrev
= ThreadQueue
->spwndFocus
? UserHMGetHandle(ThreadQueue
->spwndFocus
) : 0;
500 if (hWndPrev
== UserHMGetHandle(Window
))
502 return hWndPrev
; /* Nothing to do */
505 if (Window
->head
.pti
->MessageQueue
!= ThreadQueue
)
507 ERR("SetFocus Must have the same Q!\n");
511 /* Check if we can set the focus to this window */
515 if (pwndTop
->style
& (WS_MINIMIZED
|WS_DISABLED
)) return 0;
516 if (!pwndTop
->spwndParent
|| pwndTop
->spwndParent
== UserGetDesktopWindow())
518 if ((pwndTop
->style
& (WS_POPUP
|WS_CHILD
)) == WS_CHILD
) return 0;
521 if (pwndTop
->spwndParent
== UserGetMessageWindow()) return 0;
522 pwndTop
= pwndTop
->spwndParent
;
525 if (co_HOOK_CallHooks( WH_CBT
, HCBT_SETFOCUS
, (WPARAM
)Window
->head
.h
, (LPARAM
)hWndPrev
))
527 ERR("SetFocus 1 WH_CBT Call Hook return!\n");
531 /* Activate pwndTop if needed. */
532 if (pwndTop
!= ThreadQueue
->spwndActive
)
534 PUSER_MESSAGE_QUEUE ForegroundQueue
= IntGetFocusMessageQueue(); // Keep it based on desktop.
535 if (ThreadQueue
!= ForegroundQueue
) // HACK see rule 2 & 3.
537 if (!co_IntSetForegroundAndFocusWindow(pwndTop
, FALSE
))
539 ERR("SetFocus Set Foreground and Focus Failed!\n");
544 /* Set Active when it is needed. */
545 if (pwndTop
!= ThreadQueue
->spwndActive
)
547 if (!co_IntSetActiveWindow(pwndTop
, NULL
, FALSE
, FALSE
))
549 ERR("SetFocus Set Active Failed!\n");
554 /* Abort if window destroyed */
555 if (Window
->state2
& WNDS2_INDESTROY
) return 0;
556 /* Do not change focus if the window is no longer active */
557 if (pwndTop
!= ThreadQueue
->spwndActive
)
559 ERR("SetFocus Top window did not go active!\n");
564 /* check if the specified window can be set in the input data of a given queue */
565 if ( !Window
|| ThreadQueue
== Window
->head
.pti
->MessageQueue
)
566 /* set the current thread focus window */
567 ThreadQueue
->spwndFocus
= Window
;
569 TRACE("Focus: %d -> %d\n", hWndPrev
, Window
->head
.h
);
571 co_IntSendKillFocusMessages(hWndPrev
, Window
->head
.h
);
572 co_IntSendSetFocusMessages(hWndPrev
, Window
->head
.h
);
574 else /* NULL hwnd passed in */
576 if (!hWndPrev
) return 0; /* nothing to do */
577 if (co_HOOK_CallHooks( WH_CBT
, HCBT_SETFOCUS
, (WPARAM
)0, (LPARAM
)hWndPrev
))
579 ERR("SetFocusWindow 2 WH_CBT Call Hook return!\n");
583 /* set the current thread focus window null */
584 ThreadQueue
->spwndFocus
= 0;
586 co_IntSendKillFocusMessages(hWndPrev
, 0);
588 return hWndPrev
? (IntIsWindow(hWndPrev
) ? hWndPrev
: 0) : 0;
592 UserGetForegroundWindow(VOID
)
594 PUSER_MESSAGE_QUEUE ForegroundQueue
;
596 ForegroundQueue
= IntGetFocusMessageQueue();
597 return( ForegroundQueue
? (ForegroundQueue
->spwndActive
? UserHMGetHandle(ForegroundQueue
->spwndActive
) : 0) : 0);
600 HWND FASTCALL
UserGetActiveWindow(VOID
)
603 PUSER_MESSAGE_QUEUE ThreadQueue
;
605 pti
= PsGetCurrentThreadWin32Thread();
606 ThreadQueue
= pti
->MessageQueue
;
607 return( ThreadQueue
? (ThreadQueue
->spwndActive
? UserHMGetHandle(ThreadQueue
->spwndActive
) : 0) : 0);
614 PUSER_MESSAGE_QUEUE ThreadQueue
;
615 DECLARE_RETURN(HWND
);
617 TRACE("Enter IntGetCapture\n");
619 pti
= PsGetCurrentThreadWin32Thread();
620 ThreadQueue
= pti
->MessageQueue
;
621 RETURN( ThreadQueue
? ThreadQueue
->CaptureWindow
: 0);
624 TRACE("Leave IntGetCapture, ret=%i\n",_ret_
);
629 co_UserSetCapture(HWND hWnd
)
632 PUSER_MESSAGE_QUEUE ThreadQueue
;
636 pti
= PsGetCurrentThreadWin32Thread();
637 ThreadQueue
= pti
->MessageQueue
;
639 if (ThreadQueue
->QF_flags
& QF_CAPTURELOCKED
)
642 if ((Window
= UserGetWindowObject(hWnd
)))
644 if (Window
->head
.pti
->MessageQueue
!= ThreadQueue
)
650 hWndPrev
= MsqSetStateWindow(ThreadQueue
, MSQ_STATE_CAPTURE
, hWnd
);
654 pWnd
= UserGetWindowObject(hWndPrev
);
656 IntNotifyWinEvent(EVENT_SYSTEM_CAPTUREEND
, pWnd
, OBJID_WINDOW
, CHILDID_SELF
, WEF_SETBYWNDPTI
);
660 IntNotifyWinEvent(EVENT_SYSTEM_CAPTURESTART
, Window
, OBJID_WINDOW
, CHILDID_SELF
, WEF_SETBYWNDPTI
);
662 if (hWndPrev
&& hWndPrev
!= hWnd
)
664 if (ThreadQueue
->MenuOwner
&& Window
) ThreadQueue
->QF_flags
|= QF_CAPTURELOCKED
;
666 co_IntPostOrSendMessage(hWndPrev
, WM_CAPTURECHANGED
, 0, (LPARAM
)hWnd
);
668 ThreadQueue
->QF_flags
&= ~QF_CAPTURELOCKED
;
671 ThreadQueue
->CaptureWindow
= hWnd
;
673 if (hWnd
== NULL
) // Release mode.
677 /* Also remove other windows if not capturing anymore */
678 MsqSetStateWindow(ThreadQueue
, MSQ_STATE_MENUOWNER
, NULL
);
679 MsqSetStateWindow(ThreadQueue
, MSQ_STATE_MOVESIZE
, NULL
);
681 /* Somebody may have missed some mouse movements */
685 mi
.dwFlags
= MOUSEEVENTF_MOVE
;
688 UserSendMouseInput(&mi
, FALSE
);
698 IntReleaseCapture(VOID
)
701 PUSER_MESSAGE_QUEUE ThreadQueue
;
703 pti
= PsGetCurrentThreadWin32Thread();
704 ThreadQueue
= pti
->MessageQueue
;
706 // Can not release inside WM_CAPTURECHANGED!!
707 if (ThreadQueue
->QF_flags
& QF_CAPTURELOCKED
) return FALSE
;
709 co_UserSetCapture(NULL
);
718 co_IntSetForegroundWindow(PWND Window
)
720 ASSERT_REFS_CO(Window
);
722 return co_IntSetForegroundAndFocusWindow(Window
, FALSE
);
729 IntLockSetForegroundWindow(UINT uLockCode
)
731 ULONG Err
= ERROR_ACCESS_DENIED
;
732 PPROCESSINFO ppi
= PsGetCurrentProcessWin32Process();
736 if ( CanForceFG(ppi
) && !gppiLockSFW
)
743 if ( gppiLockSFW
== ppi
)
750 Err
= ERROR_INVALID_PARAMETER
;
752 EngSetLastError(Err
);
760 IntAllowSetForegroundWindow(DWORD dwProcessId
)
762 PPROCESSINFO ppi
, ppiCur
;
763 PEPROCESS Process
= NULL
;
766 if (dwProcessId
!= ASFW_ANY
)
768 if (!NT_SUCCESS(PsLookupProcessByProcessId((HANDLE
)dwProcessId
, &Process
)))
770 EngSetLastError(ERROR_INVALID_PARAMETER
);
773 ppi
= PsGetProcessWin32Process(Process
);
776 ObDereferenceObject(Process
);
780 ppiCur
= PsGetCurrentProcessWin32Process();
781 if (!CanForceFG(ppiCur
))
783 if (Process
) ObDereferenceObject(Process
);
784 EngSetLastError(ERROR_ACCESS_DENIED
);
787 if (dwProcessId
== ASFW_ANY
)
788 { // All processes will be enabled to set the foreground window.
792 { // Rule #3, last input event in force.
793 ptiLastInput
= ppi
->ptiList
;
794 ObDereferenceObject(Process
);
803 NtUserGetForegroundWindow(VOID
)
805 DECLARE_RETURN(HWND
);
807 TRACE("Enter NtUserGetForegroundWindow\n");
808 UserEnterExclusive();
810 RETURN( UserGetForegroundWindow());
813 TRACE("Leave NtUserGetForegroundWindow, ret=%i\n",_ret_
);
819 NtUserSetActiveWindow(HWND hWnd
)
821 USER_REFERENCE_ENTRY Ref
;
824 DECLARE_RETURN(HWND
);
826 TRACE("Enter NtUserSetActiveWindow(%x)\n", hWnd
);
827 UserEnterExclusive();
832 if (!(Window
= UserGetWindowObject(hWnd
)))
839 Window
->head
.pti
->MessageQueue
== gptiCurrent
->MessageQueue
)
841 if (Window
) UserRefObjectCo(Window
, &Ref
);
842 if (!co_IntSetActiveWindow(Window
, &hWndPrev
, FALSE
, TRUE
)) hWndPrev
= NULL
;
843 if (Window
) UserDerefObjectCo(Window
);
848 RETURN( hWndPrev
? (IntIsWindow(hWndPrev
) ? hWndPrev
: 0) : 0 );
851 TRACE("Leave NtUserSetActiveWindow, ret=%i\n",_ret_
);
860 NtUserSetCapture(HWND hWnd
)
862 DECLARE_RETURN(HWND
);
864 TRACE("Enter NtUserSetCapture(%x)\n", hWnd
);
865 UserEnterExclusive();
867 RETURN( co_UserSetCapture(hWnd
));
870 TRACE("Leave NtUserSetCapture, ret=%i\n",_ret_
);
879 NtUserSetFocus(HWND hWnd
)
882 USER_REFERENCE_ENTRY Ref
;
883 DECLARE_RETURN(HWND
);
886 TRACE("Enter NtUserSetFocus(%x)\n", hWnd
);
887 UserEnterExclusive();
891 if (!(Window
= UserGetWindowObject(hWnd
)))
896 UserRefObjectCo(Window
, &Ref
);
897 ret
= co_UserSetFocus(Window
);
898 UserDerefObjectCo(Window
);
904 RETURN( co_UserSetFocus(0));
908 TRACE("Leave NtUserSetFocus, ret=%i\n",_ret_
);