diff --git a/include/input/touch.h b/include/input/touch.h new file mode 100644 index 00000000..27e6a261 --- /dev/null +++ b/include/input/touch.h @@ -0,0 +1,10 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +#ifndef LABWC_TOUCH_H +#define LABWC_TOUCH_H + +struct seat; + +void touch_init(struct seat *seat); +void touch_finish(struct seat *seat); + +#endif /* LABWC_TOUCH_H */ diff --git a/include/labwc.h b/include/labwc.h index ebabb3c6..14299f1f 100644 --- a/include/labwc.h +++ b/include/labwc.h @@ -418,9 +418,6 @@ void keyboard_init(struct seat *seat); bool keyboard_any_modifiers_pressed(struct wlr_keyboard *keyboard); void keyboard_finish(struct seat *seat); -void touch_init(struct seat *seat); -void touch_finish(struct seat *seat); - void seat_init(struct server *server); void seat_finish(struct server *server); void seat_reconfigure(struct server *server); diff --git a/src/input/cursor.c b/src/input/cursor.c index c2275944..97de12b4 100644 --- a/src/input/cursor.c +++ b/src/input/cursor.c @@ -14,6 +14,7 @@ #include "dnd.h" #include "idle.h" #include "input/gestures.h" +#include "input/touch.h" #include "labwc.h" #include "menu/menu.h" #include "regions.h" @@ -1201,6 +1202,7 @@ cursor_init(struct seat *seat) wl_signal_add(&seat->cursor->events.frame, &seat->cursor_frame); gestures_init(seat); + touch_init(seat); seat->request_cursor.notify = request_cursor_notify; wl_signal_add(&seat->seat->events.request_set_cursor, @@ -1226,6 +1228,7 @@ void cursor_finish(struct seat *seat) wl_list_remove(&seat->cursor_frame.link); gestures_finish(seat); + touch_finish(seat); wl_list_remove(&seat->request_cursor.link); wl_list_remove(&seat->request_set_selection.link); diff --git a/src/input/touch.c b/src/input/touch.c index 9b7f2f67..9ee11bf7 100644 --- a/src/input/touch.c +++ b/src/input/touch.c @@ -1,10 +1,11 @@ // SPDX-License-Identifier: GPL-2.0-only #include #include -#include "idle.h" -#include "labwc.h" #include "common/mem.h" #include "common/scene-helpers.h" +#include "idle.h" +#include "input/touch.h" +#include "labwc.h" /* Holds layout -> surface offsets to report motion events in relative coords */ struct touch_point { diff --git a/src/seat.c b/src/seat.c index 807c5a5b..778729ac 100644 --- a/src/seat.c +++ b/src/seat.c @@ -417,9 +417,8 @@ seat_init(struct server *server) } wlr_cursor_attach_output_layout(seat->cursor, server->output_layout); - keyboard_init(seat); cursor_init(seat); - touch_init(seat); + keyboard_init(seat); } void @@ -434,14 +433,8 @@ seat_finish(struct server *server) input_device_destroy(&input->destroy, NULL); } - keyboard_finish(seat); - /* - * Caution - touch_finish() unregisters event listeners from - * seat->cursor and must come before cursor_finish(), otherwise - * a use-after-free occurs. - */ - touch_finish(seat); cursor_finish(seat); + keyboard_finish(seat); } static void