Skip to content

✨ Add more SkyLight APIs for improved window/screen selection#1087

Merged
MrKai77 merged 3 commits intodevelopfrom
kai/more-skylight
Apr 28, 2026
Merged

✨ Add more SkyLight APIs for improved window/screen selection#1087
MrKai77 merged 3 commits intodevelopfrom
kai/more-skylight

Conversation

@MrKai77
Copy link
Copy Markdown
Owner

@MrKai77 MrKai77 commented Apr 25, 2026

Adds two private SkyLight APIs: SLSCopyBestManagedDisplayForPoint and SLSFindWindowByGeometry.

SLSCopyBestManagedDisplayForPoint
Picks 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.

SLSFindWindowByGeometry
Finds the window at the mouse position. Previously we'd ask AX for the UI element under the cursor, or fall back to walking CGWindowListCopyWindowInfo and 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.

@MrKai77 MrKai77 self-assigned this Apr 25, 2026
@MrKai77 MrKai77 force-pushed the kai/more-skylight branch 2 times, most recently from 1f922f1 to 7a0660e Compare April 25, 2026 21:20
@MrKai77 MrKai77 force-pushed the kai/more-skylight branch from 7a0660e to 9b130bc Compare April 25, 2026 21:21
@MrKai77 MrKai77 requested a review from SenpaiHunters April 25, 2026 21:22
@MrKai77 MrKai77 changed the title ✨ Add more SkyLight APIs to speed up window/screen selection ✨ Add more SkyLight APIs for improved window/screen selection Apr 26, 2026
Copy link
Copy Markdown
Collaborator

@SenpaiHunters SenpaiHunters left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 : nil

If 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.

@MrKai77 MrKai77 merged commit 891c574 into develop Apr 28, 2026
1 check passed
@MrKai77 MrKai77 deleted the kai/more-skylight branch April 28, 2026 20:55
@MrKai77 MrKai77 linked an issue Apr 29, 2026 that may be closed by this pull request
6 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

🐞 Stage Manager conflict: Loop resizes wrong window

2 participants