Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions packages/desktop_drop/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## Unreleased

* [desktop_drop] [Linux] prefer the `text/uri-list` drag target over `application/vnd.portal.filetransfer`. File managers such as Dolphin and dde-fileManager advertise the portal target on plain X11 drags too, where `org.freedesktop.portal.FileTransfer.RetrieveFiles` rejects the key with `AccessDenied: Invalid transfer` and the drop is silently lost. The portal target is now a fallback, used only when the source offers nothing else. [#501](https://github.com/MixinNetwork/flutter-plugins/pull/501)

## 0.8.4

* fix: use builtInKotlin property to conditionally apply KGP [#500](https://github.com/MixinNetwork/flutter-plugins/pull/500)
Expand Down
29 changes: 22 additions & 7 deletions packages/desktop_drop/linux/desktop_drop_plugin.cc
Original file line number Diff line number Diff line change
Expand Up @@ -112,14 +112,29 @@ void desktop_drop_plugin_register_with_registrar(FlPluginRegistrar *registrar) {
g_object_new(desktop_drop_plugin_get_type(), nullptr));

auto *fl_view = fl_plugin_registrar_get_view(registrar);
// Register portal file transfer target FIRST (highest priority)
// then STRING, then URI targets
static GtkTargetEntry entries[] = {
{strdup("application/vnd.portal.filetransfer"), GTK_TARGET_OTHER_APP, 0},
{strdup("STRING"), GTK_TARGET_OTHER_APP, 0}
};
gtk_drag_dest_set(GTK_WIDGET(fl_view), GTK_DEST_DEFAULT_ALL, entries, 2, GDK_ACTION_COPY);
// Match `text/uri-list` before `application/vnd.portal.filetransfer`.
//
// GTK picks the first destination target the drag source also offers, so
// whichever target is registered first wins. The portal transfer key is
// only resolvable when the source is sandboxed and has actually registered
// a FileTransfer with the document portal. File managers such as Dolphin
// and dde-fileManager advertise `application/vnd.portal.filetransfer` on
// plain X11 drags as well, where `RetrieveFiles` then rejects the key with
// `org.freedesktop.DBus.Error.AccessDenied: Invalid transfer` and the drop
// is silently lost. Register the URI targets first and keep the portal key
// (and a bare STRING) as fallbacks for sources that offer nothing better.
gtk_drag_dest_set(GTK_WIDGET(fl_view), GTK_DEST_DEFAULT_ALL, nullptr, 0,
GDK_ACTION_COPY);
gtk_drag_dest_add_uri_targets(GTK_WIDGET(fl_view));
GtkTargetList *target_list = gtk_drag_dest_get_target_list(GTK_WIDGET(fl_view));
if (target_list != nullptr) {
gtk_target_list_add(
target_list,
gdk_atom_intern_static_string("application/vnd.portal.filetransfer"),
GTK_TARGET_OTHER_APP, 0);
gtk_target_list_add(target_list, gdk_atom_intern_static_string("STRING"),
GTK_TARGET_OTHER_APP, 0);
}

g_autoptr(FlStandardMethodCodec) codec = fl_standard_method_codec_new();
FlMethodChannel *channel =
Expand Down