Skip to content

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

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

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

Conversation

@mklasen

@mklasen mklasen commented Aug 18, 2026 •

Copy link
Copy Markdown
Owner

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: omacom#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 1.27.0, not in this change, though this change makes it reachable. Details below.
  • The pkill in dismissScreensaver() overlaps with Stop screensavers through their supervisors omacom/omarchy#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.

Not worked around here, because a timing delay would only narrow the race rather than close it. Note also that omacom#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 omacom#6762 / omacom#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.

omacom#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.

@mklasen
mklasen force-pushed the touch-dismiss-screensaver branch 2 times, most recently from a06e54d to 28e2fb1 Compare August 19, 2026 18:26
@mklasen mklasen closed this Aug 19, 2026
@mklasen mklasen reopened this Aug 19, 2026
@mklasen mklasen changed the title Dismiss the screensaver on touch and pointer input Dismiss the screensaver on touch and (bluetooth) pointer input Aug 19, 2026
@mklasen
mklasen force-pushed the touch-dismiss-screensaver branch from 28e2fb1 to c6d91ab Compare August 19, 2026 18:36
…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>
@mklasen
mklasen force-pushed the touch-dismiss-screensaver branch from c6d91ab to 0521dfb Compare August 19, 2026 18:36
@mklasen mklasen changed the title Dismiss the screensaver on touch and (bluetooth) pointer input Dismiss the screensaver on touch and pointer input, bluetooth mice included Aug 19, 2026
@mklasen

mklasen commented Aug 19, 2026

Copy link
Copy Markdown
Owner Author

Superseded by omacom#7528 — same branch, opened upstream.

@mklasen mklasen closed this Aug 19, 2026
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