Bug 390652

Summary: Capturing the active window fails if compositing is off and the window touches a screen border
Product: [Applications] Spectacle Reporter: null <null>
Component: GeneralAssignee: Boudhayan Gupta <me>
Severity: normal CC: blargblarg, bugseforuns, joerg.lerche, kde, nate
Priority: NOR    
Version: 17.12.2   
Target Milestone: ---   
Platform: Other   
OS: Linux   
Latest Commit: Version Fixed In:

Description null 2018-02-18 01:03:48 UTC
Switch off compositing, then try to capture the active window (either via option in Spectacle, or via Meta+Print shortcut). It will fail as soon as the active window touches the left/bottom/right screen border or extends beyond (top).

It works with compositing enabled.

If it sounds weird, it is…
Comment 1 null 2018-02-18 01:06:54 UTC
*** Bug 384585 has been marked as a duplicate of this bug. ***
Comment 2 Nate Graham 2018-02-19 18:12:47 UTC
Hmm, I taking screenshots all the time using Active Window mode when the window is touching a screen edge in a VM with compositing disabled. Never tried putting it beyond the window borders though.
Comment 3 Nate Graham 2018-02-19 23:42:53 UTC
Never mind, my VM composits! Who knew? Can confirm the issue.
Comment 4 null 2018-02-19 23:46:22 UTC
Thanks for testing ;)

Telling whether compositing is off should be easy, because there are no shadows… Also, make sure to test once in a while in this mode, because especially the performance might be totally different (e.g. moving windows, moving region capture in Spectacle etc.).
Comment 5 Nate Graham 2018-02-19 23:47:51 UTC
Excellent idea.
Comment 6 Kai Uwe Broulik 2018-02-20 08:37:25 UTC
It fails whenever the coordinates of the window are out of bounds of the screen. This already happens when it touches a border since the window decoration would be outside the screen and xcb_image_get returns a null pixmap; the coordinates need to be clamped to the screen area.
Comment 7 null 2018-02-20 08:39:30 UTC
Thanks for the insight. There is a patch in https://phabricator.kde.org/D10672 (sadly no automatic linking…), is that what you mean?
Comment 8 Kai Uwe Broulik 2018-02-20 08:40:18 UTC
Haha, cool, that was virtually the same patch I was just about to write now. Thanks you saved me from doing so ;)
Comment 9 null 2018-02-20 08:43:12 UTC
Cool ;) If you want to write more patches, I'd like to plug Bug 372408
Comment 10 Patrick Silva 2018-02-20 13:48:15 UTC
on my Arch Linux meta+print does not work when compositing is off (it works again after re-enable compositing).

Spectable capture an empty "screenshot" when I try capture an active window that is touching a screen border.
Comment 11 null 2018-02-20 14:35:16 UTC
*** Bug 378621 has been marked as a duplicate of this bug. ***
Comment 12 Nate Graham 2018-02-20 14:40:05 UTC
Now I see: the reason why I was never able to reproduce this is because I turn window borders off, so there was never any content out of bounds.
Comment 13 Nate Graham 2018-02-20 14:41:07 UTC
(In reply to Henrik Fehlauer from comment #9)
> Cool ;) If you want to write more patches, I'd like to plug Bug 372408

That would be quite the crowd pleaser. I've looked into this several times but it's a bit beyond my current skill level.
Comment 14 null 2018-03-06 20:29:56 UTC
Git commit 5d2e20ce7e4c19fbd7227ab750ea6b31c9f8968a by Henrik Fehlauer, on behalf of Alex Nemeth.
Committed on 06/03/2018 at 20:29.
Pushed by rkflx into branch 'master'.

Set screen bounds for active window grab when compositor is disabled

It failed to capture the window area when the window was outside of the screen and showed a null image to the user when compositor was not enabled.
Now it only captures the area that is on the screen.

Reviewers: #spectacle, rkflx, ngraham, broulik

Reviewed By: #spectacle, rkflx, ngraham

Subscribers: davidedmundson, broulik, ngraham

Tags: #spectacle

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

M  +9    -0    src/PlatformBackends/X11ImageGrabber.cpp