Simplify screenshot capture and add support for wayland
pyscreenshot supports capturing screenshots via numerous backends and can automatically select the best one depending on platform. This enables capturing of the QR code on wayland-based desktops while maintaining support for Windows and X11 desktops.
Fixes #1010
This should be working now, at least on Linux. I'll give it a checkout on Windows once the test build is done. I don't have a macOS machine available to test.
Small note, I tested this in the Flatpak but there's a small bug in pyscreenshot that causes an issue. I am going to patch pyscreenshot to fix the behavior, but I don't think this should block merging this request. The dependency can be updated later.
Hi, and thanks for the PR! We have tried the builds on win10, win11, and macOS. Unfortunately, scanning does not work properly. When pressing "Scan QR code" the spinner spins and never stops. Are you able to reproduce this on your Windows?
I tested merging this (+ resolving conflicts) with latest main @ e753fac5 on Manjaro Sway with Wayland 1.22.0, and gnome-screenshot 41.0+r25+g45f08f0-1. Unfortunately, I was also able to reproduce the spinner bug mentioned by @fdennis. However, it's likely that the symptoms are similar but the underlying cause may be different on Windows versus Linux + Wayland. It appears that at least on Wayland wlroots-based compositors (e.g. without X11, nor Gnome Shell + Mutter (as compositor), gnome-screenshot does not support screen capture.
Upstream bug report is here: GNOME/gnome-screenshot#201. (It was closed as "Won't Fix", given the dependency on non-Wayland compositor + Gnome Shell).
So, if GNOME devs are not interested in fixing this for Wayland, that leaves some other options.
Not sure about what might be going on with the spinner issue on Windows' side.
Guys, just use portals for Wayland. It's generally impossible to implement a universal screenshot tool for Wayland without using something like portals, thanks to Wayland protocol. GNOME devs physically can't fix that issue. Also screenshoters for Sway (that uses wl-roots extra protocols) won't work on GNOME or KDE, or generally any non-wl-roots Wayland compositor. Don't implement more and more broken hacks. Just use portals, generic API to do that.
Documentation for the portal you need: https://flatpak.github.io/xdg-desktop-portal/#gdbus-org.freedesktop.portal.Screenshot
The same could be done for #1399
The current thing just uses an zenity based menu afaik but that probably needs to be addressed upstream
https://github.com/miguelpruivo/flutter_file_picker/issues/1451
https://github.com/miguelpruivo/flutter_file_picker/pull/1275