summaryrefslogtreecommitdiffstats
path: root/sway/input/input-manager.c
diff options
context:
space:
mode:
authorLibravatar Tony Crisci <tony@dubstepdish.com>2017-12-07 09:58:32 -0500
committerLibravatar Tony Crisci <tony@dubstepdish.com>2017-12-07 09:58:32 -0500
commitf6f63f60d6c7f9602dd1c07b45eb45a97e5b6f5a (patch)
treed1a2e6ae45c827956f4bd181aad3cdea82d32804 /sway/input/input-manager.c
parentrename input to input-manager (diff)
downloadsway-f6f63f60d6c7f9602dd1c07b45eb45a97e5b6f5a.tar.gz
sway-f6f63f60d6c7f9602dd1c07b45eb45a97e5b6f5a.tar.zst
sway-f6f63f60d6c7f9602dd1c07b45eb45a97e5b6f5a.zip
basic input manager and seat
Diffstat (limited to 'sway/input/input-manager.c')
-rw-r--r--sway/input/input-manager.c54
1 files changed, 54 insertions, 0 deletions
diff --git a/sway/input/input-manager.c b/sway/input/input-manager.c
index 285a68b8..b5ab8cc1 100644
--- a/sway/input/input-manager.c
+++ b/sway/input/input-manager.c
@@ -7,12 +7,52 @@
7#include <libinput.h> 7#include <libinput.h>
8#include "sway/config.h" 8#include "sway/config.h"
9#include "sway/input-manager.h" 9#include "sway/input-manager.h"
10#include "sway/seat.h"
10#include "sway/server.h" 11#include "sway/server.h"
11#include "list.h" 12#include "list.h"
12#include "log.h" 13#include "log.h"
13 14
15static const char *default_seat = "seat0";
16
14struct input_config *current_input_config = NULL; 17struct input_config *current_input_config = NULL;
15 18
19static struct sway_seat *input_manager_get_seat(
20 struct sway_input_manager *input, const char *seat_name) {
21 struct sway_seat *seat = NULL;
22
23 for (int i = 0; i < input->seats->length; ++i) {
24 seat = input->seats->items[i];
25 if (strcmp(seat->seat->name, seat_name) == 0) {
26 return seat;
27 }
28 }
29
30 seat = sway_seat_create(input->server->wl_display, seat_name);
31 list_add(input->seats, seat);
32
33 return seat;
34}
35
36static void input_add_notify(struct wl_listener *listener, void *data) {
37 struct sway_input_manager *input =
38 wl_container_of(listener, input, input_add);
39 struct wlr_input_device *device = data;
40
41 // TODO device configuration
42 struct sway_seat *seat = input_manager_get_seat(input, default_seat);
43 sway_seat_add_device(seat, device);
44}
45
46static void input_remove_notify(struct wl_listener *listener, void *data) {
47 struct sway_input_manager *input =
48 wl_container_of(listener, input, input_remove);
49 struct wlr_input_device *device = data;
50
51 // TODO device configuration
52 struct sway_seat *seat = input_manager_get_seat(input, default_seat);
53 sway_seat_remove_device(seat, device);
54}
55
16struct sway_input_manager *sway_input_manager_create( 56struct sway_input_manager *sway_input_manager_create(
17 struct sway_server *server) { 57 struct sway_server *server) {
18 struct sway_input_manager *input = 58 struct sway_input_manager *input =
@@ -20,6 +60,20 @@ struct sway_input_manager *sway_input_manager_create(
20 if (!input) { 60 if (!input) {
21 return NULL; 61 return NULL;
22 } 62 }
63 // XXX probably don't need the full server
64 input->server = server;
65
66 input->seats = create_list();
67
68 // create the default seat
69 input_manager_get_seat(input, default_seat);
70
71 input->input_add.notify = input_add_notify;
72 wl_signal_add(&server->backend->events.input_add, &input->input_add);
73
74 input->input_remove.notify = input_remove_notify;
75 wl_signal_add(&server->backend->events.input_remove, &input->input_remove);
76
23 return input; 77 return input;
24} 78}
25 79