Skip to content

gfx: an output window keeps the displays awake - #2423

Open
jcelerier wants to merge 1 commit into
masterfrom
split/idle-inhibitor
Open

jcelerier wants to merge 1 commit into
masterfrom
split/idle-inhibitor

Conversation

@jcelerier

Copy link
Copy Markdown
Member

Displays driven by score could go to sleep, or be dimmed, when the machine saw no input. A top-level output window now holds an idle inhibition while it is exposed. It drops the inhibition when the window is hidden, minimized or closed, so a preview or a hidden output does not keep the display awake.

  • Linux: org.freedesktop.ScreenSaver.Inhibit when built with Qt DBus. KDE also dims projectors over DDC/CI. The call is asynchronous. A release that arrives before the cookie undoes the inhibition once the cookie comes. A failed call is tried again the next time an output window shows.
  • macOS: a PreventUserIdleDisplaySleep assertion.
  • Windows: SetThreadExecutionState, which also keeps the system from idle sleep.

The windows share one OS inhibition, taken by the first holder and dropped by the last, on the GUI thread (asserted). A minimized or embedded window holds nothing. The freedesktop protocol, whose reply comes late, is its own small state machine (ScreenSaverInhibition), so it can be tested without D-Bus.

Nothing reaches the OS on the offscreen and minimal platforms, or when SCORE_NO_IDLE_INHIBIT is set. The test environment (cmake/ScoreTests.cmake) sets it, so test runs never inhibit the developer's session.

Commits

  • b8b6cacee1 gfx: an output window keeps the displays awake

Tests

  • New test_gfx_idle_inhibitor (tests/gfx/GfxIdleInhibitor.cpp) covers: the inhibition is sent once and undone once; a release before the Inhibit reply undoes it when the reply comes; wanted again before the reply, it is kept; a failed Inhibit is sent again on the next want; inhibitors count each holder once; a shown output window holds the display awake and a hidden one does not.
  • The whole series was built and tested with ctest on Linux (Xvfb, lavapipe Vulkan and Mesa OpenGL). Nothing failed beyond master's own known failures (test_gfx_shader_corpus_targets, test_gfx_window_layout, test_threedim_ply_fingerprint, test_unit_miniaudio_alsa and the few others master's run lists).

Notes for review

  • On Windows the inhibition also prevents system idle sleep, not only display sleep. That is intended for a show machine, but it is broader than on the other platforms.
  • The macOS and Windows paths are not covered by the tests, which exercise the shared counting and the freedesktop state machine.

🤖 Generated with Claude Code

https://claude.ai/code/session_01KdPgujQFUTMVZBdH6Hv7Vj

A per-window handle, taken when a top-level output window is exposed and
dropped when it is hidden, minimized or closed, so a preview or a hidden
output does not keep the display awake:
- org.freedesktop.ScreenSaver.Inhibit when built with Qt DBus (KDE also dims
  projectors over DDC/CI). The call is asynchronous, and a release arriving
  before the cookie undoes the inhibition once it comes;
- a PreventUserIdleDisplaySleep assertion on macOS;
- SetThreadExecutionState on Windows, which also keeps the system from
  idle sleep.

The windows share one OS inhibition, taken by the first holder and dropped
by the last, on the GUI thread (asserted). A minimized or embedded window
holds nothing. The freedesktop Inhibit reply comes late, so its protocol
is a small state machine of its own (ScreenSaverInhibition); a failed call
is tried again the next time an output window shows. Nothing reaches the OS
on the offscreen and minimal platforms, nor with SCORE_NO_IDLE_INHIBIT set,
which the test environment sets so that test runs never inhibit the
developer's session.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KdPgujQFUTMVZBdH6Hv7Vj

This branch is waiting to be deployed

1 waiting deployment
full-ci — b8b6cace Waiting Nov 25, 2026 by jcelerier via Approve full PR suite #12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant