summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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 */