Bug 469644 - Dragging and dropping files and screenshots from notifications into Chromium-based apps does not work
Summary: Dragging and dropping files and screenshots from notifications into Chromium-...
Status: RESOLVED FIXED
Alias: None
Product: plasmashell
Classification: Plasma
Component: Notifications (show other bugs)
Version: 6.1.2
Platform: Arch Linux Linux
: NOR normal
Target Milestone: 1.0
Assignee: Plasma Bugs List
URL:
Keywords: wayland
Depends on:
Blocks:
 
Reported: 2023-05-12 02:08 UTC by Patrick Silva
Modified: 2024-07-26 19:20 UTC (History)
5 users (show)

See Also:
Latest Commit:
Version Fixed In: 6.1.4
Sentry Crash Report:


Attachments
screenshot of Discord (86.07 KB, image/png)
2024-07-22 11:51 UTC, Patrick Silva
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Patrick Silva 2023-05-12 02:08:40 UTC
STEPS TO REPRODUCE
1. save a file with Firefox - I saved a .jpg file. Plasma shows a notification with a file icon after saving the file.
2. drag the file icon from the notification and try to drop it on Discord
3. 

OBSERVED RESULT
the mouse pointer changes to "not allowed" mode while we hover over Discord and we cannot drop the file.

EXPECTED RESULT
drag-and-drop works

SOFTWARE/OS VERSIONS
Operating System: Arch Linux 
KDE Plasma Version: 5.27.5
KDE Frameworks Version: 5.105.0
Qt Version: 5.15.9
Graphics Platform: Wayland
Comment 1 Patrick Silva 2023-05-12 02:20:36 UTC
Cannot reproduce on X11.
Comment 2 Nate Graham 2023-05-15 19:00:08 UTC
Could reproduce in the past on Plasma 5, but now this works for me on Wayland in Plasma 6; probably fixed by Qt changes.
Comment 3 Patrick Silva 2024-07-15 01:11:23 UTC
This bug persists on Plasma 6; can reproduce on Wayland, cannot on X11.

Another way to reproduce:
1. take a screenshot with Spectacle by pressing shift+printscreen - Plasma shows a notification with a preview of the screenshot
2. drag the preview of the screenshot from the notification and try to drop it on another app - Discord or an internet browser (tested Firefox and Vivaldi on my system), for example

Result: we cannot drop the screenshot on another app

Operating System: Arch Linux 
KDE Plasma Version: 6.1.2
KDE Frameworks Version: 6.3.0
Qt Version: 6.7.2
Graphics Platform: Wayland
Comment 4 Nate Graham 2024-07-15 01:16:29 UTC
Are these apps running as Flatpaks, or native packages?
Comment 5 Patrick Silva 2024-07-15 12:21:16 UTC
All apps mentioned in comment 3 are native packages and run natively on Wayland, not on Xwayland.
Comment 6 Nate Graham 2024-07-15 13:28:46 UTC
Ok, I can reproduce the issue. Either I was testing wrong before, or else it regressed.
Comment 7 Vlad Zahorodnii 2024-07-22 07:40:48 UTC
I can reproduce the issue neither in 6.1 nor in master
Comment 8 Patrick Silva 2024-07-22 11:51:17 UTC
Created attachment 171889 [details]
screenshot of Discord

I can reproduce consistently both cases (described in comment 0 and comment 3) with chromium, vivaldi and discord.

Can reproduce both cases with Firefox too, but inconsistently. Sometimes DnD works, sometimes it fails.

As we can see in the screenshot attached to this comment, Discord even shows the message indicating that a file dragged from a notification can be dropped, but the mouse pointer enters in "not-allowed" mode and the droppping fails.

Operating System: Arch Linux 
KDE Plasma Version: 6.1.3
KDE Frameworks Version: 6.4.0
Qt Version: 6.7.2
Graphics Platform: Wayland
Comment 9 Nate Graham 2024-07-22 14:17:06 UTC
So to clarify my previous ability to reproduce the issue:

- I can reproduce it with Discord, in either native Wayland or XWayland more, as a Flatpak or a native package.
- I can reproduce it with chromium, in either native Wayland or XWayland more, as a Flatpak or a native package.
- I cannot reproduce it in Firefox in any case.

So it seems like perhaps the problem is Chromium-specific. Regardless, in Chromium and Discord I get the exact same result you do, Patrick: dragging-and-dropping a screenshot from Plasma's notification produces a red "can't drop here" cursor even though the content on the page visible changes in a way that looks like it will accept the drag.
Comment 10 Bug Janitor Service 2024-07-22 15:15:52 UTC Comment hidden (spam)
Comment 11 Bug Janitor Service 2024-07-23 08:43:24 UTC
A possibly relevant merge request was started @ https://invent.kde.org/plasma/plasma-workspace/-/merge_requests/4548
Comment 12 David Edmundson 2024-07-23 09:00:00 UTC
Git commit d6016d8401c4a28928c7d641df73fbddec83871d by David Edmundson.
Committed on 23/07/2024 at 08:59.
Pushed by davidedmundson into branch 'master'.

notifications: When doing a drag and drop, set the supported action to cpoy

By default QDrag::exec performs a drag where the allowed actions are
only "move".

