aboutsummaryrefslogtreecommitdiffstats
path: root/sway
diff options
context:
space:
mode:
authorLibravatar Dominique Martinet <asmadeus@codewreck.org>2018-06-27 18:16:49 +0900
committerLibravatar Dominique Martinet <asmadeus@codewreck.org>2018-07-02 09:29:16 +0900
commite4bfb3bc98b28cb083b4138a76d88384a33d6e57 (patch)
tree2ec9ee9b2d63385d204ad5012a1e385703990721 /sway
parentMerge pull request #2190 from emersion/screencopy (diff)
downloadsway-e4bfb3bc98b28cb083b4138a76d88384a33d6e57.tar.gz
sway-e4bfb3bc98b28cb083b4138a76d88384a33d6e57.tar.zst
sway-e4bfb3bc98b28cb083b4138a76d88384a33d6e57.zip
Add idle inhibit unstable v1 support
Diffstat (limited to 'sway')
-rw-r--r--sway/desktop/idle_inhibit_v1.c35
-rw-r--r--sway/meson.build1
-rw-r--r--sway/server.c6
3 files changed, 42 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
8static 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
17void 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);