[evince] shell: Replace deprecated symbols on ev-utils
- From: Germán Poo-Caamaño <gpoo src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evince] shell: Replace deprecated symbols on ev-utils
- Date: Mon, 12 Nov 2018 19:13:17 +0000 (UTC)
commit de650dea42e401987f4349d5e5917debb93b0fcb
Author: Germán Poo-Caamaño <gpoo gnome org>
Date: Mon Nov 12 16:04:45 2018 -0300
shell: Replace deprecated symbols on ev-utils
Add helped function to determine monitor number based on the
current that is not deprecated. Function is useful to determine
where to display a popup menu when invoked with the keyboard
(e.g. Shift+F10).
shell/ev-utils.c | 30 ++++++++++++++++++++++++------
1 file changed, 24 insertions(+), 6 deletions(-)
---
diff --git a/shell/ev-utils.c b/shell/ev-utils.c
index 44b7d61a..50d3906b 100644
--- a/shell/ev-utils.c
+++ b/shell/ev-utils.c
@@ -212,27 +212,45 @@ ev_print_region_contents (cairo_region_t *region)
}
}
+static gint
+get_monitor_number (GdkDisplay *display,
+ GdkMonitor *monitor)
+{
+ gint i;
+
+ for (i = 0; i < gdk_display_get_n_monitors (display); i++) {
+ if (monitor == gdk_display_get_monitor (display, i))
+ return i;
+ }
+ /* Assume monitor 0 if none */
+ return 0;
+}
+
static void
ev_gui_sanitise_popup_position (GtkMenu *menu,
GtkWidget *widget,
gint *x,
gint *y)
{
- GdkScreen *screen = gtk_widget_get_screen (widget);
+ GdkDisplay *display;
+ GdkMonitor *monitor;
+ GdkRectangle geometry;
gint monitor_num;
- GdkRectangle monitor;
GtkRequisition req;
g_return_if_fail (widget != NULL);
gtk_widget_get_preferred_size (GTK_WIDGET (menu), &req, NULL);
- monitor_num = gdk_screen_get_monitor_at_point (screen, *x, *y);
+ display = gtk_widget_get_display (widget);
+ monitor = gdk_display_get_monitor_at_point (display, *x, *y);
+ monitor_num = get_monitor_number (display, monitor);
gtk_menu_set_monitor (menu, monitor_num);
- gdk_screen_get_monitor_geometry (screen, monitor_num, &monitor);
- *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));
+ gdk_monitor_get_geometry (monitor, &geometry);
+
+ *x = CLAMP (*x, geometry.x, geometry.x + MAX (0, geometry.width - req.width));
+ *y = CLAMP (*y, geometry.y, geometry.y + MAX (0, geometry.height - req.height));
}
void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]