Repository navigation
Dismiss screensaver on pointer motion - #8048
Open
kazeshini178 wants to merge 3 commits into
Open
kazeshini178 wants to merge 3 commits into
kazeshini178 wants to merge 3 commits into
Conversation
Contributor
There was a problem hiding this comment.
Copilot wasn't able to review any files in this pull request.
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
The screensaver detects input with `read -n1` on stdin, which carries the keyboard alone. ttfx never enables terminal mouse reporting, so trackpad and mouse motion have no path into the process, and the other exit condition (losing focus) cannot fire because the window is fullscreen on every monitor. Enable any-event mouse tracking so the terminal delivers motion on stdin and the existing read loop exits on pointer input too. This re-arms the mechanism ddf0d1e shipped in v3.2.3, which d2ea6ad then reverted for v3.3.0 because it did not work with Bluetooth mice ("Could not get it to stop existing with a Logitech MX4 when connected via bluetooth"). That cause does not reproduce here. On a Logitech M720 Triathlon connected over Bluetooth (BlueZ uhid transport, bus 0005, no Unifying receiver present), motion delivered 3559 bytes of SGR reports, a click 177 and the scroll wheel 876, against an internal-trackpad control of 3876 and 4488 bytes in the same session. Arm it a second late. omarchy-launch-screensaver focuses each monitor in turn, which warps the pointer when there is more than one, and a warp that lands after arming reads as user input and dismisses the screensaver on sight. Sampling the pointer every 100ms across three runs on a two-monitor session, the launcher's last warp arrives 100-400ms after launch; one second leaves a margin. Arming runs in the background so the read loop starts immediately, keeping the keyboard responsive from the first frame rather than ignoring it for a second. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
kazeshini178
force-pushed
the
screensaver-dismiss-on-pointer-motion
branch
from
September 2, 2026 09:53
a71143e to
5bc0ac9
Compare
This was referenced Oct 2, 2026
Replace the fixed 1s delay with a bounded wait for a mapped screensaver on every monitor, then a 0.5s settle for the launcher's focus-restore warp. Capped at 5s per monitor, matching the launcher's own deadline. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
|
Cover waiting for every monitor, the 5s-per-monitor cap, teardown disarming, and keyboard dismissal before arming. The last exposed an orphaned arming job that kept polling Hyprland after exit; kill it in exit_screensaver. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Addresses part of #7762.
Problem
Only a keypress dismisses the screensaver. Mouse and trackpad input do nothing.
omarchy-screensaverdetects input withread -n1on stdin, which carries the keyboard alone —ttfxnever enables terminal mouse reporting, so pointer motion has no path into the process. The other exit condition cannot fire either:screensaver_in_focusonly goes false when the focused window's class changes, and the window is fullscreen on every monitor.This was shipped once and reverted — and the stated cause no longer reproduces
Being upfront about the precedent, because it applies to every proposed fix in #7762:
ddf0d1e8(Exit screensaver when mouse moves or clicks #3723) armed terminal mouse reporting and shipped in v3.2.3d2ea6ad1reverted it for v3.3.0: "Canceling the screensaver on mouse movement doesn't work with bluetooth mice. Could not get it to stop existing with a Logitech MX4 when connected via bluetooth."I tested that specific failure. On a Logitech M720 Triathlon over Bluetooth — BlueZ
uhidtransport, bus0005(BUS_BLUETOOTH),lsusbshowing no Unifying receiver, and Hyprland listing it as a second pointer alongside the internal trackpad — with reporting armed:A Bluetooth mouse reaches the terminal at essentially the same rate as the built-in trackpad. Different mouse model and nine months of libinput/Wayland/foot changes since
d2ea6ad1, so this does not prove the original report was wrong — but the reason it was reverted does not hold on current Omarchy, and that precedent is otherwise hanging over this whole area unexamined.Fix
Enable any-event mouse tracking (
?1003h) with SGR coordinates (?1006h) so the terminal delivers pointer motion on stdin, where the existing read loop already dismisses. Disabled again on teardown.Two details worth calling out:
Arming waits for launch to finish.
omarchy-launch-screensaverfocuses each monitor in turn, which warps the pointer on multi-monitor setups. A warp landing after reporting is armed reads as user input and dismisses the screensaver the instant it appears. Sampling the pointer every 100ms across three runs on a two-monitor session:The first version armed after a fixed one second, which covered these 100–400ms warps. But
wait_for_screensaver_windowallows up to 5s per monitor, so a slow terminal on a later monitor could map after arming. Reviewers on #7528 and #7780 flagged the same race there. Arming now waits until every monitor has a mappedorg.omarchy.screensaverwindow, then waits 0.5s for the launcher's last warp: the focus restore that runs straight after the final window maps. The wait is capped at 5s per monitor, matching the launcher's own deadline, so a terminal that never maps can't leave the mouse dead. The failure mode is still mild if it is ever wrong: the screensaver closes immediately and idle re-triggers. The warp measurements above were taken with the fixed delay. The launch-complete wait has been checked by script syntax and against samplehyprctloutput, but not yet in a live multi-monitor session.Arming runs in the background. In the foreground it blocks before the read loop, leaving the keyboard dead until it arms — worse than current behaviour.
It also fixes the lock-during-activity defect
Worth separating, because #7762 contains two problems and this addresses both.
The genuine regression identified in that thread is that
handleActiveSignal()is edge-triggered offIdleMonitor.onIsIdleChanged: while the user keeps moving, the monitor never re-idles, no further edge arrives,lockTimeris never stopped, and the session locks on the original deadline however active the user has been.This patch fixes that through the sanctioned path — pointer input closes the window, so
closewindow→handleScreensaverWindowClosed→cancelIdleCycle→lockTimer.stop(). Note the guard-narrowing suggested in the issue does not fix it.Verification
Two-monitor Hyprland session with one display at negative X, so focusing it warps the pointer ~1400px. Both windows survived 2.8s past arming untouched, then a single trackpad nudge closed both within 200ms.
Input coverage, measured by logging bytes arriving with reporting armed:
The two gaps are inherent to the terminal layer: Wayland three-finger gestures use the pointer-gestures protocol, which foot does not implement, and media keys never arrive as stdin bytes. Neither is a regression — today nothing but a keypress dismisses at all.
All four supported terminals
Dismissal depends on the terminal translating pointer input into SGR reports on the pty, which is per-terminal behaviour, so I measured each one using the flags
omarchy-launch-screensaverpasses it. Bytes delivered with reporting armed, internal trackpad and the Bluetooth M720:Every terminal reports both devices (ghostty run twice, consistent). So the mechanism is not foot-specific, and the Bluetooth result is not terminal-specific either.
test/shell.d/screensaver-mouse-arming-test.shruns the real script against stubbedhyprctl,ttfxandpkill, with the keyboard on a FIFO. It checks four things:The last case found an orphaned arming job that kept polling Hyprland after exit, now fixed. The test fails against the original fixed-delay version and against the script without the fix. It passes 3/3 repeat runs, and
./test/clipasses../test/all(before these follow-ups): 186/190. The four failures are pre-existing in my environment and unrelated to a shell script inbin/—config-test.shandunowned-system-paths-test.shneed anomarchy-pkgscheckout,snapper-test.shhits a permission error, andruntime-smoke-test.shfails its per-screen IPC assertion (saw 3 for 2 screen(s)) whenever two displays are attached, on a clean tree as well.Limitations, stated plainly
wl_touchresult in [Quattro] Screensaver only exits on a keypress inside its own terminal — global mouse/keyboard activity is explicitly ignored while it's up #7762 stands for foot alone, and touch-to-mouse-report translation on ghostty, alacritty and kitty is unverified. If touch is the case you care most about, that is a real gap in this PR and the compositor route sidesteps it.quattroand am happy to rebase if Stop screensavers through their supervisors #6813 lands first.ext-idle-notify(Dismiss the screensaver on any input, not just a keypress #7780, the same approach, was closed as a duplicate of it), which is seat-scoped and cannot have a per-device failure mode at all. That is a real argument in its favour and measurements do not erase it. Which route Omarchy takes is your call — I would rather say so than let this look like the obvious choice. If you go compositor-side, the Bluetooth and four-terminal data above is the part of this worth keeping, sinced2ea6ad1is the precedent that route also has to answer.Tested on Omarchy 4.0.0-1, ttfx 0.3.1, Hyprland with 1 and 2 monitors, internal trackpad and a Bluetooth Logitech M720, across foot 1.27.0, ghostty 1.3.1, alacritty 0.17.0 and kitty 0.48.2.