Bug 436218 - Rectangular region grab under xwayland doesn't work
Summary: Rectangular region grab under xwayland doesn't work
Status: RESOLVED INTENTIONAL
Alias: None
Product: Spectacle
Classification: Applications
Component: General (show other bugs)
Version: 21.04.0
Platform: Slackware Linux
: NOR normal
Target Milestone: ---
Assignee: Boudhayan Gupta
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-04-26 15:07 UTC by Fabio
Modified: 2022-12-01 23:06 UTC (History)
4 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
dbus-monitor output (2.41 KB, text/plain)
2021-04-26 15:07 UTC, Fabio
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Fabio 2021-04-26 15:07:01 UTC
Created attachment 137927 [details]
dbus-monitor output

SUMMARY

Some distro (eg slackware, suse) use a "mixed" wayland session, where both the xcb and the wayland platforms are available. Basically each app can decide to start as pure wayland or inside XWayland using xcb.
When spectacle is run in XWayland, it is not able to grab rectangle regions.

STEPS TO REPRODUCE
1. run spectacle with the xcb platform inside a wayland session
2. try to grab a rectangular region

OBSERVED RESULT

The correct wayland platform is loaded by looking at XDG_SESSION_TYPE, but something goes wrong during the screen grab.
Console output:
Error calling KWin DBus interface: "org.kde.kwin.Screenshot.Error.ScreenMissing" "Screen not found"

EXPECTED RESULT

A rectangle region grab


SOFTWARE/OS VERSIONS
Operating System: Slackware 14.2
KDE Plasma Version: 5.21.4
KDE Frameworks Version: 5.81.0
Qt Version: 5.15.2
Kernel Version: 5.12.0
OS Type: 64-bit
Graphics Platform: Wayland
Processors: 8 × AMD Ryzen 7 4700U with Radeon Graphics
Memory: 15.0 GiB of RAM
Graphics Processor: AMD RENOIR

ADDITIONAL INFORMATION

I tried the current master version that uses the new PlatformKWinWayland2, but I still get the same error
Comment 1 Fabio 2021-04-26 15:38:43 UTC
Sorry, my KWin doesn't provide org.kde.KWin.ScreenShot2 so spectacle/master is still using the old PlatformKWinWayland.
It looks like before plasma 5.21 the "ractangular region" grab used "screenshotFullscreen" that doesn't require a screen, while now it uses "screenshotScreens" providing a screen obtained from QGuiApplication::screens().
I suspect the problem is due to QGuiApplication::screens() returning the Xwayland screen instead of the Wayland one.
Comment 2 Nate Graham 2021-04-27 19:21:25 UTC
Fixed in Plasma 5.22, sorry about that.

*** This bug has been marked as a duplicate of bug 432260 ***
Comment 3 Fabio 2021-06-15 20:05:54 UTC
I'm now running spectacle 21.04.2 on plasma 5.22, and the bug is still present.
I saw the introduction of the new PlatformKWinWayland2 interface but it still uses QGuiApplication::screens() to get the screen name used in the dbus request to KWin.

When running spectacle in a mixed wayland/xwayland session (as used by suse and slackware), spectacle will default using the xcb backend.

This means that QGuiApplication::screens() will return the dummy XWayland screen, while KWin expects to get a request for a Wayland screen name.
This obviously fails.

My current workaround just comments out QGuiApplication::screens() and hardcodes my laptop screen name QStringLiteral("eDP-1"), but that's obviously a dirty hack.

I found no way from a qt app running inside xwayland to get the wayland screen names.

I can see a few possible solutions to this problem:
 * let kwin enumerate the available screens somewhere in its dbus interface for spectacle to pick it up
 * always force spectacle to use the wayland backend if available
Comment 4 postix 2022-07-13 15:03:25 UTC
Can you still reproduce it on some newer Plasma version (5.25+)?
Comment 5 Fabio 2022-07-15 11:02:41 UTC
Yes, the bug is still present.
Spectacle is not able to grab a rectangular area screenshot under XWayland.
To be honest I switched to using a full wayland session (without xwayland) just to avoid this bug, so it doesn't affect me anymore.

Operating System: Slackware 15.0 (current)
KDE Plasma Version: 5.25.3
KDE Frameworks Version: 5.96.0
Qt Version: 5.15.4
Kernel Version: 5.18.11 (64-bit)
Graphics Platform: Wayland
Processors: 8 × AMD Ryzen 7 4700U with Radeon Graphics
Memory: 15.0 GiB of RAM
Graphics Processor: AMD RENOIR
Manufacturer: HP
Product Name: HP ProBook 635 Aero G7 Notebook PC
Comment 6 Bug Janitor Service 2022-07-30 04:35:42 UTC
Dear Bug Submitter,

This bug has been in NEEDSINFO status with no change for at least
15 days. Please provide the requested information as soon as
possible and set the bug status as REPORTED. Due to regular bug
tracker maintenance, if the bug is still in NEEDSINFO status with
no change in 30 days the bug will be closed as RESOLVED > WORKSFORME
due to lack of needed information.

For more information about our bug triaging procedures please read the
wiki located here:
https://community.kde.org/Guidelines_and_HOWTOs/Bug_triaging

If you have already provided the requested information, please
mark the bug as REPORTED so that the KDE team knows that the bug is
ready to be confirmed.

Thank you for helping us make KDE software even better for everyone!
Comment 7 Nate Graham 2022-12-01 23:06:19 UTC
Those distros no longer do, and Spectacle is a fully Wayland-native app. So there should be no need to handle this case anymore.