✨ Add more SkyLight APIs for improved window/screen selection#1087
Merged
✨ Add more SkyLight APIs for improved window/screen selection#1087
SkyLight APIs for improved window/screen selection#1087Conversation
1f922f1 to
7a0660e
Compare
7a0660e to
9b130bc
Compare
SkyLight APIs to speed up window/screen selectionSkyLight APIs for improved window/screen selection
SenpaiHunters
approved these changes
Apr 26, 2026
Collaborator
SenpaiHunters
left a comment
There was a problem hiding this comment.
We're missing any error checking for SLSFindWindowByGeometry as you're doing
_ = SLSFindWindowByGeometry(cid, 0, 1, 0, &screenPoint, &windowPoint, &hitWindowID, &windowCID)
return hitWindowID != 0 ? hitWindowID : nilIf we ignore errors, that's acceptable. I'm uncertain about what it would return; if it yields nothing useful, we can disregard it. Additionally, I see no changes or updates needed. If we don't need to log the SLS failure, it's ready to commit.
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.
Adds two private SkyLight APIs:
SLSCopyBestManagedDisplayForPointandSLSFindWindowByGeometry.SLSCopyBestManagedDisplayForPointPicks the display at a given point using the system's own selection logic instead of our manual bounds iteration. Not really a performance win, but the value is that we match WindowServer's tie-breaking at boundaries, so we can't drift from it (in practice the two seem to agree, though matching the source-of-truth is cheap insurance). Falls back to the old iteration if the symbol fails to load.
SLSFindWindowByGeometryFinds the window at the mouse position. Previously we'd ask AX for the UI element under the cursor, or fall back to walking
CGWindowListCopyWindowInfoand taking the first frame that contained the point. The fallback was unreliable, as it could skip the frontmost window and return one obscured beneath the actual target. SkyLight's geometry hit-test gives us the right window directly. If this symbol is unavailable, we still fall back to the old system.