From 122112c320e62e52b3f0acc5d03c445c44bd8c4c Mon Sep 17 00:00:00 2001 From: kotontrion Date: Tue, 24 Sep 2024 10:47:14 +0200 Subject: core: add window inhibit property --- core/src/widget/window.vala | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'core/src/widget/window.vala') diff --git a/core/src/widget/window.vala b/core/src/widget/window.vala index 17dc76d..73a4f5d 100644 --- a/core/src/widget/window.vala +++ b/core/src/widget/window.vala @@ -38,6 +38,9 @@ public class Window : Gtk.Window { return false; } + private InhibitManager? inhibit_manager; + private Inhibitor? inhibitor; + construct { if (check("initialize layer shell")) return; @@ -45,6 +48,24 @@ public class Window : Gtk.Window { height_request = 1; width_request = 1; init_for_window(this); + inhibit_manager = InhibitManager.get_default(); + } + + public bool inhibit { + set { + if(inhibit_manager == null) { + return; + } + if(value && inhibitor == null) { + inhibitor = inhibit_manager.inhibit(this); + } + else if(!value && inhibitor != null){ + inhibitor = null; + } + } + get { + return inhibitor != null; + } } public string namespace { -- cgit v1.2.3 From 628f89453764bfab97d3507d351d0dfa4b50c964 Mon Sep 17 00:00:00 2001 From: kotontrion Date: Wed, 25 Sep 2024 14:14:22 +0200 Subject: core: reregister inhibitor when window is shown --- core/src/widget/window.vala | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'core/src/widget/window.vala') diff --git a/core/src/widget/window.vala b/core/src/widget/window.vala index 73a4f5d..15c666c 100644 --- a/core/src/widget/window.vala +++ b/core/src/widget/window.vala @@ -68,6 +68,13 @@ public class Window : Gtk.Window { } } + public override void show() { + base.show(); + if(inhibit) { + inhibitor = inhibit_manager.inhibit(this); + } + } + public string namespace { get { return get_namespace(this); } set { set_namespace(this, value); } -- cgit v1.2.3 From d035a539fbcc2dfa0dc03f11d3465bae650caf37 Mon Sep 17 00:00:00 2001 From: Aylur Date: Fri, 27 Sep 2024 21:39:07 +0000 Subject: style: fix indentation I will setup uncrustify at some point, but the number of options is overwhelming it will take a while --- core/src/widget/window.vala | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) (limited to 'core/src/widget/window.vala') diff --git a/core/src/widget/window.vala b/core/src/widget/window.vala index 15c666c..f1a377f 100644 --- a/core/src/widget/window.vala +++ b/core/src/widget/window.vala @@ -52,26 +52,26 @@ public class Window : Gtk.Window { } public bool inhibit { - set { - if(inhibit_manager == null) { - return; - } - if(value && inhibitor == null) { - inhibitor = inhibit_manager.inhibit(this); + set { + if (inhibit_manager == null) { + return; + } + if (value && inhibitor == null) { + inhibitor = inhibit_manager.inhibit(this); + } + else if (!value && inhibitor != null) { + inhibitor = null; + } } - else if(!value && inhibitor != null){ - inhibitor = null; + get { + return inhibitor != null; } - } - get { - return inhibitor != null; - } } public override void show() { base.show(); if(inhibit) { - inhibitor = inhibit_manager.inhibit(this); + inhibitor = inhibit_manager.inhibit(this); } } -- cgit v1.2.3