Bug 420477 - Spectacle hotkey captures do not copy to clipboard
Summary: Spectacle hotkey captures do not copy to clipboard
Status: RESOLVED FIXED
Alias: None
Product: Spectacle
Classification: Applications
Component: General (show other bugs)
Version: 19.12.3
Platform: Manjaro Linux
: HI normal
Target Milestone: ---
Assignee: Boudhayan Gupta
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-04-23 18:39 UTC by Ted Sadler
Modified: 2020-10-07 14:08 UTC (History)
9 users (show)

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


Attachments
KInfocenter system information (79.01 KB, image/png)
2020-04-23 18:39 UTC, Ted Sadler
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Ted Sadler 2020-04-23 18:39:21 UTC
Created attachment 127808 [details]
KInfocenter system information

Under Spectacle 19.12.3 (KDE 5.18.4), using hotkeys to perform rectangle region, active window, or full-screen captures does not copy the resulting image capture to the clipboard.

STEPS TO REPRODUCE
1. Configure Spectacle to copy all screen captures to the clipboard.
2. Press the configured hotkey selection for either full desktop, rectangle capture, or active window. 
3. Observe that a screenshot was captured, confirmed via notification.
4. Attempt to paste the copied image into an image editor or other software that will accept a pasted image.

OBSERVED RESULT
No image is pasted. If a previous text or image was already in the clipboard, that will be pasted instead. Otherwise, nothing at all is pasted.

EXPECTED RESULT
The captured region image should be copied to the clipboard and pasteable. Previous clipboard contents should be overwritten.

SOFTWARE/OS VERSIONS
- See attachment.

ADDITIONAL INFORMATION
- The captures will autosave to a directory correctly if configured to do so, so the captures are actually being made.
- Manually capturing a full screen, regional, or active window screenshot using the Spectacle application itself (NOT a hotkey) will properly copy the capture to the clipboard.
Comment 1 Nate Graham 2020-04-24 18:18:41 UTC
Can confirm. :(

For me the screenshot makes it to the clipboard if Spectacle's main window is currently running when you use one of the global keyboard shortcuts, and the screenshot is copied when using the main window directly. But when the main window is not open, the auto-copy feature does not work for me.
Comment 2 Ted Sadler 2020-04-24 18:23:28 UTC
(In reply to Nate Graham from comment #1)

Nate, thanks for the confirmation. I was able to reproduce that specific test also with the same results.
Comment 3 Antonio Prcela 2020-05-03 21:00:33 UTC
Just tried to reproduce with Spectacle v20.04.0.
Copy image to clipboard is set. Autosave the image is disabled.

Spectacle not running, press Pint/Meta+Print/Shift+Print/Meta+Shift+Print, Spectacle window appears and image is in clipboard. Open up KolourPaint, CTRL+V, screenshot is inserted.

Same when Spectacle is running and the window is somewhere in the background.

@Ted - I'm also on Manjaro, testing branch tho. Did you get the kde applications update so kde apps are now on v20.04.0?
Comment 4 Ted Sadler 2020-05-04 12:28:19 UTC
(In reply to @Antonio from comment #3)

I am on v20.04.0 now, yes. However, I am still experiencing the same problem...

If I just press PrntScrn alone, I get a full-image capture that I can paste. But if I press any hotkey configured in Spectacle (including any shortcuts for "full desktop capture", the capture is saved and I get a popup but my clipboard doesn't contain the image if Spectacle was not running in the foreground already.
Comment 5 Antonio Prcela 2020-05-04 13:14:52 UTC
Can you check ~/.config/spectaclerc ?

mine looks like this, the irrelevant options are not shown here (last file paths, etc.):

[General]
copyImageToClipboard=true
showMagnifier=true

[GuiConfig]
captureMode=5

[Save]
copySaveLocation=false
Comment 6 Ted Sadler 2020-05-04 13:19:11 UTC
(In reply to Antonio from comment #5)
> Can you check ~/.config/spectaclerc ?

This is mine:

[$Version]
update_info=spectacle_newConfig.upd:spectacle-new-config

[General]
alwaysRememberRegion=false
autoSaveImage=true
copyImageToClipboard=true
printKeyActionRunning=0
rememberLastRectangularRegion=true
showMagnifier=true
useLightMaskColour=false
useReleaseToCapture=true

[GuiConfig]
captureMode=5 #This was 4 previously. I changed it to 5 but the bug persists
cropRegion=4321,175,854,639
includePointer=false
window-position=124,154

[KFileDialog Settings]
detailViewIconSize=0

[Save]
compressionQuality=100
copySaveLocation=false
defaultSaveImageFormat=png
lastUsedSaveMode=0
saveFilenameFormat=Screenshot_%Y%M%D_%H%m%S
Comment 7 Antonio Prcela 2020-05-04 14:00:32 UTC
And suddenly I can reproduce it. Will see if I'll find anything in the source code.
Comment 8 Ted Sadler 2020-05-04 14:16:19 UTC
Thanks @Antonio! Out of curiosity, what did you do differently from your previous steps to reproduce the issue?
Comment 9 Antonio Prcela 2020-05-04 14:18:21 UTC
(In reply to Ted Sadler from comment #8)
> Thanks @Antonio! Out of curiosity, what did you do differently from your
> previous steps to reproduce the issue?

Well, deleted the old spectaclerc and let spectacle create a new one.
Now I could reproduce. Took the old spectaclerc from a backup and tried it again, still reproducible.
I don't know why it was working fine last night :s
Comment 10 Ted Sadler 2020-05-04 14:22:11 UTC
(In reply to Antonio from comment #9)
> 
> Well, deleted the old spectaclerc and let spectacle create a new one.
> Now I could reproduce. Took the old spectaclerc from a backup and tried it
> again, still reproducible.
> I don't know why it was working fine last night :s

that's certainly strange... you must have been testing after the bugs had gone to bed! ;)

Thanks for looking into this -- let me know what you find in the source!
Comment 11 Antonio Prcela 2020-05-10 12:42:39 UTC
(In reply to Ted Sadler from comment #10)
> (In reply to Antonio from comment #9)
> > 
> > Well, deleted the old spectaclerc and let spectacle create a new one.
> > Now I could reproduce. Took the old spectaclerc from a backup and tried it
> > again, still reproducible.
> > I don't know why it was working fine last night :s
> 
> that's certainly strange... you must have been testing after the bugs had
> gone to bed! ;)
> 
> Thanks for looking into this -- let me know what you find in the source!

@Ted Sadler , I've found an approach to make this work, tested it on my side and now it works as expected. Let's see if this is acceptable and if it will be merged: https://phabricator.kde.org/D29596
Comment 12 Ted Sadler 2020-05-11 13:48:07 UTC
(In reply to Antonio from comment #11)
> @Ted Sadler , I've found an approach to make this work, tested it on my side
> and now it works as expected. Let's see if this is acceptable and if it will
> be merged: https://phabricator.kde.org/D29596

Hey, that did it! Spectacle now copies the capture to the clipboard even when the UI is closed. I also am now seeing the new toast notification. Verified with paste and everything works as expected.

Thank you Antonio! I'll change the status to Resolved.

Cheers,
Ted
Comment 13 Ted Sadler 2020-05-11 13:50:54 UTC
Antonio,

It appears I spoke too soon... while this fix does resolve the clipboard problem, the captures are no longer auto-saving to their configured destination when using the hotkeys with Spectacle closed. This behavior was working fine before the bugfix...

Re-opening this bug for now, but I can file a new one if desired.

Thanks,
Ted
Comment 14 Antonio Prcela 2020-05-11 14:10:09 UTC
(In reply to Ted Sadler from comment #13)
> Antonio,
> 
> It appears I spoke too soon... while this fix does resolve the clipboard
> problem, the captures are no longer auto-saving to their configured
> destination when using the hotkeys with Spectacle closed. This behavior was
> working fine before the bugfix...
> 
> Re-opening this bug for now, but I can file a new one if desired.
> 
> Thanks,
> Ted

Yeah, it was a too simple fix to not cause other problems :)
No need for a new one since this didn't land on master and I'll note that info to improve the fix.
Thanks
Comment 15 Curtis Parfitt-Ford 2020-05-12 20:47:55 UTC
For what it's worth, I'm also reproducing this same issue. As far as I can tell, in the current iteration of Spectacle, it doesn't matter what settings are configured - the hotkey snips will always save as images.
Comment 16 David Redondo 2020-05-13 07:16:09 UTC
This is not a bug but is working as implemented. This is also the reason the setiing is in the "When Spectacle is running" section like what should happen if you press the print key again. I will leave this bug open as it is evident that the current situation is not clear at all and I'm not happy with it either.
Comment 17 Ted Sadler 2020-05-13 12:08:04 UTC
(In reply to David Redondo from comment #16)
> This is not a bug but is working as implemented. This is also the reason the
> setiing is in the "When Spectacle is running" section like what should
> happen if you press the print key again. I will leave this bug open as it is
> evident that the current situation is not clear at all and I'm not happy
> with it either.

David, thank you for the clarification -- and you're right. The section does say "When Spectacle is Running," but at the same time I think the interface is a bit misleading given that Spectacle has to be running *somewhere* in order for the hotkey combinations to work at all. Thanks for leaving it open.
Comment 18 Curtis Parfitt-Ford 2020-05-13 12:09:58 UTC
Perhaps it might be an idea to add a separate "When Spectacle is activated by a hotkey" section with those same options, such that the two scenarios could be controlled separately.
Comment 19 Ted Sadler 2020-05-13 12:16:46 UTC
(In reply to Curtis Parfitt-Ford from comment #18)
> Perhaps it might be an idea to add a separate "When Spectacle is activated
> by a hotkey" section with those same options, such that the two scenarios
> could be controlled separately.

That would probably be helpful. It's also misleading that the "Autosave the image to the default location" option is under "When Spectacle is Running" but Spectacle doesn't need to be running for that to work. Hotkey activation saves the screenshots when that option is enabled, even with Spectacle's UI closed. I think that behavior is what led me to believe that the failure to copy the image to the clipboard is a bug, not an intended behavior.
Comment 20 Patrick Silva 2020-05-25 14:11:58 UTC
"Autosave the image to the default location" and "Copy image to clipboard"
should not be under "When Spectable is running" because these options also work if Spectacle is closed and we launch it by pressing printscreen key.
But "Copy image to clipboard" doesn't work if Spectacle is closed and we take
a screenshot by pressing meta+print (active window), shift+print (entire desktop) and meta+shift+print (rectangular region) shortcuts.

Operating System: KDE neon Unstable Edition
KDE Plasma Version: 5.19.80
KDE Frameworks Version: 5.71.0
Qt Version: 5.14.2
Comment 21 Méven Car 2020-06-05 09:31:33 UTC
Git commit dec0e6cef23ac35754aa537db6d7ace42b23ca2a by Méven Car.
Committed on 05/06/2020 at 09:10.
Pushed by meven into branch 'master'.

Refactor Spectacle to run in single instance mode with KDBusService::Unique

Summary:
Since Spectacle got DBus activation support in 09cd11881d828da35c46c48da79f2d988e6a78cc, it has been run in multiple instance mode.
But it has been shaddowed by using qbus ee862d161a480408338d00b8826c915f7a97575c in the desktop file to mimic singleton behavior.

This refactors Spectacle to run in true single instance mode using KDBusService::Unique.
This is to allow Spectacle to have its executable in its Exec desktop Entry, to allow KWin to match the executable to the service file, itself to allow screenshots under Wayland without intermediate click.

The listed bugs are fixed incidently except for 414739 where a simple fix was added in screenShotUpdated.
Related: bug 414739, bug 412186

Test Plan:
Start spectacle, alternatively, from shortcut, command line.
Take screenshots, from alternative ways.

There is always at most one Spectacle window unless launched with `--new-instance`.

Reviewers: davidre, ngraham, bport, davidedmundson, apol

Reviewed By: davidre

Subscribers: broulik, anthonyfieroni, #spectacle

Tags: #spectacle

Differential Revision: https://phabricator.kde.org/D29487

M  +2    -2    desktop/org.kde.spectacle.desktop.cmake
M  +30   -89   src/Main.cpp
M  +170  -105  src/SpectacleCore.cpp
M  +8    -10   src/SpectacleCore.h
M  +5    -10   src/SpectacleDBusAdapter.cpp
M  +0    -31   src/SpectacleDBusAdapter.h

https://invent.kde.org/graphics/spectacle/commit/dec0e6cef23ac35754aa537db6d7ace42b23ca2a
Comment 22 Ted Sadler 2020-06-05 15:00:21 UTC
@Méven Car

Under this revision, when using a keyboard shortcut with Spectacle closed, the screenshots are copied to the clipboard as expected but the "autosave the image to default directory" function no longer works. If Spectacle is open while using the shortcut, the image is both copied to the clipboard and saved. 

This is the same behavior that I experienced with @Antonio's revision.

Ted
Comment 23 Antonio Prcela 2020-06-06 21:11:03 UTC
(In reply to Ted Sadler from comment #22)
> @Méven Car
> 
> Under this revision, when using a keyboard shortcut with Spectacle closed,
> the screenshots are copied to the clipboard as expected but the "autosave
> the image to default directory" function no longer works. If Spectacle is
> open while using the shortcut, the image is both copied to the clipboard and
> saved. 
> 
> This is the same behavior that I experienced with @Antonio's revision.
> 
> Ted

I gave it another try and seems that it works now fine:
You can test via: https://invent.kde.org/graphics/spectacle/-/merge_requests/2
Note: This commit also has some changes for the settings layout.
Comment 24 Patrick Silva 2020-06-08 13:41:29 UTC
(In reply to Ted Sadler from comment #22)
> @Méven Car
> 
> Under this revision, when using a keyboard shortcut with Spectacle closed,
> the screenshots are copied to the clipboard as expected but the "autosave
> the image to default directory" function no longer works.

I can confirm on X11 session of neon untable.
On Wayland the taken screenshot is neither copied to clipboard nor saved to default location.

Operating System: KDE neon Unstable Edition
KDE Plasma Version: 5.19.80
KDE Frameworks Version: 5.71.0
Qt Version: 5.14.2
Comment 25 Méven Car 2020-06-11 16:09:50 UTC
(In reply to Patrick Silva from comment #24)
> (In reply to Ted Sadler from comment #22)
> > @Méven Car
> > 
> > Under this revision, when using a keyboard shortcut with Spectacle closed,
> > the screenshots are copied to the clipboard as expected but the "autosave
> > the image to default directory" function no longer works.
> 
> I can confirm on X11 session of neon untable.
> On Wayland the taken screenshot is neither copied to clipboard nor saved to
> default location.
> 
> Operating System: KDE neon Unstable Edition
> KDE Plasma Version: 5.19.80
> KDE Frameworks Version: 5.71.0
> Qt Version: 5.14.2

Maybe we should open a different bug, the bug in Wayland is not so much about spectacle than it is about Wayland clipboard.
Comment 26 Patrick Silva 2020-06-12 10:32:32 UTC
(In reply to Méven Car from comment #25)
> (In reply to Patrick Silva from comment #24)
> > (In reply to Ted Sadler from comment #22)
> > > @Méven Car
> > > 
> > > Under this revision, when using a keyboard shortcut with Spectacle closed,
> > > the screenshots are copied to the clipboard as expected but the "autosave
> > > the image to default directory" function no longer works.
> > 
> > I can confirm on X11 session of neon untable.
> > On Wayland the taken screenshot is neither copied to clipboard nor saved to
> > default location.
> > 
> > Operating System: KDE neon Unstable Edition
> > KDE Plasma Version: 5.19.80
> > KDE Frameworks Version: 5.71.0
> > Qt Version: 5.14.2
> 
> Maybe we should open a different bug, the bug in Wayland is not so much
> about spectacle than it is about Wayland clipboard.

Done: bug 422860
Comment 27 Méven Car 2020-06-12 11:48:19 UTC
Fixed for X11, bug still exists in Wayland tracked at https://bugs.kde.org/show_bug.cgi?id=422860
Comment 28 kinghat 2020-08-06 17:39:20 UTC
i dont think this is fixed on x11, might be same symptom but a different bug because i have an additional symptom:

with meta + shift + prtsc. in my case i dont have auto save image enabled, only copy image to clipboard. when i run the shortcut i get a saved image and image in the notification but whats copied to clipboard is the file path of the image instead.

so maybe i have two bugs:
1. image is saved when its not supposed to be.
2. image isnt copied to clipboard.

if i have spectacle open i dont have any of these issues, the image ISNT saved to disk and the image IS copied to clipboard correctly.

Operating System: Manjaro Linux
KDE Plasma Version: 5.19.4
KDE Frameworks Version: 5.72.0
Qt Version: 5.15.0
Kernel Version: 5.7.12-1-MANJARO
OS Type: 64-bit
Processors: 8 × Intel® Xeon® CPU E5-1620 v3 @ 3.50GHz
Memory: 62.8 GiB of RAM
Graphics Processor: AMD Radeon ™ RX 470 Graphics
Comment 29 Nate Graham 2020-10-06 15:22:43 UTC
Works for me on X11 now FWIW.
Comment 30 Antonio Prcela 2020-10-07 14:08:04 UTC
Git commit db944286edbdf91e79a06871d570bd01b7c595af by Antonio Prcela.
Committed on 07/10/2020 at 13:36.
Pushed by ngraham into branch 'master'.

Improve settings logic and layout

Rearrange setting so it's no more possible to have all three options activated at once: copy image to clipboard, save location to clipboard and autosave image.
Added check to avoid having all three settings at once. Updated layout with some spacers.

M  +92   -52   src/Gui/SettingsDialog/GeneralOptions.ui
M  +14   -0    src/Gui/SettingsDialog/GeneralOptionsPage.cpp
M  +2    -0    src/Gui/SettingsDialog/GeneralOptionsPage.h
M  +50   -21   src/Gui/SettingsDialog/SaveOptions.ui
M  +5    -5    src/Gui/SettingsDialog/spectacle.kcfg
M  +1    -0    src/SpectacleCore.cpp

https://invent.kde.org/graphics/spectacle/commit/db944286edbdf91e79a06871d570bd01b7c595af