fix: resolve AeroSpace display ID mismatch with iterative fallback#506
Open
Etzeo wants to merge 2 commits intoJean-Tinland:masterfrom
Open
fix: resolve AeroSpace display ID mismatch with iterative fallback#506Etzeo wants to merge 2 commits intoJean-Tinland:masterfrom
Etzeo wants to merge 2 commits intoJean-Tinland:masterfrom
Conversation
Refactor getDisplayIndex to read monitor-id (closer resembled ubersicht display id from `window.location.pathname`) and add new getScreenIndex to read monitor-appkit-nsscreen-screens-id that returns which screen should be render for each display. Update all call sites to use the appropriate function for their context.
Replace the built-in Retina Display fix with an iterative approach that walks down from the Übersicht display ID until finding a matching AeroSpace display. This handles all phantom display scenarios: closed MacBook lid, previously connected monitors, and any number of disconnected displays that Übersicht still counts.
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.
(I found a better solution, will push it up soon, ignore this PR for now)
Description
Problem
Übersicht assigns widget display IDs based on
NSScreenNumberbut keeps counting phantom displays (closed lid, previously connected monitors) even after they're disconnected. The previous workaround only subtracted 1 when the built-in display was missing, which broke with multiple phantom displays or different configurations.e.g. I have 2 external display plugged in,
ubersichtDisplayId1on my bult-in display, and2and3for the two external displays. When I disconnect my 1st external display,ubersichtDisplayIdfor built-in display will stay as1, and for 2nd external display'subersichtDisplayIdwill stay at3even afterubersichtis restarted, I'm not sure what/when/how this is ever re-loadedProposed Solution
This is my humble attempt at amending the issue for my own use, thought I'll share it here as well. My approach is to instead of guessing how many phantom displays exist, the new approach iterates from the Übersicht display ID downward until finding a display that AeroSpace actually reports. This works regardless of how many phantom displays exist. Hopefully this helps somebody out! 😄
Changes
Refactor: Separated
getDisplayIndexinto two distinct functions —getMonitorIndex(reads AeroSpace's sequentialmonitor-id) andgetScreenIndex(readsmonitor-appkit-nsscreen-screens-id). Updated some calls to use the appropriate function to match the display vs match the screen we want to render onto the display.Fix: Replaced the fragile "Built-in Retina Display" detection workaround with an iterative fallback approach. The new logic walks down from the Übersicht display ID until finding a matching AeroSpace display, handling all phantom display scenarios: closed MacBook lid, previously connected monitors, and any number of disconnected displays that Übersicht still counts.
Disclaimer
yabaiand am unsure if I broke anything there, hopefully i didn't.Fixes: #486 without relying on Übersicht fork (more like a workaround, than a fix)
Type of change
Please delete options that are not relevant.
How Has This Been Tested?
Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration
Test Configuration:
aerospace -v)Checklist:
Changes to make to the documentation