Bug 409798

Summary: Image copied from Spectacle appears incorrectly on Wayland
Product: [Plasma] plasmashell Reporter: Alberto Díaz López <takuya>
Component: ClipboardAssignee: Plasma Bugs List <plasma-bugs>
Status: RESOLVED FIXED    
Severity: normal CC: alex765, bart, bugseforuns, bugzilla, falsodeandromeda, francois5537, FrederickAngelo, justnjag2, kde, kde, kemtulanh_codon1, lewis, m.wege, meven29, mliqkgvdttjqkaount, nate, rainer, ricardocanul7, rick, seqularise, sofia-chan00, spencervess, tbondvagyok, torotil, yourivanmill
Priority: NOR Keywords: wayland
Version: master   
Target Milestone: 1.0   
Platform: Arch Linux   
OS: Linux   
URL: https://codereview.qt-project.org/c/qt/qtwayland/+/268352
Latest Commit: Version Fixed In: Qt 5.15.2
Sentry Crash Report:
Attachments: Comparison between screenshot and pasted image
empty clipboard entry
klipper

Description Alberto Díaz López 2019-07-14 18:47:08 UTC
SUMMARY

Spectacle Copy To Clipboard Doesn't Work Properly Under Wayland Session

STEPS TO REPRODUCE
1. Login Wayland session.
2. Perform a screenshot/launch Spectacle.
3. Copy to clipboard the screenshot.
4. Paste it to everywhere.

OBSERVED RESULT

The image is corrupted, not working.

EXPECTED RESULT

The image paste it normally & flawlessly.

SOFTWARE/OS VERSIONS
Windows: 
macOS: 
Linux/KDE Plasma: 5.2.0/5.16.3
(available in About System)
KDE Plasma Version: 5.16.3
KDE Frameworks Version: 5.60
Qt Version: 5.13

ADDITIONAL INFORMATION
Comment 1 Patrick Silva 2019-07-15 00:58:56 UTC
I can confirm on Neon unstable edition.
A corrupted image is pasted on apps running natively on Wayland
(KolourPaint and PhotoFlare, for example) and I not even can paste
the image into Xwayland apps like Gimp and Pinta.

Operating System: KDE neon Unstable Edition
KDE Plasma Version: 5.16.80
KDE Frameworks Version: 5.61.0
Qt Version: 5.12.3
Comment 2 David Redondo 2019-07-22 13:08:14 UTC
Created attachment 121675 [details]
Comparison between screenshot and pasted image

An example image. Only the last rows of pixels seems to be correct.
Also I ran spectacle with WAYLAND_DEBUG and extracted the clipboard related section: https://invent.kde.org/snippets/322
Comment 3 David Edmundson 2019-07-23 07:45:52 UTC
Thanks

https://codereview.qt-project.org/c/qt/qtwayland/+/268352
Comment 4 Nate Graham 2020-07-23 21:58:02 UTC
*** Bug 424435 has been marked as a duplicate of this bug. ***
Comment 5 Nate Graham 2020-07-23 21:58:54 UTC
Re-opening as this fix was supposedly merged into Qt 5.12 yet it's still broken for me with Qt 5.15.
Comment 6 Patrick Silva 2020-08-05 03:17:41 UTC
*** Bug 425015 has been marked as a duplicate of this bug. ***
Comment 7 Rainer Finke 2020-09-24 13:07:59 UTC
I've tested this with Plasma 5.20 Beta and KDE Applications 20.08.1 and I was not able to copy the screenshot to the clipboard.

