Skip to content

Dismiss the screensaver on touch and pointer input, bluetooth mice included - #7528

Closed
mklasen wants to merge 1 commit into
omacom:quattrofrom
mklasen:touch-dismiss-screensaver
Closed

mklasen wants to merge 1 commit into
omacom:quattrofrom
mklasen:touch-dismiss-screensaver

Conversation

@mklasen

@mklasen mklasen commented Aug 19, 2026 •

Copy link
Copy Markdown

Dismiss the screensaver on touch and pointer input, bluetooth mice included

bin/omarchy-screensaver can 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):

if read -n1 -t 1 || ! screensaver_in_focus; then

read -n1 -t 1 needs a byte on stdin — a keypress. ! screensaver_in_focus needs 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 IdleMonitor for as long as a screensaver is on screen. It settles once the launch activity passes, and the next seat input dismisses.

ext-idle-notify is 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 in IdleModel.js as a pure function alongside the existing helpers, so test/shell.d/idle-test.sh covers it.

No change to bin/omarchy-screensaver: its trap already tears down in the right order, and the existing closewindow → 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

  • Dismissing by touch can segfault foot when 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.
  • The pkill in dismissScreensaver() 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.
  • Tested with foot only; alacritty/ghostty/kitty untested.
Why this cannot be fixed in handleActiveSignal(), or by polling the pointer

The main IdleMonitor is already active for 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:

21:12:39.087  idle-monitor: idle
21:12:39.087  process-start: screensaver
21:12:39.424  idle-monitor: active                          <- +337ms, self-inflicted
21:12:39.424  idle-monitor-active: screensaver cycle remains armed
      ... no further idle-monitor events for the whole display ...
21:15:09.093  lock-system: lock-timeout

That blip is what the screensaverLaunchGraceTimer guard already absorbs. The control case confirms the cause: when the session is already locked, omarchy-launch-screensaver is skipped by the isLocked guard and no idle-monitor: active follows.

So isIdle is false before the user touches anything and stays false; 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 cursorpos did not change once, while a touchpad drag tracked it sample-for-sample. cursor:hide_on_touch defaults to true and Hyprland routes touch through wl_touch, separate from the pointer.

Testing

./test/shell — 4 new assertions in test/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 via omarchy dev link. Raw evdev correlated against the shell's own journal:

input dismissed notes
keyboard yes unchanged path
touchscreen, quick tap yes finger held 0.05s
touchpad yes
bluetooth mouse (Logitech MX Master 3S) yes the device class that caused d2ea6ad
touchscreen, held ~3s yes dismisses, but trips the foot bug

270ms from finger to dismissal:

114.82  SHELL        idle-monitor: active          (launch blip)
117.67  TOUCHSCREEN  BTN_TOUCH DOWN
117.83  TOUCHSCREEN  BTN_TOUCH UP
117.94  SHELL        screensaver-dismiss: input-while-screensaver-visible
117.94  SHELL        idle-cycle-cancel: screensaver-dismissed
118.32  SHELL        process-exit: wake exitCode=0

Also covered:

  • Screensaver launched from the menu (system.screensaver → omarchy-launch-screensaver force), i.e. outside any idle cycle — dismissal works, which is why screensaverVisible keys off screensaverWindowCount rather than the idle-cycle flags.
  • Multi-monitor — with a second output added via hyprctl output create headless, omarchy-launch-screensaver starts 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 openwindow events, 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:

#0   wl_touch_up (serial=1193, time=921788) at ../input.c:3587
#10  wl_display_roundtrip_queue (wayland-client.c:1479)
#12  wayl_roundtrip   (../wayland.c:2416)
#13  wayl_win_destroy (../wayland.c:2297)

wayl_win_destroy() does a wl_display_roundtrip(), which dispatches still-queued Wayland events — and a pending wl_touch.up then runs wl_touch_up() against the window being freed.

touch trials crashes
quick tap (lifted before teardown) 4 0
held through teardown 3 3

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.up happens to be queued when the roundtrip runs — but a held touch loses it reliably in practice.

