diff options
Diffstat (limited to 'sway/input/seat.c')
-rw-r--r-- | sway/input/seat.c | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/sway/input/seat.c b/sway/input/seat.c index 7c827374..9c17250d 100644 --- a/sway/input/seat.c +++ b/sway/input/seat.c | |||
@@ -42,6 +42,18 @@ struct sway_seat *sway_seat_create(struct sway_input_manager *input, | |||
42 | return seat; | 42 | return seat; |
43 | } | 43 | } |
44 | 44 | ||
45 | static struct sway_pointer *seat_pointer_from_device(struct sway_seat *seat, | ||
46 | struct wlr_input_device *device) { | ||
47 | struct sway_pointer *pointer = NULL; | ||
48 | wl_list_for_each(pointer, &seat->pointers, link) { | ||
49 | if (pointer->device == device) { | ||
50 | return pointer; | ||
51 | } | ||
52 | } | ||
53 | |||
54 | return pointer; | ||
55 | } | ||
56 | |||
45 | static struct sway_keyboard *seat_keyboard_from_device(struct sway_seat *seat, | 57 | static struct sway_keyboard *seat_keyboard_from_device(struct sway_seat *seat, |
46 | struct wlr_input_device *device) { | 58 | struct wlr_input_device *device) { |
47 | struct sway_keyboard *keyboard = NULL; | 59 | struct sway_keyboard *keyboard = NULL; |
@@ -57,6 +69,16 @@ static struct sway_keyboard *seat_keyboard_from_device(struct sway_seat *seat, | |||
57 | static void seat_add_pointer(struct sway_seat *seat, | 69 | static void seat_add_pointer(struct sway_seat *seat, |
58 | struct wlr_input_device *device) { | 70 | struct wlr_input_device *device) { |
59 | // TODO pointer configuration | 71 | // TODO pointer configuration |
72 | if (seat_pointer_from_device(seat, device)) { | ||
73 | // already added | ||
74 | return; | ||
75 | } | ||
76 | |||
77 | struct sway_pointer *pointer = calloc(1, sizeof(struct sway_pointer)); | ||
78 | pointer->seat = seat; | ||
79 | pointer->device = device; | ||
80 | wl_list_insert(&seat->pointers, &pointer->link); | ||
81 | |||
60 | wlr_cursor_attach_input_device(seat->cursor->cursor, device); | 82 | wlr_cursor_attach_input_device(seat->cursor->cursor, device); |
61 | } | 83 | } |
62 | 84 | ||
@@ -100,7 +122,13 @@ static void seat_remove_keyboard(struct sway_seat *seat, | |||
100 | 122 | ||
101 | static void seat_remove_pointer(struct sway_seat *seat, | 123 | static void seat_remove_pointer(struct sway_seat *seat, |
102 | struct wlr_input_device *device) { | 124 | struct wlr_input_device *device) { |
103 | wlr_cursor_detach_input_device(seat->cursor->cursor, device); | 125 | struct sway_pointer *pointer = seat_pointer_from_device(seat, device); |
126 | |||
127 | if (pointer) { | ||
128 | wl_list_remove(&pointer->link); | ||
129 | free(pointer); | ||
130 | wlr_cursor_detach_input_device(seat->cursor->cursor, device); | ||
131 | } | ||
104 | } | 132 | } |
105 | 133 | ||
106 | void sway_seat_remove_device(struct sway_seat *seat, | 134 | void sway_seat_remove_device(struct sway_seat *seat, |