diff options
-rw-r--r-- | sway/input/input-manager.c | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/sway/input/input-manager.c b/sway/input/input-manager.c index a7b66b86..592e6f45 100644 --- a/sway/input/input-manager.c +++ b/sway/input/input-manager.c | |||
@@ -45,6 +45,18 @@ struct sway_seat *input_manager_get_seat(const char *seat_name, bool create) { | |||
45 | return create ? seat_create(seat_name) : NULL; | 45 | return create ? seat_create(seat_name) : NULL; |
46 | } | 46 | } |
47 | 47 | ||
48 | struct sway_seat *input_manager_sway_seat_from_wlr_seat(struct wlr_seat *wlr_seat) { | ||
49 | struct sway_seat *seat = NULL; | ||
50 | |||
51 | wl_list_for_each(seat, &server.input->seats, link) { | ||
52 | if (seat->wlr_seat == wlr_seat) { | ||
53 | return seat; | ||
54 | } | ||
55 | } | ||
56 | |||
57 | return NULL; | ||
58 | } | ||
59 | |||
48 | char *input_device_get_identifier(struct wlr_input_device *device) { | 60 | char *input_device_get_identifier(struct wlr_input_device *device) { |
49 | int vendor = device->vendor; | 61 | int vendor = device->vendor; |
50 | int product = device->product; | 62 | int product = device->product; |
@@ -288,9 +300,11 @@ void handle_virtual_keyboard(struct wl_listener *listener, void *data) { | |||
288 | struct wlr_virtual_keyboard_v1 *keyboard = data; | 300 | struct wlr_virtual_keyboard_v1 *keyboard = data; |
289 | struct wlr_input_device *device = &keyboard->input_device; | 301 | struct wlr_input_device *device = &keyboard->input_device; |
290 | 302 | ||
291 | struct sway_seat *seat = input_manager_get_default_seat(); | 303 | // TODO: Amend protocol to allow NULL seat |
304 | struct sway_seat *seat = keyboard->seat ? | ||
305 | input_manager_sway_seat_from_wlr_seat(keyboard->seat) : | ||
306 | input_manager_get_default_seat(); | ||
292 | 307 | ||
293 | // TODO: The user might want this on a different seat | ||
294 | struct sway_input_device *input_device = | 308 | struct sway_input_device *input_device = |
295 | calloc(1, sizeof(struct sway_input_device)); | 309 | calloc(1, sizeof(struct sway_input_device)); |
296 | if (!sway_assert(input_device, "could not allocate input device")) { | 310 | if (!sway_assert(input_device, "could not allocate input device")) { |
@@ -318,8 +332,9 @@ void handle_virtual_pointer(struct wl_listener *listener, void *data) { | |||
318 | struct wlr_virtual_pointer_v1 *pointer = event->new_pointer; | 332 | struct wlr_virtual_pointer_v1 *pointer = event->new_pointer; |
319 | struct wlr_input_device *device = &pointer->input_device; | 333 | struct wlr_input_device *device = &pointer->input_device; |
320 | 334 | ||
321 | /* TODO: Consider suggested seat when creating the pointer */ | 335 | struct sway_seat *seat = event->suggested_seat ? |
322 | struct sway_seat *seat = input_manager_get_default_seat(); | 336 | input_manager_sway_seat_from_wlr_seat(event->suggested_seat) : |
337 | input_manager_get_default_seat(); | ||
323 | 338 | ||
324 | struct sway_input_device *input_device = | 339 | struct sway_input_device *input_device = |
325 | calloc(1, sizeof(struct sway_input_device)); | 340 | calloc(1, sizeof(struct sway_input_device)); |