mirror of
git://source.winehq.org/git/wine.git
synced 2024-10-31 12:19:49 +00:00
user32: Don't allow activating a WS_CHILD top-level window through SetFocus.
This commit is contained in:
parent
63e6dbc139
commit
9687ceaf1d
2 changed files with 30 additions and 3 deletions
|
@ -266,7 +266,11 @@ HWND WINAPI SetFocus( HWND hwnd )
|
||||||
LONG style = GetWindowLongW( hwndTop, GWL_STYLE );
|
LONG style = GetWindowLongW( hwndTop, GWL_STYLE );
|
||||||
if (style & (WS_MINIMIZE | WS_DISABLED)) return 0;
|
if (style & (WS_MINIMIZE | WS_DISABLED)) return 0;
|
||||||
parent = GetAncestor( hwndTop, GA_PARENT );
|
parent = GetAncestor( hwndTop, GA_PARENT );
|
||||||
if (!parent || parent == GetDesktopWindow()) break;
|
if (!parent || parent == GetDesktopWindow())
|
||||||
|
{
|
||||||
|
if ((style & (WS_POPUP|WS_CHILD)) == WS_CHILD) return 0;
|
||||||
|
break;
|
||||||
|
}
|
||||||
if (parent == get_hwnd_message_parent()) return 0;
|
if (parent == get_hwnd_message_parent()) return 0;
|
||||||
hwndTop = parent;
|
hwndTop = parent;
|
||||||
}
|
}
|
||||||
|
|
|
@ -2513,7 +2513,7 @@ static LRESULT WINAPI set_focus_on_activate_proc(HWND hwnd, UINT msg, WPARAM wp,
|
||||||
|
|
||||||
static void test_SetFocus(HWND hwnd)
|
static void test_SetFocus(HWND hwnd)
|
||||||
{
|
{
|
||||||
HWND child, child2;
|
HWND child, child2, ret;
|
||||||
WNDPROC old_wnd_proc;
|
WNDPROC old_wnd_proc;
|
||||||
|
|
||||||
/* check if we can set focus to non-visible windows */
|
/* check if we can set focus to non-visible windows */
|
||||||
|
@ -2588,9 +2588,32 @@ todo_wine
|
||||||
ok( GetActiveWindow() == hwnd, "parent window %p should be active\n", hwnd);
|
ok( GetActiveWindow() == hwnd, "parent window %p should be active\n", hwnd);
|
||||||
todo_wine
|
todo_wine
|
||||||
ok( GetFocus() == child, "Focus should be on child %p, not %p\n", child, GetFocus() );
|
ok( GetFocus() == child, "Focus should be on child %p, not %p\n", child, GetFocus() );
|
||||||
|
|
||||||
SetWindowLongPtr(hwnd, GWLP_WNDPROC, (LONG_PTR)old_wnd_proc);
|
SetWindowLongPtr(hwnd, GWLP_WNDPROC, (LONG_PTR)old_wnd_proc);
|
||||||
|
|
||||||
|
SetFocus( hwnd );
|
||||||
|
SetParent( child, GetDesktopWindow());
|
||||||
|
SetParent( child2, child );
|
||||||
|
ok( GetActiveWindow() == hwnd, "parent window %p should be active\n", hwnd);
|
||||||
|
ok( GetFocus() == hwnd, "Focus should be on parent %p\n", hwnd );
|
||||||
|
ret = SetFocus( child2 );
|
||||||
|
ok( ret == 0, "SetFocus %p should fail\n", child2);
|
||||||
|
ok( GetActiveWindow() == hwnd, "parent window %p should be active\n", hwnd);
|
||||||
|
ok( GetFocus() == hwnd, "Focus should be on parent %p\n", hwnd );
|
||||||
|
ret = SetFocus( child );
|
||||||
|
ok( ret == 0, "SetFocus %p should fail\n", child);
|
||||||
|
ok( GetActiveWindow() == hwnd, "parent window %p should be active\n", hwnd);
|
||||||
|
ok( GetFocus() == hwnd, "Focus should be on parent %p\n", hwnd );
|
||||||
|
SetWindowLongW( child, GWL_STYLE, WS_POPUP|WS_CHILD );
|
||||||
|
SetFocus( child2 );
|
||||||
|
ok( GetActiveWindow() == child, "child window %p should be active\n", child);
|
||||||
|
ok( GetFocus() == child2, "Focus should be on child2 %p\n", child2 );
|
||||||
|
SetFocus( hwnd );
|
||||||
|
ok( GetActiveWindow() == hwnd, "parent window %p should be active\n", hwnd);
|
||||||
|
ok( GetFocus() == hwnd, "Focus should be on parent %p\n", hwnd );
|
||||||
|
SetFocus( child );
|
||||||
|
ok( GetActiveWindow() == child, "child window %p should be active\n", child);
|
||||||
|
ok( GetFocus() == child, "Focus should be on child %p\n", child );
|
||||||
|
|
||||||
DestroyWindow( child2 );
|
DestroyWindow( child2 );
|
||||||
DestroyWindow( child );
|
DestroyWindow( child );
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue