summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAylur <[email protected]>2024-08-04 02:15:01 +0200
committerAylur <[email protected]>2024-08-04 02:15:01 +0200
commit4da9ccc35cc43269b7e41570115398709425e0b0 (patch)
tree2790f337ef9307da2a5fa04724e19ea67b8a9a27 /src
parent3f473858a588365ac49ef3f2508e961e5379aa12 (diff)
add: layer shell check on window
Diffstat (limited to 'src')
-rw-r--r--src/widget/window.vala73
1 files changed, 66 insertions, 7 deletions
diff --git a/src/widget/window.vala b/src/widget/window.vala
index a552de4..088ef7f 100644
--- a/src/widget/window.vala
+++ b/src/widget/window.vala
@@ -29,7 +29,19 @@ public enum Keymode {
}
public class Window : Gtk.Window {
+ private static 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;
+ }
+ return false;
+ }
+
construct {
+ if (check("initialize layer shell"))
+ return;
+
height_request = 1;
width_request = 1;
init_for_window(this);
@@ -39,6 +51,9 @@ public class Window : Gtk.Window {
public int anchor {
set {
+ if (check("set anchor"))
+ return;
+
set_anchor(this, Edge.TOP, WindowAnchor.TOP in value);
set_anchor(this, Edge.BOTTOM, WindowAnchor.BOTTOM in value);
set_anchor(this, Edge.LEFT, WindowAnchor.LEFT in value);
@@ -64,6 +79,9 @@ public class Window : Gtk.Window {
public Exclusivity exclusivity {
set {
+ if (check("set exclusivity"))
+ return;
+
switch (value) {
case Exclusivity.NORMAL:
set_exclusive_zone(this, 0);
@@ -89,41 +107,79 @@ public class Window : Gtk.Window {
public Layer layer {
get { return (Layer)get_layer(this); }
- set { set_layer(this, (GtkLayerShell.Layer)value); }
+ set {
+ if (check("set layer"))
+ return;
+
+ set_layer(this, (GtkLayerShell.Layer)value);
+ }
}
public Keymode keymode {
- set { set_keyboard_mode(this, (GtkLayerShell.KeyboardMode)value); }
get { return (Keymode)get_keyboard_mode(this); }
+ set {
+ if (check("set keymode"))
+ return;
+
+ set_keyboard_mode(this, (GtkLayerShell.KeyboardMode)value);
+ }
}
public Gdk.Monitor gdkmonitor {
- set { set_monitor (this, value); }
get { return get_monitor(this); }
+ set {
+ if (check("set gdkmonitor"))
+ return;
+
+ set_monitor (this, value);
+ }
}
public new int margin_top {
get { return GtkLayerShell.get_margin(this, Edge.TOP); }
- set { GtkLayerShell.set_margin(this, Edge.TOP, value); }
+ set {
+ if (check("set margin_top"))
+ return;
+
+ GtkLayerShell.set_margin(this, Edge.TOP, value);
+ }
}
public new int margin_bottom {
get { return GtkLayerShell.get_margin(this, Edge.BOTTOM); }
- set { GtkLayerShell.set_margin(this, Edge.BOTTOM, value); }
+ set {
+ if (check("set margin_bottom"))
+ return;
+
+ GtkLayerShell.set_margin(this, Edge.BOTTOM, value);
+ }
}
public new int margin_left {
get { return GtkLayerShell.get_margin(this, Edge.LEFT); }
- set { GtkLayerShell.set_margin(this, Edge.LEFT, value); }
+ set {
+ if (check("set margin_left"))
+ return;
+
+ GtkLayerShell.set_margin(this, Edge.LEFT, value);
+ }
}
public new int margin_right {
get { return GtkLayerShell.get_margin(this, Edge.RIGHT); }
- set { GtkLayerShell.set_margin(this, Edge.RIGHT, value); }
+ set {
+ if (check("set margin_right"))
+ return;
+
+ GtkLayerShell.set_margin(this, Edge.RIGHT, value);
+ }
}
public new int margin {
set {
+ if (check("set margin"))
+ return;
+
margin_top = value;
margin_right = value;
margin_bottom = value;
@@ -137,6 +193,9 @@ public class Window : Gtk.Window {
*/
public int monitor {
set {
+ if (check("set monitor"))
+ return;
+
if (value < 0)
set_monitor(this, (Gdk.Monitor)null);