diff options
Diffstat (limited to 'sway/input/input-manager.c')
-rw-r--r-- | sway/input/input-manager.c | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/sway/input/input-manager.c b/sway/input/input-manager.c index c3507f65..f71a06e4 100644 --- a/sway/input/input-manager.c +++ b/sway/input/input-manager.c | |||
@@ -7,6 +7,7 @@ | |||
7 | #include <libinput.h> | 7 | #include <libinput.h> |
8 | #include <math.h> | 8 | #include <math.h> |
9 | #include <wlr/backend/libinput.h> | 9 | #include <wlr/backend/libinput.h> |
10 | #include <wlr/types/wlr_input_inhibitor.h> | ||
10 | #include "sway/config.h" | 11 | #include "sway/config.h" |
11 | #include "sway/input/input-manager.h" | 12 | #include "sway/input/input-manager.h" |
12 | #include "sway/input/seat.h" | 13 | #include "sway/input/seat.h" |
@@ -263,6 +264,32 @@ static void handle_new_input(struct wl_listener *listener, void *data) { | |||
263 | input_device->device_destroy.notify = handle_device_destroy; | 264 | input_device->device_destroy.notify = handle_device_destroy; |
264 | } | 265 | } |
265 | 266 | ||
267 | static void handle_inhibit_activate(struct wl_listener *listener, void *data) { | ||
268 | struct sway_input_manager *input_manager = wl_container_of( | ||
269 | listener, input_manager, inhibit_activate); | ||
270 | struct sway_seat *seat; | ||
271 | wl_list_for_each(seat, &input_manager->seats, link) { | ||
272 | seat_set_exclusive_client(seat, input_manager->inhibit->active_client); | ||
273 | } | ||
274 | } | ||
275 | |||
276 | static void handle_inhibit_deactivate(struct wl_listener *listener, void *data) { | ||
277 | struct sway_input_manager *input_manager = wl_container_of( | ||
278 | listener, input_manager, inhibit_deactivate); | ||
279 | struct sway_seat *seat; | ||
280 | wl_list_for_each(seat, &input_manager->seats, link) { | ||
281 | seat_set_exclusive_client(seat, NULL); | ||
282 | struct sway_container *previous = seat_get_focus(seat); | ||
283 | if (previous) { | ||
284 | wlr_log(L_DEBUG, "Returning focus to %p %s '%s'", previous, | ||
285 | container_type_to_str(previous->type), previous->name); | ||
286 | // Hack to get seat to re-focus the return value of get_focus | ||
287 | seat_set_focus(seat, previous->parent); | ||
288 | seat_set_focus(seat, previous); | ||
289 | } | ||
290 | } | ||
291 | } | ||
292 | |||
266 | struct sway_input_manager *input_manager_create( | 293 | struct sway_input_manager *input_manager_create( |
267 | struct sway_server *server) { | 294 | struct sway_server *server) { |
268 | struct sway_input_manager *input = | 295 | struct sway_input_manager *input = |
@@ -281,6 +308,14 @@ struct sway_input_manager *input_manager_create( | |||
281 | input->new_input.notify = handle_new_input; | 308 | input->new_input.notify = handle_new_input; |
282 | wl_signal_add(&server->backend->events.new_input, &input->new_input); | 309 | wl_signal_add(&server->backend->events.new_input, &input->new_input); |
283 | 310 | ||
311 | input->inhibit = wlr_input_inhibit_manager_create(server->wl_display); | ||
312 | input->inhibit_activate.notify = handle_inhibit_activate; | ||
313 | wl_signal_add(&input->inhibit->events.activate, | ||
314 | &input->inhibit_activate); | ||
315 | input->inhibit_deactivate.notify = handle_inhibit_deactivate; | ||
316 | wl_signal_add(&input->inhibit->events.deactivate, | ||
317 | &input->inhibit_deactivate); | ||
318 | |||
284 | return input; | 319 | return input; |
285 | } | 320 | } |
286 | 321 | ||