conform the idle inhibitor protocol
previously we disable idle tracking simply due to the fact that it exist
This commit is contained in:
parent
d738573e22
commit
0e993b5fb1
30
dwl.c
30
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);
|
||||
|
@ -687,6 +688,25 @@ chvt(const Arg *arg)
|
|||
wlr_session_change_vt(wlr_backend_get_session(backend), arg->ui);
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
|
@ -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 */
|
||||
|
|
Loading…
Reference in a new issue