aboutsummaryrefslogtreecommitdiff
path: root/src/main-window.vala
diff options
context:
space:
mode:
authorMike Gabriel <mike.gabriel@das-netzwerkteam.de>2024-06-18 08:41:54 +0200
committerMike Gabriel <mike.gabriel@das-netzwerkteam.de>2024-06-18 08:48:32 +0200
commit275703604d44fff336f631f93e7a47bb3a3b09fd (patch)
tree75590ea48ad9d8fc265636d374ce1e54c3508f02 /src/main-window.vala
parent816fdaec458028f23f249db355539392b661d16a (diff)
downloadarctica-greeter-275703604d44fff336f631f93e7a47bb3a3b09fd.tar.gz
arctica-greeter-275703604d44fff336f631f93e7a47bb3a3b09fd.tar.bz2
arctica-greeter-275703604d44fff336f631f93e7a47bb3a3b09fd.zip
src/: Set _NET_WM_STRUT{,_PARTIAL} so that notification bubbles don't overlay the menubar.
Diffstat (limited to 'src/main-window.vala')
-rw-r--r--src/main-window.vala74
1 files changed, 70 insertions, 4 deletions
diff --git a/src/main-window.vala b/src/main-window.vala
index 9b7a43b..f1d3be8 100644
--- a/src/main-window.vala
+++ b/src/main-window.vala
@@ -41,8 +41,27 @@ public class MainWindow : Gtk.Window
public ListStack stack;
- // Menubar is smaller, but with shadow, we reserve more space
- public const int MENUBAR_HEIGHT = 40;
+ public enum Struts {
+ LEFT,
+ RIGHT,
+ TOP,
+ BOTTOM,
+ LEFT_START,
+ LEFT_END,
+ RIGHT_START,
+ RIGHT_END,
+ TOP_START,
+ TOP_END,
+ BOTTOM_START,
+ BOTTOM_END
+ }
+
+ public enum MenubarPositions {
+ LEFT,
+ RIGHT,
+ TOP,
+ BOTTOM,
+ }
construct
{
@@ -76,7 +95,7 @@ public class MainWindow : Gtk.Window
background-repeat: repeat;".printf(shadow_path);
}
- menubox.set_size_request (-1, MENUBAR_HEIGHT);
+ menubox.set_size_request (-1, ArcticaGreeter.MENUBAR_HEIGHT);
menubox.show ();
login_box.add (menubox);
ArcticaGreeter.add_style_class (menubox);
@@ -126,7 +145,7 @@ public class MainWindow : Gtk.Window
align = new Gtk.Alignment (0.5f, 0.5f, 0.0f, 0.0f);
align.set_size_request (grid_size, -1);
- align.margin_bottom = MENUBAR_HEIGHT; /* offset for menubar at top */
+ align.margin_bottom = ArcticaGreeter.MENUBAR_HEIGHT; /* offset for menubar at top */
align.show ();
hbox.add (align);
@@ -228,6 +247,53 @@ public class MainWindow : Gtk.Window
resize (background.width, background.height);
move (0, 0);
move_to_monitor (primary_monitor);
+ set_struts (this, MenubarPositions.TOP, ArcticaGreeter.MENUBAR_HEIGHT);
+ }
+
+ public static void set_struts(Gtk.Window? window, uint position, long menubar_size)
+ {
+ Gdk.Atom atom;
+ long struts[12] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
+ var screen = window.screen;
+ Gdk.Monitor mon = screen.get_display().get_primary_monitor();
+ Gdk.Rectangle primary_monitor_rect = mon.get_geometry();
+
+ if (!window.get_realized()) {
+ return;
+ }
+
+ // Struts dependent on position
+ switch (position) {
+ case MenubarPositions.TOP:
+ struts[Struts.TOP] = (menubar_size + primary_monitor_rect.y);
+ struts[Struts.TOP_START] = primary_monitor_rect.x;
+ struts[Struts.TOP_END] = (primary_monitor_rect.x + primary_monitor_rect.width) - 1;
+ break;
+ case MenubarPositions.LEFT:
+ struts[Struts.LEFT] = (primary_monitor_rect.x + menubar_size);
+ struts[Struts.LEFT_START] = primary_monitor_rect.y;
+ struts[Struts.LEFT_END] = (primary_monitor_rect.y + primary_monitor_rect.height) - 1;
+ break;
+ case MenubarPositions.RIGHT:
+ struts[Struts.RIGHT] = (menubar_size + screen.get_width() - primary_monitor_rect.x - primary_monitor_rect.width);
+ struts[Struts.RIGHT_START] = primary_monitor_rect.y;
+ struts[Struts.RIGHT_END] = (primary_monitor_rect.y + primary_monitor_rect.height) - 1;
+ break;
+ case MenubarPositions.BOTTOM:
+ default:
+ struts[Struts.BOTTOM] = (menubar_size + screen.get_height() - primary_monitor_rect.y - primary_monitor_rect.height);
+ struts[Struts.BOTTOM_START] = primary_monitor_rect.x;
+ struts[Struts.BOTTOM_END] = (primary_monitor_rect.x + primary_monitor_rect.width) - 1;
+ break;
+ }
+
+ atom = Gdk.Atom.intern("_NET_WM_STRUT", false);
+ Gdk.property_change(window.get_window(), atom, Gdk.Atom.intern("CARDINAL", false),
+ 32, Gdk.PropMode.REPLACE, (uint8[])struts, 4);
+
+ atom = Gdk.Atom.intern("_NET_WM_STRUT_PARTIAL", false);
+ Gdk.property_change(window.get_window(), atom, Gdk.Atom.intern("CARDINAL", false),
+ 32, Gdk.PropMode.REPLACE, (uint8[])struts, 12);
}
public override void realize ()