From b28b26910654d67f5b6bd2d4d500948089f467f9 Mon Sep 17 00:00:00 2001 From: Consolatis <40171-Consolatis@users.noreply.gitlab.freedesktop.org> Date: Fri, 22 Nov 2024 18:29:37 +0100 Subject: [PATCH] dnd: ensure internal dnd handlers are unlinked on xwm_destroy() Fixes #3925 (cherry picked from commit be3d2b74cf4e6cfc9644a5c819be8ccd4ac81a1c) --- include/xwayland/xwm.h | 1 + xwayland/selection/dnd.c | 13 +++++++++++++ xwayland/xwm.c | 4 ++++ 3 files changed, 18 insertions(+) diff --git a/include/xwayland/xwm.h b/include/xwayland/xwm.h index 6e9eb7f38..fe15fda50 100644 --- a/include/xwayland/xwm.h +++ b/include/xwayland/xwm.h @@ -156,6 +156,7 @@ void xwm_set_cursor(struct wlr_xwm *xwm, const uint8_t *pixels, uint32_t stride, int xwm_handle_selection_event(struct wlr_xwm *xwm, xcb_generic_event_t *event); int xwm_handle_selection_client_message(struct wlr_xwm *xwm, xcb_client_message_event_t *ev); +void xwm_seat_unlink_drag_handlers(struct wlr_xwm *xwm); void xwm_set_seat(struct wlr_xwm *xwm, struct wlr_seat *seat); diff --git a/xwayland/selection/dnd.c b/xwayland/selection/dnd.c index e9cc63d9b..30084892d 100644 --- a/xwayland/selection/dnd.c +++ b/xwayland/selection/dnd.c @@ -315,6 +315,7 @@ static void seat_handle_drag_source_destroy(struct wl_listener *listener, wl_container_of(listener, xwm, seat_drag_source_destroy); wl_list_remove(&xwm->seat_drag_source_destroy.link); + wl_list_init(&xwm->seat_drag_source_destroy.link); xwm->drag_focus = NULL; } @@ -337,3 +338,15 @@ void xwm_seat_handle_start_drag(struct wlr_xwm *xwm, struct wlr_drag *drag) { xwm->seat_drag_source_destroy.notify = seat_handle_drag_source_destroy; } } + +void xwm_seat_unlink_drag_handlers(struct wlr_xwm *xwm) { + wl_list_remove(&xwm->seat_drag_source_destroy.link); + + if (!xwm->drag) { + return; + } + wl_list_remove(&xwm->seat_drag_focus.link); + wl_list_remove(&xwm->seat_drag_motion.link); + wl_list_remove(&xwm->seat_drag_drop.link); + wl_list_remove(&xwm->seat_drag_destroy.link); +} diff --git a/xwayland/xwm.c b/xwayland/xwm.c index 0807d32ad..a1c597852 100644 --- a/xwayland/xwm.c +++ b/xwayland/xwm.c @@ -1879,6 +1879,8 @@ void xwm_destroy(struct wlr_xwm *xwm) { xwm_selection_finish(&xwm->primary_selection); xwm_selection_finish(&xwm->dnd_selection); + xwm_seat_unlink_drag_handlers(xwm); + if (xwm->seat) { if (xwm->seat->selection_source && data_source_is_xwayland(xwm->seat->selection_source)) { @@ -2173,6 +2175,8 @@ struct wlr_xwm *xwm_create(struct wlr_xwayland *xwayland, int wm_fd) { wl_list_init(&xwm->surfaces_in_stack_order); wl_list_init(&xwm->unpaired_surfaces); wl_list_init(&xwm->pending_startup_ids); + wl_list_init(&xwm->seat_drag_source_destroy.link); + xwm->ping_timeout = 10000; xwm->xcb_conn = xcb_connect_to_fd(wm_fd, NULL);