Don't send messages when doing a ShowWindow(SW_HIDE) on an invisible window

Mike Hearn mh at codeweavers.com
Thu Jun 3 10:15:41 CDT 2004


This fixes TightVNC. Praise be to open source Windows apps! :)

Mike Hearn <mh at codeweavers.com>
Don't send WM_SIZE, WM_MOVE nor WM_WINDOWPOSCHANGING in ShowWindow when
hiding an invisible window. Add a test for this behaviour which passes on
Windows 2000 and Wine.

Index: dlls/x11drv/winpos.c
===================================================================
RCS file: /home/wine/wine/dlls/x11drv/winpos.c,v
retrieving revision 1.83
diff -u -p -r1.83 winpos.c
--- dlls/x11drv/winpos.c        27 Apr 2004 23:32:01 -0000      1.83
+++ dlls/x11drv/winpos.c        3 Jun 2004 15:12:47 -0000
@@ -1284,7 +1284,7 @@ BOOL X11DRV_ShowWindow( HWND hwnd, INT c
     {
         case SW_HIDE:
            swp |= SWP_HIDEWINDOW | SWP_NOSIZE | SWP_NOMOVE |
-                       SWP_NOACTIVATE | SWP_NOZORDER;
+                       SWP_NOACTIVATE | SWP_NOZORDER | SWP_NOSENDCHANGING;
            break;
  
        case SW_SHOWMINNOACTIVE:
@@ -1376,7 +1376,7 @@ BOOL X11DRV_ShowWindow( HWND hwnd, INT c
     if (!IsWindow( hwnd )) goto END;
     else if( wndPtr->dwStyle & WS_MINIMIZE ) WINPOS_ShowIconTitle( hwnd, TRUE );
  
-    if (wndPtr->flags & WIN_NEED_SIZE)
+    if ((wndPtr->flags & WIN_NEED_SIZE) && (cmd != SW_HIDE))
     {
         /* should happen only in CreateWindowEx() */
        int wParam = SIZE_RESTORED;
Index: dlls/user/tests/msg.c
===================================================================
RCS file: /home/wine/wine/dlls/user/tests/msg.c,v
retrieving revision 1.21
diff -u -p -r1.21 msg.c
--- dlls/user/tests/msg.c       1 Jun 2004 19:39:26 -0000       1.21
+++ dlls/user/tests/msg.c       3 Jun 2004 15:12:47 -0000
@@ -145,6 +145,10 @@ static const struct message WmHideOverla
     { WM_IME_SETCONTEXT, sent|wparam|optional, 0 },
     { 0 }
 };
+/* ShowWindow(SW_HIDE) for an invisible overlapped window */
+static const struct message WmHideInvisibleOverlappedSeq[] = {
+    { 0 }
+};
 /* DestroyWindow for a visible overlapped window */
 static const struct message WmDestroyOverlappedSeq[] = {
     { HCBT_DESTROYWND, hook },
@@ -748,6 +752,10 @@ static void test_messages(void)
                            100, 100, 200, 200, 0, 0, 0, NULL);
     ok (hwnd != 0, "Failed to create overlapped window\n");
     ok_sequence(WmCreateOverlappedSeq, "CreateWindow:overlapped");
+
+    /* test ShowWindow(SW_HIDE) on a newly created invisible window */
+    ShowWindow(hwnd, SW_HIDE);
+    ok_sequence(WmHideInvisibleOverlappedSeq, "ShowWindow(SW_HIDE):overlapped, invisible");
  
     /* test WM_SETREDRAW on a not visible top level window */
     test_WM_SETREDRAW(hwnd);





More information about the wine-patches mailing list