Operating System: Arch Linux
KDE Plasma Version: 5.19.90
KDE Frameworks Version: 5.74.0
Qt Version: 5.15.1
Kernel Version: 5.8.10-arch1-1
OS Type: 64-bit
Processors: 24 × AMD Ryzen 9 3900X 12-Core Processor
Memory: 31.4 GiB of RAM
Graphics Processor: AMD Radeon VII
Comment 8 Alberto Díaz López 2020-10-06 09:54:03 UTC
(In reply to Rainer Finke from comment #7)
> I've tested this with Plasma 5.20 Beta and KDE Applications 20.08.1 and I
> was not able to copy the screenshot to the clipboard.
> 
> Operating System: Arch Linux
> KDE Plasma Version: 5.19.90
> KDE Frameworks Version: 5.74.0
> Qt Version: 5.15.1
> Kernel Version: 5.8.10-arch1-1
> OS Type: 64-bit
> Processors: 24 × AMD Ryzen 9 3900X 12-Core Processor
> Memory: 31.4 GiB of RAM
> Graphics Processor: AMD Radeon VII

Hi Rainer,

I may be wrong, but I think it could be caused because of an already fixed bug (for the 5.20 Plasma Stable release), that was affecting to the clipboard under Wayland session. In fact, I'm suffering for the first try to copy anything, every time I try to copy something to the clipboard.
Comment 9 Méven Car 2020-10-24 06:03:31 UTC
cc bug 422860
Comment 10 Nate Graham 2020-10-24 19:56:54 UTC
*** Bug 422860 has been marked as a duplicate of this bug. ***
Comment 11 Nate Graham 2020-10-24 19:56:58 UTC
*** Bug 427713 has been marked as a duplicate of this bug. ***
Comment 12 Youri van Mill 2020-12-01 23:30:59 UTC
Created attachment 133793 [details]
empty clipboard entry

Is this issue fixed? When I have a screenshot, and I click copy to clipboard. I'm not able to paste it anywhere, it creates an empty entry in the clipboard...

Operating System: Arch Linux
KDE Plasma Version: 5.20.4
KDE Frameworks Version: 5.76.0
Qt Version: 5.15.2
Kernel Version: 5.9.11-arch2-1
OS Type: 64-bit
Processors: 12 × AMD Ryzen 5 5600X 6-Core Processor
Memory: 15.6 GiB of RAM
Graphics Processor: Radeon RX 570 Series
Comment 13 Youri van Mill 2020-12-01 23:33:44 UTC
I am using wayland BTW.
Comment 14 Lewis Lakerink 2020-12-09 04:32:28 UTC
Yea +1 for this still persisting. Spectacle 20.11.90 on wayland is copying a 0x0 image to the clipboard (according to klipper) - an image which can not be pasted.

I suspect the 0x0 image is a separate bug to the initial bug reported under this ticket.
Comment 15 Alberto Díaz López 2021-04-14 21:21:22 UTC
(In reply to Lewis Lakerink from comment #14)
> Yea +1 for this still persisting. Spectacle 20.11.90 on wayland is copying a
> 0x0 image to the clipboard (according to klipper) - an image which can not
> be pasted.
> 
> I suspect the 0x0 image is a separate bug to the initial bug reported under
> this ticket.

I think this issue is fixed, the only issue relatively related that I opened https://bugs.kde.org/show_bug.cgi?id=421974 this other bug, because the issue I experiment is that under the Wayland session, the screenshot is not automatically copied to the clipboard. But this issue was closed a long time ago, as far as I can tell/remember.
Comment 16 cauchy 2021-06-11 08:08:38 UTC
Hi,

unfortunately bug is still present in the Spectacle 21.04.2 on Arch Linux with KDE 5.22 running full wayland.

There is no difference if I use a shortcut to take a screenshot and copy it into the clipboard or copy it from the GUI still the result is the same - no screenshot in the clipboard thus no way to paste it anywhere.

FUN FACTS:

#1 I have tried flameshot 0.9. It has a problem with .desktop file as described in this github issue: https://github.com/flameshot-org/flameshot/issues/1380 and quickfixed with this PR: . After fixing it, flameshot will start on KDE with wayland but still can not copy screenshot. However someone found some workaround: https://github.com/flameshot-org/flameshot/issues/1446 (at the bottom). In my case I had to turn ON copying as JPG to make it work (instead of turning off as the person described). Hooray! I even have a miniature in the klipper but pasting it is different story… I can paste this picture into LibreOffice writer but not into Slack desktop. Probably because LO is wayland and slack is xwayland. Buuuuuut if I paste the picture into the LO I can copy it once again in the LO and now I can paste it into the Slack o_0

#2 Firefox has internal screenshot tool: https://support.mozilla.org/en-US/kb/take-screenshots-firefox It has no problem with taking screenshot of webpages, copying it into the clipboard and then it is possible to paste it into any app I wish
Comment 17 Lewis Lakerink 2021-06-11 08:13:39 UTC
(In reply to cauchy from comment #16)
> Hi,
> 
> unfortunately bug is still present in the Spectacle 21.04.2 on Arch Linux
> with KDE 5.22 running full wayland.
> 
> There is no difference if I use a shortcut to take a screenshot and copy it
> into the clipboard or copy it from the GUI still the result is the same - no
> screenshot in the clipboard thus no way to paste it anywhere.
> 

Yea, still a +1 for me too. I've been using spectacle on wayland by saving the screenshot to disk and uploading/opening the saved screenshots in the programs I need.
Comment 18 Nate Graham 2021-06-14 15:43:37 UTC
Works for me. For people affected, can you share a screenshot of what your Klipper popup/history looks like immediately after copying the screenshot in Spectacle?
Comment 19 Bart 2021-06-14 19:25:03 UTC
Created attachment 139322 [details]
klipper

klipper
Comment 20 Bart 2021-06-14 19:26:33 UTC
Comment on attachment 139322 [details]
klipper

@nate: See "https://bugs.kde.org/attachment.cgi?id=139322". Empty entry in klipper.
Using latest Kde neon dev builds, wayland,but dual screen + scaling. (not sure if this matters)
Comment 21 cauchy 2021-06-15 07:44:54 UTC
If I open spectacle as an app and take a screenshot then press button to copy it to the clipboard I have the same result as Bart (an empty entry in the clipboard). If I use a shortcut to take a rectangular area screenshot and copy it to the clipboard I have completely nothing. However if I take a screenshot with running spectacle GUI and press button to copy it to the clipboard I can paste it into the KolourPaint but not into LibreOffice
Comment 22 cauchy 2021-06-21 07:42:27 UTC
changed wrong status "FIXED"
Comment 23 Bug Janitor Service 2021-07-06 04:33:52 UTC
Dear Bug Submitter,

This bug has been in NEEDSINFO status with no change for at least
15 days. Please provide the requested information as soon as
possible and set the bug status as REPORTED. Due to regular bug
tracker maintenance, if the bug is still in NEEDSINFO status with
no change in 30 days the bug will be closed as RESOLVED > WORKSFORME
due to lack of needed information.

For more information about our bug triaging procedures please read the
wiki located here:
https://community.kde.org/Guidelines_and_HOWTOs/Bug_triaging

If you have already provided the requested information, please
mark the bug as REPORTED so that the KDE team knows that the bug is
ready to be confirmed.

Thank you for helping us make KDE software even better for everyone!
Comment 24 Frederick 2021-07-10 12:04:01 UTC
(In reply to Patrick Silva from comment #1)
> I can confirm on Neon unstable edition.
> A corrupted image is pasted on apps running natively on Wayland
> (KolourPaint and PhotoFlare, for example) and I not even can paste
> the image into Xwayland apps like Gimp and Pinta.
> 
> Operating System: KDE neon Unstable Edition
> KDE Plasma Version: 5.16.80
> KDE Frameworks Version: 5.61.0
> Qt Version: 5.12.3

i too has this exact problem.

Operating System: KDE neon 5.22
KDE Plasma Version: 5.22.3
KDE Frameworks Version: 5.83.0
Qt Version: 5.15.3
Kernel Version: 5.12.15-xanmod1 (64-bit)
Graphics Platform: Wayland
Processors: 12 × AMD Ryzen 5 3600 6-Core Processor
Memory: 15,6 GiB of RAM
Graphics Processor: AMD Radeon HD 7800 Series
Comment 25 Frederick 2021-07-10 13:02:41 UTC
(In reply to Frederick from comment #24)
> (In reply to Patrick Silva from comment #1)
> > I can confirm on Neon unstable edition.
> > A corrupted image is pasted on apps running natively on Wayland
> > (KolourPaint and PhotoFlare, for example) and I not even can paste
> > the image into Xwayland apps like Gimp and Pinta.
> > 
> > Operating System: KDE neon Unstable Edition
> > KDE Plasma Version: 5.16.80
> > KDE Frameworks Version: 5.61.0
> > Qt Version: 5.12.3
> 
> i too has this exact problem.
> 
> Operating System: KDE neon 5.22
> KDE Plasma Version: 5.22.3
> KDE Frameworks Version: 5.83.0
> Qt Version: 5.15.3
> Kernel Version: 5.12.15-xanmod1 (64-bit)
> Graphics Platform: Wayland
> Processors: 12 × AMD Ryzen 5 3600 6-Core Processor
> Memory: 15,6 GiB of RAM
> Graphics Processor: AMD Radeon HD 7800 Series

As a follow up heres a screenshot of my clipboard.

https://imgur.com/a/0FdYObb
Comment 26 sofia-chan00 2021-07-14 23:01:22 UTC
(In reply to Patrick Silva from comment #1)
> I can confirm on Neon unstable edition.
> A corrupted image is pasted on apps running natively on Wayland
> (KolourPaint and PhotoFlare, for example) and I not even can paste
> the image into Xwayland apps like Gimp and Pinta.
> 
> Operating System: KDE neon Unstable Edition
> KDE Plasma Version: 5.16.80
> KDE Frameworks Version: 5.61.0
> Qt Version: 5.12.3

I also have this exact problem
Operating System: Kubuntu 21.04
KDE Plasma Version: 5.21.4
KDE Frameworks Version: 5.80.0
Qt Version: 5.15.2
Kernel Version: 5.11.0-22-generic
OS Type: 64-bit
Graphics Platform: Wayland
Processors: 8 × Intel® Core™ i7-10510U CPU @ 1.80GHz
Memory: 15,4 GiB of RAM
Graphics Processor: Mesa Intel® UHD Graphics
Comment 27 sofia-chan00 2021-07-14 23:25:44 UTC
A bit more of information:
On the Clipboard Contents icon, the picture appears as '0x0 0bpp'
I tried with other screenshot tools and had the same problem.
I could paste the screenshot into KolourPaint
I couldn't paste it into discord or libreoffice
Comment 28 Nate Graham 2021-07-29 16:09:23 UTC
*** Bug 439197 has been marked as a duplicate of this bug. ***
Comment 29 Nate Graham 2021-07-29 16:09:46 UTC
*** Bug 439230 has been marked as a duplicate of this bug. ***
Comment 30 Rick Kerkhof 2021-07-30 08:17:53 UTC
I am observing the same behaviour as others on Fedora 34.

Creating a screenshot through a global shortcut leaves me with an empty clipboard. Creating a screenshot through the Spectacle interface with "After taking a screenshot -> Copy image to clipboard" still leaves me with an empty clipboard.

Once I click the Copy image to clipboard button, I finally get image data in my clipboard. However, Klipper seems to show the generic image icon instead of a thumbnail. I can paste it in Kontact/KMail (which recognises it as an image/png) and Telegram running as a flatpak which shows the correct thumbnail, but not in Discord running as a flatpak but in Xwayland.

Operating System: Fedora 34
KDE Plasma Version: 5.22.4
KDE Frameworks Version: 5.83.0
Qt Version: 5.15.2
Kernel Version: 5.13.5-200.fc34.x86_64 (64-bit)
Graphics Platform: Wayland
Processors: 4 × Intel® Core™ i5-4300U CPU @ 1.90GHz
Memory: 15,4 GiB of RAM
Graphics Processor: Mesa DRI Intel® HD Graphics 4400
Comment 31 Nate Graham 2021-08-03 21:39:26 UTC
Let's make sure we're all discussing the same bug here. From what I can tell, clicking on the "Copy to clipboard" button works properly now, with the image making it onto the clipboard. However I can reproduce Klipper showing the wrong contents; sometimes it shows a generic image icon, and sometimes it shows two blank entries.

Discord running in an XWayland Flatpak being unable to receive it would be still another bug (and please file that one).

For people who are still seeing the image not even appearing on the clipboard at all, please file new separate bug reports; this one is too confused and overloaded at this point. :0
Comment 32 cauchy 2021-08-19 06:49:34 UTC
Operating System: Arch Linux (latest)
KDE Plasma Version: 5.22.4
KDE Frameworks Version: 5.85.0
Qt Version: 5.15.2
Full Wayland


Hi Nate,

unfortunately copy to clipboard is still somewhat broken.

Scenario #1:

1. open spectacle GUI
2. take rectangular screenshot
3. click "copy to clipboard" button
4. EMPTY entry in klipper (no icon, no data)
5. CAN paste into kolour paint

Scenario #2:

1. open spectacle GUI
2. take rectangular screenshot
3. click "copy to clipboard" button
4. if executed after scenario #1 there is no extra empty entry in klipper
5. CLOSE spectacle gui
6. CAN'T paste into kolour paint
7. selecting empty entry from klipper doesn't help

FUN FACT

Latest version of flameshot 0.10.1 can copy to clipboard: https://github.com/flameshot-org/flameshot/commit/adcf2501f33bcbcd29769015ddddb37b50b4da39 but still it produces an empty entry in klippper (not a problem for me)
Comment 33 Nate Graham 2021-08-20 15:05:34 UTC
*** Bug 441211 has been marked as a duplicate of this bug. ***
Comment 34 Méven Car 2021-09-02 08:55:41 UTC
There is a fix that should help here in some scenarios https://codereview.qt-project.org/c/qt/qtwayland/+/366769 it is already in KDE qt patch collection https://invent.kde.org/qt/qt/qtwayland/-/commit/6072c1dc87e185f30c014f764737ac97b906640f that should land in arch soonish if not already.
Comment 35 Lewis Lakerink 2021-09-03 03:00:25 UTC
(In reply to Méven Car from comment #34)
> There is a fix that should help here in some scenarios
> https://codereview.qt-project.org/c/qt/qtwayland/+/366769 it is already in
> KDE qt patch collection
> https://invent.kde.org/qt/qt/qtwayland/-/commit/
> 6072c1dc87e185f30c014f764737ac97b906640f that should land in arch soonish if
> not already.

Yup, this fixes it for me! I built the kde qtwayland 5.12 branch with this patch applied and spectacle copies to the clipboard exactly how I expect it to, and I can paste the copied images in to any program.
Comment 36 Nate Graham 2021-09-03 14:17:55 UTC
Nice, that's great news!
Comment 37 cauchy 2021-09-07 14:21:53 UTC
With qt5-wayland 5.15.2+kde+r30-1 on Arch it is possible to copy and paste screenshot! Still don't have a proper entry in Klipper but I don't care as long as pasting works :)
Comment 38 cauchy 2021-09-08 06:18:13 UTC
Too fast too furious :)

Copying and pasting WORKS ONLY with present GUI and "copy to clipboard" button.

What DOES NOT work:

1. take screenshot with spectacle -brc. Can't paste the screenshot and nothing in klipper
2. take screenshot with spectacle with GUI, copy to clipboard by pressing button and close the GUI. Can't paste the screenshot and nothing in klipper
Comment 39 Nate Graham 2021-09-08 16:40:02 UTC
Those would be separate bugs. Can you file new bug reports for them? Thanks!
Comment 40 Patrick Silva 2021-09-08 19:16:23 UTC
(In reply to cauchy from comment #38)
> Too fast too furious :)
> 
> Copying and pasting WORKS ONLY with present GUI and "copy to clipboard"
> button.
> 
> What DOES NOT work:
> 
> 1. take screenshot with spectacle -brc. Can't paste the screenshot and
> nothing in klipper
> 2. take screenshot with spectacle with GUI, copy to clipboard by pressing
> button and close the GUI. Can't paste the screenshot and nothing in klipper

already reported as bug 433681