[2/2] user32: Make a SetFocus message test for a top level child window pass.
Dmitry Timoshkov
dmitry at baikal.ru
Fri Dec 9 02:44:33 CST 2011
This is a more correct fix for the problem reported in the bug 28447.
---
dlls/user32/focus.c | 29 +++++++++--------------------
dlls/user32/tests/msg.c | 2 +-
2 files changed, 10 insertions(+), 21 deletions(-)
diff --git a/dlls/user32/focus.c b/dlls/user32/focus.c
index 81169db..3cb3398 100644
--- a/dlls/user32/focus.c
+++ b/dlls/user32/focus.c
@@ -80,11 +80,12 @@ static BOOL set_active_window( HWND hwnd, HWND *prev, BOOL mouse, BOOL focus )
DWORD old_thread, new_thread;
CBTACTIVATESTRUCT cbt;
- if (previous == hwnd)
- {
- if (prev) *prev = hwnd;
- return TRUE;
- }
+ if (prev) *prev = previous;
+
+ if (previous == hwnd) return TRUE;
+
+ if (hwnd && (GetWindowLongW( hwnd, GWL_STYLE ) & (WS_POPUP|WS_CHILD)) == WS_CHILD)
+ return FALSE;
/* call CBT hook chain */
cbt.fMouse = mouse;
@@ -230,17 +231,9 @@ HWND WINAPI SetActiveWindow( HWND hwnd )
TRACE( "%p\n", hwnd );
- if (hwnd)
- {
- LONG style = GetWindowLongW( hwnd, GWL_STYLE );
-
- if ((style & (WS_POPUP|WS_CHILD)) == WS_CHILD)
- return GetActiveWindow(); /* Windows doesn't seem to return an error here */
-
- hwnd = WIN_GetFullHandle( hwnd );
- }
+ hwnd = WIN_GetFullHandle( hwnd );
- if (!set_active_window( hwnd, &prev, FALSE, TRUE )) return 0;
+ set_active_window( hwnd, &prev, FALSE, TRUE );
return prev;
}
@@ -266,11 +259,7 @@ HWND WINAPI SetFocus( HWND hwnd )
LONG style = GetWindowLongW( hwndTop, GWL_STYLE );
if (style & (WS_MINIMIZE | WS_DISABLED)) return 0;
parent = GetAncestor( hwndTop, GA_PARENT );
- if (!parent || parent == GetDesktopWindow())
- {
- if ((style & (WS_POPUP|WS_CHILD)) == WS_CHILD) return 0;
- break;
- }
+ if (!parent || parent == GetDesktopWindow()) break;
if (parent == get_hwnd_message_parent()) return 0;
hwndTop = parent;
}
diff --git a/dlls/user32/tests/msg.c b/dlls/user32/tests/msg.c
index 40fd25a..865bb93 100644
--- a/dlls/user32/tests/msg.c
+++ b/dlls/user32/tests/msg.c
@@ -13598,7 +13598,7 @@ static void test_SetFocus(void)
old_focus = SetFocus(child);
while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) DispatchMessage(&msg);
- ok_sequence(WmSetFocus_3, "SetFocus on a child window", TRUE);
+ ok_sequence(WmSetFocus_3, "SetFocus on a child 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());
--
1.7.7.4
More information about the wine-patches
mailing list