From 1887cdedfeb7ab3d5a0e6148a6c842c59f0ef1f3 Mon Sep 17 00:00:00 2001 From: Neil Date: Wed, 4 Jan 2017 09:55:33 +1100 Subject: Use new simplified API for showing menu on GTK+ 3.22 as old API was deprecated. --- doc/ScintillaHistory.html | 1 + gtk/PlatGTK.cxx | 14 +++++++++++--- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/doc/ScintillaHistory.html b/doc/ScintillaHistory.html index 6f97a07ff..fcca31931 100644 --- a/doc/ScintillaHistory.html +++ b/doc/ScintillaHistory.html @@ -530,6 +530,7 @@
  • Fix display of autocompletion lists and calltips on GTK+ 3.22 on Wayland. + Newer APIs used on GTK+ 3.22 as older APIs were deprecated.
  • diff --git a/gtk/PlatGTK.cxx b/gtk/PlatGTK.cxx index d35a379ba..fe207cece 100644 --- a/gtk/PlatGTK.cxx +++ b/gtk/PlatGTK.cxx @@ -1914,17 +1914,24 @@ void Menu::Destroy() { mid = 0; } +#if !GTK_CHECK_VERSION(3,22,0) static void MenuPositionFunc(GtkMenu *, gint *x, gint *y, gboolean *, gpointer userData) { sptr_t intFromPointer = GPOINTER_TO_INT(userData); *x = intFromPointer & 0xffff; *y = intFromPointer >> 16; } +#endif -void Menu::Show(Point pt, Window &) { - int screenHeight = gdk_screen_height(); - int screenWidth = gdk_screen_width(); +void Menu::Show(Point pt, Window &wnd) { GtkMenu *widget = static_cast(mid); gtk_widget_show_all(GTK_WIDGET(widget)); +#if GTK_CHECK_VERSION(3,22,0) + // Rely on GTK+ to do the right thing with positioning + gtk_menu_popup_at_pointer(widget, NULL); +#else + GdkRectangle rcScreen = MonitorRectangleForWidget(PWidget(wnd.GetID())); + const int screenWidth = rcScreen.width; + const int screenHeight = rcScreen.height; GtkRequisition requisition; #if GTK_CHECK_VERSION(3,0,0) gtk_widget_get_preferred_size(GTK_WIDGET(widget), NULL, &requisition); @@ -1940,6 +1947,7 @@ void Menu::Show(Point pt, Window &) { gtk_menu_popup(widget, NULL, NULL, MenuPositionFunc, GINT_TO_POINTER((static_cast(pt.y) << 16) | static_cast(pt.x)), 0, gtk_get_current_event_time()); +#endif } ElapsedTime::ElapsedTime() { -- cgit v1.2.3