[3/3] user32: Move the server call up in order to perform the thread input check earlier in SetActiveWindow.

Dmitry Timoshkov dmitry at baikal.ru
Thu Jan 5 03:58:51 CST 2012


SetForegroundWindow already does a similar thing.
---
 dlls/user32/focus.c     |   24 +++++++++---------------
 dlls/user32/tests/msg.c |    6 +++---
 2 files changed, 12 insertions(+), 18 deletions(-)

diff --git a/dlls/user32/focus.c b/dlls/user32/focus.c
index 6b5312f..97c402c 100644
--- a/dlls/user32/focus.c
+++ b/dlls/user32/focus.c
@@ -75,16 +75,21 @@ static HWND set_focus_window( HWND hwnd )
  */
 static BOOL set_active_window( HWND hwnd, HWND *prev, BOOL mouse, BOOL focus )
 {
-    HWND previous = GetActiveWindow();
+    HWND previous;
     BOOL ret;
     DWORD old_thread, new_thread;
     CBTACTIVATESTRUCT cbt;
 
-    if (previous == hwnd)
+    SERVER_START_REQ( set_active_window )
     {
-        if (prev) *prev = hwnd;
-        return TRUE;
+        req->handle = wine_server_user_handle( hwnd );
+        if ((ret = !wine_server_call_err( req )))
+            previous = wine_server_ptr_handle( reply->previous );
     }
+    SERVER_END_REQ;
+    if (!ret) return FALSE;
+    if (prev) *prev = previous;
+    if (previous == hwnd) return TRUE;
 
     /* call CBT hook chain */
     cbt.fMouse     = mouse;
@@ -98,17 +103,6 @@ static BOOL set_active_window( HWND hwnd, HWND *prev, BOOL mouse, BOOL focus )
                       MAKEWPARAM( WA_INACTIVE, IsIconic(previous) ), (LPARAM)hwnd );
     }
 
-    SERVER_START_REQ( set_active_window )
-    {
-        req->handle = wine_server_user_handle( hwnd );
-        if ((ret = !wine_server_call_err( req )))
-            previous = wine_server_ptr_handle( reply->previous );
-    }
-    SERVER_END_REQ;
-    if (!ret) return FALSE;
-    if (prev) *prev = previous;
-    if (previous == hwnd) return TRUE;
-
     if (hwnd)
     {
         /* send palette messages */
diff --git a/dlls/user32/tests/msg.c b/dlls/user32/tests/msg.c
index 6f40a0b..8315772 100644
--- a/dlls/user32/tests/msg.c
+++ b/dlls/user32/tests/msg.c
@@ -13585,7 +13585,7 @@ static void test_SetFocus(void)
     ok(GetLastError() == ERROR_ACCESS_DENIED /* Vista+ */ ||
        broken(GetLastError() == 0xdeadbeef), "expected ERROR_ACCESS_DENIED, got %d\n", GetLastError());
     while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) DispatchMessage(&msg);
-    ok_sequence(WmEmptySeq, "SetFocus on a desktop window", TRUE);
+    ok_sequence(WmEmptySeq, "SetFocus on a desktop window", FALSE);
     ok(old_focus == 0, "expected old focus 0, got %p\n", old_focus);
     ok(GetActiveWindow() == parent, "expected active %p, got %p\n", parent, GetActiveWindow());
     ok(GetFocus() == parent, "expected focus %p, got %p\n", parent, GetFocus());
@@ -13614,7 +13614,7 @@ static void test_SetFocus(void)
 todo_wine
     ok(GetLastError() == 0xdeadbeef, "expected 0xdeadbeef, got %d\n", GetLastError());
     while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) DispatchMessage(&msg);
-    ok_sequence(WmEmptySeq, "SetActiveWindow on a desktop window", TRUE);
+    ok_sequence(WmEmptySeq, "SetActiveWindow on a desktop window", FALSE);
     ok(old_active == 0, "expected old focus 0, got %p\n", old_focus);
     ok(GetActiveWindow() == parent, "expected active %p, got %p\n", parent, GetActiveWindow());
     ok(GetFocus() == parent, "expected focus %p, got %p\n", parent, GetFocus());
@@ -13624,7 +13624,7 @@ todo_wine
 todo_wine
     ok(GetLastError() == 0xdeadbeef, "expected 0xdeadbeef, got %d\n", GetLastError());
     while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) DispatchMessage(&msg);
-    ok_sequence(WmEmptySeq, "SetActiveWindow on another thread window", TRUE);
+    ok_sequence(WmEmptySeq, "SetActiveWindow on another thread window", FALSE);
     ok(old_active == 0, "expected old focus 0, got %p\n", old_active);
     ok(GetActiveWindow() == parent, "expected active %p, got %p\n", parent, GetActiveWindow());
     ok(GetFocus() == parent, "expected focus %p, got %p\n", parent, GetFocus());
-- 
1.7.7.4




More information about the wine-patches mailing list