Skip to content

Show the real cursor over password prompts drawn above the hand - #45

Closed
jorgenbruntveit wants to merge 4 commits into
nilbuild:mainfrom
jorgenbruntveit:fix-secure-dialogs
Closed

jorgenbruntveit wants to merge 4 commits into
nilbuild:mainfrom
jorgenbruntveit:fix-secure-dialogs

Conversation

@jorgenbruntveit

@jorgenbruntveit jorgenbruntveit commented Nov 18, 2026 •

Copy link
Copy Markdown

macOS draws some system windows in front of TinyHand's overlay although their window level is lower. The password prompt from SecurityAgent (for example from do shell script … with administrator privileges, or an installer asking for an admin password) reports layer 1000 but sits in front of the overlay at 1002. While the pointer is on, the hand is drawn underneath the prompt and the system cursor is hidden, so there is nothing to aim with inside it.

What it does

  • Windows that CGWindowListCopyWindowInfo lists in front of the overlay, with a level lower than the overlay's, now count like open menus: over them the real cursor shows and clicks reach them.
  • The real cursor shows over them even with Keep the hand on, because the hand would be hidden under the window anyway.
  • While one is on screen, Esc reaches it, as it already does for open menus.
  • Windows at the overlay's level or above don't count. They are in front by ordinary window ordering, as before this change.

How

  • openMenus(overlay:overlayLevel:) walks the front-to-back window list and also returns windows that come before the overlay's own window, have a lower level and are not owned by TinyHand. It returns those separately as well.
  • If the overlay is not in the list (briefly, during a Space switch), nothing counts as in front of it.
  • updateZones forces the real cursor when the mouse is over one of those windows.
  • The scan runs again on the next tick after the pointer turns on and after every Space change, so a prompt is picked up without waiting for the slow poll.
  • The log records when such a window appears and goes, and gives window in front as the reason for the real cursor.

Why the level check

The first version counted every window listed in front of the overlay. CleanShot X keeps an invisible full-screen window at layer 2147483628, above the overlay, so the whole screen counted as covered: the real cursor showed everywhere and clicks went through to apps. During a Space switch the overlay is missing from the on-screen list for a moment, so every window counted and the hand flickered. Both are fixed by the level check and the missing-overlay guard.

Testing

Built with swift build -c release on macOS 27.3. With the pointer on, I opened an admin password prompt with osascript -e 'do shell script "true" with administrator privileges'. The log showed the window being detected, the real cursor each time the mouse went inside the prompt and the hand each time it left. The hand came back as soon as the prompt closed. With CleanShot X running, its full-screen window is no longer counted, and taps, drawing and Space switches work as usual. The password prompt has not been re-tested since the level check was added; its layer (1000) is below the overlay's (1002), so the rule still counts it.

Council review

Rounds: 3

Delegate Round 1 Round 2 Round 3
Claude Opus 9/10 9/10 9/10
GPT Sol 8/10 8/10 10/10
Gemini Neon 9/10 9/10 9.5/10

🤖 Generated with Claude Code

jorgenbruntveit and others added 4 commits November 18, 2026 12:01
macOS draws some system windows, like SecurityAgent's password
prompts, in front of the overlay whatever its level, so the hand was
hidden under them while the system cursor was hidden too. Windows in
front of the overlay now count like open menus: over them the real
cursor shows, even with Keep the hand on, and clicks reach them.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The password-prompt fix counted every window listed in front of the
overlay as covering it. CleanShot X keeps a full-screen window at a
level above the overlay, so the whole screen counted as covered: the
real cursor showed everywhere and clicks went through. Only windows
macOS draws in front despite a level no higher than the overlay's,
like SecurityAgent's prompts, now count.

While the overlay is off the active Space during a switch it is not
in the window list, so every window counted as in front of it, which
made the hand flicker. Nothing counts as covering then.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…vels

Council review of the previous commit: activate() scans before the
overlay is ordered front, and the Space-switch handler may skip its
scan, so a password prompt could go uncounted for up to 250 ms. Both
now force a scan on the next tick. A window at the overlay's own level
is in front by ordinary ordering, so only lower levels count now.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Council round 2: a normal Space switch, where the overlay is already on
the new Space, did not force a scan, so a cover there could wait for
the 250 ms poll. The reset now runs on both paths, after the re-show
tick.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@jorgenbruntveit jorgenbruntveit closed this by deleting the head repository Nov 25, 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