Bug 411263 - Spectacle does not send screenshot to clipboard when --nonotify is used
Summary: Spectacle does not send screenshot to clipboard when --nonotify is used
Status: RESOLVED FIXED
Alias: None
Product: Spectacle
Classification: Applications
Component: General (show other bugs)
Version: 19.08.0
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: Antonio Prcela
URL:
Keywords:
: 418983 (view as bug list)
Depends on:
Blocks:
 
Reported: 2019-08-25 07:18 UTC by Frederick Zhang
Modified: 2021-08-23 12:29 UTC (History)
5 users (show)

See Also:
Latest Commit:
Version Fixed In: 20.04.0


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Frederick Zhang 2019-08-25 07:18:04 UTC
STEPS TO REPRODUCE
1. Run spectacle --background --clipboard --region --nonotify
2. Select a region, confirm

OBSERVED RESULT
The screenshot does not get copied to clipboard. And another side effect I noticed was that the desktop seemed to be frozen after the screenshot for a few seconds (roughly the same as how long a notification stays on screen when Spectacle is called without --nonotify), during which I cannot call KRunner, cannot pop up Latte Dock, etc.

EXPECTED RESULT
The screenshot is sent to clipboard.

SOFTWARE/OS VERSIONS
Linux/KDE Plasma: Arch Linux
KDE Plasma Version: 5.16.4-1
KDE Frameworks Version: 5.61.0-1
Qt Version: 5.13.0-7
Comment 1 Antonio Prcela 2019-08-25 13:44:37 UTC
I get the following error:

kf5.kconfig.core: "\"cropRegion\" - conversion of \"0,0,0,0\" to QRect failed"

And it freeze.
Can confirm it and will have a look into it.
Comment 2 David Redondo 2019-08-28 13:50:31 UTC
Git commit 331d3ceaaf74ce376a08b2efcf4394e45f8a8e97 by David Redondo, on behalf of Antonio Prcela.
Committed on 28/08/2019 at 13:48.
Pushed by davidre into branch 'Applications/19.08'.

FIX: Close spectacle if it's started with: -b -c

Summary:
Spectacle should close if both `-b` and `-c` are set

Preparation to fix this one:

Test Plan:
start spectacle:
spectacle -b -c

Expected:

  # Spectacle runs in background and the screenshot gets saved to clipboard
  # Spectacle closes itself after the notification disappears (or has been closed by the user)

Observed:
  # Spectacle runs in background and the screenshot gets saved to clipboard
  # Spectacle never quits

Reviewers: davidre

Subscribers: ngraham, #spectacle

Tags: #spectacle

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

M  +6    -5    src/SpectacleCore.cpp

https://commits.kde.org/spectacle/331d3ceaaf74ce376a08b2efcf4394e45f8a8e97
Comment 3 Antonio Prcela 2019-09-03 13:11:59 UTC
works:
spectacle -b -c (image ends up in clipboard)
spectacle -b -n (image ends up in the default save location)

does not work:
spectacle -b -c -n

So the combination of -c & -n is troublesome.
I'm looking into it for a few days now and I'd say that Spectacle gets closed too fast and it doesn't have time to save the image into the clipboard. But I ain't 100% sure. 

maybe delay 'emit allDone()' if both -c & -n are set?
https://cgit.kde.org/spectacle.git/tree/src/SpectacleCore.cpp#n281
Comment 4 David Redondo 2019-09-04 08:57:49 UTC
The freezing isn't related to notifications but is triggered by     QApplication::clipboard()->setMimeData(data, QClipboard::Clipboard);
and can also be observed when clicking on copy to clipboard in the GUI.
Comment 5 Nate Graham 2019-12-06 13:37:04 UTC
Git commit 02f51eb2652fff0cc3471cf5cf3df73d214641c2 by Nate Graham, on behalf of Antonio Prcela.
Committed on 06/12/2019 at 13:36.
Pushed by ngraham into branch 'master'.

Save image to clipboard if --nonotify is used

Summary: BUG: 411263

Test Plan: run spectacle with --nonotify

Reviewers: #spectacle, davidre, ngraham

Reviewed By: #spectacle, davidre, ngraham

Subscribers: ngraham, #spectacle

Tags: #spectacle

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

M  +5    -1    src/SpectacleCore.cpp

