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 <caolanm@redhat.com>
diff --git a/include/vcl/syswin.hxx b/include/vcl/syswin.hxx
index 03d79f2..24f4133 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 7d0a620..fad841f 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 99b6067..b67ffea 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 bf6be3b..40fff00 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;
}
}