Open
Conversation
Emacs child frames (posframes, corfu completion popups, etc.) are transient UI elements that should not be managed by Aerospace. Fixes nikitabobko#776
Author
|
@nikitabobko I realize my PR description is pretty verbose compared to the actual commit message for the change. I'm happy to force push/change the commit message to be more descriptive, and/or amend the PR body, too. |
6 tasks
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.
This fixes the focus jumping issue when using Emacs completion popups (corfu, posframes, etc.) with AeroSpace.
Originally I had implemented a very hack-y "solution" to this in #1914, but it only addressed the symptom, and not the root cause of the issue.
Emacs "child frames" (posframes, corfu completion popups, etc.) are a bit of an oddity in modern window-based UIs, but for Aerospace, they are effectively transient elements that should not be managed.
These child frames were being detected as dialogs, which caused AeroSpace to track them. When they were closed and GC triggered, a focus recalculation would occur, and then the focus could potentially jump to another application, depending on application/window layouts, and GC timing.
After @nikitabobko mentioned that
aerospace debug-windowscould be used to capture window properties (great tool/shortcut, btw!), it was actually pretty straightforward to adjust theisWindowHeuristicinAxUiElementWindowType.swiftto account for the emacs-specific oddities.Child frames now get detected as popups by checking for an
AXSubroleofAXFloatingWindow, andAXMainwith value0for the emacs bundle ID. This seems to be consistent behaviour for modern emacs (Emacs-Plus 30.2) on macOS.Dumps I generated have been added to
axDumpsfor the issue. I had to parse the output to extract out the app/PID prefixes and convert it to JSON, but the format seems to be the same as other examples in the dumps folder.I added two window property dumps, one for when the focus change was triggered by a completion "popup" from a popular emacs library named corfu, and one for posframe, another popular package that does similar things with "popups", and is used by a lot of other packages that want the popup-like functionality.
Without the fix, the test suite fails:
Test suite failures _without_ the updated dialog heuristic
and with the updated heuristic, the test suite passes without issue.
Thank you @nikitabobko for the guidance, here, on how to address the underlying issue instead of mucking about with focus recalculation logic.
Fixes #776
Fixes #1220
Refs. #1914
PR checklist
./run-tests.shexits with non-zero exit code.