summaryrefslogtreecommitdiff
path: root/src/daemon/daemon.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/daemon/daemon.c')
-rw-r--r--src/daemon/daemon.c57
1 files changed, 57 insertions, 0 deletions
diff --git a/src/daemon/daemon.c b/src/daemon/daemon.c
index 2090885..16c1f5e 100644
--- a/src/daemon/daemon.c
+++ b/src/daemon/daemon.c
@@ -176,11 +176,36 @@ static void remove_exit_timeout(NotifyDaemon* daemon)
daemon->priv->exit_timeout_source = 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;
+}
+
+static void create_stack_for_monitor(NotifyDaemon* daemon, GdkScreen* screen, GdkMonitor *monitor_num)
+#else
static void create_stack_for_monitor(NotifyDaemon* daemon, GdkScreen* screen, int monitor_num)
+#endif
{
NotifyScreen* nscreen = daemon->priv->screen;
+#if GTK_CHECK_VERSION(3, 22, 0)
+ nscreen->stacks[_gtk_get_monitor_num(monitor_num)] = notify_stack_new(daemon, screen, monitor_num, daemon->priv->stack_location);
+#else
nscreen->stacks[monitor_num] = notify_stack_new(daemon, screen, monitor_num, daemon->priv->stack_location);
+#endif
}
static void on_screen_monitors_changed(GdkScreen* screen, NotifyDaemon* daemon)
@@ -209,7 +234,11 @@ static void on_screen_monitors_changed(GdkScreen* screen, NotifyDaemon* daemon)
/* add more stacks */
for (i = nscreen->n_stacks; i < n_monitors; i++)
{
+#if GTK_CHECK_VERSION (3, 22, 0)
+ create_stack_for_monitor(daemon, screen, gdk_display_get_monitor (display, i));
+#else
create_stack_for_monitor(daemon, screen, i);
+#endif
}
nscreen->n_stacks = n_monitors;
@@ -267,7 +296,11 @@ static void create_stacks_for_screen(NotifyDaemon* daemon, GdkScreen *screen)
for (i = 0; i < nscreen->n_stacks; i++)
{
+#if GTK_CHECK_VERSION (3, 22, 0)
+ create_stack_for_monitor(daemon, screen, gdk_display_get_monitor (display, i));
+#else
create_stack_for_monitor(daemon, screen, i);
+#endif
}
}
@@ -1503,7 +1536,11 @@ gboolean notify_daemon_notify_handler(NotifyDaemon* daemon, const char* app_name
}
else
{
+#if GTK_CHECK_VERSION (3, 22, 0)
+ GdkMonitor *monitor_id;
+#else
int monitor_num;
+#endif
GdkDisplay *display;
#if GTK_CHECK_VERSION (3, 20, 0)
GdkSeat *seat;
@@ -1531,14 +1568,33 @@ gboolean notify_daemon_notify_handler(NotifyDaemon* daemon, const char* app_name
#endif
gdk_device_get_position (pointer, &screen, &x, &y);
+#if GTK_CHECK_VERSION (3, 22, 0)
+ monitor_id = gdk_display_get_monitor_at_point (gdk_screen_get_display (screen), x, y);
+#else
monitor_num = gdk_screen_get_monitor_at_point (screen, x, y);
+#endif
}
else
{
screen = gdk_display_get_default_screen(gdk_display_get_default());
+#if GTK_CHECK_VERSION (3, 22, 0)
+ monitor_id = gdk_display_get_monitor (gdk_display_get_default(),
+ g_settings_get_int(daemon->gsettings, GSETTINGS_KEY_MONITOR_NUMBER));
+#else
monitor_num = g_settings_get_int(daemon->gsettings, GSETTINGS_KEY_MONITOR_NUMBER);
+#endif
}
+#if GTK_CHECK_VERSION (3, 22, 0)
+ if (_gtk_get_monitor_num (monitor_id) >= priv->screen->n_stacks)
+ {
+ /* screw it - dump it on the last one we'll get
+ a monitors-changed signal soon enough*/
+ monitor_id = gdk_display_get_monitor (gdk_display_get_default(), priv->screen->n_stacks - 1);
+ }
+
+ notify_stack_add_window (priv->screen->stacks[_gtk_get_monitor_num (monitor_id)], nw, new_notification);
+#else
if (monitor_num >= priv->screen->n_stacks)
{
/* screw it - dump it on the last one we'll get
@@ -1547,6 +1603,7 @@ gboolean notify_daemon_notify_handler(NotifyDaemon* daemon, const char* app_name
}
notify_stack_add_window (priv->screen->stacks[monitor_num], nw, new_notification);
+#endif
}
if (id == 0)