Bug 437652

Summary: Spectacle sometimes fails to take a screenshot under Wayland
Product: [Applications] Spectacle Reporter: Marco Rebhan <me>
Component: GeneralAssignee: Boudhayan Gupta <me>
Status: RESOLVED FIXED    
Severity: normal CC: kde, meven.car, nate, vlad.zahorodnii
Priority: NOR Keywords: wayland
Version: 21.04.1   
Target Milestone: ---   
Platform: Other   
OS: Linux   
Latest Commit: Version Fixed In: 21.04.2

Description Marco Rebhan 2021-05-25 10:23:09 UTC
SUMMARY
Spectacle sometimes fails to take a screenshot under Wayland, I'm not sure what causes it but if it fails once, it never works again until a restart (probably logout/login too, but I don't do that under Wayland because of bug 433293). This is using a "normal" KDE setup with Kwin.

STEPS TO REPRODUCE
1. ???
2. Open Spectacle
3. Take a screenshot (with any of the screenshot modes)

OBSERVED RESULT
Spectacle says "Could not take a screenshot. Please report this bug here: <link to bug tracker>". It also prints the following to stdout every time I try taking a screenshot:

    libpng error: Read Error
    QPixmap::scaled: Pixmap is a null pixmap
    qt.qpa.wayland: Wayland does not support QWindow::requestActivate()

EXPECTED RESULT
A screenshot is taken and appears in the preview.

SOFTWARE/OS VERSIONS
Operating System: Gentoo
KDE Plasma Version: 5.21.90
KDE Frameworks Version: 5.82.0
Qt Version: 5.15.2
Kernel Version: 5.12.6-gentoo (64-bit)
Graphics Platform: Wayland
Comment 1 Vlad Zahorodnii 2021-05-26 18:56:36 UTC
It seems like Spectacle 21.04 doesn't use the new screenshot dbus api. :( As for "libpng error: Read Error" I'm not sure what can cause it, I have never seen that error message.
Comment 2 Nate Graham 2021-05-26 19:04:49 UTC
Git commit 777038952edfe8b1eff0a2a732fd3d9d8171fc43 by Nate Graham, on behalf of Vlad Zahorodnii.
Committed on 26/05/2021 at 19:04.
Pushed by ngraham into branch 'release/21.04'.

Platforms: Introduce PlatformKWinWayland2

The new interface is more extensible and it fixes the latency issue on
wayland. The old org.kde.kwin.Screenshot interface is deprecated.
FIXED-IN: 21.04.2
(cherry picked from commit be8ee0f7efd17f5f29cbf70ac1374ad05f0481ff)

M  +1    -1    desktop/org.kde.spectacle.desktop.cmake
M  +1    -0    src/CMakeLists.txt
A  +356  -0    src/Platforms/PlatformKWinWayland2.cpp     [License: LGPL(v2.0+)]
A  +149  -0    src/Platforms/PlatformKWinWayland2.h     [License: LGPL(v2.0+)]
M  +5    -0    src/Platforms/PlatformLoader.cpp

https://invent.kde.org/graphics/spectacle/commit/777038952edfe8b1eff0a2a732fd3d9d8171fc43