Commits

Anonymous committed 35977f0

vcl115: #i89397# SetWindowState now maximizes again on the correct screen

  • Participants
  • Parent commits ba0682b

Comments (0)

Files changed (1)

File vcl/win/source/window/salframe.cxx

 // =======================================================================
 
 static void UpdateFrameGeometry( HWND hWnd, WinSalFrame* pFrame );
-static void SetMaximizedFrameGeometry( HWND hWnd, WinSalFrame* pFrame );
+static void SetMaximizedFrameGeometry( HWND hWnd, WinSalFrame* pFrame, RECT* pParentRect = NULL );
 
 static void ImplSaveFrameState( WinSalFrame* pFrame )
 {
         }
     }
 
-    // Wenn Fenster nicht minimiert/maximiert ist oder nicht optisch
-    // umgesetzt werden muss, dann SetWindowPos() benutzen, da
-    // SetWindowPlacement() die TaskBar mit einrechnet
+    // if a window is neither minimized nor maximized or need not be
+    // positioned visibly (that is in visible state), do not use
+    // SetWindowPlacement since it calculates including the TaskBar
     if ( !IsIconic( mhWnd ) && !IsZoomed( mhWnd ) &&
          (!bVisible || (aPlacement.showCmd == SW_RESTORE)) )
     {
 		if( bUpdateHiddenFramePos )
 		{
+		    RECT aStateRect;
+		    aStateRect.left   = nX;
+		    aStateRect.top    = nY;
+		    aStateRect.right  = nX+nWidth;
+		    aStateRect.bottom = nY+nHeight;
 			// #96084 set a useful internal window size because
 			// the window will not be maximized (and the size updated) before show()
-            SetMaximizedFrameGeometry( mhWnd, this );
+            SetMaximizedFrameGeometry( mhWnd, this, &aStateRect );
+			SetWindowPos( mhWnd, 0,
+                          maGeometry.nX, maGeometry.nY, maGeometry.nWidth, maGeometry.nHeight,
+                          SWP_NOZORDER | SWP_NOACTIVATE | nPosSize );
 		}
 		else
 			SetWindowPos( mhWnd, 0,
 
 // -----------------------------------------------------------------------
 
-static void SetMaximizedFrameGeometry( HWND hWnd, WinSalFrame* pFrame )
+static void SetMaximizedFrameGeometry( HWND hWnd, WinSalFrame* pFrame, RECT* pParentRect )
 {
     // calculate and set frame geometry of a maximized window - useful if the window is still hidden
 
     // dualmonitor support:
     // Get screensize of the monitor whith the mouse pointer
 
-    POINT pt;
-    GetCursorPos( &pt );
     RECT aRectMouse;
-    aRectMouse.left = pt.x;
-    aRectMouse.top = pt.y;
-    aRectMouse.right = pt.x+2;
-    aRectMouse.bottom = pt.y+2;
+    if( ! pParentRect )
+    {
+        POINT pt;
+        GetCursorPos( &pt );
+        aRectMouse.left = pt.x;
+        aRectMouse.top = pt.y;
+        aRectMouse.right = pt.x+2;
+        aRectMouse.bottom = pt.y+2;
+        pParentRect = &aRectMouse;
+    }
 
     RECT aRect;
-    ImplSalGetWorkArea( hWnd, &aRect, &aRectMouse );
+    ImplSalGetWorkArea( hWnd, &aRect, pParentRect );
 
     // a maximized window has no other borders than the caption
     pFrame->maGeometry.nLeftDecoration = pFrame->maGeometry.nRightDecoration = pFrame->maGeometry.nBottomDecoration = 0;