From 8c3c6987dbdffa74eb1fee901b4ab1d73641e29f Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Thu, 11 Aug 2022 09:09:37 +0200 Subject: [PATCH] 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 --- backend/wayland/backend.c | 4 ++++ backend/wayland/seat.c | 6 ++++-- include/backend/wayland.h | 2 ++ 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/backend/wayland/backend.c b/backend/wayland/backend.c index 07df6912..2980324f 100644 --- a/backend/wayland/backend.c +++ b/backend/wayland/backend.c @@ -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); } diff --git a/backend/wayland/seat.c b/backend/wayland/seat.c index d1c75b39..655f9dad 100644 --- a/backend/wayland/seat.c +++ b/backend/wayland/seat.c @@ -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,7 +333,9 @@ 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); - init_seat_touch(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); diff --git a/include/backend/wayland.h b/include/backend/wayland.h index 5baaac9d..3a0b1327 100644 --- a/include/backend/wayland.h +++ b/include/backend/wayland.h @@ -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);