summaryrefslogtreecommitdiff
path: root/drivemount/drive-button.c
diff options
context:
space:
mode:
authorZenWalker <[email protected]>2017-08-18 02:57:02 +0200
committerraveit65 <[email protected]>2017-08-26 16:28:58 +0200
commit6f213290fe740621fc4d3f8bf20cbc6b47f5ea0c (patch)
tree7db1a166fa88ae28d7273cb3a2e07cc0c7ef2b3a /drivemount/drive-button.c
parent5126a9a1dedddf14a53f16d12a7215aab75907d4 (diff)
downloadmate-applets-6f213290fe740621fc4d3f8bf20cbc6b47f5ea0c.tar.bz2
mate-applets-6f213290fe740621fc4d3f8bf20cbc6b47f5ea0c.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
Diffstat (limited to 'drivemount/drive-button.c')
-rw-r--r--drivemount/drive-button.c37
1 files changed, 37 insertions, 0 deletions
diff --git a/drivemount/drive-button.c b/drivemount/drive-button.c
index 2c93ce75..6bc598a5 100644
--- a/drivemount/drive-button.c
+++ b/drivemount/drive-button.c
@@ -176,6 +176,25 @@ drive_button_unrealize (GtkWidget *widget)
}
#endif /* 0 */
+#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
+
/* the following function is adapted from gtkmenuitem.c */
static void
position_menu (GtkMenu *menu, gint *x, gint *y,
@@ -188,7 +207,12 @@ position_menu (GtkMenu *menu, gint *x, gint *y,
GtkRequisition requisition;
GtkTextDirection direction;
GdkRectangle monitor;
+#if GTK_CHECK_VERSION (3, 22, 0)
+ GdkMonitor *monitor_num;
+ GdkDisplay *display;
+#else
gint monitor_num;
+#endif
g_return_if_fail (menu != NULL);
g_return_if_fail (x != NULL);
@@ -203,9 +227,17 @@ position_menu (GtkMenu *menu, gint *x, gint *y,
theight = requisition.height;
screen = gtk_widget_get_screen (GTK_WIDGET (menu));
+#if GTK_CHECK_VERSION (3, 22, 0)
+ display =gdk_screen_get_display (screen);
+ monitor_num = gdk_display_get_monitor_at_window (display, gtk_widget_get_window (widget));
+ 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, gtk_widget_get_window (widget));
if (monitor_num < 0) monitor_num = 0;
gdk_screen_get_monitor_geometry (screen, monitor_num, &monitor);
+#endif
if (!gdk_window_get_origin (gtk_widget_get_window (widget), &tx, &ty)) {
g_warning ("Menu not on screen");
@@ -230,7 +262,12 @@ position_menu (GtkMenu *menu, gint *x, gint *y,
*x = CLAMP (tx, monitor.x, MAX (monitor.x, monitor.x + monitor.width - twidth));
*y = ty;
+
+#if GTK_CHECK_VERSION (3, 22, 0)
+ gtk_menu_set_monitor (menu, _gtk_get_monitor_num (monitor_num));
+#else
gtk_menu_set_monitor (menu, monitor_num);
+#endif
}
static gboolean