From c556e09077bb820e752d7266d2b20328db629883 Mon Sep 17 00:00:00 2001 From: ZenWalker Date: Tue, 29 Aug 2017 01:27:00 +0200 Subject: gtk 3.22: avoid deprecated gdk_screen_get_monitor... functions: avoid deprecated: gdk_screen_get_monitor_geometry gdk_screen_get_monitor_at_point --- src/daemon/stack.c | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) (limited to 'src/daemon/stack.c') diff --git a/src/daemon/stack.c b/src/daemon/stack.c index a173b5e..c5ee8e3 100644 --- a/src/daemon/stack.c +++ b/src/daemon/stack.c @@ -36,7 +36,11 @@ struct _NotifyStack { NotifyDaemon* daemon; GdkScreen* screen; +#if GTK_CHECK_VERSION (3, 22, 0) + GdkMonitor *monitor; +#else guint monitor; +#endif NotifyStackLocation location; GList* windows; guint update_id; @@ -190,10 +194,33 @@ translate_coordinates (NotifyStackLocation stack_location, } } +#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 + NotifyStack * notify_stack_new (NotifyDaemon *daemon, GdkScreen *screen, +#if GTK_CHECK_VERSION (3, 22, 0) + GdkMonitor *monitor, +#else guint monitor, +#endif NotifyStackLocation location) { NotifyStack *stack; @@ -205,7 +232,7 @@ notify_stack_new (NotifyDaemon *daemon, g_assert (daemon != NULL); g_assert (screen != NULL && GDK_IS_SCREEN (screen)); #if GTK_CHECK_VERSION (3, 22, 0) - g_assert (monitor < (guint)gdk_display_get_n_monitors (display)); + g_assert ((guint)_gtk_get_monitor_num (monitor) < (guint)gdk_display_get_n_monitors (display)); #else g_assert (monitor < (guint)gdk_screen_get_n_monitors (screen)); #endif @@ -281,9 +308,13 @@ notify_stack_shift_notifications (NotifyStack *stack, int n_wins; get_work_area (stack, &workarea); +#if GTK_CHECK_VERSION (3, 22, 0) + gdk_monitor_get_geometry (stack->monitor, &monitor); +#else gdk_screen_get_monitor_geometry (stack->screen, stack->monitor, &monitor); +#endif gdk_rectangle_intersect (&monitor, &workarea, &workarea); add_padding_to_rect (&workarea); -- cgit v1.2.1