diff options
author | Michael Weghorn <m.weghorn@posteo.de> | 2023-07-24 10:50:20 +0200 |
---|---|---|
committer | Michael Weghorn <m.weghorn@posteo.de> | 2023-07-24 17:27:20 +0200 |
commit | 447b91964daf3ffed5bfd59382ba5724e9992fe8 (patch) | |
tree | 943ef1bc06bbbf201d25a246a6918b218eb9a9b3 /vcl | |
parent | 7b060d1c2acf03378c87abb7215f9c0a957b549c (diff) |
tdf#154447 qt: Take menu bar into account for popup pos
Change-Id I66b312fe09e078ec067773a483f9e59f627fcf93
("tdf#154447 Fix menu position in kf5") fixes the
position for menu popups for the case where no menu
bar is present, e.g. the default after switching to
the Tabbed interface.
While it improves the case where a menu bar is present,
the menu would would still open a bit too far up for
that case.
Adapt the position by the menu bar height to make that
case work as expected as well.
Do this in `QtMenu::ShowNativePopupMenu` for now since that's
easiest. Potentially, the height should have been taken
into consideration somewhere earlier, but since the whole
handling of menu bar height is quite "special", don't
aim to address that elsewhere now, s.a. an earlier attempt
to rework the whole handling in
commit afc828b9833b7a612369e95606ba56d41ef2c369
Date: Sat May 28 23:47:21 2022 +0200
VCL expect correct frame size for native menubars
which was later reverted in
commit f51b220b953ec71fb742f799fbe645a93cf3d944
Date: Fri Mar 24 08:06:56 2023 +0100
tdf#149805 tdf#151677 tdf#152217 tdf#154043 tdf#153458 tdf#153800 Revert "VCL expect
... correct frame size for native menubars"
Change-Id: Iafd80997f9f506cb22afe1aaf6d1a3f716700ea3
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154839
Tested-by: Jenkins
Tested-by: Rafael Lima <rafael.palma.lima@gmail.com>
Tested-by: Gabor Kelemen <kelemeng@ubuntu.com>
Reviewed-by: Gabor Kelemen <kelemeng@ubuntu.com>
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/inc/qt5/QtFrame.hxx | 2 | ||||
-rw-r--r-- | vcl/qt5/QtMenu.cxx | 8 |
2 files changed, 7 insertions, 3 deletions
diff --git a/vcl/inc/qt5/QtFrame.hxx b/vcl/inc/qt5/QtFrame.hxx index 09abe5301538..1fd010d7c8ae 100644 --- a/vcl/inc/qt5/QtFrame.hxx +++ b/vcl/inc/qt5/QtFrame.hxx @@ -131,7 +131,6 @@ 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(); @@ -146,6 +145,7 @@ public: QtMainWindow* GetTopLevelWindow() const { return m_pTopLevel; } QWidget* asChild() const; qreal devicePixelRatioF() const; + int menuBarOffset() const; void Damage(sal_Int32 nExtentsX, sal_Int32 nExtentsY, sal_Int32 nExtentsWidth, sal_Int32 nExtentsHeight) const; diff --git a/vcl/qt5/QtMenu.cxx b/vcl/qt5/QtMenu.cxx index b239b457ce9a..b976fa3f5739 100644 --- a/vcl/qt5/QtMenu.cxx +++ b/vcl/qt5/QtMenu.cxx @@ -837,9 +837,13 @@ bool QtMenu::ShowNativePopupMenu(FloatingWindow* pWin, const tools::Rectangle& r mpQMenu->setTearOffEnabled(bool(nFlags & FloatWinPopupFlags::AllowTearOff)); const VclPtr<vcl::Window> xParent = pWin->ImplGetWindowImpl()->mpRealParent; - const QtFrame* pFrame = static_cast<QtFrame*>(xParent->ImplGetFrame()); + tools::Rectangle aFloatRect = FloatingWindow::ImplConvertToAbsPos(xParent, rRect); + + // tdf#154447 Menu bar height has to be added + QtFrame* pFrame = static_cast<QtFrame*>(pWin->ImplGetFrame()); assert(pFrame); - const tools::Rectangle aFloatRect = FloatingWindow::ImplConvertToAbsPos(xParent, rRect); + aFloatRect.SetPosY(aFloatRect.getY() + pFrame->menuBarOffset()); + const QRect aRect = toQRect(aFloatRect, 1 / pFrame->devicePixelRatioF()); mpQMenu->exec(aRect.bottomLeft()); |