Module: wine Branch: master Commit: d13a44e4aa12fa5ad3498c39934e88a7dcd30916 URL: http://source.winehq.org/git/wine.git/?a=commit;h=d13a44e4aa12fa5ad3498c3993...
Author: Jacek Caban jacek@codeweavers.com Date: Mon Feb 22 12:54:59 2016 +0100
user32: Don't use window's parent as an owner if WS_CHILD style is not set.
Signed-off-by: Jacek Caban jacek@codeweavers.com Signed-off-by: Alexandre Julliard julliard@winehq.org
---
dlls/user32/tests/win.c | 25 +++++++++++++++++++++++++ server/window.c | 3 ++- 2 files changed, 27 insertions(+), 1 deletion(-)
diff --git a/dlls/user32/tests/win.c b/dlls/user32/tests/win.c index 71459e1..988aa6c 100644 --- a/dlls/user32/tests/win.c +++ b/dlls/user32/tests/win.c @@ -652,6 +652,31 @@ static void test_parent_owner(void) DestroyWindow( child ); DestroyWindow( test ); DestroyWindow( owner ); + + /* Test that owner window takes into account WS_CHILD flag even if parent is set by SetParent. */ + owner = create_tool_window( WS_VISIBLE | WS_OVERLAPPEDWINDOW, desktop ); + SetParent(owner, hwndMain); + check_parents( owner, hwndMain, hwndMain, NULL, NULL, hwndMain, owner ); + test = create_tool_window( WS_VISIBLE | WS_OVERLAPPEDWINDOW, owner ); + check_parents( test, desktop, owner, NULL, owner, test, test ); + DestroyWindow( owner ); + DestroyWindow( test ); + + owner = create_tool_window( WS_VISIBLE | WS_CHILD, desktop ); + SetParent(owner, hwndMain); + check_parents( owner, hwndMain, hwndMain, hwndMain, NULL, hwndMain, hwndMain ); + test = create_tool_window( WS_VISIBLE | WS_OVERLAPPEDWINDOW, owner ); + check_parents( test, desktop, hwndMain, NULL, hwndMain, test, test ); + DestroyWindow( owner ); + DestroyWindow( test ); + + owner = create_tool_window( WS_VISIBLE | WS_POPUP | WS_CHILD, desktop ); + SetParent(owner, hwndMain); + check_parents( owner, hwndMain, hwndMain, NULL, NULL, hwndMain, owner ); + test = create_tool_window( WS_VISIBLE | WS_OVERLAPPEDWINDOW, owner ); + check_parents( test, desktop, owner, NULL, owner, test, test ); + DestroyWindow( owner ); + DestroyWindow( test ); }
static BOOL CALLBACK enum_proc( HWND hwnd, LPARAM lParam) diff --git a/server/window.c b/server/window.c index 9328211..143b60c 100644 --- a/server/window.c +++ b/server/window.c @@ -1901,7 +1901,8 @@ DECL_HANDLER(create_window) return; } else /* owner must be a top-level window */ - while (!is_desktop_window(owner->parent)) owner = owner->parent; + while ((owner->style & (WS_POPUP|WS_CHILD)) == WS_CHILD && !is_desktop_window(owner->parent)) + owner = owner->parent; }
atom = cls_name.len ? find_global_atom( NULL, &cls_name ) : req->atom;