[Libreoffice-commits] core.git: vcl/unx
Caolán McNamara (via logerrit)
logerrit at kemper.freedesktop.org
Tue Dec 15 08:45:32 UTC 2020
vcl/unx/gtk3/gtk3gtkinst.cxx | 25 +++++++++++++++++++++----
1 file changed, 21 insertions(+), 4 deletions(-)
New commits:
commit ba48287d486190a5daec7ef9612fbe7f361228d1
Author: Caolán McNamara <caolanm at redhat.com>
AuthorDate: Mon Dec 14 14:52:40 2020 +0000
Commit: Caolán McNamara <caolanm at redhat.com>
CommitDate: Tue Dec 15 09:44:54 2020 +0100
popup_at_rect needs to work like ShowNativePopupMenu for toplevel frame
Change-Id: Iec313faa525ddd5564009403060c58d72482038a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/107726
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm at redhat.com>
diff --git a/vcl/unx/gtk3/gtk3gtkinst.cxx b/vcl/unx/gtk3/gtk3gtkinst.cxx
index 1f59a80637cd..06c7c75121eb 100644
--- a/vcl/unx/gtk3/gtk3gtkinst.cxx
+++ b/vcl/unx/gtk3/gtk3gtkinst.cxx
@@ -26,6 +26,7 @@
#include <unx/gtk/gtksalmenu.hxx>
#include <headless/svpvd.hxx>
#include <headless/svpbmp.hxx>
+#include <vcl/floatwin.hxx>
#include <vcl/inputtypes.hxx>
#include <vcl/transfer.hxx>
#include <unx/genpspgraphics.h>
@@ -8104,10 +8105,26 @@ public:
#if GTK_CHECK_VERSION(3,22,0)
if (gtk_check_version(3, 22, 0) == nullptr)
{
- GdkRectangle aRect{static_cast<int>(rRect.Left()), static_cast<int>(rRect.Top()),
- static_cast<int>(rRect.GetWidth()), static_cast<int>(rRect.GetHeight())};
- if (SwapForRTL(pWidget))
- aRect.x = gtk_widget_get_allocated_width(pWidget) - aRect.width - 1 - aRect.x;
+ GdkRectangle aRect;
+ if (GtkSalFrame* pFrame = GtkSalFrame::getFromWindow(pWidget))
+ {
+ // this is the relatively unusual case where pParent is the toplevel GtkSalFrame and not a stock GtkWidget
+ // so use the same style of logic as GtkSalMenu::ShowNativePopupMenu to get the right position
+ tools::Rectangle aFloatRect = FloatingWindow::ImplConvertToAbsPos(pFrame->GetWindow(), rRect);
+ aFloatRect.Move(-pFrame->maGeometry.nX, -pFrame->maGeometry.nY);
+
+ aRect = GdkRectangle{static_cast<int>(aFloatRect.Left()), static_cast<int>(aFloatRect.Top()),
+ static_cast<int>(aFloatRect.GetWidth()), static_cast<int>(aFloatRect.GetHeight())};
+
+ pWidget = pFrame->getMouseEventWidget();
+ }
+ else
+ {
+ aRect = GdkRectangle{static_cast<int>(rRect.Left()), static_cast<int>(rRect.Top()),
+ static_cast<int>(rRect.GetWidth()), static_cast<int>(rRect.GetHeight())};
+ if (SwapForRTL(pWidget))
+ aRect.x = gtk_widget_get_allocated_width(pWidget) - aRect.width - 1 - aRect.x;
+ }
// Send a keyboard event through gtk_main_do_event to toggle any active tooltip offs
// before trying to launch the menu
More information about the Libreoffice-commits
mailing list