include/vcl/syswin.hxx        |    2 +-
 vcl/source/app/salvtables.cxx |    6 +++---
 vcl/source/window/layout.cxx  |    2 +-
 vcl/source/window/syswin.cxx  |    9 ++++-----
 4 files changed, 9 insertions(+), 10 deletions(-)

New commits:
commit 0d5c5c17a43726c1407d100e440a87ed06966d30
Author:     Caolán McNamara <[email protected]>
AuthorDate: Thu Apr 14 10:37:04 2022 +0100
Commit:     Caolán McNamara <[email protected]>
CommitDate: Thu Apr 14 17:15:56 2022 +0200

    Resolves: tdf#148476 allow dialog resize buttons to "shrink" again
    
    a problem since:
    
    commit 5d388b94735e34ba445d65e1d5030a646aad7dbe
    Date:   Thu Jan 27 12:17:48 2022 +0000
    
        Related: tdf#146648 let SetWindowState size trump the initial layout 
pref size
    
    Change-Id: Ia765fc011e740386fce568704cb1efb066a5d5bc
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133001
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <[email protected]>

diff --git a/include/vcl/syswin.hxx b/include/vcl/syswin.hxx
index 03d79f2e3497..24f41331eb21 100644
--- a/include/vcl/syswin.hxx
+++ b/include/vcl/syswin.hxx
@@ -159,7 +159,7 @@ public:
     virtual Size    GetOptimalSize() const override;
     virtual void    queue_resize(StateChangedType eReason = 
StateChangedType::Layout) override;
     bool            isLayoutEnabled() const;
-    void            setOptimalLayoutSize();
+    void            setOptimalLayoutSize(bool bAllowWindowShrink);
     bool            isCalculatingInitialLayoutSize() const { return 
mbIsCalculatingInitialLayoutSize; }
 
     void            SetIcon( sal_uInt16 nIcon );
diff --git a/vcl/source/app/salvtables.cxx b/vcl/source/app/salvtables.cxx
index 7d0a62057231..fad841f45787 100644
--- a/vcl/source/app/salvtables.cxx
+++ b/vcl/source/app/salvtables.cxx
@@ -1439,7 +1439,7 @@ void resize_to_request(vcl::Window* pWindow)
 {
     if (SystemWindow* pSysWin = dynamic_cast<SystemWindow*>(pWindow))
     {
-        pSysWin->setOptimalLayoutSize();
+        pSysWin->setOptimalLayoutSize(true);
         return;
     }
     if (DockingWindow* pDockWin = dynamic_cast<DockingWindow*>(pWindow))
@@ -1695,7 +1695,7 @@ void SalInstanceDialog::collapse(weld::Widget* pEdit, 
weld::Widget* pButton)
     m_xDialog->set_border_width(0);
     if (vcl::Window* pActionArea = m_xDialog->get_action_area())
         pActionArea->Hide();
-    m_xDialog->setOptimalLayoutSize();
+    m_xDialog->setOptimalLayoutSize(true);
     m_xRefEdit = pRefEdit;
 }
 
@@ -1713,7 +1713,7 @@ void SalInstanceDialog::undo_collapse()
     m_xDialog->set_border_width(m_nOldBorderWidth);
     if (vcl::Window* pActionArea = m_xDialog->get_action_area())
         pActionArea->Show();
-    m_xDialog->setOptimalLayoutSize();
+    m_xDialog->setOptimalLayoutSize(true);
 }
 
 void SalInstanceDialog::SetInstallLOKNotifierHdl(
diff --git a/vcl/source/window/layout.cxx b/vcl/source/window/layout.cxx
index 99b60673b7c0..b67ffeabbfd4 100644
--- a/vcl/source/window/layout.cxx
+++ b/vcl/source/window/layout.cxx
@@ -1812,7 +1812,7 @@ IMPL_LINK( VclExpander, ClickHdl, CheckBox&, rBtn, void )
         queue_resize();
         Dialog* pResizeDialog = m_bResizeTopLevel ? GetParentDialog() : 
nullptr;
         if (pResizeDialog)
-            pResizeDialog->setOptimalLayoutSize();
+            pResizeDialog->setOptimalLayoutSize(true);
     }
     maExpandedHdl.Call(*this);
 }
diff --git a/vcl/source/window/syswin.cxx b/vcl/source/window/syswin.cxx
index bf6be3b0ab10..40fff00aa7d9 100644
--- a/vcl/source/window/syswin.cxx
+++ b/vcl/source/window/syswin.cxx
@@ -1070,7 +1070,7 @@ void SystemWindow::settingOptimalLayoutSize(Window* 
/*pBox*/)
 {
 }
 
-void SystemWindow::setOptimalLayoutSize()
+void SystemWindow::setOptimalLayoutSize(bool bAllowWindowShrink)
 {
     maLayoutIdle.Stop();
 
@@ -1088,9 +1088,7 @@ void SystemWindow::setOptimalLayoutSize()
 
     SetMinOutputSizePixel(aSize);
 
-    if (!mbInitialLayoutSizeCalculated)
-        mbInitialLayoutSizeCalculated = true;
-    else
+    if (!bAllowWindowShrink)
     {
         Size aCurrentSize = GetSizePixel();
         aSize.setWidth(std::max(aSize.Width(), aCurrentSize.Width()));
@@ -1110,7 +1108,8 @@ void SystemWindow::DoInitialLayout()
     {
         mbIsCalculatingInitialLayoutSize = true;
         setDeferredProperties();
-        setOptimalLayoutSize();
+        setOptimalLayoutSize(!mbInitialLayoutSizeCalculated);
+        mbInitialLayoutSizeCalculated = true;
         mbIsCalculatingInitialLayoutSize = false;
     }
 }

Reply via email to