Support XDG Inhibit portal#108704
Conversation
Current Godot releases support using org.freedesktop.ScreenSaver to inhibit the screensaver, but do not support using the Inhibit portal. I have implemented Inhibit portal support upstream, but it is awaiting review; and since it missed the 4.5 feature freeze it will not be part of a Godot release until 4.6, which is probably close to a year away. godotengine/godot#108704
This is necessary because Godot does not know how to use the Inhibit portal to inhibit the screensaver. godotengine/godot#108634 I have implemented this in a PR that I hope to land for Godot 4.6 godotengine/godot#108704 In the meantime, allow the editor to talk to org.freedesktop.ScreenSaver. This will require approval from Flathub reviewers but I am confident this exception will be accepted because: a. it was accepted for a game I co-maintain; b. there is a solution in progress; c. the editor has host filesystem access and the ability to spawn commands on the host, so this new flag does not meaningfully reduce the sandboxing.
9c31577 to
64b503b
Compare
|
I have rebased this branch (and its parent) and resolved conflicts due to commit 0edb6bd. |
Calinou
left a comment
There was a problem hiding this comment.
Tested locally, it works as expected (outside a Flatpak). Code looks good to me.
Operating System: Fedora Linux 42
KDE Plasma Version: 6.4.4
KDE Frameworks Version: 6.17.0
Qt Version: 6.9.1
Kernel Version: 6.16.7-200.fc42.x86_64 (64-bit)
Graphics Platform: X11
Processors: 32 × AMD Ryzen 9 9950X3D 16-Core Processor
Memory: 64 GiB of RAM (62.3 GiB usable)
Graphics Processor: NVIDIA GeForce RTX 5090
Manufacturer: Micro-Star International Co., Ltd.
Product Name: MS-7E49
System Version: 1.0
|
Thanks for testing! Since you were testing outside a Flatpak, you have tested that the code prefers to use the existing API in that case: // If not sandboxed, prefer to use org.freedesktop.Screenshot
supported = OS::get_singleton()->is_sandboxed() && _is_interface_supported(BUS_INTERFACE_INHIBIT, 1); |
|
I have just re-read https://contributing.godotengine.org/en/latest/organization/pull_requests/review_guidelines.html#git-checklist and noticed this section:
This PR is 5 commits. I have taken care that each commit is logically independent, can be built individually, and makes a distinct change, but if preferred I can squash this down into fewer commits. |
Since godotengine/godot#108704, the sentence about Flatpak is fully obsolete: 1. All standard Flatpak runtimes contain libdbus; 2. With the addition of support for the XDG Inhibit portal, Godot is able to inhibit idle without any sandboxing adjustments. More generally, I don't think we need to mention that D-Bus is required to inhibit idle, even outside Flatpak: practically speaking, all desktop Linux systems have had libdbus available for 20+ years. Remove the whole paragraph.
|
Squashing the commits isn't necessary until this is ready to merge, but it should be a single commit for merger, we only merge multiple commits in very specific cases when the changes can be completely separated from each other or for practical reasons like ignoring for git blame |
|
OK! I look forward to making whatever changes are needed to make this ready to merge :) |
ff4ed08 to
e080eb9
Compare
e080eb9 to
3994c4a
Compare
|
Thanks! I infer that the convention is |
|
That standard is here |
3994c4a to
704e196
Compare
|
Thanks for your help! I have collapsed this down into one commit, folding the important parts of the other commit messages into it. |
704e196 to
de4fb0b
Compare
Previously, on Linux and BSD, inhibiting the screensaver was handled using the org.freedesktop.ScreenSaver D-Bus API. Unfortunately, this API is not available in a Flatpak sandbox. (This is because there is a desire to tie inhibit sessions to a specific app and visible window; but the org.freedesktop.ScreenSaver API does not support this.) As a result, when using the Flatpak build of the Godot Editor (or a Flatpak-ed build of a game) and using a controller to play a game, the session will become idle after a few minutes. The XDG desktop portal -- which is already used for color-picking, file choosing, and querying the system theme -- has an Inhibit interface that provides a superset of the functionality of the org.freedesktop.ScreenSaver API, and is available to any sandboxed app. Refactor code for making XDG portal requests that was previously duplicated for the FileChooser and ColorPicker portal code. Check the portal version to determine whether these portals can be used: - FileChooser portal version 3 is required due to the use of the "directory" parameter. - On the Settings portal, the only addition in version 2 is the ReadOne() method which is not used here, so version 1 suffices. - On the Screenshot portal, the only addition in version 2 is the "interactive" parameter to the Screenshot() method; this code only uses the PickColor() method, so version 1 suffices. Then, add support for the Inhibit portal. Use it if available and if running in a sandbox. Prefer to use org.freedesktop.ScreenSaver if not running in a sandbox, even if the portal is available, because (at least in the GNOME 43 implementation of the portal) it does not work correctly if the portal cannot map the request to a running app. This adds a small amount of complexity to the implementation, but supporting both APIs is necessary anyway (there are many systems in the wild that support org.freedesktop.ScreenSaver but not the desktop portal). Fixes godotengine#108634
de4fb0b to
1a3a254
Compare
|
Rebased & fixed conflicts introduced by #112629 last week. Is there anything else I can do here to help get this into a dev snapshot of 4.6? It'd be nice to be able to update the |
|
Hi, it got approved, so I think it's just a matter of time. |
|
Thanks! |
Because 4.6~dev5 is considered newer than 4.6~beta1 by AppStream (d > b), the ~~ syntax is needed to avoid errors when we later update to ~beta. (And in turn the -betas must use ~ so that 4.6~beta1 sorts before 4.6.) --talk-name=org.freedesktop.ScreenSaver is no longer needed: godotengine/godot#108704.
Godot 4.6 supports using the Inhibit portal <godotengine/godot#108704> so this is no longer necessary.
Godot 4.6 supports using the Inhibit portal <godotengine/godot#108704> so this is no longer necessary.
Previously, on Linux and BSD, inhibiting the screensaver was handled
using the org.freedesktop.ScreenSaver D-Bus API. Unfortunately, this API
is not available in a Flatpak sandbox. (This is because there is a
desire to tie inhibit sessions to a specific app and visible window; but
the org.freedesktop.ScreenSaver API does not support this.)
As a result, when using the Flatpak build of the Godot Editor (or a
Flatpak-ed build of a game) and using a controller to play a game, the
session will become idle after a few minutes.
The XDG desktop portal -- which is already used for color-picking, file
choosing, and querying the system theme -- has an Inhibit interface that
provides a superset of the functionality of the
org.freedesktop.ScreenSaver API, and is available to any sandboxed app.
Add support for this API to the FreeDesktopPortalDesktop class. Use it
if available and if running in a sandbox. Prefer to use
org.freedesktop.ScreenSaver if not running in a sandbox, even if the
portal is available, because (at least in the GNOME 43 implementation of
the portal) it does not work correctly if the portal cannot map the
request to a running app. This adds a small amount of complexity to the
implementation, but supporting both APIs is necessary anyway (there are
many systems in the wild that support org.freedesktop.ScreenSaver but
not the desktop portal).
Fixes #108634