diff options
-rw-r--r-- | include/sway/desktop/idle_inhibit_v1.h | 13 | ||||
-rw-r--r-- | include/sway/server.h | 5 | ||||
-rw-r--r-- | sway/desktop/idle_inhibit_v1.c | 35 | ||||
-rw-r--r-- | sway/meson.build | 1 | ||||
-rw-r--r-- | sway/server.c | 6 |
5 files changed, 60 insertions, 0 deletions
diff --git a/include/sway/desktop/idle_inhibit_v1.h b/include/sway/desktop/idle_inhibit_v1.h new file mode 100644 index 00000000..94c25a42 --- /dev/null +++ b/include/sway/desktop/idle_inhibit_v1.h | |||
@@ -0,0 +1,13 @@ | |||
1 | |||
2 | #ifndef _SWAY_DESKTOP_IDLE_INHIBIT_V1_H | ||
3 | #define _SWAY_DESKTOP_IDLE_INHIBIT_V1_H | ||
4 | #include <wlr/types/wlr_idle_inhibit_v1.h> | ||
5 | #include "sway/server.h" | ||
6 | |||
7 | struct sway_idle_inhibitor_v1 { | ||
8 | struct sway_server *server; | ||
9 | |||
10 | struct wl_listener destroy; | ||
11 | }; | ||
12 | |||
13 | #endif | ||
diff --git a/include/sway/server.h b/include/sway/server.h index 1e1aa3cc..246a9381 100644 --- a/include/sway/server.h +++ b/include/sway/server.h | |||
@@ -24,11 +24,15 @@ struct sway_server { | |||
24 | struct wlr_compositor *compositor; | 24 | struct wlr_compositor *compositor; |
25 | struct wlr_data_device_manager *data_device_manager; | 25 | struct wlr_data_device_manager *data_device_manager; |
26 | struct wlr_idle *idle; | 26 | struct wlr_idle *idle; |
27 | struct wlr_idle_inhibit_manager_v1 *idle_inhibit; | ||
27 | 28 | ||
28 | struct sway_input_manager *input; | 29 | struct sway_input_manager *input; |
29 | 30 | ||
30 | struct wl_listener new_output; | 31 | struct wl_listener new_output; |
31 | 32 | ||
33 | struct wlr_idle_inhibit_manager_v1 *idle_inhibit_v1; | ||
34 | struct wl_listener new_idle_inhibitor_v1; | ||
35 | |||
32 | struct wlr_layer_shell *layer_shell; | 36 | struct wlr_layer_shell *layer_shell; |
33 | struct wl_listener layer_shell_surface; | 37 | struct wl_listener layer_shell_surface; |
34 | 38 | ||
@@ -61,6 +65,7 @@ void server_run(struct sway_server *server); | |||
61 | 65 | ||
62 | void handle_new_output(struct wl_listener *listener, void *data); | 66 | void handle_new_output(struct wl_listener *listener, void *data); |
63 | 67 | ||
68 | void handle_idle_inhibitor_v1(struct wl_listener *listener, void *data); | ||
64 | void handle_layer_shell_surface(struct wl_listener *listener, void *data); | 69 | void handle_layer_shell_surface(struct wl_listener *listener, void *data); |
65 | void handle_xdg_shell_v6_surface(struct wl_listener *listener, void *data); | 70 | void handle_xdg_shell_v6_surface(struct wl_listener *listener, void *data); |
66 | void handle_xdg_shell_surface(struct wl_listener *listener, void *data); | 71 | void handle_xdg_shell_surface(struct wl_listener *listener, void *data); |
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 | } | ||
diff --git a/sway/meson.build b/sway/meson.build index 9ff3f05f..a81a3406 100644 --- a/sway/meson.build +++ b/sway/meson.build | |||
@@ -10,6 +10,7 @@ sway_sources = files( | |||
10 | 'security.c', | 10 | 'security.c', |
11 | 11 | ||
12 | 'desktop/desktop.c', | 12 | 'desktop/desktop.c', |
13 | 'desktop/idle_inhibit_v1.c', | ||
13 | 'desktop/layer_shell.c', | 14 | 'desktop/layer_shell.c', |
14 | 'desktop/output.c', | 15 | 'desktop/output.c', |
15 | 'desktop/transaction.c', | 16 | 'desktop/transaction.c', |
diff --git a/sway/server.c b/sway/server.c index bd107617..3456931c 100644 --- a/sway/server.c +++ b/sway/server.c | |||
@@ -10,6 +10,7 @@ | |||
10 | #include <wlr/types/wlr_export_dmabuf_v1.h> | 10 | #include <wlr/types/wlr_export_dmabuf_v1.h> |
11 | #include <wlr/types/wlr_gamma_control.h> | 11 | #include <wlr/types/wlr_gamma_control.h> |
12 | #include <wlr/types/wlr_idle.h> | 12 | #include <wlr/types/wlr_idle.h> |
13 | #include <wlr/types/wlr_idle_inhibit_v1.h> | ||
13 | #include <wlr/types/wlr_layer_shell.h> | 14 | #include <wlr/types/wlr_layer_shell.h> |
14 | #include <wlr/types/wlr_linux_dmabuf.h> | 15 | #include <wlr/types/wlr_linux_dmabuf.h> |
15 | #include <wlr/types/wlr_primary_selection.h> | 16 | #include <wlr/types/wlr_primary_selection.h> |
@@ -63,6 +64,11 @@ bool server_init(struct sway_server *server) { | |||
63 | wlr_xdg_output_manager_create(server->wl_display, | 64 | wlr_xdg_output_manager_create(server->wl_display, |
64 | root_container.sway_root->output_layout); | 65 | root_container.sway_root->output_layout); |
65 | 66 | ||
67 | server->idle_inhibit = wlr_idle_inhibit_v1_create(server->wl_display); | ||
68 | wl_signal_add(&server->idle_inhibit->events.new_inhibitor, | ||
69 | &server->new_idle_inhibitor_v1); | ||
70 | server->new_idle_inhibitor_v1.notify = handle_idle_inhibitor_v1; | ||
71 | |||
66 | server->layer_shell = wlr_layer_shell_create(server->wl_display); | 72 | server->layer_shell = wlr_layer_shell_create(server->wl_display); |
67 | wl_signal_add(&server->layer_shell->events.new_surface, | 73 | wl_signal_add(&server->layer_shell->events.new_surface, |
68 | &server->layer_shell_surface); | 74 | &server->layer_shell_surface); |