Bug 389164 - Spectacle on wayland interface causes screen refresh
Summary: Spectacle on wayland interface causes screen refresh
Status: RESOLVED FIXED
Alias: None
Product: Spectacle
Classification: Applications
Component: General (show other bugs)
Version: 17.12.1
Platform: Compiled Sources Linux
: NOR normal
Target Milestone: ---
Assignee: Boudhayan Gupta
URL:
Keywords:
: 391391 (view as bug list)
Depends on:
Blocks:
 
Reported: 2018-01-18 14:25 UTC by bug2017
Modified: 2020-12-15 15:27 UTC (History)
9 users (show)

See Also:
Latest Commit:
Version Fixed In: 20.12


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description bug2017 2018-01-18 14:25:04 UTC
Spectacle has an unnessary extra step in the user interface. After pressing the "print" key a box with "press enter or click..." apears. In case of the print key and a delayed screenshot this box is unnesesary (from the user point of view).
(On ksnapshot this box was only there to finaly select a rectangular region.)

The main issue with that box is, that it steels the focus and causes a redraw of the full screen. It prevents taking snapshots of:

1) A context menu of the desktop
2) Any screen corruption or rendering bug
Comment 1 bug2017 2018-01-23 11:19:58 UTC
It is impossible to take a screenshot of the Application Menu (Kicker), it closes before the screenshot has been taken.
Comment 2 Patrick Silva 2018-01-23 12:30:59 UTC
(In reply to bug2017 from comment #1)
> It is impossible to take a screenshot of the Application Menu (Kicker), it
> closes before the screenshot has been taken.

confirmed in plasma 5.12 beta, Arch Linux.
Comment 3 Alexander Mentyu 2018-04-27 17:17:55 UTC
(In reply to bug2017 from comment #1)
> It is impossible to take a screenshot of the Application Menu (Kicker), it
> closes before the screenshot has been taken.

Cannot reproduce in:

Plasma: 5.12.4
Apps: 18.04.0
Frameworks: 5.45.0
Qt: 5.10.1
Kernel: 4.14.36-1-MANJARO
OS: Netrunner Rolling
Video: Intel 4400
Driver: xf86-video-intel 1:2.99.917+823+gd9bf46e4-1
Screen: 1600x900
wayland-protocols 1.13-1
wayland 1.14.0-1

Options used in Spectacle:
Window Under Cursor
On Click

Take a New Screenshot > Meta key press > click on Kicker
Comment 4 null 2018-04-28 08:51:48 UTC
> Take a New Screenshot > Meta key press > click on Kicker
You are cheating ;) Try capturing the context menu of the desktop: This will fail, because the popup (which comes from KWin, not from Spectacle) causes it to close (not only when clicking or pressing Enter, but as soon as the message appears).

@Martin: Is this a conceptual problem, or simply a bug in KWin: Why are popups closing when KWin asks "Create screen shot with left click or enter"?
Comment 5 Martin Flöser 2018-04-28 13:44:47 UTC
> @Martin: Is this a conceptual problem, or simply a bug in KWin: Why are
> popups closing when KWin asks "Create screen shot with left click or enter"?

When creating a screenshot KWin takes over the mouse cursor which results in a pointer leave event being sent to the window. This results (at least in Qt) in closing the popup.

This is also not really a difference to X11. There it is also not possible to screenshot context menus.
Comment 6 Nate Graham 2018-04-28 13:57:18 UTC
(In reply to Martin Flöser from comment #5)
> > @Martin: Is this a conceptual problem, or simply a bug in KWin: Why are
> > popups closing when KWin asks "Create screen shot with left click or enter"?
> 
> When creating a screenshot KWin takes over the mouse cursor which results in
> a pointer leave event being sent to the window. This results (at least in
> Qt) in closing the popup.

Maybe we could omit the pointer leave event? If you're taking a screenshot, it's a good bet you want the screen to remain exactly as it is so nothing disappears or changes before the screenshot can be captured.


> This is also not really a difference to X11. There it is also not possible
> to screenshot context menus.

Not by clicking, but you currently can do this in X11: Open Spectacle > Set 2 second timer > switch to "Window under cursor" mode > Click "take new screenshot" > Open context menu > position mouse cursor over menu. It would be a shame to lose this feature in Wayland.
Comment 7 Martin Flöser 2018-04-28 16:05:33 UTC
(In reply to Nate Graham from comment #6)
> (In reply to Martin Flöser from comment #5)
> > > @Martin: Is this a conceptual problem, or simply a bug in KWin: Why are
> > > popups closing when KWin asks "Create screen shot with left click or enter"?
> > 
> > When creating a screenshot KWin takes over the mouse cursor which results in
> > a pointer leave event being sent to the window. This results (at least in
> > Qt) in closing the popup.
> 
> Maybe we could omit the pointer leave event? If you're taking a screenshot,
> it's a good bet you want the screen to remain exactly as it is so nothing
> disappears or changes before the screenshot can be captured.

Not without breaking our Wayland protocol support. There is a guarantee that all pointer events are delivered while an application has the focus. Imagine you click a second button while taking the screenshot and release it afterwards. Then the application gets a button release event for a button it never got the press event. That is a clear violation of Wayland protocol and I would understand any program which asserts under this condition.

We must send a leave event when we take over the mouse pointer.

> 
> 
> > This is also not really a difference to X11. There it is also not possible
> > to screenshot context menus.
> 
> Not by clicking, but you currently can do this in X11: Open Spectacle > Set
> 2 second timer > switch to "Window under cursor" mode > Click "take new
> screenshot" > Open context menu > position mouse cursor over menu. It would
> be a shame to lose this feature in Wayland.

Yes, this is currently not possible. It could be achieved by moving the time delay to KWin. So that KWin does not have to take the pointer focus, but just screenshots after the 2 second timer. This would require changes in spectacle and the dbus protocol.
Comment 8 null 2018-04-28 23:26:17 UTC
Thanks for the info, Martin!

Nothing to solve in the short term, but good to keep in mind for a future adaptation of Spectacle to the slightly different conditions on Wayland.

One more thought: Could we change how the confirmation message works? Currently KWin asks first, and then captures a screenshot.

What if KWin captured the screenshot directly, and only handed over this screenshot once the user confirmed? (Would this need some kind of DoS protection?) This is relevant both for the "context menu" case, as well as for "immediately capture this video frame upon pressing Print".
Comment 9 Martin Flöser 2018-04-29 07:23:36 UTC
(In reply to Henrik Fehlauer from comment #8)
> One more thought: Could we change how the confirmation message works?
> Currently KWin asks first, and then captures a screenshot.

Would be possible but I recommend against it as we also have the interactive selection of a screen and window. So it would be different user behavior.
Comment 10 null 2018-04-29 07:46:55 UTC
> interactive selection of a screen and window
I'd be in favour of porting some of Kaption's UI (which is exactly about consolidating all features in a single interactive mode) to Spectacle. However, you'll probably don't want to have all of that code in KWin.

Another point is that Spectacle will get a magnifier for rectangle mode (which itself does not work on Wayland currently), which also had to live in KWin.

Or maybe we should indeed enhance KWin's UI features for screenshotting? We're already starting to see some duplication of UI (and effort) in https://phabricator.kde.org/D12068#243228.
Comment 11 Martin Flöser 2018-04-29 15:26:25 UTC
(In reply to Henrik Fehlauer from comment #10)
> > interactive selection of a screen and window
> I'd be in favour of porting some of Kaption's UI (which is exactly about
> consolidating all features in a single interactive mode) to Spectacle.
> However, you'll probably don't want to have all of that code in KWin.

We already have most... and we need to have most on Wayland. If we don't capture the mouse cursor, no application will have access to it.

> 
> Another point is that Spectacle will get a magnifier for rectangle mode
> (which itself does not work on Wayland currently), which also had to live in
> KWin.

KWin has a magnifier effect. That can be utilized. Though personally I am not a fan of such magnifier as it's zooming pixel data.
> 
> Or maybe we should indeed enhance KWin's UI features for screenshotting?
> We're already starting to see some duplication of UI (and effort) in
> https://phabricator.kde.org/D12068#243228.

I don't want any UI in KWin. The idea was to provide the functionality to capture a screenshot, not to be a screenshot tool. Also to make it possible to have simple and complex screenshot tools.

If UI gets duplicated, maybe spectacle could provide a library.
Comment 12 Patrick Silva 2019-03-25 12:01:10 UTC
duplicate of bug 391391 ?
Comment 13 Nate Graham 2019-03-25 13:23:03 UTC
*** Bug 391391 has been marked as a duplicate of this bug. ***
Comment 14 Justin Zobel 2020-11-12 23:42:30 UTC
I've not found many screenshot tools that allow you to snip a context menu due to the leave events but I usually work around it by taking a "Full Screen" screenshot then opening that file in my image editor and then crop the image to the area I want to share.
Comment 15 Méven Car 2020-12-15 15:27:42 UTC
With Plasma 5.20 and Spectacle 5.12 we don't have those confirmation intermediate screen rendering.

To take context menu and such delay now work as expected, even with rectangular selection (supported on single screen for Plasma 5.20)