https://commits.kde.org/spectacle/02f51eb2652fff0cc3471cf5cf3df73d214641c2
Comment 6 malachy1681 2020-02-25 08:56:57 UTC
As of version 19.12.2-1, this bug seems to still be present.  I am running on Arch Linux, and have tested using:

  spectacle -bnc

  as well as

  spectacle --background --nonotify --clipboard

No output is given from the command and Plasma seems to freeze for a short duration.  There is also nothing in the clipboard.
Comment 7 Antonio Prcela 2020-03-01 18:07:42 UTC
(In reply to malachy1681 from comment #6)
> As of version 19.12.2-1, this bug seems to still be present.  I am running
> on Arch Linux, and have tested using:
> 
>   spectacle -bnc
> 
>   as well as
> 
>   spectacle --background --nonotify --clipboard
> 
> No output is given from the command and Plasma seems to freeze for a short
> duration.  There is also nothing in the clipboard.

I just checked with 20.03.70. So far, copy to clipboard does not work if used standalone (spectacle -c) or in combination with background and nonotify (spectacle -bnc & spectacle -nc):

command         background  clipboard   nonotify        RESULT

spectacle -bn   Y (ok)                    Y (ok)        GOOD
spectacle -bc   Y (ok)        Y (ok)                    GOOD
spectacle -b    Y (ok)                                  GOOD
spectacle -n                              Y (ok)        GOOD

spectacle -bnc  Y (ok)        N (BAD)     N (ok)        BAD
spectacle -nc                 N (BAD)     Y (ok)        BAD
spectacle -c                  N (BAD)                   BAD


Will look into it in the next few days.
Comment 8 Antonio Prcela 2020-03-02 20:52:17 UTC
(In reply to Antonio from comment #7)
> (In reply to malachy1681 from comment #6)
> > As of version 19.12.2-1, this bug seems to still be present.  I am running
> > on Arch Linux, and have tested using:
> > 
> >   spectacle -bnc
> > 
> >   as well as
> > 
> >   spectacle --background --nonotify --clipboard
> > 
> > No output is given from the command and Plasma seems to freeze for a short
> > duration.  There is also nothing in the clipboard.
> 
> I just checked with 20.03.70. So far, copy to clipboard does not work if
> used standalone (spectacle -c) or in combination with background and
> nonotify (spectacle -bnc & spectacle -nc):
> 
> command         background  clipboard   nonotify        RESULT
> 
> spectacle -bn   Y (ok)                    Y (ok)        GOOD
> spectacle -bc   Y (ok)        Y (ok)                    GOOD
> spectacle -b    Y (ok)                                  GOOD
> spectacle -n                              Y (ok)        GOOD
> 
> spectacle -bnc  Y (ok)        N (BAD)     N (ok)        BAD
> spectacle -nc                 N (BAD)     Y (ok)        BAD
> spectacle -c                  N (BAD)                   BAD
> 
> 
> Will look into it in the next few days.

I have made a mistake here.
Clipboard doesn't work at all...

Now this narrows it down and should be 'easily' fixed. Might fix it until this weekend.
Comment 9 David Redondo 2020-03-02 20:57:03 UTC
>I have made a mistake here.
>Clipboard doesn't work at all...

-b -c and -b -c -n work fine here. Do you have Klipper running?
Comment 10 Antonio Prcela 2020-03-02 21:06:49 UTC
(In reply to David Redondo from comment #9)
> >I have made a mistake here.
> >Clipboard doesn't work at all...
> 
> -b -c and -b -c -n work fine here. Do you have Klipper running?

Yes I have Klipper running.
-b -c works now too
-b -c -n does save the image into Klipper, but ctrl+v into an image editor doesn't do anything
Comment 11 David Redondo 2020-03-02 21:09:44 UTC
(In reply to Antonio from comment #10)
> Yes I have Klipper running.
> -b -c works now too
> -b -c -n does save the image into Klipper, but ctrl+v into an image editor
> doesn't do anything

Then this is probably a bug in Klipper. If the image is in Klipper from Spectacle side we can't do anything anymore we copied it to the clipboard and at this point Spectacle is not even running anymore.
Comment 12 Antonio Prcela 2020-03-02 21:13:06 UTC
(In reply to David Redondo from comment #11)
> (In reply to Antonio from comment #10)
> > Yes I have Klipper running.
> > -b -c works now too
> > -b -c -n does save the image into Klipper, but ctrl+v into an image editor
> > doesn't do anything
> 
> Then this is probably a bug in Klipper. If the image is in Klipper from
> Spectacle side we can't do anything anymore we copied it to the clipboard
> and at this point Spectacle is not even running anymore.

Ok. leaves us with:
spectacle -nc
spectacle -c
does this work for you? Here it doesn't save anything to clipboard, just launches Spectacle with a screenshot taken.
Comment 13 David Redondo 2020-03-02 21:19:09 UTC
(In reply to Antonio from comment #12)
> Ok. leaves us with:
> spectacle -nc
> spectacle -c
> does this work for you? Here it doesn't save anything to clipboard, just
> launches Spectacle with a screenshot taken.

Currently this is intentional that it only works in background mode and is documented as such. I didn't implement it myself this way but see the following comments for reference: https://phabricator.kde.org/D19715#429973
Comment 14 Antonio Prcela 2020-03-02 21:45:02 UTC
(In reply to David Redondo from comment #13)
> (In reply to Antonio from comment #12)
> > Ok. leaves us with:
> > spectacle -nc
> > spectacle -c
> > does this work for you? Here it doesn't save anything to clipboard, just
> > launches Spectacle with a screenshot taken.
> 
> Currently this is intentional that it only works in background mode and is
> documented as such. I didn't implement it myself this way but see the
> following comments for reference: https://phabricator.kde.org/D19715#429973

if it's documented like this, we can keep it. Tho, I'd wonder if anyone uses -c without -b?

Anyway, back to malachy1681 report.
spectacle -bnc doesn't work on 19.12.2 (tested on my machine). Works on 20.03.70
This one didn't make it into v19.xx.x?

https://phabricator.kde.org/R166:02f51eb2652fff0cc3471cf5cf3df73d214641c2
Comment 15 Antonio Prcela 2020-11-22 16:55:01 UTC
This one has been fixed, but not sure what commit it was.
Can you test again with the latest Spectacle? Thanks.

(In reply to Frederick Zhang from comment #0)
> STEPS TO REPRODUCE
> 1. Run spectacle --background --clipboard --region --nonotify
> 2. Select a region, confirm
> 
> OBSERVED RESULT
> The screenshot does not get copied to clipboard. And another side effect I
> noticed was that the desktop seemed to be frozen after the screenshot for a
> few seconds (roughly the same as how long a notification stays on screen
> when Spectacle is called without --nonotify), during which I cannot call
> KRunner, cannot pop up Latte Dock, etc.
> 
> EXPECTED RESULT
> The screenshot is sent to clipboard.
> 
> SOFTWARE/OS VERSIONS
> Linux/KDE Plasma: Arch Linux
> KDE Plasma Version: 5.16.4-1
> KDE Frameworks Version: 5.61.0-1
> Qt Version: 5.13.0-7
Comment 16 Frederick Zhang 2020-11-24 10:49:03 UTC
Yes I can confirm this has been fixed! Thank you!

(In reply to Antonio Prcela from comment #15)
> This one has been fixed, but not sure what commit it was.
> Can you test again with the latest Spectacle? Thanks.
> 
> (In reply to Frederick Zhang from comment #0)
> > STEPS TO REPRODUCE
> > 1. Run spectacle --background --clipboard --region --nonotify
> > 2. Select a region, confirm
> > 
> > OBSERVED RESULT
> > The screenshot does not get copied to clipboard. And another side effect I
> > noticed was that the desktop seemed to be frozen after the screenshot for a
> > few seconds (roughly the same as how long a notification stays on screen
> > when Spectacle is called without --nonotify), during which I cannot call
> > KRunner, cannot pop up Latte Dock, etc.
> > 
> > EXPECTED RESULT
> > The screenshot is sent to clipboard.
> > 
> > SOFTWARE/OS VERSIONS
> > Linux/KDE Plasma: Arch Linux
> > KDE Plasma Version: 5.16.4-1
> > KDE Frameworks Version: 5.61.0-1
> > Qt Version: 5.13.0-7
Comment 17 Jan Paul Batrina 2021-08-23 12:29:33 UTC
*** Bug 418983 has been marked as a duplicate of this bug. ***