]> git.mdlowis.com Git - proto/labwc.git/commitdiff
Make touch depend on cursor to prevent racing
authorConsolatis <35009135+Consolatis@users.noreply.github.com>
Sun, 3 Sep 2023 17:07:55 +0000 (19:07 +0200)
committerJohan Malm <johanmalm@users.noreply.github.com>
Mon, 30 Oct 2023 21:14:04 +0000 (21:14 +0000)
include/input/touch.h [new file with mode: 0644]
include/labwc.h
src/input/cursor.c
src/input/touch.c
src/seat.c

diff --git a/include/input/touch.h b/include/input/touch.h
new file mode 100644 (file)
index 0000000..27e6a26
--- /dev/null
@@ -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 */
index ebabb3c6c66ee4ff47e34d61ad7b4228c2fe764c..14299f1fd80bc9faf9723cb0187c8de3d9070bac 100644 (file)
@@ -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);
index c227594438c234c76a8cd88e7b728442eeb00d74..97de12b4c3d6c299a8fc1fc2baf3fd91d5dc6093 100644 (file)
@@ -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);
index 9b7f2f67978150ae6c5db8cd321965067f9dad31..9ee11bf7e708c2e232d0936a739d8d37d9a67507 100644 (file)
@@ -1,10 +1,11 @@
 // SPDX-License-Identifier: GPL-2.0-only
 #include <wayland-util.h>
 #include <wlr/types/wlr_touch.h>
-#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 {
index 807c5a5b7d6c539d9f17ecb4080e101640e5d438..778729ac367e4035e30fa5bef45bc9105f8e5fed 100644 (file)
@@ -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