Comment 9 for bug 1923241

Revision history for this message
James Carroll (james-carroll) wrote (last edit ):

For Linux/Wayland, the/my recommended approach here is to make use of the XDG Desktop Portals screenshot interface.

The portals are simply a scoped DBus API that's considered safe to use in the context of Snap/Flatpak packages, but they still work in unconfined environments. Specifically regarding the screenshot API, it ideally acts as a wrapper API around any compositor-specific screenshotting API's. It likely won't work everywhere (considering niche environments exist), but it should give a workable solution on the most common setups.

Because of its design, it would open an out-of-process application window that would allow the user to pick what they wanted to select themselves, so you'd need to supress the Pinta native UI in this instance.

You could rely on this API even in X11 contexts, if desired.

The general flow of using the DBus API would be to make a DBus call, and wait for it's return; whereby it will either fail (user cancelled/unsupported/etc) or return a filepath which contains the screenshot for you to use.

https://flatpak.github.io/xdg-desktop-portal/#gdbus-org.freedesktop.portal.Screenshot