diff options
-rw-r--r-- | libview/ev-view-presentation.c | 11 | ||||
-rw-r--r-- | shell/ev-navigation-action-widget.c | 16 | ||||
-rw-r--r-- | shell/ev-utils.c | 30 |
3 files changed, 57 insertions, 0 deletions
diff --git a/libview/ev-view-presentation.c b/libview/ev-view-presentation.c index 40dea3ea..1dae35d5 100644 --- a/libview/ev-view-presentation.c +++ b/libview/ev-view-presentation.c @@ -1213,12 +1213,23 @@ static gboolean init_presentation (GtkWidget *widget) { EvViewPresentation *pview = EV_VIEW_PRESENTATION (widget); +#if GTK_CHECK_VERSION (3, 22, 0) + GdkDisplay *display = gtk_widget_get_display (widget); + GdkRectangle monitor; + GdkMonitor *monitor_num; +#else GdkScreen *screen = gtk_widget_get_screen (widget); GdkRectangle monitor; gint monitor_num; +#endif +#if GTK_CHECK_VERSION (3, 22, 0) + monitor_num = gdk_display_get_monitor_at_window (display, gtk_widget_get_window (widget)); + gdk_monitor_get_geometry (monitor_num, &monitor); +#else monitor_num = gdk_screen_get_monitor_at_window (screen, gtk_widget_get_window (widget)); gdk_screen_get_monitor_geometry (screen, monitor_num, &monitor); +#endif pview->monitor_width = monitor.width; pview->monitor_height = monitor.height; diff --git a/shell/ev-navigation-action-widget.c b/shell/ev-navigation-action-widget.c index de60674f..97bd0da5 100644 --- a/shell/ev-navigation-action-widget.c +++ b/shell/ev-navigation-action-widget.c @@ -131,18 +131,34 @@ menu_position_func (GtkMenu *menu, GtkTextDirection direction; GdkWindow *gdk_window; GdkRectangle monitor; +#if GTK_CHECK_VERSION (3, 22, 0) + GdkMonitor *monitor_num; + GdkDisplay *display; +#else gint monitor_num; GdkScreen *screen; +#endif gtk_widget_get_preferred_size (GTK_WIDGET (button->menu), &menu_req, NULL); direction = gtk_widget_get_direction (widget); +#if GTK_CHECK_VERSION (3, 22, 0) + display = gtk_widget_get_display (GTK_WIDGET (menu)); +#else screen = gtk_widget_get_screen (GTK_WIDGET (menu)); +#endif gdk_window = gtk_widget_get_window (widget); +#if GTK_CHECK_VERSION (3, 22, 0) + monitor_num = gdk_display_get_monitor_at_window (display, gdk_window); + if (monitor_num == NULL) + monitor_num = gdk_display_get_monitor (display, 0); + gdk_monitor_get_geometry (monitor_num, &monitor); +#else monitor_num = gdk_screen_get_monitor_at_window (screen, gdk_window); if (monitor_num < 0) monitor_num = 0; gdk_screen_get_monitor_geometry (screen, monitor_num, &monitor); +#endif gdk_window_get_origin (gdk_window, x, y); gtk_widget_get_allocation (widget, &allocation); 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)); |