data-device: destroy previous source when starting drag

This supersedes f24e17259e and
04c9ca4198. These commits were manually removing
wlr_data_source destroy handlers when starting a new drag. This is error-prone.

Instead, this commit destroys the previous source whenever we start a new drag.
This commit is contained in:
emersion 2019-02-05 10:49:28 +01:00
parent b2f56ad4a8
commit 556bf3ac31
No known key found for this signature in database
GPG key ID: 0FDE7BE0E88F5E48
2 changed files with 4 additions and 9 deletions

View file

@ -487,12 +487,12 @@ bool seat_client_start_drag(struct wlr_seat_client *client,
drag_set_focus(drag, point->surface, point->sx, point->sy); drag_set_focus(drag, point->surface, point->sx, point->sy);
} }
seat->drag = drag; // TODO: unset this thing somewhere seat->drag = drag;
seat->drag_serial = serial; seat->drag_serial = serial;
if (seat->drag_source != NULL) { // We need to destroy the previous source, because listeners only expect one
wl_list_remove(&seat->drag_source_destroy.link); // active drag source at a time.
} wlr_data_source_destroy(seat->drag_source);
seat->drag_source = source; seat->drag_source = source;
if (source != NULL) { if (source != NULL) {
seat->drag_source_destroy.notify = seat_handle_drag_source_destroy; seat->drag_source_destroy.notify = seat_handle_drag_source_destroy;

View file

@ -315,8 +315,6 @@ static void seat_handle_drag_source_destroy(struct wl_listener *listener,
wl_container_of(listener, xwm, seat_drag_source_destroy); wl_container_of(listener, xwm, seat_drag_source_destroy);
wl_list_remove(&xwm->seat_drag_source_destroy.link); wl_list_remove(&xwm->seat_drag_source_destroy.link);
xwm->seat_drag_source_destroy.link.prev = NULL;
xwm->seat_drag_source_destroy.link.next = NULL;
xwm->drag_focus = NULL; xwm->drag_focus = NULL;
} }
@ -334,9 +332,6 @@ void xwm_seat_handle_start_drag(struct wlr_xwm *xwm, struct wlr_drag *drag) {
wl_signal_add(&drag->events.destroy, &xwm->seat_drag_destroy); wl_signal_add(&drag->events.destroy, &xwm->seat_drag_destroy);
xwm->seat_drag_destroy.notify = seat_handle_drag_destroy; xwm->seat_drag_destroy.notify = seat_handle_drag_destroy;
if (xwm->seat_drag_source_destroy.link.prev != NULL) {
wl_list_remove(&xwm->seat_drag_source_destroy.link);
}
wl_signal_add(&drag->source->events.destroy, wl_signal_add(&drag->source->events.destroy,
&xwm->seat_drag_source_destroy); &xwm->seat_drag_source_destroy);
xwm->seat_drag_source_destroy.notify = seat_handle_drag_source_destroy; xwm->seat_drag_source_destroy.notify = seat_handle_drag_source_destroy;