wl_touch has no leave event, so the unmap in wayl_win_destroy() cannot drop touch focus the way it drops keyboard and pointer focus — seat->touch.surface keeps 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's trap runs exit_screensaver and stops ttfx before the terminal closes. Closing the terminal first takes ttfx's pty with it and ttfx aborts — 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 the bash prefix 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

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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>
Copilot AI review requested due to automatic review settings August 19, 2026 19:17
@mklasen
mklasen force-pushed the touch-dismiss-screensaver branch from 0521dfb to f42c32e Compare August 19, 2026 19:17
@mklasen

mklasen commented Aug 19, 2026

Copy link
Copy Markdown
Author

Updated based on Copilot's feedback.

startIdleCycle() no longer clears the tracked-window map — that was disarming dismissal for a screensaver launched from the menu and still on screen when the idle timeout arrived, since Hyprland sends no second openwindow for a window that is already open. Reproduced and re-verified.

The foot crash is a use-after-free in foot 1.27.0 (wl_touch_up at input.c:3587, reached from wayl_win_destroy → wl_display_roundtrip), not introduced here — any path that destroys the window mid-touch hits it. Filing it with foot upstream and will link it here.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.up can 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-70 opens 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 after settled became 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()

@mklasen

mklasen commented Aug 19, 2026

Copy link
Copy Markdown
Author

The foot crash noted above is now root-caused and fixed upstream: https://codeberg.org/dnkl/foot/pulls/2436

wl_touch has no leave event, so the unmap in wayl_win_destroy() cannot drop touch focus the way it drops keyboard and pointer focus — seat->touch.surface keeps pointing at the window being destroyed, and the queued wl_touch.up dereferences it. 17 lines; 3/3 crashes before the patch, 0/7 after.

@mklasen

mklasen commented Aug 25, 2026

Copy link
Copy Markdown
Author

FYI: Seems like foot will get the necessary changed merged:
https://codeberg.org/dnkl/foot/pulls/2436

@mklasen

mklasen commented Aug 29, 2026

Copy link
Copy Markdown
Author

Upstream fix in foot is merged:

https://codeberg.org/dnkl/foot/pulls/2436#issuecomment-21947408

@omarchybot omarchybot added bug Something isn't working verified Omarchy Triage has verified that this issue is ready for final review labels Sep 27, 2026
@omarchybot

Copy link
Copy Markdown
Collaborator

Reviewed at f42c32e, merged onto current quattro (de63134; it merges cleanly), on a disposable Omarchy VM (Hyprland 0.56.2, quickshell 0.3.1, foot 1.28.0), with input injected through a virtual uinput mouse and touchscreen.

The fix works. On quattro, pointer motion, a click and a touchscreen tap all leave the screensaver up. With this change each one dismisses it, across one, two and three outputs, and with no input it stays up. With the commit reverted, all three fail again. A touch held for three seconds through the dismissal tore down cleanly three times with no core dump, so the foot use-after-free doesn't reproduce on foot 1.28.0. test/shell.d/idle-test.sh, screensaver-workspace-test.sh and plugin-auth-boundary-test.sh pass. ./test/cli stops at the vscode theme-link test, but it does the same on quattro without this change, so that failure isn't from this pull request. I linked #12650, which this fixes.

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:

  • Service.qml:282 arms the dismiss monitor as soon as the first screensaver window exists. After one quiet second, moving focus to another monitor or mapping a new window counts as input and dismisses every screensaver. On the VM, both did it. omarchy-launch-screensaver does both between monitors, so a terminal that takes more than a second to map on a later monitor would dismiss the screensaver with nobody touching anything. Today that case never gets this far: while focus is on the monitor still waiting for its window, the first screensaver's own focus-loss check closes them all, and it does that on quattro too. Keep the screensaver up until it has been focused once #12258 would remove that check's early exit, and then this race would fire. Arming only once every screen has its screensaver closes the race but leaves pointer dismissal off when a terminal never starts or a monitor is plugged in mid-screensaver, so it needs a bounded launch-complete signal.
  • IdleModel.js:49 only accepts input after the monitor has been idle for a full second. A tap in the first second is swallowed, and pointer motion that starts at once and never pauses never dismisses. The keyboard is unaffected.

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.

@omarchybot

Copy link
Copy Markdown
Collaborator

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working verified Omarchy Triage has verified that this issue is ready for final review

Projects

None yet

3 participants