user32: Change SetForegroundWindow behavior on windows with parent and no WS_CHILD flag.

This commit is contained in:
Piotr Caban 2014-03-27 14:59:51 +01:00 committed by Alexandre Julliard
parent 7420b7fe73
commit de21941178
4 changed files with 22 additions and 11 deletions

View File

@ -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");

View File

@ -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);

View File

@ -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 );

View File

@ -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 */