[Libreoffice-commits] core.git: vcl/unx
Caolán McNamara (via logerrit)
logerrit at kemper.freedesktop.org
Tue May 11 07:43:55 UTC 2021
vcl/unx/gtk3/gtksalmenu.cxx | 29 ++++++++++++++++++++---------
1 file changed, 20 insertions(+), 9 deletions(-)
New commits:
commit 18b27b017ea8221b33f7e169f7725d3b9fc13c53
Author: Caolán McNamara <caolanm at redhat.com>
AuthorDate: Mon May 10 20:12:30 2021 +0100
Commit: Caolán McNamara <caolanm at redhat.com>
CommitDate: Tue May 11 09:42:39 2021 +0200
gtk4: get context menus working
Change-Id: I14fe637ce3539196cffba90851f57193afc9b76b
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/115359
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm at redhat.com>
diff --git a/vcl/unx/gtk3/gtksalmenu.cxx b/vcl/unx/gtk3/gtksalmenu.cxx
index b965880cfbcb..5f9b20effbbf 100644
--- a/vcl/unx/gtk3/gtksalmenu.cxx
+++ b/vcl/unx/gtk3/gtksalmenu.cxx
@@ -456,6 +456,25 @@ bool GtkSalMenu::ShowNativePopupMenu(FloatingWindow* pWin, const tools::Rectangl
// don't allow any more to appear until menu is dismissed
mpFrame->BlockTooltip();
+#if GTK_CHECK_VERSION(4, 0, 0)
+ tools::Rectangle aFloatRect = FloatingWindow::ImplConvertToAbsPos(xParent, rRect);
+ aFloatRect.Move(-mpFrame->maGeometry.nX, -mpFrame->maGeometry.nY);
+ GdkRectangle rect {static_cast<int>(aFloatRect.Left()), static_cast<int>(aFloatRect.Top()),
+ static_cast<int>(aFloatRect.GetWidth()), static_cast<int>(aFloatRect.GetHeight())};
+
+ gtk_popover_set_pointing_to(GTK_POPOVER(pWidget), &rect);
+
+ if (nFlags & FloatWinPopupFlags::Left)
+ gtk_popover_set_position(GTK_POPOVER(pWidget), GTK_POS_LEFT);
+ else if (nFlags & FloatWinPopupFlags::Up)
+ gtk_popover_set_position(GTK_POPOVER(pWidget), GTK_POS_TOP);
+ else if (nFlags & FloatWinPopupFlags::Right)
+ gtk_popover_set_position(GTK_POPOVER(pWidget), GTK_POS_RIGHT);
+ else
+ gtk_popover_set_position(GTK_POPOVER(pWidget), GTK_POS_BOTTOM);
+
+ gtk_popover_popup(GTK_POPOVER(pWidget));
+#else
#if GTK_CHECK_VERSION(3,22,0)
if (gtk_check_version(3, 22, 0) == nullptr)
{
@@ -464,7 +483,6 @@ bool GtkSalMenu::ShowNativePopupMenu(FloatingWindow* pWin, const tools::Rectangl
GdkRectangle rect {static_cast<int>(aFloatRect.Left()), static_cast<int>(aFloatRect.Top()),
static_cast<int>(aFloatRect.GetWidth()), static_cast<int>(aFloatRect.GetHeight())};
-#if !GTK_CHECK_VERSION(4, 0, 0)
GdkGravity rect_anchor = GDK_GRAVITY_SOUTH_WEST, menu_anchor = GDK_GRAVITY_NORTH_WEST;
if (nFlags & FloatWinPopupFlags::Left)
@@ -484,17 +502,10 @@ bool GtkSalMenu::ShowNativePopupMenu(FloatingWindow* pWin, const tools::Rectangl
GdkWindow* gdkWindow = gtk_widget_get_window(mpFrame->getMouseEventWidget());
gtk_menu_popup_at_rect(GTK_MENU(pWidget), gdkWindow, &rect, rect_anchor, menu_anchor, nullptr);
-#else
- gtk_popover_set_pointing_to(GTK_POPOVER(pWidget), &rect);
- (void)nFlags;
- //TODO use gtk_popover_set_position
- gtk_popover_popup(GTK_POPOVER(pWidget));
-#endif
}
else
#endif
{
-#if !GTK_CHECK_VERSION(4, 0, 0)
guint nButton;
guint32 nTime;
@@ -521,8 +532,8 @@ bool GtkSalMenu::ShowNativePopupMenu(FloatingWindow* pWin, const tools::Rectangl
gtk_menu_popup(GTK_MENU(pWidget), nullptr, nullptr, MenuPositionFunc,
&aPos, nButton, nTime);
-#endif
}
+#endif
if (g_main_loop_is_running(pLoop))
{
More information about the Libreoffice-commits
mailing list