Skip raise when frontmost app has overlay window at cursor#275
Open
candrabeqx wants to merge 1 commit intosbmpost:masterfrom
Open
Skip raise when frontmost app has overlay window at cursor#275candrabeqx wants to merge 1 commit intosbmpost:masterfrom
candrabeqx wants to merge 1 commit intosbmpost:masterfrom
Conversation
When an app displays a high-level overlay window (e.g. a custom context menu) that extends beyond its main window bounds, the cursor may land over a different app's layer-0 window while the overlay is visually on top. AutoRaise would then activate that background window, stealing focus and closing the overlay. This adds a check before raising: if the window under the cursor belongs to a different process than the frontmost app, and the frontmost app owns a non-layer-0 (overlay) window containing the cursor position, the raise is suppressed. Affected apps include Telegram for macOS which uses a custom NSWindow at screenSaver level for its context menu (Reply, Copy Text, Translate, etc). ✨ Generated with Claude Code (claude.ai/claude-code) 2.1.50 (Claude Code) (claude-opus-4-6)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
When an app displays a custom overlay window (non-layer-0) that extends beyond its main window bounds, moving the cursor to the overlay area outside the main window causes AutoRaise to activate the wrong window.
Example: Telegram for macOS uses a custom
NSWindowat.screenSaverwindow level for its right-click context menu (Reply, Copy Text, Translate, Save As, etc.). When the context menu extends past the main Telegram window:AXUIElementCopyElementAtPositioneither skips the overlay (menu-role elements are filtered) or sees through ittopwindow()fallback only considers layer-0 windows, so it finds the window behind the overlayThis affects any app that uses high-level custom windows for popups, context menus, or floating panels that extend beyond the main window bounds.
Solution
Before committing to a raise, check whether the frontmost app owns any non-layer-0 (overlay) window that contains the cursor position. If the cursor is over a different app's layer-0 window and the frontmost app has an overlay at that position, suppress the raise.
The check is intentionally narrow:
mouseWindow_pid != frontmost_pid(different app under cursor)Test plan
needs_raiseis true andmouseWindow_pid != frontmost_pid)✨ Generated with Claude Code (claude.ai/claude-code) 2.1.50 (claude-opus-4-6)