aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar Drew DeVault <sir@cmpwn.com>2018-04-03 16:16:42 -0400
committerLibravatar Drew DeVault <sir@cmpwn.com>2018-04-04 18:47:48 -0400
commit06fbd51ff5563f548599615a6baf5a1854bf9983 (patch)
treec1890f3554621ad8f1d44a054e88f72f065644ee
parentRefocus the last focused container on lock exit (diff)
downloadsway-06fbd51ff5563f548599615a6baf5a1854bf9983.tar.gz
sway-06fbd51ff5563f548599615a6baf5a1854bf9983.tar.zst
sway-06fbd51ff5563f548599615a6baf5a1854bf9983.zip
Add input inhibitor to input manager
-rw-r--r--include/sway/input/input-manager.h5
-rw-r--r--include/sway/input/seat.h3
-rw-r--r--sway/input/input-manager.c27
-rw-r--r--sway/input/seat.c5
4 files changed, 40 insertions, 0 deletions
diff --git a/include/sway/input/input-manager.h b/include/sway/input/input-manager.h
index 8e39a4a7..89a3ac71 100644
--- a/include/sway/input/input-manager.h
+++ b/include/sway/input/input-manager.h
@@ -1,6 +1,7 @@
1#ifndef _SWAY_INPUT_INPUT_MANAGER_H 1#ifndef _SWAY_INPUT_INPUT_MANAGER_H
2#define _SWAY_INPUT_INPUT_MANAGER_H 2#define _SWAY_INPUT_INPUT_MANAGER_H
3#include <libinput.h> 3#include <libinput.h>
4#include <wlr/types/wlr_input_inhibitor.h>
4#include "sway/server.h" 5#include "sway/server.h"
5#include "sway/config.h" 6#include "sway/config.h"
6#include "list.h" 7#include "list.h"
@@ -23,7 +24,11 @@ struct sway_input_manager {
23 struct wl_list devices; 24 struct wl_list devices;
24 struct wl_list seats; 25 struct wl_list seats;
25 26
27 struct wlr_input_inhibit_manager *inhibit;
28
26 struct wl_listener new_input; 29 struct wl_listener new_input;
30 struct wl_listener inhibit_activate;
31 struct wl_listener inhibit_deactivate;
27}; 32};
28 33
29struct sway_input_manager *input_manager_create(struct sway_server *server); 34struct sway_input_manager *input_manager_create(struct sway_server *server);
diff --git a/include/sway/input/seat.h b/include/sway/input/seat.h
index 137fcd22..53031d70 100644
--- a/include/sway/input/seat.h
+++ b/include/sway/input/seat.h
@@ -64,6 +64,9 @@ void seat_set_focus_warp(struct sway_seat *seat,
64void seat_set_focus_layer(struct sway_seat *seat, 64void seat_set_focus_layer(struct sway_seat *seat,
65 struct wlr_layer_surface *layer); 65 struct wlr_layer_surface *layer);
66 66
67void seat_set_exclusive_client(struct sway_seat *seat,
68 struct wl_client *client);
69
67struct sway_container *seat_get_focus(struct sway_seat *seat); 70struct sway_container *seat_get_focus(struct sway_seat *seat);
68 71
69/** 72/**
diff --git a/sway/input/input-manager.c b/sway/input/input-manager.c
index c3507f65..3b2d1d55 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,24 @@ 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
267static 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
276static 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 }
283}
284
266struct sway_input_manager *input_manager_create( 285struct sway_input_manager *input_manager_create(
267 struct sway_server *server) { 286 struct sway_server *server) {
268 struct sway_input_manager *input = 287 struct sway_input_manager *input =
@@ -281,6 +300,14 @@ struct sway_input_manager *input_manager_create(
281 input->new_input.notify = handle_new_input; 300 input->new_input.notify = handle_new_input;
282 wl_signal_add(&server->backend->events.new_input, &input->new_input); 301 wl_signal_add(&server->backend->events.new_input, &input->new_input);
283 302
303 input->inhibit = wlr_input_inhibit_manager_create(server->wl_display);
304 input->inhibit_activate.notify = handle_inhibit_activate;
305 wl_signal_add(&input->inhibit->events.activate,
306 &input->inhibit_activate);
307 input->inhibit_deactivate.notify = handle_inhibit_deactivate;
308 wl_signal_add(&input->inhibit->events.deactivate,
309 &input->inhibit_deactivate);
310
284 return input; 311 return input;
285} 312}
286 313
diff --git a/sway/input/seat.c b/sway/input/seat.c
index a6b42598..318fa9f6 100644
--- a/sway/input/seat.c
+++ b/sway/input/seat.c
@@ -460,6 +460,11 @@ void seat_set_focus_layer(struct sway_seat *seat,
460 } 460 }
461} 461}
462 462
463void seat_set_exclusive_client(struct sway_seat *seat,
464 struct wl_client *client) {
465 // TODO
466}
467
463struct sway_container *seat_get_focus_inactive(struct sway_seat *seat, 468struct sway_container *seat_get_focus_inactive(struct sway_seat *seat,
464 struct sway_container *container) { 469 struct sway_container *container) {
465 return seat_get_focus_by_type(seat, container, C_TYPES); 470 return seat_get_focus_by_type(seat, container, C_TYPES);