From: Rémi Bernon rbernon@codeweavers.com
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=56073 --- dlls/user32/tests/input.c | 2 +- dlls/win32u/input.c | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/dlls/user32/tests/input.c b/dlls/user32/tests/input.c index b33f592b8c2..4d4c3c81000 100644 --- a/dlls/user32/tests/input.c +++ b/dlls/user32/tests/input.c @@ -6302,7 +6302,7 @@ static void test_SetFocus_process(void) SetFocus( hwnd ); ok( GetFocus() == hwnd, "got focus %p\n", GetFocus() ); ok( GetActiveWindow() == hwnd, "got active %p\n", GetActiveWindow() ); - todo_wine ok( GetForegroundWindow() == hwnd, "got foreground %p\n", GetForegroundWindow() ); + ok( GetForegroundWindow() == hwnd, "got foreground %p\n", GetForegroundWindow() );
SetForegroundWindow( hwnd ); DestroyWindow( hwnd ); diff --git a/dlls/win32u/input.c b/dlls/win32u/input.c index a4834b740d8..99a0dcb2ace 100644 --- a/dlls/win32u/input.c +++ b/dlls/win32u/input.c @@ -2107,7 +2107,7 @@ HWND WINAPI NtUserSetActiveWindow( HWND hwnd ) */ HWND WINAPI NtUserSetFocus( HWND hwnd ) { - HWND hwndTop = hwnd; + HWND hwndTop = hwnd, active; HWND previous = get_focus();
TRACE( "%p prev %p\n", hwnd, previous ); @@ -2142,7 +2142,8 @@ HWND WINAPI NtUserSetFocus( HWND hwnd ) if (call_hooks( WH_CBT, HCBT_SETFOCUS, (WPARAM)hwnd, (LPARAM)previous, 0 )) return 0;
/* activate hwndTop if needed. */ - if (hwndTop != get_active_window()) + if (!(active = get_active_window()) && !set_foreground_window( hwndTop, FALSE )) return 0; + if (hwndTop != active) { if (!set_active_window( hwndTop, NULL, FALSE, FALSE, 0 )) return 0; if (!is_window( hwnd )) return 0; /* Abort if window destroyed */