From db96b4a9d17b994633b9899f17fd954145c46dc5 Mon Sep 17 00:00:00 2001
From: Ilya Shpigor <shpigor@etersoft.ru>
Date: Thu, 26 Feb 2009 10:55:05 +0300
Subject: [PATCH] user32: Moving minimized windows without the cursor for dragging (eterbug #1011)

---
 dlls/user32/defwnd.c |    9 +++++----
 dlls/user32/winpos.c |   47 ++++++++++++-----------------------------------
 2 files changed, 17 insertions(+), 39 deletions(-)

diff --git a/dlls/user32/defwnd.c b/dlls/user32/defwnd.c
index 7d6ba66..6217b5f 100644
--- a/dlls/user32/defwnd.c
+++ b/dlls/user32/defwnd.c
@@ -509,15 +509,16 @@ static LRESULT DEFWND_DefWinProc( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPa
         return (LRESULT)DEFWND_ControlColor( (HDC)wParam, HIWORD(lParam) );
 
     case WM_SETCURSOR:
-        if (GetWindowLongW( hwnd, GWL_STYLE ) & WS_CHILD)
+        if ((LOWORD(lParam) < HTSIZEFIRST) || (LOWORD(lParam) > HTSIZELAST))
         {
-            /* with the exception of the border around a resizable wnd,
-             * give the parent first chance to set the cursor */
-            if ((LOWORD(lParam) < HTSIZEFIRST) || (LOWORD(lParam) > HTSIZELAST))
+            if (GetWindowLongW( hwnd, GWL_STYLE ) & WS_CHILD)
             {
+                /* with the exception of the border around a resizable wnd,
+                 * give the parent first chance to set the cursor */
                 if (SendMessageW(GetParent(hwnd), WM_SETCURSOR, wParam, lParam)) return TRUE;
             }
         }
+        else if (IsIconic(hwnd)) return TRUE;
         NC_HandleSetCursor( hwnd, wParam, lParam );
         break;
 
diff --git a/dlls/user32/winpos.c b/dlls/user32/winpos.c
index 01ee427..01080fd 100644
--- a/dlls/user32/winpos.c
+++ b/dlls/user32/winpos.c
@@ -2301,7 +2301,6 @@ void WINPOS_SysCommandSizeMove( HWND hwnd, WPARAM wParam )
     HWND parent;
     LONG hittest = (LONG)(wParam & 0x0f);
     WPARAM syscommand = wParam & 0xfff0;
-    HCURSOR hDragCursor = 0, hOldCursor = 0;
     POINT minTrack, maxTrack;
     POINT capturePoint, pt;
     LONG style = GetWindowLongW( hwnd, GWL_STYLE );
@@ -2327,6 +2326,7 @@ void WINPOS_SysCommandSizeMove( HWND hwnd, WPARAM wParam )
     }
     else  /* SC_SIZE */
     {
+        if (iconic) return;
         if ( hittest && (syscommand != SC_MOUSEMENU) )
             hittest += (HTLEFT - WMSZ_LEFT);
         else
@@ -2388,13 +2388,6 @@ void WINPOS_SysCommandSizeMove( HWND hwnd, WPARAM wParam )
     /* Retrieve a default cache DC (without using the window style) */
     hdc = GetDCEx( parent, 0, DCX_CACHE );
 
-    if( iconic ) /* create a cursor for dragging */
-    {
-        hDragCursor = (HCURSOR)GetClassLongPtrW( hwnd, GCLP_HICON);
-        if( !hDragCursor ) hDragCursor = (HCURSOR)SendMessageW( hwnd, WM_QUERYDRAGICON, 0, 0L);
-        if( !hDragCursor ) iconic = FALSE;
-    }
-
     /* we only allow disabling the full window drag for child windows */
     if (parent) SystemParametersInfoW( SPI_GETDRAGFULLWINDOWS, 0, &DragFullWindows, 0 );
 
@@ -2447,12 +2440,7 @@ void WINPOS_SysCommandSizeMove( HWND hwnd, WPARAM wParam )
             {
                 moved = TRUE;
 
-                if( iconic ) /* ok, no system popup tracking */
-                {
-                    hOldCursor = SetCursor(hDragCursor);
-                    ShowCursor( TRUE );
-                }
-                else if(!DragFullWindows)
+                if(!DragFullWindows)
                     draw_moving_frame( hdc, &sizingRect, thickframe );
             }
 
@@ -2467,7 +2455,7 @@ void WINPOS_SysCommandSizeMove( HWND hwnd, WPARAM wParam )
                 else if (ON_RIGHT_BORDER(hittest)) newRect.right += dx;
                 if (ON_TOP_BORDER(hittest)) newRect.top += dy;
                 else if (ON_BOTTOM_BORDER(hittest)) newRect.bottom += dy;
-                if(!iconic && !DragFullWindows) draw_moving_frame( hdc, &sizingRect, thickframe );
+                if(!DragFullWindows) draw_moving_frame( hdc, &sizingRect, thickframe );
                 capturePoint = pt;
 
                 /* determine the hit location */
@@ -2475,30 +2463,19 @@ void WINPOS_SysCommandSizeMove( HWND hwnd, WPARAM wParam )
                     wpSizingHit = WMSZ_LEFT + (hittest - HTLEFT);
                 SendMessageW( hwnd, WM_SIZING, wpSizingHit, (LPARAM)&newRect );
 
-                if (!iconic)
-                {
-                    if(!DragFullWindows)
-                        draw_moving_frame( hdc, &newRect, thickframe );
-                    else
-                        SetWindowPos( hwnd, 0, newRect.left, newRect.top,
-                                      newRect.right - newRect.left,
-                                      newRect.bottom - newRect.top,
-                                      ( hittest == HTCAPTION ) ? SWP_NOSIZE : 0 );
-                }
+                if(!DragFullWindows)
+                    draw_moving_frame( hdc, &newRect, thickframe );
+                else
+                    SetWindowPos( hwnd, 0, newRect.left, newRect.top,
+                                  newRect.right - newRect.left,
+                                  newRect.bottom - newRect.top,
+                                  ( hittest == HTCAPTION ) ? SWP_NOSIZE : 0 );
                 sizingRect = newRect;
             }
         }
     }
 
-    if( iconic )
-    {
-        if( moved ) /* restore cursors, show icon title later on */
-        {
-            ShowCursor( FALSE );
-            SetCursor( hOldCursor );
-        }
-    }
-    else if (moved && !DragFullWindows)
+    if (moved && !DragFullWindows)
     {
         draw_moving_frame( hdc, &sizingRect, thickframe );
     }
@@ -2521,7 +2498,7 @@ void WINPOS_SysCommandSizeMove( HWND hwnd, WPARAM wParam )
         if (!((msg.message == WM_KEYDOWN) && (msg.wParam == VK_ESCAPE)) )
         {
             /* NOTE: SWP_NOACTIVATE prevents document window activation in Word 6 */
-            if(!DragFullWindows || iconic)
+            if(!DragFullWindows)
                 SetWindowPos( hwnd, 0, sizingRect.left, sizingRect.top,
                               sizingRect.right - sizingRect.left,
                               sizingRect.bottom - sizingRect.top,
-- 
1.6.1.3.GIT

