Commit de650dea authored by Germán Poo-Caamaño's avatar Germán Poo-Caamaño

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).
parent 3053a3d4
......@@ -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));
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment