aboutsummaryrefslogtreecommitdiff
path: root/sway/input/seat.c
diff options
context:
space:
mode:
Diffstat (limited to 'sway/input/seat.c')
-rw-r--r--sway/input/seat.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/sway/input/seat.c b/sway/input/seat.c
index bc72ff0c..371de56e 100644
--- a/sway/input/seat.c
+++ b/sway/input/seat.c
@@ -6,6 +6,7 @@
#include <time.h>
#include <wlr/types/wlr_cursor.h>
#include <wlr/types/wlr_data_device.h>
+#include <wlr/types/wlr_idle.h>
#include <wlr/types/wlr_output_layout.h>
#include <wlr/types/wlr_primary_selection.h>
#include <wlr/types/wlr_tablet_v2.h>
@@ -71,6 +72,25 @@ static void seat_node_destroy(struct sway_seat_node *seat_node) {
free(seat_node);
}
+void seat_idle_notify_activity(struct sway_seat *seat,
+ enum sway_input_idle_source source) {
+ uint32_t mask = seat->idle_inhibit_sources;
+ struct wlr_idle_timeout *timeout;
+ int ntimers = 0, nidle = 0;
+ wl_list_for_each(timeout, &server.idle->idle_timers, link) {
+ ++ntimers;
+ if (timeout->idle_state) {
+ ++nidle;
+ }
+ }
+ if (nidle == ntimers) {
+ mask = seat->idle_wake_sources;
+ }
+ if ((source & mask) > 0) {
+ wlr_idle_notify_activity(server.idle, seat->wlr_seat);
+ }
+}
+
/**
* Activate all views within this container recursively.
*/
@@ -491,6 +511,14 @@ struct sway_seat *seat_create(const char *seat_name) {
return NULL;
}
+ seat->idle_inhibit_sources = seat->idle_wake_sources =
+ IDLE_SOURCE_KEYBOARD |
+ IDLE_SOURCE_POINTER |
+ IDLE_SOURCE_TOUCH |
+ IDLE_SOURCE_TABLET_PAD |
+ IDLE_SOURCE_TABLET_TOOL |
+ IDLE_SOURCE_SWITCH;
+
// init the focus stack
wl_list_init(&seat->focus_stack);
@@ -1325,6 +1353,9 @@ void seat_apply_config(struct sway_seat *seat,
return;
}
+ seat->idle_inhibit_sources = seat_config->idle_inhibit_sources;
+ seat->idle_wake_sources = seat_config->idle_wake_sources;
+
wl_list_for_each(seat_device, &seat->devices, link) {
seat_configure_device(seat, seat_device->input_device);
}