Repository navigation
Conversation
There was a problem hiding this comment.
Pull request overview
Adds compositor-level input detection so touch and pointer activity can dismiss the screensaver.
Changes:
- Adds a dedicated dismissal
IdleMonitor. - Introduces a pure dismissal state helper.
- Adds unit assertions for state transitions.
Tip
If you aren't ready for review, convert to a draft PR.
Click "Convert to draft" or run gh pr ready --undo.
Click "Ready for review" or run gh pr ready to reengage.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
shell/plugins/services/idle/Service.qml |
Detects input and signals screensaver teardown. |
shell/plugins/services/idle/IdleModel.js |
Models dismissal state transitions. |
test/shell.d/idle-test.sh |
Tests dismissal state behavior. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| readonly property int lockDelaySeconds: Math.max(0, lockTimeoutSeconds - firstIdleTimeoutSeconds) | ||
| readonly property bool idleEnabled: stayAwakeStateLoaded && !stayAwake | ||
| readonly property string screensaverClass: "org.omarchy.screensaver" | ||
| readonly property bool screensaverVisible: screensaverWindowCount > 0 |
| function handleDismissMonitorChanged() { | ||
| var next = IdleModel.dismissStateAfter(dismissMonitor.settled, dismissMonitor.isIdle, root.screensaverVisible) | ||
| dismissMonitor.settled = next.settled | ||
| if (next.dismiss) dismissScreensaver("input-while-screensaver-visible") |
…cluded The screensaver's loop only exits on a byte from stdin or a change of focused window class, so only a keypress dismisses it. Touch, pointer motion and clicks produce neither: a click on the fullscreen screensaver does not change focus, and the mouse-tracking escapes that used to catch motion were removed in d2ea6ad. The main idle monitor cannot cover this. Launching the screensaver focuses the new window, which registers as activity, so isIdle goes false about 300ms after the screensaver appears and never changes again while it is displayed. Arm a second idle monitor for as long as a screensaver is on screen, however it was started. It settles once the launch activity passes, and the next seat input dismisses. ext-idle-notify is compositor-side, so one path covers keyboard, touch, touchpad, clicks and bluetooth mice. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
0521dfb to
f42c32e
Compare
|
Updated based on Copilot's feedback.
The foot crash is a use-after-free in foot 1.27.0 ( |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated no new comments.
Suppressed comments (2)
shell/plugins/services/idle/Service.qml:88
- This path knowingly makes held-touch dismissal crash the supported Foot terminal (the PR reports 3/3 held-touch trials segfaulting and producing a core dump). Sending SIGTERM immediately tears down the window while
wl_touch.upcan still target it, so the primary tablet use case introduces a reliable process crash. Please gate this dismissal path for Foot until the native client is available, or use an input-aware teardown that waits for touch release rather than closing the terminal immediately.
runProcess(dismissProcess, "dismiss", "pkill -f 'bash .*bin/omarchy-screensaver$'")
shell/plugins/services/idle/Service.qml:286
- The one-second quiet period can expire while a multi-monitor launch is still in progress.
bin/omarchy-launch-screensaver:45-70opens outputs sequentially and may wait up to five seconds for each window; mapping/focusing a later screensaver produces the same activity this handler treats as input. If a terminal takes over one second to map, that launch activity arrives aftersettledbecame true and dismisses every screensaver without user input. Keep dismissal unarmed until the full launch has completed, or reset the settling phase for each newly opened screensaver window before accepting activity.
enabled: root.screensaverVisible
timeout: 1
respectInhibitors: false
onEnabledChanged: settled = false
onIsIdleChanged: root.handleDismissMonitorChanged()
|
The foot crash noted above is now root-caused and fixed upstream: https://codeberg.org/dnkl/foot/pulls/2436
|
|
FYI: Seems like foot will get the necessary changed merged: |
|
Upstream fix in foot is merged: https://codeberg.org/dnkl/foot/pulls/2436#issuecomment-21947408 |
|
Reviewed at f42c32e, merged onto current The fix works. On Two latent gaps, found by Codex at medium effort as the second opinion (Copilot also flagged the first). I confirmed the first on the VM. The second follows from how the settle logic reads, and I didn't test it. I haven't pushed a fix for either, because closing them properly is a design choice rather than a contained correction:
Competing fixes. #12975 makes the same code change as this one, with more comments and tests, and was opened later. #12465 brings back the terminal mouse-tracking approach reverted in d2ea6ad, which doesn't cover touch. #11746 takes the same IdleMonitor approach, plus launch-complete tracking and a concealed lock handoff, which is much wider than this bug. Codex also judged this one the proportionate fix of the four. Its agreement isn't guaranteed to be independent of my review. Waiting on the maintainer: whether to take this now and handle the launch-time arming with #12258, or to have it here first. |
|
Thanks for working on this. #16800, now merged, replaced the terminal screensaver with a native Wayland overlay that dismisses itself on any key, click, scroll or mouse movement, so this fix to the terminal version is no longer needed. Closing in favour of it. |
Dismiss the screensaver on touch and pointer input, bluetooth mice included
bin/omarchy-screensavercan only be dismissed by a keypress. Touch, pointer motion and mouse clicks are all ignored. On a convertible in tablet mode there is no way to dismiss it at all — and touch is delivered into the screensaver terminal, so you can tap, scroll and select text in it while it is displayed.The dismiss loop has exactly two exits (
bin/omarchy-screensaver:43-47):read -n1 -t 1needs a byte on stdin — a keypress.! screensaver_in_focusneeds the focused window class to change. A click on a fullscreen screensaver that already has focus produces neither, and pointer motion produces neither since the mouse-tracking escapes were removed in d2ea6ad.The fix
Arm a second
IdleMonitorfor as long as a screensaver is on screen. It settles once the launch activity passes, and the next seat input dismisses.ext-idle-notifyis compositor-side and device-agnostic, so one path covers keyboard, touch, touchpad, clicks and bluetooth mice — the terminal and per-device escape sequences are not involved at all. The state machine lives inIdleModel.jsas a pure function alongside the existing helpers, sotest/shell.d/idle-test.shcovers it.No change to
bin/omarchy-screensaver: itstrapalready tears down in the right order, and the existingclosewindow→handleScreensaverWindowClosed()path already cancels the pending lock and runs wake.On the d2ea6ad revert
The revert reason was "Could not get it to stop existing with a Logitech MX4 when connected via bluetooth." That failure was specific to the approach: #3723 made the terminal watch for mouse reports (
\e[?1000h\e[?1003h), which is client-side and device-dependent. This never involves the terminal, and is verified here with a Logitech MX Master 3S over bluetooth.Caveats
footwhen the finger is still down as the window tears down — a use-after-free in foot, not in this change, though this change makes it reachable. Root-caused and fixed upstream: dnkl/foot#2436. Details below.pkillindismissScreensaver()overlaps with Stop screensavers through their supervisors #6813, which reworks screensaver teardown into per-supervisor ownership. The detection half (the second monitor) is what is missing today and composes with whatever lands there.Why this cannot be fixed in
handleActiveSignal(), or by polling the pointerThe main
IdleMonitoris alreadyactivefor the whole time the screensaver is displayed and never signals again. Launching the screensaver focuses the new window, which the compositor reports as activity. Every cycle, from the shell's own log:That blip is what the
screensaverLaunchGraceTimerguard already absorbs. The control case confirms the cause: when the session is already locked,omarchy-launch-screensaveris skipped by theisLockedguard and noidle-monitor: activefollows.So
isIdleisfalsebefore the user touches anything and staysfalse; a new branch there would be unreachable.Polling the pointer does not work either. Touch never moves it: across 1248 touchscreen events over 5.5s,
hyprctl cursorposdid not change once, while a touchpad drag tracked it sample-for-sample.cursor:hide_on_touchdefaults to true and Hyprland routes touch throughwl_touch, separate from the pointer.Testing
./test/shell— 4 new assertions intest/shell.d/idle-test.sh; 181/184 files pass. The 3 failures (config,snapper,unowned-system-paths) reproduce identically on a clean checkout here and are environment-specific.Verified in the running UI per
agents/skills/visual-verification.md, running the checkout viaomarchy dev link. Raw evdev correlated against the shell's own journal:270ms from finger to dismissal:
Also covered:
system.screensaver→omarchy-launch-screensaver force), i.e. outside any idle cycle — dismissal works, which is whyscreensaverVisiblekeys offscreensaverWindowCountrather than the idle-cycle flags.hyprctl output create headless,omarchy-launch-screensaverstarts one instance per output and dismissal tears down both.Environment: Acer Spin SP313-51N (Wacom HID 49AF Finger touchscreen), Hyprland 0.56.2, foot 1.27.0.
Known limitation, inherited rather than introduced: the service learns about screensaver windows from
openwindowevents, so a screensaver already on screen when the shell restarts is not tracked and will not arm the dismiss monitor.The foot use-after-free, in detail
Symbolized, and identical across three independent crashes:
wayl_win_destroy()does awl_display_roundtrip(), which dispatches still-queued Wayland events — and a pendingwl_touch.upthen runswl_touch_up()against the window being freed.In one run the two crashes land 1.4s and 0.9s after the two held-touch dismissals and nowhere else, while a tap held 0.05s dismissed cleanly in the same run.
Dismissal is issued about 270ms after finger-down, so a normal tap is already clear of the window and only a held touch hits it. It is a race rather than a certainty — it depends on whether a
wl_touch.uphappens to be queued when the roundtrip runs — but a held touch loses it reliably in practice.wl_touchhas noleaveevent, so the unmap inwayl_win_destroy()cannot drop touch focus the way it drops keyboard and pointer focus —seat->touch.surfacekeeps pointing at the window being destroyed. Fixed upstream in dnkl/foot#2436 (17 lines, tested: 3/3 crashes before, 0/7 after).Not worked around here, because a timing delay would only narrow the race rather than close it. Note also that #7193 replaces the foot-based screensaver with a native Wayland client, which would remove this exposure entirely.
Teardown ordering, and why the pkill pattern looks like that
dismissScreensaver()signals the screensaver script, not its terminal, so the script'straprunsexit_screensaverand stopsttfxbefore the terminal closes. Closing the terminal first takesttfx's pty with it andttfxaborts — the same failure as #6762 / #6764.The terminal's own command line also ends in
omarchy-screensaver(foot … -e omarchy-screensaver), so the pattern requires thebashprefix to avoid matching both and killing them simultaneously.#7193 is unaffected by this change: it execs an externally packaged binary and does not alter dismissal logic in this repo. A fix at the idle-service level is implementation-independent, though the stop command would need to cover the native client too.
Diagnosis and patch developed with AI assistance (Claude), verified on hardware.
Fixes #12650
Fixes #7762