Skip to content

Use .onScreen window list for detached emoji popover lookup#90

Open
indent[bot] wants to merge 1 commit into
mainfrom
indent-2026-05-24-onscreen-window-list
Open

Use .onScreen window list for detached emoji popover lookup#90
indent[bot] wants to merge 1 commit into
mainfrom
indent-2026-05-24-onscreen-window-list

Conversation

@indent
Copy link
Copy Markdown
Contributor

@indent indent Bot commented May 24, 2026

Summary

  • Switch CharacterPickerPopover.windowCandidates() from Window.listDescriptions(.all, …) to .onScreen so off-screen windows are filtered by Core Graphics before reaching Swift.

Motivation
Follow-up to #89. The retry(withTimeout: 1.0, interval: 0.05) around characterPickerSearchField calls windowCandidates() ~20× per setReaction on the Tahoe detached-popover path. Each call was copying descriptors for every window owned by every app on the system. isCandidateWindow already requires description.isOnscreen == true, so .onScreen is semantics-preserving and lets CG drop the rest of the windows up front.

Testing
No behavior change — covered by the existing reaction flow exercised by #89. The filter predicate is unchanged; only the upstream CGWindowListCopyWindowInfo option flag flips.

Open in Indent
Tag @indent to continue the conversation here.

The retry loop around characterPickerSearchField was enumerating every
window owned by every app on the system (.all) up to 20 times per
setReaction. Switching to .onScreen lets CG drop off-screen windows
before they cross into Swift land, and isCandidateWindow already
required isOnscreen == true so semantics are preserved.

Generated with [Indent](https://indent.com)
Co-Authored-By: KishanBagaria <KishanBagaria@users.noreply.github.com>
@indent
Copy link
Copy Markdown
Contributor Author

indent Bot commented May 24, 2026

PR Summary

Switches the detached emoji-picker popover lookup in CharacterPickerPopover.windowCandidates() from Window.listDescriptions(.all, …) to .onScreen, so CoreGraphics drops off-screen windows before they cross into Swift. This is a performance-only change for setReaction (the lookup runs in a retry loop up to ~20 times, previously enumerating every window of every app on the system) and preserves semantics because isCandidateWindow already required isOnscreen == true.

  • src/IMessage/Sources/IMessage/Messages/MessagesAppElements.swift: pass .onScreen to Window.listDescriptions and add a comment explaining the CG-level pre-filter complements the existing isOnscreen == true check.

Issues

No issues found.

CI Checks

Waiting for CI checks...

@indent indent Bot added the indent label May 24, 2026
@KishanBagaria KishanBagaria force-pushed the main branch 2 times, most recently from 17cbef3 to e9fc979 Compare May 24, 2026 10:09
@pmanot
Copy link
Copy Markdown
Contributor

pmanot commented May 27, 2026

@KishanBagaria what's stopping this from being merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Development

Successfully merging this pull request may close these issues.

1 participant