diff options
author | ZenWalker <[email protected]> | 2017-08-20 04:35:51 +0200 |
---|---|---|
committer | raveit65 <[email protected]> | 2017-08-20 17:00:09 +0200 |
commit | 0568785bbd484714a63caa4b9ca9639a2867d6e9 (patch) | |
tree | ffcda2d32cb3b951a3e8d2c5c7e82204755e2cf7 /shell/ev-utils.c | |
parent | 444cec08e38299e5d6ae9489ae74d02f4e4a5f97 (diff) | |
download | atril-0568785bbd484714a63caa4b9ca9639a2867d6e9.tar.bz2 atril-0568785bbd484714a63caa4b9ca9639a2867d6e9.tar.xz |
gtk 3.22: avoid deprecated gdk_screen_get_monitor... functions:
avoid deprecated:
gdk_screen_get_monitor_geometry
gdk_screen_get_monitor_at_window
gdk_screen_get_monitor_at_point
Diffstat (limited to 'shell/ev-utils.c')
-rw-r--r-- | shell/ev-utils.c | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/shell/ev-utils.c b/shell/ev-utils.c index 8789ef88..d4a8ff76 100644 --- a/shell/ev-utils.c +++ b/shell/ev-utils.c @@ -26,14 +26,38 @@ #include <string.h> #include <glib/gi18n.h> +#if GTK_CHECK_VERSION(3, 22, 0) +static int +_gtk_get_monitor_num (GdkMonitor *monitor) +{ + GdkDisplay *display; + int n_monitors, i; + + display = gdk_monitor_get_display (monitor); + n_monitors = gdk_display_get_n_monitors (display); + + for(i = 0; i < n_monitors; i++) + { + if (gdk_display_get_monitor (display, i) == monitor) return i; + } + + return -1; +} +#endif + static void ev_gui_sanitise_popup_position (GtkMenu *menu, GtkWidget *widget, gint *x, gint *y) { +#if GTK_CHECK_VERSION (3, 22, 0) + GdkDisplay *display = gtk_widget_get_display (widget); + GdkMonitor *monitor_num; +#else GdkScreen *screen = gtk_widget_get_screen (widget); gint monitor_num; +#endif GdkRectangle monitor; GtkRequisition req; @@ -41,9 +65,15 @@ ev_gui_sanitise_popup_position (GtkMenu *menu, gtk_widget_get_preferred_size (GTK_WIDGET (menu), &req, NULL); +#if GTK_CHECK_VERSION (3, 22, 0) + monitor_num = gdk_display_get_monitor_at_point (display, *x, *y); + gtk_menu_set_monitor (menu, _gtk_get_monitor_num (monitor_num)); + gdk_monitor_get_geometry (monitor_num, &monitor); +#else monitor_num = gdk_screen_get_monitor_at_point (screen, *x, *y); gtk_menu_set_monitor (menu, monitor_num); gdk_screen_get_monitor_geometry (screen, monitor_num, &monitor); +#endif *x = CLAMP (*x, monitor.x, monitor.x + MAX (0, monitor.width - req.width)); *y = CLAMP (*y, monitor.y, monitor.y + MAX (0, monitor.height - req.height)); |