mirror of
https://gitlab.freedesktop.org/wlroots/wlroots.git
synced 2025-11-02 09:01:38 -05:00
data-device: reset focused surface when destroyed
The surface may be destroyed before the struct wlr_seat_client.
Spotted by Consolatis.
(cherry picked from commit 71943b3b1e)
This commit is contained in:
parent
1fc9409df2
commit
35ab453360
2 changed files with 18 additions and 1 deletions
|
|
@ -126,6 +126,7 @@ struct wlr_drag {
|
||||||
|
|
||||||
struct wl_listener source_destroy;
|
struct wl_listener source_destroy;
|
||||||
struct wl_listener seat_client_destroy;
|
struct wl_listener seat_client_destroy;
|
||||||
|
struct wl_listener focus_destroy;
|
||||||
struct wl_listener icon_destroy;
|
struct wl_listener icon_destroy;
|
||||||
|
|
||||||
void *data;
|
void *data;
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,14 @@ static void drag_handle_seat_client_destroy(struct wl_listener *listener,
|
||||||
wl_list_remove(&drag->seat_client_destroy.link);
|
wl_list_remove(&drag->seat_client_destroy.link);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void drag_set_focus(struct wlr_drag *drag,
|
||||||
|
struct wlr_surface *surface, double sx, double sy);
|
||||||
|
|
||||||
|
static void drag_handle_focus_destroy(struct wl_listener *listener, void *data) {
|
||||||
|
struct wlr_drag *drag = wl_container_of(listener, drag, focus_destroy);
|
||||||
|
drag_set_focus(drag, NULL, 0, 0);
|
||||||
|
}
|
||||||
|
|
||||||
static void drag_set_focus(struct wlr_drag *drag,
|
static void drag_set_focus(struct wlr_drag *drag,
|
||||||
struct wlr_surface *surface, double sx, double sy) {
|
struct wlr_surface *surface, double sx, double sy) {
|
||||||
if (drag->focus == surface) {
|
if (drag->focus == surface) {
|
||||||
|
|
@ -48,9 +56,12 @@ static void drag_set_focus(struct wlr_drag *drag,
|
||||||
}
|
}
|
||||||
|
|
||||||
drag->focus_client = NULL;
|
drag->focus_client = NULL;
|
||||||
drag->focus = NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
wl_list_remove(&drag->focus_destroy.link);
|
||||||
|
wl_list_init(&drag->focus_destroy.link);
|
||||||
|
drag->focus = NULL;
|
||||||
|
|
||||||
if (!surface) {
|
if (!surface) {
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
@ -99,6 +110,8 @@ static void drag_set_focus(struct wlr_drag *drag,
|
||||||
|
|
||||||
drag->focus = surface;
|
drag->focus = surface;
|
||||||
drag->focus_client = focus_client;
|
drag->focus_client = focus_client;
|
||||||
|
drag->focus_destroy.notify = drag_handle_focus_destroy;
|
||||||
|
wl_signal_add(&surface->events.destroy, &drag->focus_destroy);
|
||||||
drag->seat_client_destroy.notify = drag_handle_seat_client_destroy;
|
drag->seat_client_destroy.notify = drag_handle_seat_client_destroy;
|
||||||
wl_signal_add(&focus_client->events.destroy, &drag->seat_client_destroy);
|
wl_signal_add(&focus_client->events.destroy, &drag->seat_client_destroy);
|
||||||
|
|
||||||
|
|
@ -150,6 +163,7 @@ static void drag_destroy(struct wlr_drag *drag) {
|
||||||
if (drag->source) {
|
if (drag->source) {
|
||||||
wl_list_remove(&drag->source_destroy.link);
|
wl_list_remove(&drag->source_destroy.link);
|
||||||
}
|
}
|
||||||
|
wl_list_remove(&drag->focus_destroy.link);
|
||||||
|
|
||||||
if (drag->icon != NULL) {
|
if (drag->icon != NULL) {
|
||||||
drag_icon_destroy(drag->icon);
|
drag_icon_destroy(drag->icon);
|
||||||
|
|
@ -410,6 +424,8 @@ struct wlr_drag *wlr_drag_create(struct wlr_seat_client *seat_client,
|
||||||
wl_signal_init(&drag->events.drop);
|
wl_signal_init(&drag->events.drop);
|
||||||
wl_signal_init(&drag->events.destroy);
|
wl_signal_init(&drag->events.destroy);
|
||||||
|
|
||||||
|
wl_list_init(&drag->focus_destroy.link);
|
||||||
|
|
||||||
drag->seat = seat_client->seat;
|
drag->seat = seat_client->seat;
|
||||||
drag->seat_client = seat_client;
|
drag->seat_client = seat_client;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue