Bug 421974 - [Wayland] Spectacle Doesn't Copy To The Clipboard The Screenshot Automatically
Summary: [Wayland] Spectacle Doesn't Copy To The Clipboard The Screenshot Automatically
Status: RESOLVED FIXED
Alias: None
Product: Spectacle
Classification: Applications
Component: General (show other bugs)
Version: 21.08.0
Platform: unspecified Linux
: NOR minor
Target Milestone: ---
Assignee: Boudhayan Gupta
URL:
Keywords: wayland
Depends on:
Blocks:
 
Reported: 2020-05-23 12:54 UTC by Alberto Díaz López
Modified: 2021-11-03 16:04 UTC (History)
7 users (show)

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


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Alberto Díaz López 2020-05-23 12:54:08 UTC
SUMMARY
Spectacle doesn't copy to the clipboard the screenshot just did, even showing the message that it has done it, having it configured on its settings, under Wayland session.

STEPS TO REPRODUCE
1. Login into Wayland session.
2. Launch Spectacle and realize a screenshot, having the marked option at the settings to auto copy to clipboard. You'll see the message information, that the screenshot has been copied to the clipboard.
3. Try to paste the content of the clipboard.

OBSERVED RESULT
The screenshot hasn't been copied to the clipboard.

EXPECTED RESULT
The screenshot should be copied to the clipboard.

SOFTWARE/OS VERSIONS
Linux/KDE Plasma: Linux 5.6.14
(available in About System)
KDE Plasma Version: 5.18.5
KDE Frameworks Version: 5.70
Qt Version: 5.14.2

ADDITIONAL INFORMATION
Actually, I haven't tested yet if it happens on X11/Xorg session, I will test it and comment it here when I test it.
Comment 1 Alberto Díaz López 2020-06-06 10:46:57 UTC
I will close this bug, because after the update to Qt 5.15, it's fixed.

Looks like it wasn't on KDE's side, sorry about that :(.
Comment 2 Méven Car 2020-06-06 11:58:18 UTC
Great to learn this is fixed in Qt 5.15.
Comment 3 Alberto Díaz López 2020-06-09 16:19:49 UTC
(In reply to Alberto Díaz López from comment #1)
> I will close this bug, because after the update to Qt 5.15, it's fixed.
> 
> Looks like it wasn't on KDE's side, sorry about that :(.

Sorry, it looks like I was wrong and anticipated events, the bug is still there, even with the update to Qt 5.15 :(.
Comment 4 Méven Car 2020-06-09 16:51:26 UTC
This should have been fixed by https://phabricator.kde.org/D29487 then.
This will be in Spectacle 20.08.
Comment 5 Méven Car 2020-06-09 16:53:13 UTC
I confirmed this is fixed in master (future 20.08).
Comment 6 Alberto Díaz López 2020-12-03 13:12:01 UTC
(In reply to Méven Car from comment #5)
> I confirmed this is fixed in master (future 20.08).

Sadly, I have to say this isn't fixed to me even on 20.11.90. I'm not sure if it's an specific bug related with old hardware or something like that.
Comment 7 Méven Car 2020-12-03 14:54:51 UTC
(In reply to Alberto Díaz López from comment #6)
> (In reply to Méven Car from comment #5)
> > I confirmed this is fixed in master (future 20.08).
> 
> Sadly, I have to say this isn't fixed to me even on 20.11.90. I'm not sure
> if it's an specific bug related with old hardware or something like that.

What (In reply to Alberto Díaz López from comment #6)
> (In reply to Méven Car from comment #5)
> > I confirmed this is fixed in master (future 20.08).
> 
> Sadly, I have to say this isn't fixed to me even on 20.11.90. I'm not sure
> if it's an specific bug related with old hardware or something like that.

What is your Qt Framework version ?

This could be the same cause as https://bugs.kde.org/show_bug.cgi?id=422860
Comment 8 Méven Car 2020-12-03 15:02:25 UTC
And your spectacle version.

Could be also a duplicate of https://bugs.kde.org/show_bug.cgi?id=420477
Comment 9 Alberto Díaz López 2020-12-03 15:36:03 UTC
(In reply to Méven Car from comment #7)
> (In reply to Alberto Díaz López from comment #6)
> > (In reply to Méven Car from comment #5)
> > > I confirmed this is fixed in master (future 20.08).
> > 
> > Sadly, I have to say this isn't fixed to me even on 20.11.90. I'm not sure
> > if it's an specific bug related with old hardware or something like that.
> 
> What (In reply to Alberto Díaz López from comment #6)
> > (In reply to Méven Car from comment #5)
> > > I confirmed this is fixed in master (future 20.08).
> > 
> > Sadly, I have to say this isn't fixed to me even on 20.11.90. I'm not sure
> > if it's an specific bug related with old hardware or something like that.
> 
> What is your Qt Framework version ?
> 
> This could be the same cause as https://bugs.kde.org/show_bug.cgi?id=422860

My Qt Framework version is 5.15.2.

(In reply to Méven Car from comment #8)
> And your spectacle version.
> 
> Could be also a duplicate of https://bugs.kde.org/show_bug.cgi?id=420477

My Spectacle version is 20.11.90.
Comment 10 Méven Car 2020-12-03 15:37:46 UTC
I don't have Qt 5.15.2 :/ Can't reproduce myself ATM.
Comment 11 Alberto Díaz López 2020-12-03 16:29:10 UTC
(In reply to Méven Car from comment #10)
> I don't have Qt 5.15.2 :/ Can't reproduce myself ATM.

I've been suffering of this bug since I reported, a few times it copied automatically successfully (as it should), but about 99% of the times (I do a lot of screenshots a day, so it's rather frustrating in my case).

Hoping other dev who use the latest stable version of KDE Applications & Qt Framework can see this and test it :). Nate Graham I know he uses openSUSE TW, so he would be a possible candidate ^^.
Comment 12 Shawn 2021-07-02 17:21:46 UTC
Still seeing this with Spectacle 21.04.2, Plasma 5.22.2, Frameworks 5.83.0, Qt 5.15.2 using Wayland.

Screenshots using Spectacle show up in Clipboard and will copy/paste to email but can't paste to Facebook or Twitter using any browser.  Copying a saved graphic from a drive to clipboard will paste to FB and Twitter.

Can reproduce this on all 3 local KDE machines.
Comment 13 d3coder 2021-08-13 09:40:27 UTC
Copy to clipboard does not work



Operating System: Arch Linux
KDE Plasma Version: 5.22.4
KDE Frameworks Version: 5.84.0
Qt Version: 5.15.2
Kernel Version: 5.13.9-arch1-1 (64-bit)
Graphics Platform: Wayland
Processors: 8 × Intel® Core™ i7-4790K CPU @ 4.00GHz
Memory: 15.5 GiB of RAM
Graphics Processor: Mesa DRI Intel® HD Graphics 4600
Comment 14 Alberto Díaz López 2021-08-13 14:29:23 UTC
(In reply to d3coder from comment #13)
> Copy to clipboard does not work
> 
> 
> 
> Operating System: Arch Linux
> KDE Plasma Version: 5.22.4
> KDE Frameworks Version: 5.84.0
> Qt Version: 5.15.2
> Kernel Version: 5.13.9-arch1-1 (64-bit)
> Graphics Platform: Wayland
> Processors: 8 × Intel® Core™ i7-4790K CPU @ 4.00GHz
> Memory: 15.5 GiB of RAM
> Graphics Processor: Mesa DRI Intel® HD Graphics 4600

I can confirm it on Spectacle 21.08 too. My system still remains the same as I filed the bug, so my System Specs are basically the same as you :). Just that I'm still on Linux 5.13.8-zen.
Comment 15 Méven Car 2021-08-14 14:22:29 UTC
I do reproduce it:

Operating System: Kubuntu 21.04
KDE Plasma Version: 5.22.80
KDE Frameworks Version: 5.85.0
Qt Version: 5.15.2
Kernel Version: 5.11.0-25-generic (64-bit)
Graphics Platform: Wayland
Processors: 8 × Intel® Core™ i7-8550U CPU @ 1.80GHz
Memory: 15.1 Gio of RAM
Graphics Processor: Mesa Intel® UHD Graphics 620

After https://bugreports.qt.io/browse/QTBUG-87657 the mime type are correctly advertised.

But I could see something suspicious in the logs:

[1675147,350]  -> wl_data_device_manager@9.create_data_source(new id wl_data_source@31)
[1675147,497]  -> wl_data_source@31.offer("application/x-qt-image")
[1675147,512]  -> wl_data_source@31.offer("x-kde-force-image-copy")
[1675147,520]  -> wl_data_source@31.offer("image/png")
[1675147,529]  -> wl_data_source@31.offer("image/avif")
[1675147,536]  -> wl_data_source@31.offer("image/bmp")
[1675147,546]  -> wl_data_source@31.offer("image/bw")
[1675147,555]  -> wl_data_source@31.offer("image/cur")
[1675147,567]  -> wl_data_source@31.offer("image/eps")
[1675147,577]  -> wl_data_source@31.offer("image/epsf")
[1675147,586]  -> wl_data_source@31.offer("image/epsi")
[1675147,596]  -> wl_data_source@31.offer("image/icns")
[1675147,607]  -> wl_data_source@31.offer("image/ico")
[1675147,616]  -> wl_data_source@31.offer("image/jpeg")
[1675147,627]  -> wl_data_source@31.offer("image/jpg")
[1675147,639]  -> wl_data_source@31.offer("image/pbm")
[1675147,650]  -> wl_data_source@31.offer("image/pcx")
[1675147,661]  -> wl_data_source@31.offer("image/pgm")
[1675147,672]  -> wl_data_source@31.offer("image/pic")
[1675147,684]  -> wl_data_source@31.offer("image/ppm")
[1675147,694]  -> wl_data_source@31.offer("image/rgb")
[1675147,705]  -> wl_data_source@31.offer("image/rgba")
[1675147,717]  -> wl_data_source@31.offer("image/sgi")
[1675147,728]  -> wl_data_source@31.offer("image/tga")
[1675147,739]  -> wl_data_source@31.offer("image/tif")
[1675147,750]  -> wl_data_source@31.offer("image/tiff")
[1675147,761]  -> wl_data_source@31.offer("image/wbmp")
[1675147,773]  -> wl_data_source@31.offer("image/webp")
[1675147,784]  -> wl_data_source@31.offer("image/xbm")
[1675147,796]  -> wl_data_source@31.offer("image/xpm")
[1675147,812]  -> wl_data_device@10.set_selection(wl_data_source@31, 42469)
[1675147,831]  -> wl_data_source@34.destroy()                      <-- this looks very suspicious
[1675148,131]  -> xdg_toplevel@20.set_min_size(921, 411)
[1675148,158]  -> xdg_toplevel@20.set_max_size(0, 0)
[1675148,175]  -> wl_surface@50.commit()

A good old gdb showed:

Thread 1 "spectacle" hit Breakpoint 1, QtWaylandClient::QWaylandDataOffer::~QWaylandDataOffer (this=0x555555b52a60, __in_chrg=<optimized out>)
    at qwaylanddataoffer.cpp:66
66      qwaylanddataoffer.cpp: Aucun fichier ou dossier de ce type.
(gdb) bt
#0  QtWaylandClient::QWaylandDataOffer::~QWaylandDataOffer (this=0x555555b52a60, __in_chrg=<optimized out>) at qwaylanddataoffer.cpp:66
#1  0x00007ffff3810d52 in QScopedPointerDeleter<QtWaylandClient::QWaylandDataOffer>::cleanup (pointer=<optimized out>)
    at /usr/include/x86_64-linux-gnu/qt5/QtCore/qscopedpointer.h:60
#2  QScopedPointer<QtWaylandClient::QWaylandDataOffer, QScopedPointerDeleter<QtWaylandClient::QWaylandDataOffer> >::reset (other=0x0, 
    this=<optimized out>) at /usr/include/x86_64-linux-gnu/qt5/QtCore/qscopedpointer.h:159
#3  QtWaylandClient::QWaylandDataDevice::invalidateSelectionOffer (this=<optimized out>) at qwaylanddatadevice.cpp:87
#4  0x00007ffff37f01b6 in QtWaylandClient::QWaylandInputDevice::Keyboard::handleFocusLost (this=0x55555560cb50) at qwaylandinputdevice.cpp:1305

So qtwaylandclient discard the data_offer upon keyboard focus loss, which would be fine for primary selection copy, but it is not for regular case.

This seems to relate to the bug fix https://bugreports.qt.io/browse/QTBUG-73825
And qt patch https://codereview.qt-project.org/c/qt/qtwayland/+/253360
Comment 16 Alberto Díaz López 2021-08-18 08:05:43 UTC
(In reply to Alberto Díaz López from comment #14)
> (In reply to d3coder from comment #13)
> > Copy to clipboard does not work
> > 
> > 
> > 
> > Operating System: Arch Linux
> > KDE Plasma Version: 5.22.4
> > KDE Frameworks Version: 5.84.0
> > Qt Version: 5.15.2
> > Kernel Version: 5.13.9-arch1-1 (64-bit)
> > Graphics Platform: Wayland
> > Processors: 8 × Intel® Core™ i7-4790K CPU @ 4.00GHz
> > Memory: 15.5 GiB of RAM
> > Graphics Processor: Mesa DRI Intel® HD Graphics 4600
> 
> I can confirm it on Spectacle 21.08 too. My system still remains the same as
> I filed the bug, so my System Specs are basically the same as you :). Just
> that I'm still on Linux 5.13.8-zen.

Sorry, right now I'm on my ultrabook, I confused myself.

I have no access right now to the Desktop PC, the PC on which I can confirm it has the following specs:

Operating System: Arch Linux
KDE Plasma Version: 5.22.4
KDE Frameworks Version: 5.85.0
Qt Version: 5.15.2
Kernel Version: 5.13.8-zen1-1-zen (64-bit)
Graphics Platform: Wayland
Processors: 8 × Intel® Core™ i7-8550U CPU @ 4.00GHz
Memory: 15.5 GiB of RAM
Graphics Processor: Mesa DRI Intel® UHD Graphics 620

And, of course, as I said before, KDE Gear 21.08 already.
Comment 17 Bug Janitor Service 2021-08-18 17:49:31 UTC
A possibly relevant merge request was started @ https://invent.kde.org/graphics/spectacle/-/merge_requests/74
Comment 18 Méven Car 2021-08-21 07:10:49 UTC
Git commit 138f9c2680a3044d9e078fce1fefd3a2bc159ae2 by Méven Car.
Committed on 21/08/2021 at 07:08.
Pushed by meven into branch 'master'.

ExportManager: delay copy to clipboard

Until a window is focused.

M  +25   -8    src/ExportManager.cpp

https://invent.kde.org/graphics/spectacle/commit/138f9c2680a3044d9e078fce1fefd3a2bc159ae2
Comment 19 Alberto Díaz López 2021-08-21 08:58:08 UTC
Nice to see this is fixed already, after the works :).
May I know if it will arrive in 20.08.1 or in which version to test it and confirm is already fixed?
Thanks Méven & Nate for you work and efforts as always ^^.
Comment 20 Méven Car 2021-08-21 09:44:31 UTC
Git commit bca68c17191f27723b6d96c4767dca5ef021087a by Méven Car.
Committed on 21/08/2021 at 09:44.
Pushed by meven into branch 'release/21.08'.

ExportManager: delay copy to clipboard

Until a window is focused.

M  +25   -8    src/ExportManager.cpp

https://invent.kde.org/graphics/spectacle/commit/bca68c17191f27723b6d96c4767dca5ef021087a
Comment 21 Méven Car 2021-08-21 09:45:55 UTC
(In reply to Alberto Díaz López from comment #19)
> Nice to see this is fixed already, after the works :).
> May I know if it will arrive in 20.08.1 or in which version to test it and
> confirm is already fixed?
> Thanks Méven & Nate for you work and efforts as always ^^.

I was hesitant to land this for 21.08.1, I just did it
https://invent.kde.org/graphics/spectacle/commit/bca68c17191f27723b6d96c4767dca5ef021087a
Comment 22 Alberto Díaz López 2021-08-21 14:13:05 UTC
(In reply to Méven Car from comment #21)
> (In reply to Alberto Díaz López from comment #19)
> > Nice to see this is fixed already, after the works :).
> > May I know if it will arrive in 20.08.1 or in which version to test it and
> > confirm is already fixed?
> > Thanks Méven & Nate for you work and efforts as always ^^.
> 
> I was hesitant to land this for 21.08.1, I just did it
> https://invent.kde.org/graphics/spectacle/commit/
> bca68c17191f27723b6d96c4767dca5ef021087a

Terrific, yeah, my mistake, I wrote 20.08.1, being logically 21.08.1 instead.
I can't wait to try this in a few days, I tend to do a huge amount of screenshots on a daily basis (maybe around 30 or more per day), so if I don't need to tabulate to Spectacle and copy the screenshot with Ctrl + C manually each time, it'll be such a nice improvement .
Again, thank you very much Méven for your work and efforts :).
Bests ^^.
Comment 23 Alberto Díaz López 2021-09-06 10:17:54 UTC
I just checked yesterday and it seems that it works as expected, but only with the first screenshot. If I don't close Spectacle and do a second, third, etc, screenshot with Spectacle already open, the behavior is again the incorrect.
Comment 24 Nate Graham 2021-09-07 16:07:09 UTC
That sounds like a separate bug. Can you file a new bug report for it? Thanks!
Comment 25 Bug Janitor Service 2021-10-28 08:23:27 UTC
A possibly relevant merge request was started @ https://invent.kde.org/frameworks/kio/-/merge_requests/619
Comment 26 Méven Car 2021-10-28 14:52:44 UTC
This cases is not yet handled:

 * launch spectacle, take any screenshot
 * click on copy to clipboard
 * in dolphin, right click > paste clipboard content
 * a popup opens, type in a file name (any), click on ok

That's what https://invent.kde.org/frameworks/kio/-/merge_requests/619 fix and its requires latest KDE Qt Patch collection.
Comment 27 Nate Graham 2021-11-03 16:04:45 UTC
Git commit 19460119e9360b4f67eeac3e5f77b66e498c7417 by Nate Graham, on behalf of Méven Car.
Committed on 03/11/2021 at 15:59.
Pushed by ngraham into branch 'master'.

PasteDialog: fix data pasting in Wayland

In Wayland the clipboard changes anytime the focused window changes, which happens when opening the PasteDialog.

In order to support this case, just check that chosen mimetype is still available after the dialog returns.

M  +3    -3    src/widgets/paste.cpp
M  +1    -11   src/widgets/pastedialog.cpp
M  +1    -9    src/widgets/pastedialog_p.h

https://invent.kde.org/frameworks/kio/commit/19460119e9360b4f67eeac3e5f77b66e498c7417