summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/daemon/daemon.c57
-rw-r--r--src/daemon/stack.c33
-rw-r--r--src/daemon/stack.h4
-rw-r--r--src/themes/standard/theme.c22
4 files changed, 115 insertions, 1 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)
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);
diff --git a/src/daemon/stack.h b/src/daemon/stack.h
index a196e1f..5f478b8 100644
--- a/src/daemon/stack.h
+++ b/src/daemon/stack.h
@@ -38,7 +38,11 @@ typedef enum {
typedef struct _NotifyStack NotifyStack;
+#if GTK_CHECK_VERSION (3, 22, 0)
+NotifyStack* notify_stack_new(NotifyDaemon* daemon, GdkScreen* screen, GdkMonitor *monitor, NotifyStackLocation stack_location);
+#else
NotifyStack* notify_stack_new(NotifyDaemon* daemon, GdkScreen* screen, guint monitor, NotifyStackLocation stack_location);
+#endif
void notify_stack_destroy(NotifyStack* stack);
void notify_stack_set_location(NotifyStack* stack, NotifyStackLocation location);
diff --git a/src/themes/standard/theme.c b/src/themes/standard/theme.c
index c4a75d6..3366736 100644
--- a/src/themes/standard/theme.c
+++ b/src/themes/standard/theme.c
@@ -266,13 +266,24 @@ static GtkArrowType get_notification_arrow_type(GtkWidget* nw)
WindowData* windata;
GdkScreen* screen;
GdkRectangle monitor_geometry;
+#if GTK_CHECK_VERSION (3, 22, 0)
+ GdkDisplay* display;
+ GdkMonitor* monitor;
+#else
int monitor;
+#endif
windata = g_object_get_data(G_OBJECT(nw), "windata");
screen = gdk_window_get_screen(GDK_WINDOW( gtk_widget_get_window(nw)));
+#if GTK_CHECK_VERSION (3, 22, 0)
+ display = gdk_screen_get_display (screen);
+ monitor = gdk_display_get_monitor_at_point (display, windata->point_x, windata->point_y);
+ gdk_monitor_get_geometry (monitor, &monitor_geometry);
+#else
monitor = gdk_screen_get_monitor_at_point(screen, windata->point_x, windata->point_y);
gdk_screen_get_monitor_geometry(screen, monitor, &monitor_geometry);
+#endif
if (windata->point_y - monitor_geometry.y + windata->height + DEFAULT_ARROW_HEIGHT > monitor_geometry.height)
{
@@ -307,15 +318,26 @@ static void create_border_with_arrow(GtkWidget* nw, WindowData* windata)
int arrow_offset = DEFAULT_ARROW_OFFSET;
GdkPoint* shape_points = NULL;
int i = 0;
+#if GTK_CHECK_VERSION (3, 22, 0)
+ GdkMonitor* monitor;
+ GdkDisplay* display;
+#else
int monitor;
+#endif
GdkRectangle monitor_geometry;
width = windata->width;
height = windata->height;
screen = gdk_window_get_screen(GDK_WINDOW(gtk_widget_get_window(nw)));
+#if GTK_CHECK_VERSION (3, 22, 0)
+ display = gdk_screen_get_display (screen);
+ monitor = gdk_display_get_monitor_at_point (display, windata->point_x, windata->point_y);
+ gdk_monitor_get_geometry (monitor, &monitor_geometry);
+#else
monitor = gdk_screen_get_monitor_at_point(screen, windata->point_x, windata->point_y);
gdk_screen_get_monitor_geometry(screen, monitor, &monitor_geometry);
+#endif
windata->num_border_points = 5;