vcl/inc/qt5/QtFrame.hxx |    2 +-
 vcl/qt5/QtMenu.cxx      |   10 +++++++---
 2 files changed, 8 insertions(+), 4 deletions(-)

New commits:
commit 447b91964daf3ffed5bfd59382ba5724e9992fe8
Author:     Michael Weghorn <m.wegh...@posteo.de>
AuthorDate: Mon Jul 24 10:50:20 2023 +0200
Commit:     Michael Weghorn <m.wegh...@posteo.de>
CommitDate: Mon Jul 24 17:27:20 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 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());
 
commit 7b060d1c2acf03378c87abb7215f9c0a957b549c
Author:     Rafael Lima <rafael.palma.l...@gmail.com>
AuthorDate: Sun Jul 23 14:57:58 2023 +0200
Commit:     Michael Weghorn <m.wegh...@posteo.de>
CommitDate: Mon Jul 24 17:27:12 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 dca03050c30e..b239b457ce9a 100644
--- a/vcl/qt5/QtMenu.cxx
+++ b/vcl/qt5/QtMenu.cxx
@@ -841,7 +841,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;
 }

Reply via email to