vcl/qt5/QtMenu.cxx | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)
New commits: commit ee3976f2c613f9015477ab327996c074e8516f9d Author: Michael Weghorn <m.wegh...@posteo.de> AuthorDate: Fri Jun 24 10:27:04 2022 +0200 Commit: Michael Weghorn <m.wegh...@posteo.de> CommitDate: Fri Jul 1 07:28:01 2022 +0200 tdf#149680 qt: Open native popup menu at given position Calculate the position at which to open the popup menu from the passed window and rectangle, rather than always opening the native popup menu at the cursor position. The commit message in commit 1e0b16f8695498e4eea7c2208aabf7e7664ce749 Date: Wed Feb 12 08:07:42 2020 +0100 tdf#128921 tdf#130341 tdf#122053 qt5: Native PopupMenus which had implemented native poup menus, already said: > For now, this always shows the popup menu at cursor position, which > can be changed by taking the Rectangle passed to > 'Qt5Menu::ShowNativePopupMenu' into account if there should be any > need. Change-Id: If1a44b6d53f3dcd6fa7ceec0738219f11cfc22c4 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136356 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.wegh...@posteo.de> diff --git a/vcl/qt5/QtMenu.cxx b/vcl/qt5/QtMenu.cxx index 5a4d3e859e9d..c1e4cb0e1a29 100644 --- a/vcl/qt5/QtMenu.cxx +++ b/vcl/qt5/QtMenu.cxx @@ -828,15 +828,19 @@ void QtMenu::ShowCloseButton(bool bShow) lcl_force_menubar_layout_update(*mpQMenuBar); } -bool QtMenu::ShowNativePopupMenu(FloatingWindow*, const tools::Rectangle&, +bool QtMenu::ShowNativePopupMenu(FloatingWindow* pWin, const tools::Rectangle& rRect, FloatWinPopupFlags nFlags) { assert(mpQMenu); DoFullMenuUpdate(mpVCLMenu); mpQMenu->setTearOffEnabled(bool(nFlags & FloatWinPopupFlags::AllowTearOff)); - const QPoint aPos = QCursor::pos(); - mpQMenu->exec(aPos); + const VclPtr<vcl::Window> xParent = pWin->ImplGetWindowImpl()->mpRealParent; + const QtFrame* pFrame = static_cast<QtFrame*>(xParent->ImplGetFrame()); + assert(pFrame); + const tools::Rectangle aFloatRect = FloatingWindow::ImplConvertToAbsPos(xParent, rRect); + const QRect aRect = toQRect(aFloatRect, 1 / pFrame->devicePixelRatioF()); + mpQMenu->exec(aRect.topLeft()); return true; }