Author: tkreuzer
Date: Wed Jan 10 07:23:33 2007
New Revision: 25410
URL:
http://svn.reactos.org/svn/reactos?rev=25410&view=rev
Log:
Make NtUserSetFocus accept NULL window.
Modified:
trunk/reactos/subsystems/win32/win32k/ntuser/focus.c
Modified: trunk/reactos/subsystems/win32/win32k/ntuser/focus.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/nt…
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/ntuser/focus.c (original)
+++ trunk/reactos/subsystems/win32/win32k/ntuser/focus.c Wed Jan 10 07:23:33 2007
@@ -304,27 +304,37 @@
static
HWND FASTCALL
-co_IntSetFocusWindow(PWINDOW_OBJECT Window)
+co_IntSetFocusWindow(PWINDOW_OBJECT Window OPTIONAL)
{
HWND hWndPrev = 0;
PUSER_MESSAGE_QUEUE ThreadQueue;
- ASSERT_REFS_CO(Window);
+ if (Window)
+ ASSERT_REFS_CO(Window);
ThreadQueue = (PUSER_MESSAGE_QUEUE)PsGetCurrentThreadWin32Thread()->MessageQueue;
ASSERT(ThreadQueue != 0);
hWndPrev = ThreadQueue->FocusWindow;
- if (hWndPrev == Window->hSelf)
- {
- return hWndPrev;
- }
-
- ThreadQueue->FocusWindow = Window->hSelf;
-
- co_IntSendKillFocusMessages(hWndPrev, Window->hSelf);
- co_IntSendSetFocusMessages(hWndPrev, Window->hSelf);
-
+
+ if (Window != 0)
+ {
+ if (hWndPrev == Window->hSelf)
+ {
+ return hWndPrev;
+ }
+
+ ThreadQueue->FocusWindow = Window->hSelf;
+
+ co_IntSendKillFocusMessages(hWndPrev, Window->hSelf);
+ co_IntSendSetFocusMessages(hWndPrev, Window->hSelf);
+ }
+ else
+ {
+ ThreadQueue->FocusWindow = 0;
+
+ co_IntSendKillFocusMessages(hWndPrev, 0);
+ }
return hWndPrev;
}
@@ -562,16 +572,23 @@
DPRINT("Enter NtUserSetFocus(%x)\n", hWnd);
UserEnterExclusive();
- if (!(Window = UserGetWindowObject(hWnd)))
- {
- RETURN(NULL);
- }
-
- UserRefObjectCo(Window, &Ref);
- ret = co_UserSetFocus(Window);
- UserDerefObjectCo(Window);
+ if (hWnd)
+ {
+ if (!(Window = UserGetWindowObject(hWnd)))
+ {
+ RETURN(NULL);
+ }
+
+ UserRefObjectCo(Window, &Ref);
+ ret = co_UserSetFocus(Window);
+ UserDerefObjectCo(Window);
- RETURN(ret);
+ RETURN(ret);
+ }
+ else
+ {
+ RETURN( co_UserSetFocus(0));
+ }
CLEANUP:
DPRINT("Leave NtUserSetFocus, ret=%i\n",_ret_);