summaryrefslogtreecommitdiff
path: root/src/daemon/wayland.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/daemon/wayland.c')
-rw-r--r--src/daemon/wayland.c42
1 files changed, 42 insertions, 0 deletions
diff --git a/src/daemon/wayland.c b/src/daemon/wayland.c
index 837e8a2..dbf1f30 100644
--- a/src/daemon/wayland.c
+++ b/src/daemon/wayland.c
@@ -37,3 +37,45 @@ void wayland_init_notification (GtkWindow* nw)
{
gtk_layer_init_for_window (nw);
}
+
+void wayland_move_notification (GtkWindow* nw, int x, int y)
+{
+ GdkWindow *window = gtk_widget_get_window (GTK_WIDGET (nw));
+ GdkMonitor *monitor = gdk_display_get_monitor_at_window (
+ gdk_window_get_display (window),
+ window);
+ GdkRectangle workarea;
+ gdk_monitor_get_workarea (monitor, &workarea);
+ GtkRequisition req;
+ gtk_widget_get_preferred_size (GTK_WIDGET (nw), NULL, &req);
+ int left_gap = x;
+ int top_gap = y;
+ int right_gap = workarea.width - x - req.width;
+ int bottom_gap = workarea.height - y - req.height;
+
+ if (left_gap < right_gap)
+ {
+ gtk_layer_set_anchor (nw, GTK_LAYER_SHELL_EDGE_LEFT, TRUE);
+ gtk_layer_set_anchor (nw, GTK_LAYER_SHELL_EDGE_RIGHT, FALSE);
+ gtk_layer_set_margin (nw, GTK_LAYER_SHELL_EDGE_LEFT, left_gap);
+ }
+ else
+ {
+ gtk_layer_set_anchor (nw, GTK_LAYER_SHELL_EDGE_LEFT, FALSE);
+ gtk_layer_set_anchor (nw, GTK_LAYER_SHELL_EDGE_RIGHT, TRUE);
+ gtk_layer_set_margin (nw, GTK_LAYER_SHELL_EDGE_RIGHT, right_gap);
+ }
+
+ if (top_gap < bottom_gap)
+ {
+ gtk_layer_set_anchor (nw, GTK_LAYER_SHELL_EDGE_TOP, TRUE);
+ gtk_layer_set_anchor (nw, GTK_LAYER_SHELL_EDGE_BOTTOM, FALSE);
+ gtk_layer_set_margin (nw, GTK_LAYER_SHELL_EDGE_TOP, top_gap);
+ }
+ else
+ {
+ gtk_layer_set_anchor (nw, GTK_LAYER_SHELL_EDGE_TOP, FALSE);
+ gtk_layer_set_anchor (nw, GTK_LAYER_SHELL_EDGE_BOTTOM, TRUE);
+ gtk_layer_set_margin (nw, GTK_LAYER_SHELL_EDGE_BOTTOM, bottom_gap);
+ }
+}