diff options
author | Aylur <[email protected]> | 2024-11-03 01:05:50 +0000 |
---|---|---|
committer | Aylur <[email protected]> | 2024-11-03 01:29:00 +0000 |
commit | c0612d1d7e78c413d0c69de34f1ae7951e90bc90 (patch) | |
tree | b3c1429a3d39b5ffb0cc8f416d804e819e18a955 /lib/astal | |
parent | 3bec67f014021637112727d9f3384395dd2f104c (diff) |
lib(astal4): touchups
Diffstat (limited to 'lib/astal')
-rw-r--r-- | lib/astal/gtk3/src/widget/window.vala | 17 | ||||
-rw-r--r-- | lib/astal/gtk4/src/widget/window.vala | 24 |
2 files changed, 20 insertions, 21 deletions
diff --git a/lib/astal/gtk3/src/widget/window.vala b/lib/astal/gtk3/src/widget/window.vala index 9287200..11d542d 100644 --- a/lib/astal/gtk3/src/widget/window.vala +++ b/lib/astal/gtk3/src/widget/window.vala @@ -47,28 +47,27 @@ public enum Astal.Keymode { * Subclass of [[email protected]] which integrates GtkLayerShell as class fields. */ public class Astal.Window : Gtk.Window { - private static bool check(string action) { + private InhibitManager? inhibit_manager; + private Inhibitor? inhibitor; + + private bool check(string action) { if (!is_supported()) { critical(@"can not $action on window: layer shell not supported"); print("tip: running from an xwayland terminal can cause this, for example VsCode"); return true; } + if (!is_layer_window(this)) { + init_for_window(this); + } return false; } - private InhibitManager? inhibit_manager; - private Inhibitor? inhibitor; - construct { - if (check("initialize layer shell")) - return; - // If the window has no size allocatoted when it gets mapped. // It won't show up later either when it size changes by adding children. height_request = 1; width_request = 1; - - init_for_window(this); + check("initialize layer shell"); inhibit_manager = InhibitManager.get_default(); } diff --git a/lib/astal/gtk4/src/widget/window.vala b/lib/astal/gtk4/src/widget/window.vala index 7b73b7c..0cf3d11 100644 --- a/lib/astal/gtk4/src/widget/window.vala +++ b/lib/astal/gtk4/src/widget/window.vala @@ -1,11 +1,12 @@ using GtkLayerShell; +[Flags] public enum Astal.WindowAnchor { - NONE = 0, - TOP = 1, - RIGHT = 2, - LEFT = 4, - BOTTOM = 8, + NONE, + TOP, + RIGHT, + LEFT, + BOTTOM, } public enum Astal.Exclusivity { @@ -46,25 +47,24 @@ public enum Astal.Keymode { * Subclass of [[email protected]] which integrates GtkLayerShell as class fields. */ public class Astal.Window : Gtk.Window { - private static bool check(string action) { + private bool check(string action) { if (!is_supported()) { critical(@"can not $action on window: layer shell not supported"); print("tip: running from an xwayland terminal can cause this, for example VsCode"); return true; } + if (!is_layer_window(this)) { + init_for_window(this); + } return false; } construct { - if (check("initialize layer shell")) - return; - // If the window has no size allocatoted when it gets mapped. // It won't show up later either when it size changes by adding children. height_request = 1; width_request = 1; - - init_for_window(this); + check("initialize layer shell"); } /** @@ -81,7 +81,7 @@ public class Astal.Window : Gtk.Window { * If two perpendicular edges are anchored, the surface will be anchored to that corner. * If two opposite edges are anchored, the window will be stretched across the screen in that direction. */ - public int anchor { + public WindowAnchor anchor { set { if (check("set anchor")) return; |