Module: wine Branch: master Commit: 93825eab3e0938f65e9bdcc14519a05cc3def4a4 URL: http://source.winehq.org/git/wine.git/?a=commit;h=93825eab3e0938f65e9bdcc145...
Author: Alexandre Julliard julliard@winehq.org Date: Mon Oct 30 17:43:38 2006 +0100
user32: SetWindowRgn should call SetWindowPos, not RedrawWindow.
---
dlls/user/tests/msg.c | 68 +++++++++++++++++++++++++++++++++++++++++++++++++ dlls/user/winpos.c | 8 +++++- 2 files changed, 75 insertions(+), 1 deletions(-)
diff --git a/dlls/user/tests/msg.c b/dlls/user/tests/msg.c index 14a7bdd..6149170 100644 --- a/dlls/user/tests/msg.c +++ b/dlls/user/tests/msg.c @@ -7996,6 +7996,73 @@ #undef track_query #undef track_hover_cancel }
+ +static const struct message WmSetWindowRgn[] = { + { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE|SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_NOZORDER|SWP_NOSIZE|SWP_NOMOVE }, + { WM_NCCALCSIZE, sent|wparam, 1 }, + { WM_NCPAINT, sent }, /* wparam != 1 */ + { WM_GETTEXT, sent|defwinproc|optional }, + { WM_ERASEBKGND, sent|optional }, /* FIXME: remove optional once Wine is fixed */ + { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE|SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_NOZORDER|SWP_NOSIZE|SWP_NOMOVE }, + { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, + { 0 } +}; + +static const struct message WmSetWindowRgn_no_redraw[] = { + { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE|SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_NOZORDER|SWP_NOSIZE|SWP_NOMOVE|SWP_NOREDRAW }, + { WM_NCCALCSIZE, sent|wparam, 1 }, + { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE|SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_NOZORDER|SWP_NOSIZE|SWP_NOMOVE|SWP_NOREDRAW }, + { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, + { 0 } +}; + +static const struct message WmSetWindowRgn_clear[] = { + { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_NOZORDER|SWP_NOSIZE|SWP_NOMOVE }, + { WM_NCCALCSIZE, sent|wparam, 1 }, + { WM_NCPAINT, sent }, /* wparam != 1 */ + { WM_GETTEXT, sent|defwinproc|optional }, + { WM_ERASEBKGND, sent|optional }, /* FIXME: remove optional once Wine is fixed */ + { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE|SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_NOZORDER|SWP_NOSIZE|SWP_NOMOVE }, + { WM_NCCALCSIZE, sent|wparam|optional, 1 }, + { WM_NCPAINT, sent|optional }, /* wparam != 1 */ + { WM_GETTEXT, sent|defwinproc|optional }, + { WM_ERASEBKGND, sent|optional }, + { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, + { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, + { 0 } +}; + +static void test_SetWindowRgn(void) +{ + HRGN hrgn; + HWND hwnd = CreateWindowExA(0, "TestWindowClass", "Test overlapped", WS_OVERLAPPEDWINDOW, + 100, 100, 200, 200, 0, 0, 0, NULL); + ok( hwnd != 0, "Failed to create overlapped window\n" ); + + ShowWindow( hwnd, SW_SHOW ); + UpdateWindow( hwnd ); + flush_events(); + flush_sequence(); + + trace("testing SetWindowRgn\n"); + hrgn = CreateRectRgn( 0, 0, 150, 150 ); + SetWindowRgn( hwnd, hrgn, TRUE ); + ok_sequence( WmSetWindowRgn, "WmSetWindowRgn", FALSE ); + + hrgn = CreateRectRgn( 30, 30, 160, 160 ); + SetWindowRgn( hwnd, hrgn, FALSE ); + ok_sequence( WmSetWindowRgn_no_redraw, "WmSetWindowRgn_no_redraw", FALSE ); + + hrgn = CreateRectRgn( 0, 0, 180, 180 ); + SetWindowRgn( hwnd, hrgn, TRUE ); + ok_sequence( WmSetWindowRgn, "WmSetWindowRgn2", FALSE ); + + SetWindowRgn( hwnd, 0, TRUE ); + ok_sequence( WmSetWindowRgn_clear, "WmSetWindowRgn_clear", FALSE ); + + DestroyWindow( hwnd ); +} + START_TEST(msg) { BOOL ret; @@ -8060,6 +8127,7 @@ #endif test_edit_messages(); test_quit_message(); test_TrackMouseEvent(); + test_SetWindowRgn();
UnhookWindowsHookEx(hCBT_hook); if (pUnhookWinEvent) diff --git a/dlls/user/winpos.c b/dlls/user/winpos.c index fbc99a2..55716ba 100644 --- a/dlls/user/winpos.c +++ b/dlls/user/winpos.c @@ -265,7 +265,13 @@ int WINAPI SetWindowRgn( HWND hwnd, HRGN
if (ret) ret = USER_Driver->pSetWindowRgn( hwnd, hrgn, bRedraw );
- if (ret && bRedraw) RedrawWindow( hwnd, NULL, 0, RDW_FRAME | RDW_INVALIDATE | RDW_ERASE ); + if (ret) + { + UINT swp_flags = SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOACTIVATE|SWP_FRAMECHANGED; + if (hrgn) swp_flags |= SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE; + if (!bRedraw) swp_flags |= SWP_NOREDRAW; + SetWindowPos( hwnd, 0, 0, 0, 0, 0, swp_flags ); + } return ret; }