diff options
author | Mike Gabriel <mike.gabriel@das-netzwerkteam.de> | 2024-06-18 08:41:54 +0200 |
---|---|---|
committer | Mike Gabriel <mike.gabriel@das-netzwerkteam.de> | 2024-06-18 08:48:32 +0200 |
commit | 275703604d44fff336f631f93e7a47bb3a3b09fd (patch) | |
tree | 75590ea48ad9d8fc265636d374ce1e54c3508f02 | |
parent | 816fdaec458028f23f249db355539392b661d16a (diff) | |
download | arctica-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.
-rw-r--r-- | src/arctica-greeter.vala | 4 | ||||
-rw-r--r-- | src/greeter-list.vala | 4 | ||||
-rw-r--r-- | src/main-window.vala | 74 |
3 files changed, 76 insertions, 6 deletions
diff --git a/src/arctica-greeter.vala b/src/arctica-greeter.vala index 119f3af..426149d 100644 --- a/src/arctica-greeter.vala +++ b/src/arctica-greeter.vala @@ -35,6 +35,10 @@ public class ArcticaGreeter : Object public Gtk.Window? pMagnifierWindow { get; set; default = null; } public bool test_mode { get; construct; default = false; } public bool test_highcontrast { get; construct; default = false; } + + // Menubar is smaller, but with shadow, we reserve more space + public const int MENUBAR_HEIGHT = 40; + private string state_file; private KeyFile state; private DBusServer pServer; diff --git a/src/greeter-list.vala b/src/greeter-list.vala index a0ae6da..d4a5db1 100644 --- a/src/greeter-list.vala +++ b/src/greeter-list.vala @@ -120,11 +120,11 @@ public abstract class GreeterList : FadableBox get { /* First, get grid row number as if menubar weren't there */ - var row = (MainWindow.MENUBAR_HEIGHT + get_allocated_height ()) / grid_size; + var row = (ArcticaGreeter.MENUBAR_HEIGHT + get_allocated_height ()) / grid_size; row = row - DEFAULT_BOX_HEIGHT; /* and no default dash box */ row = row / 2; /* and in the middle */ /* Now calculate y pixel spot keeping in mind menubar's allocation */ - return row * grid_size - MainWindow.MENUBAR_HEIGHT; + return row * grid_size - ArcticaGreeter.MENUBAR_HEIGHT; } } 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 () |