summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLeonardo Hernández Hernández <leohdz172@protonmail.com>2022-08-12 23:47:34 -0500
committerLeonardo Hernández Hernández <leohdz172@protonmail.com>2022-08-28 22:40:11 -0500
commit0e993b5fb1820189b78bed9fc2eb642230b47a58 (patch)
treea8dbf0c6fecfa48e2e042272345ac3f113d8fac0
parentd738573e22649dfb01f70eca00cef221839c9efb (diff)
conform the idle inhibitor protocol
previously we disable idle tracking simply due to the fact that it exist
-rw-r--r--dwl.c30
1 files changed, 25 insertions, 5 deletions
diff --git a/dwl.c b/dwl.c
index 66aea65..a3b13b6 100644
--- a/dwl.c
+++ b/dwl.c
@@ -216,6 +216,7 @@ static void arrangelayers(Monitor *m);
static void axisnotify(struct wl_listener *listener, void *data);
static void buttonpress(struct wl_listener *listener, void *data);
static void chvt(const Arg *arg);
+static void checkidleinhibitor(struct wlr_surface *exclude);
static void cleanup(void);
static void cleanupkeyboard(struct wl_listener *listener, void *data);
static void cleanupmon(struct wl_listener *listener, void *data);
@@ -688,6 +689,25 @@ chvt(const Arg *arg)
}
void
+checkidleinhibitor(struct wlr_surface *exclude)
+{
+ Client *c, *w;
+ int inhibited = 0;
+ struct wlr_idle_inhibitor_v1 *inhibitor;
+ wl_list_for_each(inhibitor, &idle_inhibit_mgr->inhibitors, link) {
+ c = client_from_wlr_surface(inhibitor->surface);
+ if (exclude && (!(w = client_from_wlr_surface(exclude)) || w == c))
+ continue;
+ if (!c || VISIBLEON(c, c->mon)) {
+ inhibited = 1;
+ break;
+ }
+ }
+
+ wlr_idle_set_enabled(idle, NULL, !inhibited);
+}
+
+void
cleanup(void)
{
#ifdef XWAYLAND
@@ -809,7 +829,7 @@ createidleinhibitor(struct wl_listener *listener, void *data)
struct wlr_idle_inhibitor_v1 *idle_inhibitor = data;
wl_signal_add(&idle_inhibitor->events.destroy, &idle_inhibitor_destroy);
- wlr_idle_set_enabled(idle, seat, 0);
+ checkidleinhibitor(NULL);
}
void
@@ -1040,9 +1060,9 @@ cursorframe(struct wl_listener *listener, void *data)
void
destroyidleinhibitor(struct wl_listener *listener, void *data)
{
- /* I've been testing and at this point the inhibitor has not yet been
- * removed from the list, checking if it has at least one item. */
- wlr_idle_set_enabled(idle, seat, wl_list_length(&idle_inhibit_mgr->inhibitors) <= 1);
+ /* `data` is the wlr_surface of the idle inhibitor being destroyed,
+ * at this point the idle inhibitor is still in the list of the manager */
+ checkidleinhibitor(data);
}
void
@@ -1163,7 +1183,7 @@ focusclient(Client *c, int lift)
}
printstatus();
- wlr_idle_set_enabled(idle, seat, wl_list_empty(&idle_inhibit_mgr->inhibitors));
+ checkidleinhibitor(NULL);
if (!c) {
/* With no client, all we have left is to clear focus */