diff options
Diffstat (limited to 'sway/desktop/idle_inhibit_v1.c')
-rw-r--r-- | sway/desktop/idle_inhibit_v1.c | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/sway/desktop/idle_inhibit_v1.c b/sway/desktop/idle_inhibit_v1.c new file mode 100644 index 00000000..a06e00d5 --- /dev/null +++ b/sway/desktop/idle_inhibit_v1.c | |||
@@ -0,0 +1,35 @@ | |||
1 | #include <stdlib.h> | ||
2 | #include <wlr/types/wlr_idle.h> | ||
3 | #include "log.h" | ||
4 | #include "sway/desktop/idle_inhibit_v1.h" | ||
5 | #include "sway/server.h" | ||
6 | |||
7 | |||
8 | static void handle_destroy(struct wl_listener *listener, void *data) { | ||
9 | struct sway_idle_inhibitor_v1 *inhibitor = | ||
10 | wl_container_of(listener, inhibitor, destroy); | ||
11 | wlr_log(L_DEBUG, "Sway idle inhibitor destroyed"); | ||
12 | wlr_idle_set_enabled(inhibitor->server->idle, NULL, true); | ||
13 | wl_list_remove(&inhibitor->destroy.link); | ||
14 | free(inhibitor); | ||
15 | } | ||
16 | |||
17 | void handle_idle_inhibitor_v1(struct wl_listener *listener, void *data) { | ||
18 | struct wlr_idle_inhibitor_v1 *wlr_inhibitor = data; | ||
19 | struct sway_server *server = | ||
20 | wl_container_of(listener, server, new_idle_inhibitor_v1); | ||
21 | wlr_log(L_DEBUG, "New sway idle inhibitor"); | ||
22 | |||
23 | struct sway_idle_inhibitor_v1 *inhibitor = | ||
24 | calloc(1, sizeof(struct sway_idle_inhibitor_v1)); | ||
25 | if (!inhibitor) { | ||
26 | return; | ||
27 | } | ||
28 | |||
29 | inhibitor->server = server; | ||
30 | |||
31 | inhibitor->destroy.notify = handle_destroy; | ||
32 | wl_signal_add(&wlr_inhibitor->events.destroy, &inhibitor->destroy); | ||
33 | |||
34 | wlr_idle_set_enabled(server->idle, NULL, false); | ||
35 | } | ||