backend/wayland: fix touch device not added on startup

We were firing the new_input signal on backend initialization,
before the compositor had the chance to add a listener for it.

Mimick what's done for wl_keyboard: if the backend hasn't been
started, delay wl_touch initialization.

Closes: https://gitlab.freedesktop.org/wlroots/wlroots/-/issues/3473
This commit is contained in:
Simon Ser 2022-08-11 09:09:37 +02:00
parent f244094682
commit 8c3c6987db
3 changed files with 10 additions and 2 deletions

View File

@ -424,6 +424,10 @@ static bool backend_start(struct wlr_backend *backend) {
init_seat_keyboard(seat);
}
if (seat->wl_touch) {
init_seat_touch(seat);
}
if (wl->tablet_manager) {
init_seat_tablet(seat);
}

View File

@ -212,7 +212,7 @@ static const struct wlr_touch_impl touch_impl = {
.name = "wl-touch",
};
static void init_seat_touch(struct wlr_wl_seat *seat) {
void init_seat_touch(struct wlr_wl_seat *seat) {
assert(seat->wl_touch);
char name[128] = {0};
@ -333,8 +333,10 @@ static void seat_handle_capabilities(void *data, struct wl_seat *wl_seat,
wlr_log(WLR_DEBUG, "seat '%s' offering touch", seat->name);
seat->wl_touch = wl_seat_get_touch(wl_seat);
if (backend->started) {
init_seat_touch(seat);
}
}
if (!(caps & WL_SEAT_CAPABILITY_TOUCH) && seat->wl_touch != NULL) {
wlr_log(WLR_DEBUG, "seat '%s' dropping touch", seat->name);

View File

@ -144,6 +144,8 @@ void init_seat_pointer(struct wlr_wl_seat *seat);
void finish_seat_pointer(struct wlr_wl_seat *seat);
void create_pointer(struct wlr_wl_seat *seat, struct wlr_wl_output *output);
void init_seat_touch(struct wlr_wl_seat *seat);
void init_seat_tablet(struct wlr_wl_seat *seat);
void finish_seat_tablet(struct wlr_wl_seat *seat);