Bug 386250

Summary: [Wayland] Spectacle opens anyway when you try to cancel out of the window selection UI
Product: [Applications] Spectacle Reporter: Patrick Silva <bugseforuns>
Component: GeneralAssignee: Boudhayan Gupta <me>
Severity: normal CC: nate
Priority: NOR Keywords: usability
Version: 19.04.0   
Target Milestone: ---   
Platform: Arch Linux   
OS: Linux   
Latest Commit: Version Fixed In:

Description Patrick Silva 2017-10-27 14:22:07 UTC
neon dev unstable here...

start wayland session
press printscreen key
press ESC to cancel the capture
spectacle window is unnecessarily open
Comment 1 Nate Graham 2017-11-19 05:22:15 UTC
Works for me in a Wayland session on 5.11.3. on Kubuntu 17.10. Can you reproduce?
Comment 2 Patrick Silva 2017-11-19 13:11:01 UTC
yes, I can.
when I press printscreen under Wayland plasma shows this message
~Create screen shot with left click or enter. Escape or right click to cancel.~
If I press ESC, spectacle is opened and the area where should be the screenshot is empty.
If I press enter the screenshot is correctly taked.
If I press no key during 30 seconds spectacle window opens over the message and no screenshot is taked, like when I press ESC

Tested on Arch, plasma 5.11.3.
Comment 3 Nate Graham 2017-11-20 04:12:30 UTC
Ah I see, you can't cancel out of the initial window selection UI.
Comment 4 Patrick Silva 2018-01-23 12:57:30 UTC
same bug in plasma 5.12 beta.
Comment 5 Patrick Silva 2018-05-18 21:48:15 UTC
bug persists on Arch Linux, plasma 5.13 beta, spectacle 18.04.1.
Comment 6 Boudhayan Gupta 2019-06-12 08:13:26 UTC
This is due to the way KWin handles taking screenshots in Wayland mode. The  "click now to take a screenshot" screen is presented by KWin as a security feature to let you know some app is trying to grab the screen image. If you cancel out of it, no image is returned, which is why you see Spectacle with a null image. This works exactly as designed.

KWin doesn't know who asked for the screenshot, so it can't kill the application which requested it if the grab is cancelled. Also, even if it could, how do you differentiate the initial grab and subsequent grabs (with the Take New Screenshot button for example) where Spectacle shouldn't be killed?

Note that we can't just tell KWin our PID and whether we should get killed if the grab is cancelled because:

(a) this information can be faked, and a malicious program could use it to kill other stuff.
(b) in things like Flatpak, Spectacle and KWin might live in different PID namespaces, leading to us killing the wrong app again.
Comment 7 Nate Graham 2019-06-13 04:21:18 UTC
(In reply to Boudhayan Gupta from comment #6)
> If you cancel out of it, no image is returned, which is why you see
> Spectacle with a null image.
Could we maybe have Spectacle display a nice message instead of a null image, so the user knows what happened and what do do next?