diff options
author | Tony Crisci <tony@dubstepdish.com> | 2017-12-10 15:37:17 -0500 |
---|---|---|
committer | Tony Crisci <tony@dubstepdish.com> | 2017-12-10 15:37:17 -0500 |
commit | 4d449743c5c476f1891a64b31f00cb7d5dd1555b (patch) | |
tree | 5dc510182eaaa41721a2b78859078d1010e9c60d /sway/input/seat.c | |
parent | set focus on new window (diff) | |
download | sway-4d449743c5c476f1891a64b31f00cb7d5dd1555b.tar.gz sway-4d449743c5c476f1891a64b31f00cb7d5dd1555b.tar.zst sway-4d449743c5c476f1891a64b31f00cb7d5dd1555b.zip |
keyboard remove
Diffstat (limited to 'sway/input/seat.c')
-rw-r--r-- | sway/input/seat.c | 31 |
1 files changed, 29 insertions, 2 deletions
diff --git a/sway/input/seat.c b/sway/input/seat.c index 0a5329c8..7c827374 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_keyboard *seat_keyboard_from_device(struct sway_seat *seat, | ||
46 | struct wlr_input_device *device) { | ||
47 | struct sway_keyboard *keyboard = NULL; | ||
48 | wl_list_for_each(keyboard, &seat->keyboards, link) { | ||
49 | if (keyboard->device == device) { | ||
50 | return keyboard; | ||
51 | } | ||
52 | } | ||
53 | |||
54 | return keyboard; | ||
55 | } | ||
56 | |||
45 | static void seat_add_pointer(struct sway_seat *seat, | 57 | static void seat_add_pointer(struct sway_seat *seat, |
46 | struct wlr_input_device *device) { | 58 | struct wlr_input_device *device) { |
47 | // TODO pointer configuration | 59 | // TODO pointer configuration |
@@ -50,8 +62,13 @@ static void seat_add_pointer(struct sway_seat *seat, | |||
50 | 62 | ||
51 | static void seat_add_keyboard(struct sway_seat *seat, | 63 | static void seat_add_keyboard(struct sway_seat *seat, |
52 | struct wlr_input_device *device) { | 64 | struct wlr_input_device *device) { |
53 | struct sway_keyboard *keyboard = sway_keyboard_create(seat, device); | 65 | // TODO keyboard configuration |
54 | wl_list_insert(&seat->keyboards, &keyboard->link); | 66 | if (seat_keyboard_from_device(seat, device)) { |
67 | // already added | ||
68 | return; | ||
69 | } | ||
70 | |||
71 | sway_keyboard_create(seat, device); | ||
55 | wlr_seat_set_keyboard(seat->seat, device); | 72 | wlr_seat_set_keyboard(seat->seat, device); |
56 | } | 73 | } |
57 | 74 | ||
@@ -73,6 +90,14 @@ void sway_seat_add_device(struct sway_seat *seat, | |||
73 | } | 90 | } |
74 | } | 91 | } |
75 | 92 | ||
93 | static void seat_remove_keyboard(struct sway_seat *seat, | ||
94 | struct wlr_input_device *device) { | ||
95 | struct sway_keyboard *keyboard = seat_keyboard_from_device(seat, device); | ||
96 | if (keyboard) { | ||
97 | sway_keyboard_destroy(keyboard); | ||
98 | } | ||
99 | } | ||
100 | |||
76 | static void seat_remove_pointer(struct sway_seat *seat, | 101 | static void seat_remove_pointer(struct sway_seat *seat, |
77 | struct wlr_input_device *device) { | 102 | struct wlr_input_device *device) { |
78 | wlr_cursor_detach_input_device(seat->cursor->cursor, device); | 103 | wlr_cursor_detach_input_device(seat->cursor->cursor, device); |
@@ -86,6 +111,8 @@ void sway_seat_remove_device(struct sway_seat *seat, | |||
86 | seat_remove_pointer(seat, device); | 111 | seat_remove_pointer(seat, device); |
87 | break; | 112 | break; |
88 | case WLR_INPUT_DEVICE_KEYBOARD: | 113 | case WLR_INPUT_DEVICE_KEYBOARD: |
114 | seat_remove_keyboard(seat, device); | ||
115 | break; | ||
89 | case WLR_INPUT_DEVICE_TOUCH: | 116 | case WLR_INPUT_DEVICE_TOUCH: |
90 | case WLR_INPUT_DEVICE_TABLET_PAD: | 117 | case WLR_INPUT_DEVICE_TABLET_PAD: |
91 | case WLR_INPUT_DEVICE_TABLET_TOOL: | 118 | case WLR_INPUT_DEVICE_TABLET_TOOL: |