Make NtUserSetFocus accept NULL window.

svn path=/trunk/; revision=25410
This commit is contained in:
Timo Kreuzer 2007-01-10 04:23:33 +00:00
parent 78749a977a
commit d8160f0676

View file

@ -304,17 +304,21 @@ co_IntSetActiveWindow(PWINDOW_OBJECT Window OPTIONAL)
static static
HWND FASTCALL HWND FASTCALL
co_IntSetFocusWindow(PWINDOW_OBJECT Window) co_IntSetFocusWindow(PWINDOW_OBJECT Window OPTIONAL)
{ {
HWND hWndPrev = 0; HWND hWndPrev = 0;
PUSER_MESSAGE_QUEUE ThreadQueue; PUSER_MESSAGE_QUEUE ThreadQueue;
if (Window)
ASSERT_REFS_CO(Window); ASSERT_REFS_CO(Window);
ThreadQueue = (PUSER_MESSAGE_QUEUE)PsGetCurrentThreadWin32Thread()->MessageQueue; ThreadQueue = (PUSER_MESSAGE_QUEUE)PsGetCurrentThreadWin32Thread()->MessageQueue;
ASSERT(ThreadQueue != 0); ASSERT(ThreadQueue != 0);
hWndPrev = ThreadQueue->FocusWindow; hWndPrev = ThreadQueue->FocusWindow;
if (Window != 0)
{
if (hWndPrev == Window->hSelf) if (hWndPrev == Window->hSelf)
{ {
return hWndPrev; return hWndPrev;
@ -324,7 +328,13 @@ co_IntSetFocusWindow(PWINDOW_OBJECT Window)
co_IntSendKillFocusMessages(hWndPrev, Window->hSelf); co_IntSendKillFocusMessages(hWndPrev, Window->hSelf);
co_IntSendSetFocusMessages(hWndPrev, Window->hSelf); co_IntSendSetFocusMessages(hWndPrev, Window->hSelf);
}
else
{
ThreadQueue->FocusWindow = 0;
co_IntSendKillFocusMessages(hWndPrev, 0);
}
return hWndPrev; return hWndPrev;
} }
@ -562,6 +572,8 @@ NtUserSetFocus(HWND hWnd)
DPRINT("Enter NtUserSetFocus(%x)\n", hWnd); DPRINT("Enter NtUserSetFocus(%x)\n", hWnd);
UserEnterExclusive(); UserEnterExclusive();
if (hWnd)
{
if (!(Window = UserGetWindowObject(hWnd))) if (!(Window = UserGetWindowObject(hWnd)))
{ {
RETURN(NULL); RETURN(NULL);
@ -572,6 +584,11 @@ NtUserSetFocus(HWND hWnd)
UserDerefObjectCo(Window); UserDerefObjectCo(Window);
RETURN(ret); RETURN(ret);
}
else
{
RETURN( co_UserSetFocus(0));
}
CLEANUP: CLEANUP:
DPRINT("Leave NtUserSetFocus, ret=%i\n",_ret_); DPRINT("Leave NtUserSetFocus, ret=%i\n",_ret_);