vcl/inc/qt5/QtFrame.hxx | 2 +- vcl/qt5/QtMenu.cxx | 10 +++++++--- 2 files changed, 8 insertions(+), 4 deletions(-)
New commits: commit 498565907f0cefb838c1c73a7983d04a61f7961b Author: Michael Weghorn <m.wegh...@posteo.de> AuthorDate: Mon Jul 24 10:50:20 2023 +0200 Commit: Gabor Kelemen <gabor.kelemen.ext...@allotropia.de> CommitDate: Tue Jul 25 11:38:03 2023 +0200 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.l...@gmail.com> Tested-by: Gabor Kelemen <kelem...@ubuntu.com> Reviewed-by: Gabor Kelemen <kelem...@ubuntu.com> diff --git a/vcl/inc/qt5/QtFrame.hxx b/vcl/inc/qt5/QtFrame.hxx index 23a4fd9887f1..ca9736ab933d 100644 --- a/vcl/inc/qt5/QtFrame.hxx +++ b/vcl/inc/qt5/QtFrame.hxx @@ -134,7 +134,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(); @@ -149,6 +148,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 84ad3f460c7f..b9c54ed04c9d 100644 --- a/vcl/qt5/QtMenu.cxx +++ b/vcl/qt5/QtMenu.cxx @@ -684,9 +684,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()); commit b1d1a27d78c95ebd22fd681715dbf73dd23224b4 Author: Rafael Lima <rafael.palma.l...@gmail.com> AuthorDate: Sun Jul 23 14:57:58 2023 +0200 Commit: Gabor Kelemen <gabor.kelemen.ext...@allotropia.de> CommitDate: Tue Jul 25 11:37:36 2023 +0200 tdf#154447 Fix menu position in kf5 Prior to this patch the menus were using "topLeft" as reference for positioning the menu, which made them appear on top of the control that originated their appearance. With this patch, it now uses "bototmLeft" to place the menu below the control (similar to gtk3). Change-Id: I66b312fe09e078ec067773a483f9e59f627fcf93 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154771 Tested-by: Jenkins Tested-by: Gabor Kelemen <kelem...@ubuntu.com> Reviewed-by: Gabor Kelemen <kelem...@ubuntu.com> Reviewed-by: Michael Weghorn <m.wegh...@posteo.de> diff --git a/vcl/qt5/QtMenu.cxx b/vcl/qt5/QtMenu.cxx index 0646c9232d5d..84ad3f460c7f 100644 --- a/vcl/qt5/QtMenu.cxx +++ b/vcl/qt5/QtMenu.cxx @@ -688,7 +688,7 @@ bool QtMenu::ShowNativePopupMenu(FloatingWindow* pWin, const tools::Rectangle& r assert(pFrame); const tools::Rectangle aFloatRect = FloatingWindow::ImplConvertToAbsPos(xParent, rRect); const QRect aRect = toQRect(aFloatRect, 1 / pFrame->devicePixelRatioF()); - mpQMenu->exec(aRect.topLeft()); + mpQMenu->exec(aRect.bottomLeft()); return true; }