From 8ecf2d37ebd31afaed9f8c3ed952f08a572ddf00 Mon Sep 17 00:00:00 2001 From: Dudemanguy Date: Sat, 20 May 2023 16:51:12 -0500 Subject: player: add drag-and-drop option Some platforms (wayland) apparently have a lot of trouble with drag and drop. The default behavior is still the same which is basically obeying what we get from the window manager/compositor, but the --drag-and-drop option allows forcibly overriding the drag and drop behavior. i.e. you can force it to always replace the playlist or append at the end. This only implements this in X11 and Wayland but in theory windows and macos could find this option useful (both hardcode the shift key for appending). Patches welcome. --- video/out/wayland_common.c | 8 ++++++-- video/out/x11_common.c | 10 +++++++--- 2 files changed, 13 insertions(+), 5 deletions(-) (limited to 'video') diff --git a/video/out/wayland_common.c b/video/out/wayland_common.c index 48f30c9c6f..cfe641fe08 100644 --- a/video/out/wayland_common.c +++ b/video/out/wayland_common.c @@ -535,8 +535,12 @@ static void data_offer_action(void *data, struct wl_data_offer *wl_data_offer, u { struct vo_wayland_state *wl = data; if (dnd_action) { - wl->dnd_action = dnd_action & WL_DATA_DEVICE_MANAGER_DND_ACTION_COPY ? - DND_REPLACE : DND_APPEND; + if (wl->vo_opts->drag_and_drop >= 0) { + wl->dnd_action = wl->vo_opts->drag_and_drop; + } else { + wl->dnd_action = dnd_action & WL_DATA_DEVICE_MANAGER_DND_ACTION_COPY ? + DND_REPLACE : DND_APPEND; + } MP_VERBOSE(wl, "DND action is %s\n", wl->dnd_action == DND_REPLACE ? "DND_REPLACE" : "DND_APPEND"); } diff --git a/video/out/x11_common.c b/video/out/x11_common.c index 0b028b9122..4a9e742cc8 100644 --- a/video/out/x11_common.c +++ b/video/out/x11_common.c @@ -988,9 +988,13 @@ static void vo_x11_dnd_handle_selection(struct vo *vo, XSelectionEvent *se) void *prop = x11_get_property(x11, x11->window, XAs(x11, DND_PROPERTY), x11->dnd_requested_format, 8, &nitems); if (prop) { - enum mp_dnd_action action = - x11->dnd_requested_action == XA(x11, XdndActionCopy) ? - DND_REPLACE : DND_APPEND; + enum mp_dnd_action action; + if (x11->opts->drag_and_drop >= 0) { + action = x11->opts->drag_and_drop; + } else { + action = x11->dnd_requested_action == XA(x11, XdndActionCopy) ? + DND_REPLACE : DND_APPEND; + } char *mime_type = x11_dnd_mime_type(x11, x11->dnd_requested_format); MP_VERBOSE(x11, "Dropping type: %s (%s)\n", -- cgit v1.2.3