diff options
author | Andri Yngvason <andri@yngvason.is> | 2020-01-01 17:14:37 +0000 |
---|---|---|
committer | Drew DeVault <sir@cmpwn.com> | 2020-01-01 10:21:04 -0700 |
commit | d510684c4790bb6dd1de9dfc3ab220db4518eea3 (patch) | |
tree | 5930416dac26b0c5d759b0114aa1ff9e91164a41 /sway/input | |
parent | 79c5f5ba1245a8c3d575770419a6501447e78919 (diff) |
input: Assign virtual input devices to their selected seats
Diffstat (limited to 'sway/input')
-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) { return create ? seat_create(seat_name) : NULL; } +struct sway_seat *input_manager_sway_seat_from_wlr_seat(struct wlr_seat *wlr_seat) { + struct sway_seat *seat = NULL; + + wl_list_for_each(seat, &server.input->seats, link) { + if (seat->wlr_seat == wlr_seat) { + return seat; + } + } + + return NULL; +} + char *input_device_get_identifier(struct wlr_input_device *device) { int vendor = device->vendor; int product = device->product; @@ -288,9 +300,11 @@ void handle_virtual_keyboard(struct wl_listener *listener, void *data) { struct wlr_virtual_keyboard_v1 *keyboard = data; struct wlr_input_device *device = &keyboard->input_device; - struct sway_seat *seat = input_manager_get_default_seat(); + // TODO: Amend protocol to allow NULL seat + struct sway_seat *seat = keyboard->seat ? + input_manager_sway_seat_from_wlr_seat(keyboard->seat) : + input_manager_get_default_seat(); - // TODO: The user might want this on a different seat struct sway_input_device *input_device = calloc(1, sizeof(struct sway_input_device)); if (!sway_assert(input_device, "could not allocate input device")) { @@ -318,8 +332,9 @@ void handle_virtual_pointer(struct wl_listener *listener, void *data) { struct wlr_virtual_pointer_v1 *pointer = event->new_pointer; struct wlr_input_device *device = &pointer->input_device; - /* TODO: Consider suggested seat when creating the pointer */ - struct sway_seat *seat = input_manager_get_default_seat(); + struct sway_seat *seat = event->suggested_seat ? + input_manager_sway_seat_from_wlr_seat(event->suggested_seat) : + input_manager_get_default_seat(); struct sway_input_device *input_device = calloc(1, sizeof(struct sway_input_device)); |