https://git.reactos.org/?p=reactos.git;a=commitdiff;h=669b2f4465f0f5e3dac177e46865058fae0b1179

commit 669b2f4465f0f5e3dac177e46865058fae0b1179
Author:     Denis Malikov <[email protected]>
AuthorDate: Sat Nov 20 16:58:24 2021 +0700
Commit:     Victor Perevertkin <[email protected]>
CommitDate: Sun Jan 8 22:49:59 2023 +0300

    [WIN32SS:NTUSER] restore snapped window to normal size by dragging window 
caption
    
    CORE-15638
---
 win32ss/user/ntuser/nonclient.c | 39 ++++++++++++++++++++++++++++++++++++---
 1 file changed, 36 insertions(+), 3 deletions(-)

diff --git a/win32ss/user/ntuser/nonclient.c b/win32ss/user/ntuser/nonclient.c
index 0561086024b..aad6fe72d77 100644
--- a/win32ss/user/ntuser/nonclient.c
+++ b/win32ss/user/ntuser/nonclient.c
@@ -263,7 +263,7 @@ DefWndDoSizeMove(PWND pwnd, WORD wParam)
    ExStyle = pwnd->ExStyle;
    iconic = (Style & WS_MINIMIZE) != 0;
 
-   if ((Style & WS_MAXIMIZE) || !IntIsWindowVisible(pwnd)) return;
+   if (((Style & WS_MAXIMIZE) && syscommand != SC_MOVE) || 
!IntIsWindowVisible(pwnd)) return;
 
    thickframe = UserHasThickFrameStyle(Style, ExStyle) && !iconic;
 
@@ -511,7 +511,40 @@ DefWndDoSizeMove(PWND pwnd, WORD wParam)
              RECT newRect = unmodRect;
 
              if (!iconic && !DragFullWindows) UserDrawMovingFrame( hdc, 
&sizingRect, thickframe );
-             if (hittest == HTCAPTION) RECTL_vOffsetRect( &newRect, dx, dy );
+          if (hittest == HTCAPTION)
+          {
+              /* Restore window size if it is snapped */
+              if (!RECTL_bIsEmptyRect(&pwnd->InternalPos.NormalRect) &&
+                  !IntEqualRect(&pwnd->InternalPos.NormalRect, 
&pwnd->rcWindow))
+              {
+                  UserSetCursorPos(max(0, pwnd->InternalPos.NormalRect.left) + 
pt.x, pwnd->InternalPos.NormalRect.top + pt.y, 0, 0, FALSE);
+
+                  /* Save normal size - it required when window unsnapped from 
one side and snapped to another holding mouse down */
+                  origRect = pwnd->InternalPos.NormalRect;
+
+                  /* Restore from maximized state */
+                  if (Style & WS_MAXIMIZE)
+                  {
+                      co_IntSendMessage(UserHMGetHandle(pwnd), WM_SYSCOMMAND, 
SC_RESTORE, 0);
+                  }
+                  /* Restore snapped to left/right place */
+                  else
+                  {
+                      co_WinPosSetWindowPos(pwnd,
+                                            NULL,
+                                            pwnd->InternalPos.NormalRect.left,
+                                            pwnd->InternalPos.NormalRect.top,
+                                            pwnd->InternalPos.NormalRect.right 
- pwnd->InternalPos.NormalRect.left,
+                                            
pwnd->InternalPos.NormalRect.bottom - pwnd->InternalPos.NormalRect.top,
+                                            0);
+                  }
+                  RECTL_vSetEmptyRect(&pwnd->InternalPos.NormalRect);
+                  continue;
+              }
+
+              /* regular window moving */
+              RECTL_vOffsetRect(&newRect, dx, dy);
+          }
              if (ON_LEFT_BORDER(hittest)) newRect.left += dx;
              else if (ON_RIGHT_BORDER(hittest)) newRect.right += dx;
              if (ON_TOP_BORDER(hittest)) newRect.top += dy;
@@ -1648,7 +1681,7 @@ NC_HandleNCLButtonDblClk(PWND pWnd, WPARAM wParam, LPARAM 
lParam)
       UserSystemParametersInfo(SPI_GETWORKAREA, 0, &mouseRect, 0);
         
       co_WinPosSetWindowPos(pWnd,
-                            0,
+                            NULL,
                             sizingRect.left,
                             mouseRect.top,
                             sizingRect.right - sizingRect.left,

Reply via email to