Module: wine Branch: master Commit: de21941178fcf22f44b9c3d5bf7221846d723ab6 URL: http://source.winehq.org/git/wine.git/?a=commit;h=de21941178fcf22f44b9c3d5bf...
Author: Piotr Caban piotr@codeweavers.com Date: Thu Mar 27 14:59:51 2014 +0100
user32: Change SetForegroundWindow behavior on windows with parent and no WS_CHILD flag.
---
dlls/user32/tests/win.c | 19 +++++++++++++++---- server/queue.c | 6 +++--- server/user.h | 2 +- server/window.c | 6 +++--- 4 files changed, 22 insertions(+), 11 deletions(-)
diff --git a/dlls/user32/tests/win.c b/dlls/user32/tests/win.c index cb74b8e..5206642 100644 --- a/dlls/user32/tests/win.c +++ b/dlls/user32/tests/win.c @@ -2794,6 +2794,7 @@ static void test_SetForegroundWindow(HWND hwnd) BOOL ret; HWND hwnd2; MSG msg; + LONG style;
flush_events( TRUE ); ShowWindow(hwnd, SW_HIDE); @@ -2889,6 +2890,19 @@ static void test_SetForegroundWindow(HWND hwnd) todo_wine ok(GetActiveWindow() == hwnd2, "Expected active window %p, got %p.\n", hwnd2, GetActiveWindow()); todo_wine ok(GetFocus() == hwnd2, "Expected focus window %p, got %p.\n", hwnd2, GetFocus());
+ SetForegroundWindow(hwnd); + check_wnd_state(hwnd, hwnd, hwnd, 0); + style = GetWindowLongA(hwnd2, GWL_STYLE) | WS_CHILD; + ok(SetWindowLongA(hwnd2, GWL_STYLE, style), "SetWindowLong failed\n"); + ok(SetForegroundWindow(hwnd2), "SetForegroundWindow failed\n"); + check_wnd_state(hwnd2, hwnd2, hwnd2, 0); + + SetForegroundWindow(hwnd); + check_wnd_state(hwnd, hwnd, hwnd, 0); + ok(SetWindowLongA(hwnd2, GWL_STYLE, style & (~WS_POPUP)), "SetWindowLong failed\n"); + ok(!SetForegroundWindow(hwnd2), "SetForegroundWindow failed\n"); + check_wnd_state(hwnd, hwnd, hwnd, 0); + SetEvent(thread_params.test_finished); WaitForSingleObject(thread, INFINITE); CloseHandle(thread_params.test_finished); @@ -3720,7 +3734,6 @@ static void test_SetParent(void) ret = SetParent(popup, child1); ok(ret == desktop, "expected %p, got %p\n", desktop, ret); check_parents(popup, child1, child1, 0, 0, parent, popup); -todo_wine check_active_state(popup, 0, popup);
SetActiveWindow(parent); @@ -3747,10 +3760,8 @@ todo_wine check_active_state(parent, 0, parent);
bret = SetForegroundWindow(popup); -todo_wine ok(bret, "SetForegroundWindow() failed\n"); - if (bret) - check_active_state(popup, popup, popup); + check_active_state(popup, popup, popup);
ok(DestroyWindow(parent), "DestroyWindow() failed\n");
diff --git a/server/queue.c b/server/queue.c index a410691..d919f01 100644 --- a/server/queue.c +++ b/server/queue.c @@ -2869,9 +2869,9 @@ DECL_HANDLER(set_foreground_window) reply->send_msg_old = (reply->previous && desktop->foreground_input != queue->input); reply->send_msg_new = FALSE;
- if (is_top_level_window( req->handle ) && - ((thread = get_window_thread( req->handle ))) && - (thread->queue->input->desktop == desktop)) + if (is_valid_foreground_window( req->handle ) && + (thread = get_window_thread( req->handle )) && + thread->queue->input->desktop == desktop) { set_foreground_input( desktop, thread->queue->input ); reply->send_msg_new = (desktop->foreground_input != queue->input); diff --git a/server/user.h b/server/user.h index 2947de7..8535903 100644 --- a/server/user.h +++ b/server/user.h @@ -152,7 +152,7 @@ extern void post_desktop_message( struct desktop *desktop, unsigned int message, extern void destroy_window( struct window *win ); extern void destroy_thread_windows( struct thread *thread ); extern int is_child_window( user_handle_t parent, user_handle_t child ); -extern int is_top_level_window( user_handle_t window ); +extern int is_valid_foreground_window( user_handle_t window ); extern int is_window_visible( user_handle_t window ); extern int is_window_transparent( user_handle_t window ); extern int make_window_active( user_handle_t window ); diff --git a/server/window.c b/server/window.c index 1696fce..484cd22 100644 --- a/server/window.c +++ b/server/window.c @@ -581,11 +581,11 @@ int is_child_window( user_handle_t parent, user_handle_t child ) return 0; }
-/* check whether window is a top-level window */ -int is_top_level_window( user_handle_t window ) +/* check if window can be set as foreground window */ +int is_valid_foreground_window( user_handle_t window ) { struct window *win = get_user_object( window, USER_WINDOW ); - return (win && (is_desktop_window(win) || is_desktop_window(win->parent))); + return win && (win->style & (WS_POPUP|WS_CHILD)) != WS_CHILD; }
/* make a window active if possible */