seat/dnd: support null drag icon surfaces

As per the Wayland spec [1]:

> The icon surface is an optional (can be NULL) surface that provides an
> icon to be moved around with the cursor.

However, as of now Sway "start_drag" signal handler does not starts the
DND session unless a non-NULL drag icons is provided. This patch fixes
it by skipping handling of the drag icon if it is null.

Fixes #5509

[1] https://wayland.freedesktop.org/docs/html/apa.html#protocol-spec-wl_data_device

Signed-off-by: Nick Diego Yamane <nickdiego@igalia.com>
master
Nick Diego Yamane 4 years ago committed by Simon Ser
parent bac9559665
commit e5954f321f

@ -470,31 +470,29 @@ static void handle_start_drag(struct wl_listener *listener, void *data) {
wl_signal_add(&wlr_drag->events.destroy, &drag->destroy); wl_signal_add(&wlr_drag->events.destroy, &drag->destroy);
struct wlr_drag_icon *wlr_drag_icon = wlr_drag->icon; struct wlr_drag_icon *wlr_drag_icon = wlr_drag->icon;
if (wlr_drag_icon == NULL) { if (wlr_drag_icon != NULL) {
return; struct sway_drag_icon *icon = calloc(1, sizeof(struct sway_drag_icon));
} if (icon == NULL) {
sway_log(SWAY_ERROR, "Allocation failed");
struct sway_drag_icon *icon = calloc(1, sizeof(struct sway_drag_icon)); return;
if (icon == NULL) { }
sway_log(SWAY_ERROR, "Allocation failed"); icon->seat = seat;
return; icon->wlr_drag_icon = wlr_drag_icon;
} wlr_drag_icon->data = icon;
icon->seat = seat;
icon->wlr_drag_icon = wlr_drag_icon;
wlr_drag_icon->data = icon;
icon->surface_commit.notify = drag_icon_handle_surface_commit; icon->surface_commit.notify = drag_icon_handle_surface_commit;
wl_signal_add(&wlr_drag_icon->surface->events.commit, &icon->surface_commit); wl_signal_add(&wlr_drag_icon->surface->events.commit, &icon->surface_commit);
icon->unmap.notify = drag_icon_handle_unmap; icon->unmap.notify = drag_icon_handle_unmap;
wl_signal_add(&wlr_drag_icon->events.unmap, &icon->unmap); wl_signal_add(&wlr_drag_icon->events.unmap, &icon->unmap);
icon->map.notify = drag_icon_handle_map; icon->map.notify = drag_icon_handle_map;
wl_signal_add(&wlr_drag_icon->events.map, &icon->map); wl_signal_add(&wlr_drag_icon->events.map, &icon->map);
icon->destroy.notify = drag_icon_handle_destroy; icon->destroy.notify = drag_icon_handle_destroy;
wl_signal_add(&wlr_drag_icon->events.destroy, &icon->destroy); wl_signal_add(&wlr_drag_icon->events.destroy, &icon->destroy);
wl_list_insert(&root->drag_icons, &icon->link); wl_list_insert(&root->drag_icons, &icon->link);
drag_icon_update_position(icon); drag_icon_update_position(icon);
}
seatop_begin_default(seat); seatop_begin_default(seat);
} }

Loading…
Cancel
Save