summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorJan-Marek Glogowski <glogow@fbihome.de>2021-12-20 13:32:52 +0100
committerJan-Marek Glogowski <glogow@fbihome.de>2021-12-21 13:35:49 +0100
commitca28826a087245686d7fca3ffc8ca1f03307924d (patch)
tree9a4e57afb004e2328be32bf38dab5b83d8f57114 /vcl
parentb927eaa6db173702eb81ca610e751b157978fd9e (diff)
tdf#131467 Qt set default position on first resize
Setting the position in Show() is too late, because LO will try to set the mouse pointer to the default button, if configured. That obviously needs the window position. And also take the menubar offset into account. Change-Id: Ia280539c082ff6f675966869fb6643a41a17d696 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/127154 Tested-by: Jenkins Reviewed-by: Jan-Marek Glogowski <glogow@fbihome.de>
Diffstat (limited to 'vcl')
-rw-r--r--vcl/inc/qt5/QtFrame.hxx1
-rw-r--r--vcl/qt5/QtFrame.cxx20
2 files changed, 15 insertions, 6 deletions
diff --git a/vcl/inc/qt5/QtFrame.hxx b/vcl/inc/qt5/QtFrame.hxx
index 61d175cf2625..9aa31504bcd3 100644
--- a/vcl/inc/qt5/QtFrame.hxx
+++ b/vcl/inc/qt5/QtFrame.hxx
@@ -129,6 +129,7 @@ class VCLPLUG_QT_PUBLIC QtFrame : public QObject, public SalFrame
bool isMinimized() const;
bool isMaximized() const;
void SetWindowStateImpl(Qt::WindowStates eState);
+ int menuBarOffset() const;
void fixICCCMwindowGroup();
void modalReparent(bool bVisible);
diff --git a/vcl/qt5/QtFrame.cxx b/vcl/qt5/QtFrame.cxx
index 15795b3e84e6..19d9c826f625 100644
--- a/vcl/qt5/QtFrame.cxx
+++ b/vcl/qt5/QtFrame.cxx
@@ -469,7 +469,6 @@ void QtFrame::Show(bool bVisible, bool bNoActivate)
// show
SetDefaultSize();
- SetDefaultPos();
pSalInst->RunInMainThread([this, bNoActivate]() {
QWidget* const pChild = asChild();
@@ -503,6 +502,14 @@ void QtFrame::SetMaxClientSize(tools::Long nWidth, tools::Long nHeight)
}
}
+int QtFrame::menuBarOffset() const
+{
+ QtMainWindow* pTopLevel = m_pParent->GetTopLevelWindow();
+ if (pTopLevel && pTopLevel->menuBar() && pTopLevel->menuBar()->isVisible())
+ return round(pTopLevel->menuBar()->geometry().height() * devicePixelRatioF());
+ return 0;
+}
+
void QtFrame::SetDefaultPos()
{
if (!m_bDefaultPos)
@@ -515,6 +522,7 @@ void QtFrame::SetDefaultPos()
QWidget* const pParentWin = m_pParent->asChild()->window();
QWidget* const pChildWin = asChild()->window();
QPoint aPos = (pParentWin->rect().center() - pChildWin->rect().center()) * fRatio;
+ aPos.ry() -= menuBarOffset();
SetPosSize(aPos.x(), aPos.y(), 0, 0, SAL_FRAME_POSSIZE_X | SAL_FRAME_POSSIZE_Y);
assert(!m_bDefaultPos);
}
@@ -603,7 +611,11 @@ void QtFrame::SetPosSize(tools::Long nX, tools::Long nY, tools::Long nWidth, too
}
if (!(nFlags & (SAL_FRAME_POSSIZE_X | SAL_FRAME_POSSIZE_Y)))
+ {
+ if (nFlags & (SAL_FRAME_POSSIZE_WIDTH | SAL_FRAME_POSSIZE_HEIGHT))
+ SetDefaultPos();
return;
+ }
if (m_pParent)
{
@@ -612,11 +624,7 @@ void QtFrame::SetPosSize(tools::Long nX, tools::Long nY, tools::Long nWidth, too
nX = aParentGeometry.nX + aParentGeometry.nWidth - nX - maGeometry.nWidth - 1;
else
nX += aParentGeometry.nX;
- nY += aParentGeometry.nY;
-
- QtMainWindow* pTopLevel = m_pParent->GetTopLevelWindow();
- if (pTopLevel && pTopLevel->menuBar() && pTopLevel->menuBar()->isVisible())
- nY += round(pTopLevel->menuBar()->geometry().height() * devicePixelRatioF());
+ nY += aParentGeometry.nY + menuBarOffset();
}
if (!(nFlags & SAL_FRAME_POSSIZE_X))