user32.dll Add redraw and WM_WINDOWPOS* notifications to SetActiveWindow [2]
Vitaliy Margolen
wine-patch at kievinfo.com
Wed May 11 10:28:46 CDT 2005
According to native messages sent to app we should redraw window
inside SetActiveWindow.
Vitaliy Margolen
changelog:
dlls/user/tests/win.c
Tests
-------------- next part --------------
Index: dlls/user/tests/win.c
===================================================================
RCS file: /home/wine/wine/dlls/user/tests/win.c,v
retrieving revision 1.57
diff -u -p -r1.57 win.c
--- dlls/user/tests/win.c 26 Apr 2005 08:16:18 -0000 1.57
+++ dlls/user/tests/win.c 11 May 2005 15:18:05 -0000
@@ -45,6 +45,11 @@
#define LONG_PTR INT_PTR
#define ULONG_PTR UINT_PTR
+#define WP_WM_GETMINMAXINFO 0x1000000
+#define WP_WM_NCPAINT 0x0100000
+#define WP_WM_ERASEBKGND 0x0200000
+#define WP_NCPAINT_ERASE 0x0300000
+
void dump_region(HRGN hrgn);
static HWND (WINAPI *pGetAncestor)(HWND,UINT);
@@ -54,6 +59,7 @@ static BOOL test_lbuttondown_flag;
static HWND hwndMessage;
static HWND hwndMain, hwndMain2;
static HHOOK hhook;
+static BOOL test_SetActiveWindow_flag = FALSE;
/* check the values returned by the various parent/owner functions on a given window */
static void check_parents( HWND hwnd, HWND ga_parent, HWND gwl_parent, HWND get_parent,
@@ -454,7 +460,7 @@ static LRESULT WINAPI main_window_procA(
minmax->ptMaxPosition.x, minmax->ptMaxPosition.y,
minmax->ptMinTrackSize.x, minmax->ptMinTrackSize.y,
minmax->ptMaxTrackSize.x, minmax->ptMaxTrackSize.y);
- SetWindowLongA(hwnd, GWL_USERDATA, 0x20031021);
+ SetWindowLongA(hwnd, GWL_USERDATA, GetWindowLongA(hwnd, GWL_USERDATA) | WP_WM_GETMINMAXINFO);
break;
}
case WM_WINDOWPOSCHANGING:
@@ -511,7 +517,7 @@ static LRESULT WINAPI main_window_procA(
}
case WM_NCCREATE:
{
- BOOL got_getminmaxinfo = GetWindowLongA(hwnd, GWL_USERDATA) == 0x20031021;
+ BOOL got_getminmaxinfo = GetWindowLongA(hwnd, GWL_USERDATA) & WP_WM_GETMINMAXINFO;
CREATESTRUCTA *cs = (CREATESTRUCTA *)lparam;
trace("WM_NCCREATE: hwnd %p, parent %p, style %08lx\n", hwnd, cs->hwndParent, cs->style);
@@ -528,6 +534,32 @@ static LRESULT WINAPI main_window_procA(
if (test_lbuttondown_flag)
ShowWindow((HWND)wparam, SW_SHOW);
break;
+ case WM_NCPAINT:
+ {
+ trace("WM_NCPAINT: hwnd %p\n", hwnd);
+ SetWindowLongA(hwnd, GWL_USERDATA, GetWindowLongA(hwnd, GWL_USERDATA) | WP_WM_NCPAINT);
+ break;
+ }
+ case WM_ERASEBKGND:
+ {
+ trace("WM_ERASEBKGND: hwnd %p\n", hwnd);
+ SetWindowLongA(hwnd, GWL_USERDATA, GetWindowLongA(hwnd, GWL_USERDATA) | WP_WM_ERASEBKGND);
+ break;
+ }
+ case WM_NCACTIVATE:
+ {
+ BOOL got_ncpaint_erasebkgnd = (GetWindowLongA(hwnd, GWL_USERDATA) & WP_NCPAINT_ERASE) == WP_NCPAINT_ERASE;
+
+ trace("WM_NCACTIVATE: hwnd %p (%x) window %p\n", hwnd, wparam, (HWND)lparam);
+ if (LOWORD(wparam))
+ {
+ ok(got_ncpaint_erasebkgnd || !test_SetActiveWindow_flag || !IsWindowVisible(hwnd),
+ "main: WM_NCACTIVATE should NOT have been received before WM_NCPAINT & WM_ERASEBKGND\n");
+ }
+ else
+ SetWindowLongA(hwnd, GWL_USERDATA, GetWindowLongA(hwnd, GWL_USERDATA) & ~WP_NCPAINT_ERASE);
+ break;
+ }
}
return DefWindowProcA(hwnd, msg, wparam, lparam);
@@ -1942,8 +1974,10 @@ static void test_SetFocus(HWND hwnd)
static void test_SetActiveWindow(HWND hwnd)
{
- HWND hwnd2;
+ HWND hwnd2, hwnd3;
+ BOOL r;
+ test_SetActiveWindow_flag = TRUE;
ShowWindow(hwnd, SW_SHOW);
SetActiveWindow(0);
SetActiveWindow(hwnd);
@@ -1961,17 +1995,52 @@ static void test_SetActiveWindow(HWND hw
ShowWindow(hwnd, SW_SHOW);
- hwnd2 = CreateWindowExA(0, "static", NULL, WS_POPUP|WS_VISIBLE, 0, 0, 0, 0, hwnd, 0, 0, NULL);
+ hwnd2 = CreateWindowExA(0, "static", NULL, WS_POPUP|WS_VISIBLE, 100, 310, 100, 100, hwnd, 0, 0, NULL);
ok( GetActiveWindow() == hwnd2, "Window %p is not active\n", hwnd2 );
+ /* We should not activate window before destroing it. Remove when fixed */
+ test_SetActiveWindow_flag = FALSE;
DestroyWindow(hwnd2);
+ test_SetActiveWindow_flag = TRUE;
ok( GetActiveWindow() != hwnd2, "Window %p is still active\n", hwnd2 );
- hwnd2 = CreateWindowExA(0, "static", NULL, WS_POPUP|WS_VISIBLE, 0, 0, 0, 0, hwnd, 0, 0, NULL);
+ hwnd2 = CreateWindowExA(0, "static", NULL, WS_POPUP|WS_VISIBLE, 100, 310, 100, 100, hwnd, 0, 0, NULL);
ok( GetActiveWindow() == hwnd2, "Window %p is not active\n", hwnd2 );
SetWindowPos(hwnd2,0,0,0,0,0,SWP_NOZORDER|SWP_NOMOVE|SWP_NOSIZE|SWP_NOACTIVATE|SWP_HIDEWINDOW);
ok( GetActiveWindow() == hwnd2, "Window %p no longer active (%p)\n", hwnd2, GetActiveWindow() );
+ /* We should not activate window before destroing it. Remove when fixed */
+ test_SetActiveWindow_flag = FALSE;
DestroyWindow(hwnd2);
+ test_SetActiveWindow_flag = TRUE;
ok( GetActiveWindow() != hwnd2, "Window %p is still active\n", hwnd2 );
+
+ SetWindowPos(hwnd, 0, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE | SWP_HIDEWINDOW);
+ hwnd2 = CreateWindowExA(0, "MainWindowClass", "Owned window", WS_POPUP, 100, 310, 200, 200, hwnd, 0, 0, NULL);
+ hwnd3 = CreateWindowExA(0, "MainWindowClass", "Window 3", WS_POPUP, 310, 100, 200, 200, 0, 0, 0, NULL);
+ r = GetActiveWindow() == hwnd || GetActiveWindow() == hwnd2 || GetActiveWindow() == hwnd3;
+ ok( r, "Should not have any active windows\n" );
+ SetWindowPos(hwnd2, 0, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE | SWP_SHOWWINDOW);
+ r = GetActiveWindow() == hwnd || GetActiveWindow() == hwnd2 || GetActiveWindow() == hwnd3;
+ ok( r, "Should not have any active windows\n" );
+ SetWindowPos(hwnd3, 0, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE | SWP_SHOWWINDOW);
+ r = GetActiveWindow() == hwnd || GetActiveWindow() == hwnd2 || GetActiveWindow() == hwnd3;
+ ok( r, "Should not have any active windows\n" );
+ SetWindowPos(hwnd, 0, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE | SWP_SHOWWINDOW);
+ r = GetActiveWindow() == hwnd || GetActiveWindow() == hwnd2 || GetActiveWindow() == hwnd3;
+ ok( r, "Should not have any active windows\n" );
+ /* Zero out being painted flags */
+ SetWindowLongA(hwnd, GWL_USERDATA, GetWindowLongA(hwnd, GWL_USERDATA) & ~WP_NCPAINT_ERASE);
+ SetWindowLongA(hwnd2, GWL_USERDATA, GetWindowLongA(hwnd, GWL_USERDATA) & ~WP_NCPAINT_ERASE);
+ /* hwnd3 has been drawn durring show window and will not be drawn here */
+ SetActiveWindow(hwnd3);
+ /* This should redraw both owner and owned windows */
+ SetActiveWindow(hwnd);
+ SetActiveWindow(hwnd2);
+ SetActiveWindow(hwnd3);
+ SetActiveWindow(hwnd);
+ /* We should not activate window before destroing it. Move after DestroyWindow when fixed */
+ test_SetActiveWindow_flag = FALSE;
+ DestroyWindow(hwnd2);
+ DestroyWindow(hwnd3);
}
static void check_wnd_state(HWND active, HWND foreground, HWND focus, HWND capture)
More information about the wine-patches
mailing list