include/vcl/syswin.hxx       |    1 +
 vcl/source/window/syswin.cxx |   16 ++++++++++++++++
 2 files changed, 17 insertions(+)

New commits:
commit 5d388b94735e34ba445d65e1d5030a646aad7dbe
Author:     Caolán McNamara <caol...@redhat.com>
AuthorDate: Thu Jan 27 12:17:48 2022 +0000
Commit:     Caolán McNamara <caol...@redhat.com>
CommitDate: Thu Jan 27 15:03:53 2022 +0100

    Related: tdf#146648 let SetWindowState size trump the initial layout pref 
size
    
    so a size can be restored from config and overrule the initial layout
    size which is calculated on first show.
    
    for existing cases, this changes behaviour if a dialog is shown,
    hidden, layout changed and then reshown and the new layout is smaller
    than the old layout. But that should align the behaviour of vcl
    layout-enabled widgets with gtk ones.
    
    Change-Id: I526f16dba91ccfd6d52c63a17e5dc51bf79750a7
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/129037
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caol...@redhat.com>

diff --git a/include/vcl/syswin.hxx b/include/vcl/syswin.hxx
index 0c35073aec09..71661908fd86 100644
--- a/include/vcl/syswin.hxx
+++ b/include/vcl/syswin.hxx
@@ -103,6 +103,7 @@ private:
     bool            mbHideBtn;
     bool            mbSysChild;
     bool            mbIsCalculatingInitialLayoutSize;
+    bool            mbInitialLayoutSizeCalculated;
     bool            mbPaintComplete;
     MenuBarMode     mnMenuBarMode;
     sal_uInt16      mnIcon;
diff --git a/vcl/source/window/syswin.cxx b/vcl/source/window/syswin.cxx
index c624c373aa77..f691f62dfda3 100644
--- a/vcl/source/window/syswin.cxx
+++ b/vcl/source/window/syswin.cxx
@@ -70,6 +70,7 @@ SystemWindow::SystemWindow(WindowType nType, const char* 
pIdleDebugName)
     , mbHideBtn(false)
     , mbSysChild(false)
     , mbIsCalculatingInitialLayoutSize(false)
+    , mbInitialLayoutSizeCalculated(false)
     , mbPaintComplete(false)
     , mnMenuBarMode(MenuBarMode::Normal)
     , mnIcon(0)
@@ -746,6 +747,11 @@ void SystemWindow::SetWindowStateData( const 
WindowStateData& rData )
             nY = rGeom.nHeight - nHeight;
         setPosSizePixel( nX, nY, nWidth, nHeight, nPosSize );
     }
+
+    // tdf#146648 if an explicit size state was set, then use it as the 
preferred
+    // size for layout
+    if (nValidMask & WindowStateMask::Size)
+        mbInitialLayoutSizeCalculated = true;
 }
 
 void SystemWindow::GetWindowStateData( WindowStateData& rData ) const
@@ -1081,6 +1087,16 @@ void SystemWindow::setOptimalLayoutSize()
     aSize.setHeight( std::min(aMax.Height(), aSize.Height()) );
 
     SetMinOutputSizePixel(aSize);
+
+    if (!mbInitialLayoutSizeCalculated)
+        mbInitialLayoutSizeCalculated = true;
+    else
+    {
+        Size aCurrentSize = GetSizePixel();
+        aSize.setWidth(std::max(aSize.Width(), aCurrentSize.Width()));
+        aSize.setHeight(std::max(aSize.Height(), aCurrentSize.Height()));
+    }
+
     SetSizePixel(aSize);
     setPosSizeOnContainee(aSize, *pBox);
 }

Reply via email to