Open Bug 1722301 (linuxdad) Opened 3 years ago Updated 1 year ago

[Linux] Fix drag'n'drop on Linux

Categories

(Core :: Widget: Gtk, enhancement, P2)

enhancement

Tracking

()

People

(Reporter: otte, Unassigned)

References

(Depends on 32 open bugs, Blocks 1 open bug)

Details

User Agent: Mozilla/5.0 (Windows NT 6.3; Win64; x64; rv:91.0) Gecko/20100101 Firefox/91.0

Steps to reproduce:

  1. Drag an image from Firefox
  2. Drag onto an application expecting images

Actual results:

The drop is rejected

Expected results:

The drop works, just like it does in Windows.

I was working on image DND support in GTK and tried with Firefox, and It seems that Firefox only provides its internal mime types for images (like application/x-moz-nativeimage) but not image/png or image/jpeg and that severly limits where images can be dragged.

I did not test if this is just about Wayland or also affects X11.

The Bugbug bot thinks this bug should belong to the 'Core::Widget: Gtk' component, and is moving the bug to that component. Please revert this change in case you think the bot is wrong.

Component: Untriaged → Widget: Gtk
Product: Firefox → Core

Benjamin, which application do you use as a target? I see D&D works (for some images) with Nautilus.

Flags: needinfo?(otte)
Blocks: wayland
Priority: -- → P2

Also gimp works for me. But it has to be a real image and not an html placeholder (which is provided by google image search page).

I think both Gimp (which uses X11 and XWayland, so that's a separate can of worms anyway) and Nautilus accept file drops, and Firefox provides XdndDirectSave. I'm currently blanking on a good example for apps that accept DND drags for images but not just files, so all I can offer is the demos I wrote in gtk4 master to test just that case, but they aren't in distros yet.

Here's a way to reproduce:

  1. Run WAYLAND_DEBUG=1 build/demos/widget-factory/gtk4-widget-factory 2>&1 | grep wl_data_source

  2. Start an image drag (I usually use imgur images like https://i.imgur.com/YpFk55I.png ). The drag can immediately be cancelled.

  3. Observe the debug output.

For me it contains this for the above page:

[3316387.467]  -> wl_data_device_manager@11.create_data_source(new id wl_data_source@72)
[3316387.483]  -> wl_data_source@72.offer("text/x-moz-url")
[3316387.494]  -> wl_data_source@72.offer("_NETSCAPE_URL")
[3316387.504]  -> wl_data_source@72.offer("text/x-moz-url-data")
[3316387.514]  -> wl_data_source@72.offer("text/x-moz-url-desc")
[3316387.524]  -> wl_data_source@72.offer("application/x-moz-custom-clipdata")
[3316387.534]  -> wl_data_source@72.offer("text/_moz_htmlcontext")
[3316387.543]  -> wl_data_source@72.offer("text/_moz_htmlinfo")
[3316387.552]  -> wl_data_source@72.offer("text/html")
[3316387.561]  -> wl_data_source@72.offer("text/unicode")
[3316387.571]  -> wl_data_source@72.offer("text/plain;charset=utf-8")
[3316387.581]  -> wl_data_source@72.offer("text/plain")
[3316387.590]  -> wl_data_source@72.offer("application/x-moz-nativeimage")
[3316387.599]  -> wl_data_source@72.offer("application/x-moz-file-promise")
[3316387.609]  -> wl_data_source@72.offer("XdndDirectSave0")
[3316387.619]  -> wl_data_source@72.offer("application/x-moz-file-promise-url")
[3316387.628]  -> wl_data_source@72.offer("application/x-moz-file-promise-dest-filename")
[3316387.642]  -> wl_data_source@72.set_actions(3)
[3316387.653]  -> wl_data_device@24.start_drag(wl_data_source@72, wl_surface@52, wl_surface@57, 748864)

And that does not include "image/png" (or any other image format).

Flags: needinfo?(otte)

Okay, have a patch ready although I can't find any regular application which accept image/png (or jpg and so on) as a drop target :)

Anyway, beside the image/* drop support we definitely needs to:

  • remove XdndDirectSave0 from images/files accessible by URL as it fails. XdndDirectSave0 seems to work for local files only.
  • when we do D&D of html links we should use some decent file name, perhaps x-moz-url-desc or so and not 'url' and similar one.

I was just reminded: You can flatpak install https://nightly.gnome.org/repo/appstream/org.gtk.WidgetFactory4.flatpakref && flatpak run org.gtk.WidgetFactory4 - the images in the bottom left notebook can be dragged to (and from). Also: GTK 4.4.0 has that, too, if you can get that from anywhere.

That works, thanks.

Benjamin, latest nightly exports images in D&D (Bug 1730141) but we need more fixes to make sure it works reliably. But it seems to work with WidgetFactory4 somehow now.

Summary: Support image mime types in drag'n'drop on Wayland → [Linux] Fix drag'n'drop on Linux
Version: Firefox 88 → Trunk
Alias: linuxdad
Depends on: 1735773
Depends on: 1735744
Depends on: 1736523

i'm facing the same issue, i can't drag and drop anything.
organizing tabs, bookmarks, open file in current tab, upload file etc.
anything that involving drag and drop.
dragging web widgets also glitching ex. online diagram editor, phpmyadmin designer etc.
i'm on archlinux 5.10.74-1-lts

(In reply to bokunocode from comment #9)

i'm facing the same issue, i can't drag and drop anything.
organizing tabs, bookmarks, open file in current tab, upload file etc.
anything that involving drag and drop.
dragging web widgets also glitching ex. online diagram editor, phpmyadmin designer etc.
i'm on archlinux 5.10.74-1-lts

That's Bug 1736523.

Status: UNCONFIRMED → NEW
Ever confirmed: true
No longer depends on: 1736209
No longer blocks: 1739572
Depends on: 1739572
No longer blocks: 1739580
Depends on: 1739580
Depends on: 1747993
No longer depends on: 1763090
No longer depends on: 1742225
Depends on: 1794597
No longer depends on: 1788723
Depends on: 1800046
Depends on: 1800211
Depends on: 1800219
No longer depends on: 1795656
Depends on: 1827210
Depends on: 1276449
Depends on: 1832054
Depends on: 1844373
You need to log in before you can comment on or make changes to this bug.