Skip to content

Close screensaver on mouse move/click. - #16549

Closed
erykwieliczko wants to merge 1 commit into
omacom:quattrofrom
erykwieliczko:feat/screensaver-mouse-exit
Closed

erykwieliczko wants to merge 1 commit into
omacom:quattrofrom
erykwieliczko:feat/screensaver-mouse-exit

Conversation

@erykwieliczko

Copy link
Copy Markdown
Dismiss on mouse movement, clicks and scrolling using compositor input notifications. Once armed, modifier/media keys and other seat input also dismiss.

Arm 500ms after the launcher finishes, with a 1ms inactivity threshold that catches continuous input. Keep manual screensavers tracked across idle cycles.

Tested in Foot: idle/menu launches, startup input, lock cancellation, cursor/process cleanup, two outputs (second headless), and an ESP32-S3 BLE HID mouse.

Related: #7528, #12975, #11746.

Keep window tracking across idle cycles so manually started screensavers remain dismissible.

Signed-off-by: Eryk Wieliczko <eryk@wieliczko.ninja>
@greptile-apps

greptile-apps Bot commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 4/5

[Medium impact] The change reaches the desktop idle and screensaver workflow.

The PR appears safe to merge, with a non-blocking gap in tests for input dismissal.

Findings

  1. P2 Input dismissal remains untested ▶

Summary

Adds mouse-triggered screensaver dismissal through compositor input events.

  • Screensavers close on input after a short launch delay.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Launch screensaver windows] --> B[Restore monitor focus]
  B --> C[Send screensaverReady]
  C --> D[Wait 500ms]
  D --> E[Arm while windows remain]
  E --> F[Input closes screensaver terminals]
  F --> G[Last window closes and disarms input]
Loading

Reviews (1) · Last reviewed commit: "Dismiss screensavers on pointer input" · Reviewed by Greptile

Comment on lines +64 to +65
[[ -f $tmpdir/input-ready ]] || fail "input dismissal arms after both screensavers map and focus returns" "$(<"$tmpdir/calls")"
pass "input dismissal arms after both screensavers map and focus returns"

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.

P2 Input dismissal remains untested

The new assertion checks that the launcher sends screensaverReady, but never runs the dismissal code in Service.qml. It would still pass if the arm timer or input handler stopped working. Add a focused test for input before and after arming, dismissal during continuous input, and disarming when the last window closes.

@omarchybot

Copy link
Copy Markdown
Collaborator

Reviewed at c030763. It does what it says, with one gap: a screensaver window that maps late is never armed. I tried to push the fix to this branch, but GitHub refused it (403 for the maintainer-edit push), so it is below for you to apply.

What was run. All of this ran on a disposable worker built from the Omarchy ISO, with this branch linked as the running shell (foot, one monitor), driving a real pointer and keyboard through uinput:

  • Launched as the menu does (omarchy-launch-screensaver force): the screensaver armed 500 ms after the launcher returned. Mouse move, click, scroll and a plain letter key each closed it within 1.5 s, leaving no screensaver processes behind.
  • Launched by idle (screensaver 5 s, lock 12 s): moving the mouse closed it, cancelled the cycle and did not lock. The next idle cycle armed and locked normally.
  • Plugging in a pointer device and a compositor cursor warp did not dismiss it, so the launcher's focus walk is safe.
  • On the base commit 4fa93e9, the same mouse move left the screensaver up.
  • test/shell.d/idle-test.sh, screensaver-workspace-test.sh and shell-idle-spawn-test.sh pass on the worker.
  • Not covered: two monitors, Bluetooth input, terminals other than foot, and the cursor coming back (hyprctl getoption cursor:invisible does not reflect the screensaver's hl.config call, so I could not read it).

The gap. wait_for_screensaver_window gives up after 5 s, and the launcher then sends screensaverReady. When the arm timer fires 500 ms later with no window up, it leaves input unarmed, and nothing arms it when the window finally maps. I reproduced this on the worker: screensaverReady with no window up, then a screensaver-class window mapped and the mouse moved. On c030763 the window stayed up (screensaverWindows: 1, screensaverInputReady: false). With this change it armed and closed, and every case above behaved the same:

   function handleScreensaverWindowOpened(address) {
     setScreensaverWindow(address, true)
     screensaverLaunchGraceTimer.stop()
+    // A terminal that maps after the launcher stopped waiting missed its screensaverReady.
+    if (!root.screensaverInputReady) screensaverInputArmTimer.restart()
   }

During a normal launch this changes nothing: the launcher's screensaverReady still restarts the timer after the focus walk.

Second opinion. Codex Medium and muse-spark-1.3-contributor High reviewed the diff. Both raised the late-map gap and traced how it happens. I had asked them about that case, so their agreement is not independent confirmation. The other points they raised, each checked:

  • A window still left in the tracked set across cycles would keep the lock deadline running through activity, now that resetScreensaverWindows() is gone. I found no realistic way to miss a closewindow, so I left it.
  • A shell restart while the screensaver is up loses mouse dismissal for that screensaver. Keys still dismiss it, as before this PR.
  • A dismissal that fails is not retried. I found no way for the pkill to miss a terminal the launcher started.
  • A screensaver left behind the lock screen cannot happen: omarchy-system-lock already kills it.
  • Greptile's point that dismissal is untested: AGENTS.md rules out tests that grep the source, and no test harness here can generate seat input, so the worker runs above are the evidence instead.

Related. This addresses #7762. It probably fixes #15985 too: a letter key now dismisses through the compositor, though I did not reproduce that issue's ttfx condition. It does not touch #13157. #7528, #12975, #11746, #16235 and #16519 compete with it; which one lands is the maintainer's call.

Waiting on. @erykwieliczko, to apply the change above (or let the bot push to the branch). After that it goes to the maintainer.

@joshuaswarren

Copy link
Copy Markdown

Cross-reference: #16519 is an earlier two-line fix for the same click case. It turns on button-press reporting inside the screensaver script, so a click reaches the script's existing input read. It works in every terminal the launcher supports and needs no shell changes.

This PR solves it at the compositor level instead, which also covers mouse motion and keeps the idle service in charge of the screensaver lifecycle. Both fix the reported bug; they overlap, and one is enough. If this one is preferred, #16519 can close.

@omarchybot

Copy link
Copy Markdown
Collaborator

Thanks @erykwieliczko. The bot couldn't push to this branch (GitHub refused the maintainer-edit push), so the work has moved to a branch on this repository. Your commit goes across unchanged, and the late-window fix from the review above sits on top of it. It is open as a new pull request that credits you, and review continues there.

Continued in #16790.

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.

3 participants