diff options
author | Drew DeVault <sir@cmpwn.com> | 2019-12-11 11:00:39 -0500 |
---|---|---|
committer | Drew DeVault <sir@cmpwn.com> | 2019-12-12 10:37:30 -0500 |
commit | 2f3c6cccf5d6b2d6ffd3cee62e7b624dc80dc6e6 (patch) | |
tree | 69d3367cf7dbd7f756d45d89cd37e6016503a88d /sway/input/seat.c | |
parent | Fix lingering workspace with scratchpad show (diff) | |
download | sway-2f3c6cccf5d6b2d6ffd3cee62e7b624dc80dc6e6.tar.gz sway-2f3c6cccf5d6b2d6ffd3cee62e7b624dc80dc6e6.tar.zst sway-2f3c6cccf5d6b2d6ffd3cee62e7b624dc80dc6e6.zip |
Add seat <seat> idle_{inhibit,wake} <sources...>
This adds seat configuration options which can be used to configure what
events affect the idle behavior of sway.
An example use-case is mobile devices: you would remove touch from the
list of idle_wake events. This allows the phone to stay on while you're
actively using it, but doesn't wake from idle on touch events while it's
sleeping in your pocket.
Diffstat (limited to 'sway/input/seat.c')
-rw-r--r-- | sway/input/seat.c | 31 |
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 @@ | |||
6 | #include <time.h> | 6 | #include <time.h> |
7 | #include <wlr/types/wlr_cursor.h> | 7 | #include <wlr/types/wlr_cursor.h> |
8 | #include <wlr/types/wlr_data_device.h> | 8 | #include <wlr/types/wlr_data_device.h> |
9 | #include <wlr/types/wlr_idle.h> | ||
9 | #include <wlr/types/wlr_output_layout.h> | 10 | #include <wlr/types/wlr_output_layout.h> |
10 | #include <wlr/types/wlr_primary_selection.h> | 11 | #include <wlr/types/wlr_primary_selection.h> |
11 | #include <wlr/types/wlr_tablet_v2.h> | 12 | #include <wlr/types/wlr_tablet_v2.h> |
@@ -71,6 +72,25 @@ static void seat_node_destroy(struct sway_seat_node *seat_node) { | |||
71 | free(seat_node); | 72 | free(seat_node); |
72 | } | 73 | } |
73 | 74 | ||
75 | void seat_idle_notify_activity(struct sway_seat *seat, | ||
76 | enum sway_input_idle_source source) { | ||
77 | uint32_t mask = seat->idle_inhibit_sources; | ||
78 | struct wlr_idle_timeout *timeout; | ||
79 | int ntimers = 0, nidle = 0; | ||
80 | wl_list_for_each(timeout, &server.idle->idle_timers, link) { | ||
81 | ++ntimers; | ||
82 | if (timeout->idle_state) { | ||
83 | ++nidle; | ||
84 | } | ||
85 | } | ||
86 | if (nidle == ntimers) { | ||
87 | mask = seat->idle_wake_sources; | ||
88 | } | ||
89 | if ((source & mask) > 0) { | ||
90 | wlr_idle_notify_activity(server.idle, seat->wlr_seat); | ||
91 | } | ||
92 | } | ||
93 | |||
74 | /** | 94 | /** |
75 | * Activate all views within this container recursively. | 95 | * Activate all views within this container recursively. |
76 | */ | 96 | */ |
@@ -491,6 +511,14 @@ struct sway_seat *seat_create(const char *seat_name) { | |||
491 | return NULL; | 511 | return NULL; |
492 | } | 512 | } |
493 | 513 | ||
514 | seat->idle_inhibit_sources = seat->idle_wake_sources = | ||
515 | IDLE_SOURCE_KEYBOARD | | ||
516 | IDLE_SOURCE_POINTER | | ||
517 | IDLE_SOURCE_TOUCH | | ||
518 | IDLE_SOURCE_TABLET_PAD | | ||
519 | IDLE_SOURCE_TABLET_TOOL | | ||
520 | IDLE_SOURCE_SWITCH; | ||
521 | |||
494 | // init the focus stack | 522 | // init the focus stack |
495 | wl_list_init(&seat->focus_stack); | 523 | wl_list_init(&seat->focus_stack); |
496 | 524 | ||
@@ -1325,6 +1353,9 @@ void seat_apply_config(struct sway_seat *seat, | |||
1325 | return; | 1353 | return; |
1326 | } | 1354 | } |
1327 | 1355 | ||
1356 | seat->idle_inhibit_sources = seat_config->idle_inhibit_sources; | ||
1357 | seat->idle_wake_sources = seat_config->idle_wake_sources; | ||
1358 | |||
1328 | wl_list_for_each(seat_device, &seat->devices, link) { | 1359 | wl_list_for_each(seat_device, &seat->devices, link) { |
1329 | seat_configure_device(seat, seat_device->input_device); | 1360 | seat_configure_device(seat, seat_device->input_device); |
1330 | } | 1361 | } |