Bug 445661

Summary: Dragging screenshots from Spectacle into Firefox broke recently
Product: [Plasma] kwin Reporter: Nate Graham <nate>
Component: wayland-genericAssignee: KWin default assignee <kwin-bugs-null>
Status: RESOLVED LATER    
Severity: normal CC: postix
Priority: NOR Keywords: regression
Version: git master   
Target Milestone: ---   
Platform: Other   
OS: Linux   
Latest Commit: Version Fixed In: 5.26
Sentry Crash Report:

Description Nate Graham 2021-11-17 19:22:55 UTC
On Wayland git master, dragging screenshots from Spectacle into text fields on invent.kde.org with Firefox in Wayland mode is not working for me anymore. After I drop it, nothing happens. This used to work a week or two ago. Dragging from Spectacle into the same text field in Chromium in wayland mode works. Dragging from Spectacle onto the desktop works.
Comment 1 Nate Graham 2021-11-17 19:24:40 UTC
Works with both Firefox and Chromium in XWayland mode.
Comment 2 Nate Graham 2021-11-17 19:25:53 UTC
So just Firefox Wayland regressed here for invent.kde.org text fields. I don't recall any recent Firefox updates.
Comment 3 Nate Graham 2021-11-20 03:02:31 UTC
Also reproduces with trying to drag images from Spectacle into a Wordpress editor view in Firefox, which I use for my weekly blog posts.
Comment 4 Vlad Zahorodnii 2022-09-21 10:39:50 UTC
What I see is that file drag-and-drop works sometimes. After quick debugging, I see that if Firefox accepts text/uri-list, then drag-and-drop works! If Firefox accepts text/vnd.portal.filetransfer, drag-and-drop does not work.
Comment 5 Vlad Zahorodnii 2022-09-21 10:46:28 UTC
https://invent.kde.org/frameworks/kcoreaddons/-/blob/b1deba29a10b82de9fe132e4a008be1df37b7057/src/lib/io/kurlmimedata.cpp#L111 if I add `&& false`, i.e. disable xdg portal integration, then dnd works as expected.
Comment 6 Vlad Zahorodnii 2022-09-21 10:54:02 UTC
It still randomly fails to perform drop even when using text/uri-list...
Comment 7 Vlad Zahorodnii 2022-09-21 11:13:27 UTC
I can reproduce similar issue when running Firefox in GNOME Shell.
Comment 8 Vlad Zahorodnii 2022-09-21 13:14:01 UTC
One half of the puzzle: https://gitlab.freedesktop.org/wayland/wayland/-/issues/322

Even after making kwin send wl_data_offer.source_actions, there are still issues with drag-and-drop in Firefox: the first dnd works, but the next one does not.
Comment 9 Vlad Zahorodnii 2022-09-21 13:14:33 UTC
Even after making kwin send wl_data_offer.source_actions before wl_data_device.enter*
Comment 10 Vlad Zahorodnii 2022-09-21 13:37:50 UTC
Second half of the puzzle: kwin not always sends wl_data_device.leave when drop occurred
Comment 11 Bug Janitor Service 2022-09-21 14:12:43 UTC
A possibly relevant merge request was started @ https://invent.kde.org/plasma/kwin/-/merge_requests/2986
Comment 12 Bug Janitor Service 2022-09-23 08:44:45 UTC
A possibly relevant merge request was started @ https://invent.kde.org/plasma/kwin/-/merge_requests/2991
Comment 13 Vlad Zahorodnii 2022-09-23 09:30:01 UTC
Git commit 3546cc0541349feea42080b9df50fd76f3e1cd2b by Vlad Zahorodnii.
Committed on 23/09/2022 at 08:43.
Pushed by vladz into branch 'master'.

wayland: Send wl_data_offer.source_actions before wl_data_device.enter

This makes kwin's behavior consistent with other wayland compositors
(sway, GNOME Shell, etc) and it's reasonable to provide all the
information about the data source before wl_data_device.enter. It also
makes Firefox happier.

Relevant discussion upstream: https://gitlab.freedesktop.org/wayland/wayland/-/issues/322

M  +1    -1    src/wayland/datadevice_interface.cpp

https://invent.kde.org/plasma/kwin/commit/3546cc0541349feea42080b9df50fd76f3e1cd2b
Comment 14 Vlad Zahorodnii 2022-09-23 09:30:28 UTC
Git commit 00621892ff228b07f0735708ac5597506c29e4c6 by Vlad Zahorodnii.
Committed on 23/09/2022 at 09:30.
Pushed by vladz into branch 'Plasma/5.26'.

wayland: Send wl_data_offer.source_actions before wl_data_device.enter

This makes kwin's behavior consistent with other wayland compositors
(sway, GNOME Shell, etc) and it's reasonable to provide all the
information about the data source before wl_data_device.enter. It also
makes Firefox happier.

Relevant discussion upstream: https://gitlab.freedesktop.org/wayland/wayland/-/issues/322


(cherry picked from commit 3546cc0541349feea42080b9df50fd76f3e1cd2b)

M  +1    -1    src/wayland/datadevice_interface.cpp

https://invent.kde.org/plasma/kwin/commit/00621892ff228b07f0735708ac5597506c29e4c6
Comment 15 Vlad Zahorodnii 2022-09-23 09:32:55 UTC
Note that you will need https://gitlab.gnome.org/GNOME/gtk/-/merge_requests/5045 in order to make drag-and-drop work reliably in Firefox.
Comment 16 Vlad Zahorodnii 2022-09-23 09:36:11 UTC
If you run the aforementioned gtk patch and the kwin patch, drag-and-drop should work in Firefox, you may still experience minor issues in FF though, in my case, the comment editor keeps showing the attachment icon after drop.

At this point, we can't do a lot, until the final decision on https://gitlab.freedesktop.org/wayland/wayland/-/issues/323 is made.