mirror of
https://github.com/MonitorControl/MonitorControl.git
synced 2026-10-23 08:07:35 -06:00
[PR #1906] Preserve the brightness offset between displays while syncing #1329
Labels
No labels
Status: Abandoned
arm64
beta
beta
bug
done
duplicate
enhancement
feedback needed from reporter
in progress
information
invalid
investigating
known Issue
monitor Issue
pull-request
translation
unable to reproduce
unreleased
x86
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github-starred/MonitorControl#1329
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/MonitorControl/MonitorControl/pull/1906
Author: @anandghegde
Created: 9/20/2026
Status: 🔄 Open
Base:
main← Head:feat/preserve-brightness-sync-offsets📝 Commits (1)
a4e1f7dPreserve the brightness offset between displays while syncing (#1781)📊 Changes
5 files changed (+71 additions, -3 deletions)
View changed files
📝
MonitorControl.xcodeproj/project.pbxproj(+4 -0)📝
MonitorControl/Model/Display.swift(+2 -0)📝
MonitorControl/Support/AppDelegate.swift(+8 -3)➕
MonitorControl/Support/BrightnessSync.swift(+52 -0)📝
MonitorControl/View Controllers/Preferences/MainPrefsViewController.swift(+5 -0)📄 Description
Closes #1781.
The problem
AppDelegate.job()synced by adding the reported delta to each display and clamping the result:Whatever part of the change did not fit was dropped. A display parked near the top of its range loses ground on every ambient light swing up, but gets the whole change back on the way down — so the displays creep together until the sliders are aligned, which is what the issue describes ("especially when the external monitor reaches its maximum brightness and then scales back — the brightness sliders often end up aligned").
The change
BrightnessSynckeeps an unclamped anchor per display: where the display would be if it had no ends. The delta is applied to the anchor, the display is driven to the clamped anchor. The part that did not fit is therefore given back on the way down instead of being lost, and the offset survives.The anchor re-anchors itself whenever the display is no longer where the last sync left it — so a brightness the user sets by hand simply becomes the new relationship to keep, and no other code path has to know the anchor exists. The anchors are also dropped when the sync checkbox is toggled, since the user was free to move the displays apart while it was off.
Two small side effects, both intentional:
-1...2. Two displays can never be further apart than the whole range, so this only matters if several displays report changes of their own at the same time.Verification
xcodebuild -scheme MonitorControl -configuration Debug -destination 'platform=macOS' build→ BUILD SUCCEEDEDswiftformat --lint MonitorControl→0/30 files require formattingswiftlint→ no new violations (the existing ones inKeyboardShortcuts.swift,DisplayManager.swift,MenuslidersPrefsViewController.swiftandAppDelegate.swift:89are untouched)BrightnessSync.swiftonly imports Foundation, so the arithmetic can be driven directly. Replaying a day of ambient light against the realAppleDisplay.refreshBrightness()easing, starting from a built-in at 0.50 and an external parked 0.40 higher:Before, the offset decays to zero the first time the built-in reaches the top and never comes back. After, the external is still compressed while it sits at its own maximum (+0.10, +0.25 above) — nothing can be done about that, it has nowhere higher to go — but the full +0.40 is restored as soon as the built-in is back in range.
The harness, if you want to re-run it
What I could not verify
No run on real hardware. This machine has no external display and no Apple Developer signing identity, so the build above needed
CODE_SIGNING_ALLOWED=NOand I could not exercise the actual loop. So these are reasoned, not observed:OtherDisplay.getBrightness()reads the saved pref rather than the panel, so I do not believe it can, but a real monitor is the only way to be sure;Worth a run on your setup before merging. Happy to adjust the tolerance, or to put the old behaviour back behind the checkbox if you would rather have it opt-in.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.