fix(click): resolve window id when web content runs in a helper process - #4
Open
caipira113 wants to merge 1 commit into
Open
fix(click): resolve window id when web content runs in a helper process#4caipira113 wants to merge 1 commit into
caipira113 wants to merge 1 commit into
Conversation
caipira113
force-pushed
the
fix/window-id-helper-process
branch
from
August 5, 2026 00:39
ee41fca to
1415b49
Compare
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
click,dblclick, andscroll --strategy cg-pidsilently do nothing on Microsoft Teams. The event is posted, coordinates are correct, and no error is reported, but the app does not react. A real cursor click at the very same point works.The cause is a mismatch between the process the event is posted to and the window it is tagged with.
Teams renders web content in a separate helper process:
_AXUIElementGetWindowis not wrong here: an element inside the page really does belong to the WebView process's window. Butmouse_click_bgposts to the application pid while tagging fields 91/92 with that helper window id, so hit-testing finds no match and the event is dropped.Change
Added
resolve_event_window_id, used by all threecg-pidcall sites. It keeps the id from_AXUIElementGetWindowwhen that window is owned by the target pid, which is the common case, and otherwise matches the owning AX window's frame against the on-screen window list to find the right one.Two supporting helpers in
accessibility.rs:window_belongs_to_pid— ownership check againstCGWindowListCopyWindowInfo.window_id_for_frame— frame match, restricted to layer 0 and skipping fully transparent windows. Teams keeps a zero-alpha overlay over its title bar that would otherwise be a candidate.AX frames and
kCGWindowBoundsshare a top-left origin, so they compare directly; a 2pt tolerance absorbs rounding.Verification
Tested on macOS 27.0 (build 26A5388g, arm64), each command run with Finder frontmost.
Teams (helper-process app) — was broken, now works
Scroll is fixed by the same path, confirmed visually: the message list moved from the latest message to content from several months earlier, and focus stayed on Finder throughout.
No regression on apps that were already fine
Calculator still accumulates digits from background clicks, so the AppKit path is untouched.
cargo testpasses (54 tests) andcargo clippyreports no new warnings.Note on focus
Background clicks on Teams still bring it forward, but that is the app's own behaviour rather than an artifact of the event path:
--strategy ax, which posts no mouse events at all, raises it identically, while clicking a non-interactive element (a heading) leaves focus alone. Scrolling never raises it.