The mimedata for a screenshot is a URI list to the file, dragging and
dropping should not move the original file.

Equally importantly if we want to share a file, that's effectively a
copy. Some clients will rightfully not accept a URI list with the only
action being move.

Testing done:

Screenshot taken with the spectacle global shortcut, then drag from that
into the Electron app "Discord"

M  +1    -1    applets/notifications/draghelper.cpp

https://invent.kde.org/plasma/plasma-workspace/-/commit/d6016d8401c4a28928c7d641df73fbddec83871d
Comment 13 David Edmundson 2024-07-23 09:14:48 UTC
Git commit cf41b532579cb010fac218e186cf3df8968f6bbf by David Edmundson, on behalf of David Edmundson.
Committed on 23/07/2024 at 09:00.
Pushed by davidedmundson into branch 'Plasma/6.1'.

notifications: When doing a drag and drop, set the supported action to cpoy

By default QDrag::exec performs a drag where the allowed actions are
only "move".

The mimedata for a screenshot is a URI list to the file, dragging and
dropping should not move the original file.

Equally importantly if we want to share a file, that's effectively a
copy. Some clients will rightfully not accept a URI list with the only
action being move.

Testing done:

Screenshot taken with the spectacle global shortcut, then drag from that
into the Electron app "Discord"


(cherry picked from commit d6016d8401c4a28928c7d641df73fbddec83871d)

e41d94b3 notifications: When doing a drag and drop, set the supported action to cpoy

Co-authored-by: David Edmundson <kde@davidedmundson.co.uk>

M  +1    -1    applets/notifications/draghelper.cpp

https://invent.kde.org/plasma/plasma-workspace/-/commit/cf41b532579cb010fac218e186cf3df8968f6bbf
Comment 14 Vlad Zahorodnii 2024-07-23 12:58:13 UTC
Git commit 6943fab2c1c46eb15e0018ae3419c0d43eb3c8d7 by Vlad Zahorodnii, on behalf of David Edmundson.
Committed on 23/07/2024 at 12:50.
Pushed by vladz into branch 'master'.

wayland: Avoid klipper loop with existing but empty clipboards

In default settings if the clipboard or selection is empty klipper will try to
replace it with cached data.

To avoid an occurring race condition if a client deletes and then recreates a
selection kwin will deny klipper if another mimedata is present at the time
it tried to replace an empty clipboard.

Klipper also considers the presence of a valid mime data without any offers
to be an empty clipboard, whereas kwin did not.

If a super weird client set the clipboard to a valid entry with no offers,
klipper would get into an infinite loop of trying to set it's own selection
for it to be continually denied with no other valid offer from klipper's perspective
ever received.

M  +4    -3    src/wayland/seat.cpp

https://invent.kde.org/plasma/kwin/-/commit/6943fab2c1c46eb15e0018ae3419c0d43eb3c8d7
Comment 15 David Edmundson 2024-07-23 13:31:46 UTC
Git commit c91040d3deee8a2028562451fa056c002f35ae42 by David Edmundson, on behalf of David Edmundson.
Committed on 23/07/2024 at 13:13.
Pushed by davidedmundson into branch 'Plasma/6.1'.

wayland: Avoid klipper loop with existing but empty clipboards

In default settings if the clipboard or selection is empty klipper will try to
replace it with cached data.

To avoid an occurring race condition if a client deletes and then recreates a
selection kwin will deny klipper if another mimedata is present at the time
it tried to replace an empty clipboard.

Klipper also considers the presence of a valid mime data without any offers
to be an empty clipboard, whereas kwin did not.

If a super weird client set the clipboard to a valid entry with no offers,
klipper would get into an infinite loop of trying to set it's own selection
for it to be continually denied with no other valid offer from klipper's perspective
ever received.


(cherry picked from commit 6943fab2c1c46eb15e0018ae3419c0d43eb3c8d7)

Co-authored-by: David Edmundson <kde@davidedmundson.co.uk>

M  +4    -3    src/wayland/seat.cpp

https://invent.kde.org/plasma/kwin/-/commit/c91040d3deee8a2028562451fa056c002f35ae42
Comment 16 Patrick Silva 2024-07-25 02:39:07 UTC
I have built the branch 6.1 of kwin on my Arch Linux with these commands:

$ git clone https://invent.kde.org/plasma/kwin.git
$ cd kwin
$ git checkout remotes/origin/Plasma/6.1
$ mkdir build && cd build
$ cmake ..
$ make -j 4
$ sudo make install

However, the bug persists. I suspect my system is still using kwin from its repositories instead of the one built locally.
Please could anyone tell me how to replace kwin from the repositories with the one built locally?
Thanks.
Comment 17 Nate Graham 2024-07-25 03:09:16 UTC
[path to built-from-source kwin_wayland binary] --replace
Comment 18 Patrick Silva 2024-07-25 13:17:29 UTC
Thanks, Nate.
After my commands, the files of the built-from-source kwin are installed to the same location than the ones of kwin from Arch repos.
However, the bug persists when running the built-from-source kwin.
Comment 19 Patrick Silva 2024-07-25 13:30:33 UTC
Nervermind. I need to rebuild plasma-workspace too.