RFC/Proposal: Fallback code for display screenshot code (used on '/main' Web Remote)
Fixes somewhat #1236 and #1322. Closes #1405 (closed). Possibly fixes #1284 (closed) (the macOS crash), and other reports on Forum of people using negative/offscreen custom postitioning.
This MR adds code that allows a fallback to screenshots in all cases that OpenLP fails to create a screenshot on /main. It does the following:
- Removes the deprecated
QApplication.desktop()call (it's removed from Qt6; just passing '0' as winId does the same behavior); - Adds some utility functions to detect whether the OpenLP is on Wayland compositor, or running on XWayland and Wayland/XCB platform checks;
- Adds
grab_screenshot_safe()inDisplayWindowto allow to retrieve a screenshot from window in a Qt-thread-safe manner; - Adds a
_capture_maindisplay_window()andcapture_maindisplay_desktop()calls that does the Display Window capture and Desktop capture; - Adds a workaround to macOS to allow the desktop capture to happen in Qt thread (
_capture_maindisplay_desktop_mainthread_safe()) - Automatically fallbacks to Window capture when one of the following conditions is met:
- Running on Wayland compositor (even when application is running on XWayland);
- Current service item provides own display (usually presentations);
- Media is being placed
- Display custom position is out of bounds of the selected screen
- Adds a capability to allow plugins that
ProvidesOwnDisplayto provide a screenshot. - Reorganizes screen/desktop screenshot calls to grab from the correct screen and with correct sizes (relevant on HiDPI schemes)
- Adds a user setting to allow to always fallback to display window screenshotting mode (disabled by default)
But this approach has some drawbacks when using the Window screenshotting:
- Background videos will not be shown (but there's no easy way on this);
- For the present moment all the presentation plugin that controls external windows don't provide screenshots (so the image will be black on these);
- For the case @ninjakiwi said on #1236 (that it started working on Wayland, I couldn't reproduce it yet although), users would be falled back to Window screenshot code when they shouldn't (unless we find a way to know if it's working, there's nothing we can do on this).
In future, the display glue approach @ninjakiwi said would be a lightier way to do this logic (although I think this should exist alongside screenshoting code for a while).
Edited by Mateus Meyer Jiacomelli