Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
b055cb4
Compile three DDC startup options into one popup menu.
waydabber Oct 8, 2021
218522f
Updated translation files
waydabber Oct 8, 2021
c990455
Combine multiple displays radio buttons into a popup menu
waydabber Oct 8, 2021
44438f4
Changed record shortcut box to a more logical layout + needs less space
waydabber Oct 8, 2021
50ad12c
Further tweaks in keyboard preferences pane
waydabber Oct 9, 2021
5026d91
Fix constraint issue
waydabber Oct 9, 2021
c27b5f0
Updated Chinese translation
waydabber Oct 9, 2021
c608617
Merge remote-tracking branch 'refs/remotes/origin/master'
waydabber Oct 9, 2021
16db5c1
Updated Chinese translation
waydabber Oct 9, 2021
41c993c
Fix spacing
waydabber Oct 9, 2021
b64ead8
Fix signing
waydabber Oct 9, 2021
899c9bc
Updated layout of Keyboards tab to conserve more space
waydabber Oct 9, 2021
c7f15fa
Fix signing + some translations
waydabber Oct 9, 2021
28bdbc5
Merge branch 'master' into fix/beta2issues
waydabber Oct 9, 2021
fd53c33
chore: update dutch string
JoniVR Oct 9, 2021
f53593f
Removed unnecessary accessibility description
waydabber Oct 9, 2021
660d682
Merge remote-tracking branch 'refs/remotes/origin/fix/beta2issues'
waydabber Oct 9, 2021
1922f1e
Removed unnecessary accessibility description
waydabber Oct 9, 2021
23fdc4f
chore: update dutch strings
JoniVR Oct 9, 2021
8e2538b
chore: dutch translation consistency
JoniVR Oct 9, 2021
692d535
chore: missing dutch translation
JoniVR Oct 9, 2021
1b40465
chore: shorten translation to make UI look better
JoniVR Oct 9, 2021
071cef1
Permanently show scroll bar on Displays tab to indicate that the view…
waydabber Oct 9, 2021
c383247
Merge remote-tracking branch 'refs/remotes/origin/fix/beta2issues'
waydabber Oct 9, 2021
9f7562f
Sync with master
waydabber Oct 9, 2021
ff4791f
Merge branch 'master' into fix/beta2issues
waydabber Oct 9, 2021
0c4995e
Added gamma interference check.
waydabber Oct 9, 2021
e1b97d2
Merge branch 'master' into fix/beta2issues
waydabber Oct 9, 2021
9cb109c
Update screenshot
waydabber Oct 9, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified .github/screenshot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion MonitorControl/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<key>CFBundleShortVersionString</key>
<string>$(MARKETING_VERSION)</string>
<key>CFBundleVersion</key>
<string>6581</string>
<string>6632</string>
<key>LSApplicationCategoryType</key>
<string>public.app-category.utilities</string>
<key>LSMinimumSystemVersion</key>
Expand Down
49 changes: 43 additions & 6 deletions MonitorControl/Model/Display.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ class Display: Equatable {
internal var smoothBrightnessTransient: Float = 1
internal var smoothBrightnessRunning: Bool = false
internal var smoothBrightnessSlow: Bool = false
let swBrightnessSemaphore = DispatchSemaphore(value: 1)

static func == (lhs: Display, rhs: Display) -> Bool {
return lhs.identifier == rhs.identifier
Expand Down Expand Up @@ -199,8 +200,8 @@ class Display: Equatable {
}
}

let swBrightnessSemaphore = DispatchSemaphore(value: 1)
func setSwBrightness(_ value: Float, smooth: Bool = false) -> Bool {
self.swBrightnessSemaphore.wait()
let brightnessValue = min(1, value)
var currentValue = self.readPrefAsFloat(key: .SwBrightness)
self.savePref(brightnessValue, key: .SwBrightness)
Expand All @@ -209,9 +210,9 @@ class Display: Equatable {
newValue = self.swBrightnessTransform(value: newValue)
if smooth {
DispatchQueue.global(qos: .userInteractive).async {
self.swBrightnessSemaphore.wait()
for transientValue in stride(from: currentValue, to: newValue, by: 0.005 * (currentValue > newValue ? -1 : 1)) {
guard app.reconfigureID == 0 else {
self.swBrightnessSemaphore.signal()
return
}
if self.isVirtual || self.readPrefAsBool(key: .avoidGamma) {
Expand All @@ -224,10 +225,10 @@ class Display: Equatable {
}
Thread.sleep(forTimeInterval: 0.001) // Let's make things quick if not performed in the background
}
self.swBrightnessSemaphore.signal()
}
} else {
if self.isVirtual || self.readPrefAsBool(key: .avoidGamma) {
self.swBrightnessSemaphore.signal()
return DisplayManager.shared.setShadeAlpha(value: 1 - newValue, displayID: self.identifier)
} else {
let gammaTableRed = self.defaultGammaTableRed.map { $0 * newValue }
Expand All @@ -238,28 +239,64 @@ class Display: Equatable {
DisplayManager.shared.enforceGammaActivity()
}
}
self.swBrightnessSemaphore.signal()
return true
}

func getSwBrightness() -> Float {
self.swBrightnessSemaphore.wait()
if self.isVirtual || self.readPrefAsBool(key: .avoidGamma) {
let rawBrightnessValue = 1 - (DisplayManager.shared.getShadeAlpha(displayID: self.identifier) ?? 1)
self.swBrightnessSemaphore.signal()
return self.swBrightnessTransform(value: rawBrightnessValue, reverse: true)
}
var gammaTableRed = [CGGammaValue](repeating: 0, count: 256)
var gammaTableGreen = [CGGammaValue](repeating: 0, count: 256)
var gammaTableBlue = [CGGammaValue](repeating: 0, count: 256)
var gammaTableSampleCount: UInt32 = 0
var brightnessValue: Float = 1
if CGGetDisplayTransferByTable(self.identifier, 256, &gammaTableRed, &gammaTableGreen, &gammaTableBlue, &gammaTableSampleCount) == CGError.success {
let redPeak = gammaTableRed.max() ?? 0
let greenPeak = gammaTableGreen.max() ?? 0
let bluePeak = gammaTableBlue.max() ?? 0
let gammaTablePeak = max(redPeak, greenPeak, bluePeak)
let peakRatio = gammaTablePeak / self.defaultGammaTablePeak
let brightnessValue = round(self.swBrightnessTransform(value: peakRatio, reverse: true) * 256) / 256
return brightnessValue
brightnessValue = round(self.swBrightnessTransform(value: peakRatio, reverse: true) * 256) / 256
}
self.swBrightnessSemaphore.signal()
return brightnessValue
}

func checkGammaInterference() {
let currentSwBrightness = self.getSwBrightness()
guard !DisplayManager.shared.gammaInterferenceWarningShown, !(prefs.bool(forKey: PrefKey.disableSoftwareFallback.rawValue) && prefs.bool(forKey: PrefKey.disableCombinedBrightness.rawValue)), !self.readPrefAsBool(key: .avoidGamma), !self.smoothBrightnessRunning, self.prefExists(key: .SwBrightness), abs(currentSwBrightness - self.readPrefAsFloat(key: .SwBrightness)) > 0.02 else {
return
}
DisplayManager.shared.gammaInterferenceCounter += 1
_ = self.setSwBrightness(1)
os_log("Gamma table interference detected, number of events: %{public}@", type: .debug, String(DisplayManager.shared.gammaInterferenceCounter))
if DisplayManager.shared.gammaInterferenceCounter >= 3 {
DisplayManager.shared.gammaInterferenceWarningShown = true
let alert = NSAlert()
alert.messageText = NSLocalizedString("Is f.lux or similar running?", comment: "Shown in the alert dialog")
alert.informativeText = NSLocalizedString("An other app seems to change the brightness or colors which causes issues.\n\nTo solve this, you need to quit the other app or disable gamma control for your displays in MonitorControl!", comment: "Shown in the alert dialog")
alert.addButton(withTitle: NSLocalizedString("I'll quit the other app", comment: "Shown in the alert dialog"))
alert.addButton(withTitle: NSLocalizedString("Disable gamma control for my displays", comment: "Shown in the alert dialog"))
alert.alertStyle = NSAlert.Style.critical
if alert.runModal() != .alertFirstButtonReturn {
for otherDisplay in DisplayManager.shared.getOtherDisplays() {
_ = otherDisplay.setSwBrightness(1)
_ = otherDisplay.setDirectBrightness(1)
otherDisplay.savePref(true, key: .avoidGamma)
_ = otherDisplay.setSwBrightness(1)
DisplayManager.shared.gammaInterferenceWarningShown = false
DisplayManager.shared.gammaInterferenceCounter = 0
displaysPrefsVc?.loadDisplayList()
}
} else {
os_log("We won't watch for gamma table interference anymore", type: .debug)
}
}
return 1
}

func resetSwBrightness() -> Bool {
Expand Down
9 changes: 8 additions & 1 deletion MonitorControl/Model/OtherDisplay.swift
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,11 @@ class OtherDisplay: Display {
}
}

override func setBrightness(_ to: Float = -1, slow: Bool = false) -> Bool {
self.checkGammaInterference()
return super.setBrightness(to, slow: slow)
}

override func setDirectBrightness(_ to: Float, transient: Bool = false) -> Bool {
let value = max(min(to, 1), 0)
if !self.isSw() {
Expand All @@ -341,7 +346,9 @@ class OtherDisplay: Display {
brightnessSwValue = (value / self.combinedBrightnessSwitchingValue())
}
_ = self.writeDDCValues(command: .brightness, value: self.convValueToDDC(for: .brightness, from: brightnessValue))
_ = self.setSwBrightness(brightnessSwValue)
if self.readPrefAsFloat(key: .SwBrightness) != brightnessSwValue {
_ = self.setSwBrightness(brightnessSwValue)
}
} else {
_ = self.writeDDCValues(command: .brightness, value: self.convValueToDDC(for: .brightness, from: value))
}
Expand Down
1 change: 1 addition & 0 deletions MonitorControl/Support/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ class AppDelegate: NSObject, NSApplicationDelegate {
}
os_log("Request for configuration with reconfigreID %{public}@", type: .info, String(dispatchedReconfigureID))
self.reconfigureID = 0
DisplayManager.shared.gammaInterferenceCounter = 0
DisplayManager.shared.configureDisplays()
DisplayManager.shared.addDisplayCounterSuffixes()
DisplayManager.shared.updateArm64AVServices()
Expand Down
2 changes: 2 additions & 0 deletions MonitorControl/Support/DisplayManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ class DisplayManager {
var audioControlTargetDisplays: [OtherDisplay] = []
let ddcQueue = DispatchQueue(label: "DDC queue")
let gammaActivityEnforcer = NSWindow(contentRect: .init(origin: NSPoint(x: 0, y: 0), size: .init(width: DEBUG_GAMMA_ENFORCER ? 15 : 1, height: DEBUG_GAMMA_ENFORCER ? 15 : 1)), styleMask: [], backing: .buffered, defer: false)
var gammaInterferenceCounter = 0
var gammaInterferenceWarningShown = false

func createGammaActivityEnforcer() {
self.gammaActivityEnforcer.title = "Monior Control Gamma Activity Enforcer"
Expand Down
12 changes: 12 additions & 0 deletions MonitorControl/UI/de.lproj/Localizable.strings
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
/* Shown in the main prefs window */
"About" = "Über";

/* Shown in the alert dialog */
"An other app seems to change the brightness or colors which causes issues.\n\nTo solve this, you need to quit the other app or disable gamma control for your displays in MonitorControl!" = "An other app seems to change the brightness or colors which causes issues.\n\nTo solve this, you need to quit the other app or disable gamma control for your displays in MonitorControl!";

/* Shown in the main prefs window */
"App menu" = "App Menü";

Expand Down Expand Up @@ -34,6 +37,9 @@
/* Shown in record shortcut box */
"Decrease" = "Verringern";

/* Shown in the alert dialog */
"Disable gamma control for my displays" = "Disable gamma control for my displays";

/* Shown in the main prefs window */
"Displays" = "Monitore";

Expand All @@ -52,6 +58,9 @@
/* Shown in the Display Preferences */
"Hardware (DDC)" = "Hardware (DDC)";

/* Shown in the alert dialog */
"I'll quit the other app" = "I'll quit the other app";

/* Shown in the alert dialog */
"Incompatible previous version" = "Inkompatible Vorgängerversion";

Expand All @@ -61,6 +70,9 @@
/* Intel designation (shown after the version number in Preferences) */
"Intel" = "Intel";

/* Shown in the alert dialog */
"Is f.lux or similar running?" = "Is f.lux or similar running?";

/* Shown in the main prefs window */
"Keyboard" = "Tastatur";

Expand Down
12 changes: 12 additions & 0 deletions MonitorControl/UI/en.lproj/Localizable.strings
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
/* Shown in the main prefs window */
"About" = "About";

/* Shown in the alert dialog */
"An other app seems to change the brightness or colors which causes issues.\n\nTo solve this, you need to quit the other app or disable gamma control for your displays in MonitorControl!" = "An other app seems to change the brightness or colors which causes issues.\n\nTo solve this, you need to quit the other app or disable gamma control for your displays in MonitorControl!";

/* Shown in the main prefs window */
"App menu" = "App menu";

Expand Down Expand Up @@ -34,6 +37,9 @@
/* Shown in record shortcut box */
"Decrease" = "Decrease";

/* Shown in the alert dialog */
"Disable gamma control for my displays" = "Disable gamma control for my displays";

/* Shown in the main prefs window */
"Displays" = "Displays";

Expand All @@ -52,6 +58,9 @@
/* Shown in the Display Preferences */
"Hardware (DDC)" = "Hardware (DDC)";

/* Shown in the alert dialog */
"I'll quit the other app" = "I'll quit the other app";

/* Shown in the alert dialog */
"Incompatible previous version" = "Incompatible previous version";

Expand All @@ -61,6 +70,9 @@
/* Intel designation (shown after the version number in Preferences) */
"Intel" = "Intel";

/* Shown in the alert dialog */
"Is f.lux or similar running?" = "Is f.lux or similar running?";

/* Shown in the main prefs window */
"Keyboard" = "Keyboard";

Expand Down
12 changes: 12 additions & 0 deletions MonitorControl/UI/es-419.lproj/Localizable.strings
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
/* Shown in the main prefs window */
"About" = "Acerca de";

/* Shown in the alert dialog */
"An other app seems to change the brightness or colors which causes issues.\n\nTo solve this, you need to quit the other app or disable gamma control for your displays in MonitorControl!" = "An other app seems to change the brightness or colors which causes issues.\n\nTo solve this, you need to quit the other app or disable gamma control for your displays in MonitorControl!";

/* Shown in the main prefs window */
"App menu" = "App menu";

Expand Down Expand Up @@ -34,6 +37,9 @@
/* Shown in record shortcut box */
"Decrease" = "Decrease";

/* Shown in the alert dialog */
"Disable gamma control for my displays" = "Disable gamma control for my displays";

/* Shown in the main prefs window */
"Displays" = "Pantallas";

Expand All @@ -52,6 +58,9 @@
/* Shown in the Display Preferences */
"Hardware (DDC)" = "Hardware (DDC)";

/* Shown in the alert dialog */
"I'll quit the other app" = "I'll quit the other app";

/* Shown in the alert dialog */
"Incompatible previous version" = "Incompatible previous version";

Expand All @@ -61,6 +70,9 @@
/* Intel designation (shown after the version number in Preferences) */
"Intel" = "Intel";

/* Shown in the alert dialog */
"Is f.lux or similar running?" = "Is f.lux or similar running?";

/* Shown in the main prefs window */
"Keyboard" = "Keyboard";

Expand Down
12 changes: 12 additions & 0 deletions MonitorControl/UI/fr.lproj/Localizable.strings
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
/* Shown in the main prefs window */
"About" = "À Propos";

/* Shown in the alert dialog */
"An other app seems to change the brightness or colors which causes issues.\n\nTo solve this, you need to quit the other app or disable gamma control for your displays in MonitorControl!" = "An other app seems to change the brightness or colors which causes issues.\n\nTo solve this, you need to quit the other app or disable gamma control for your displays in MonitorControl!";

/* Shown in the main prefs window */
"App menu" = "Menu de l'app";

Expand Down Expand Up @@ -34,6 +37,9 @@
/* Shown in record shortcut box */
"Decrease" = "Diminuer";

/* Shown in the alert dialog */
"Disable gamma control for my displays" = "Disable gamma control for my displays";

/* Shown in the main prefs window */
"Displays" = "Écrans";

Expand All @@ -52,6 +58,9 @@
/* Shown in the Display Preferences */
"Hardware (DDC)" = "Matériel (DDC)";

/* Shown in the alert dialog */
"I'll quit the other app" = "I'll quit the other app";

/* Shown in the alert dialog */
"Incompatible previous version" = "Version précédente incompatible";

Expand All @@ -61,6 +70,9 @@
/* Intel designation (shown after the version number in Preferences) */
"Intel" = "Intel";

/* Shown in the alert dialog */
"Is f.lux or similar running?" = "Is f.lux or similar running?";

/* Shown in the main prefs window */
"Keyboard" = "Clavier";

Expand Down
12 changes: 12 additions & 0 deletions MonitorControl/UI/hu.lproj/Localizable.strings
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
/* Shown in the main prefs window */
"About" = "Névjegy";

/* Shown in the alert dialog */
"An other app seems to change the brightness or colors which causes issues.\n\nTo solve this, you need to quit the other app or disable gamma control for your displays in MonitorControl!" = "An other app seems to change the brightness or colors which causes issues.\n\nTo solve this, you need to quit the other app or disable gamma control for your displays in MonitorControl!";

/* Shown in the main prefs window */
"App menu" = "Menü";

Expand Down Expand Up @@ -34,6 +37,9 @@
/* Shown in record shortcut box */
"Decrease" = "Csökkentés";

/* Shown in the alert dialog */
"Disable gamma control for my displays" = "Disable gamma control for my displays";

/* Shown in the main prefs window */
"Displays" = "Kijelzők";

Expand All @@ -52,6 +58,9 @@
/* Shown in the Display Preferences */
"Hardware (DDC)" = "Hardver (DDC)";

/* Shown in the alert dialog */
"I'll quit the other app" = "I'll quit the other app";

/* Shown in the alert dialog */
"Incompatible previous version" = "Inkompatibilis előző verzió";

Expand All @@ -61,6 +70,9 @@
/* Intel designation (shown after the version number in Preferences) */
"Intel" = "Intel";

/* Shown in the alert dialog */
"Is f.lux or similar running?" = "Is f.lux or similar running?";

/* Shown in the main prefs window */
"Keyboard" = "Billentyűzet";

Expand Down
12 changes: 12 additions & 0 deletions MonitorControl/UI/it.lproj/Localizable.strings
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
/* Shown in the main prefs window */
"About" = "Informazioni";

/* Shown in the alert dialog */
"An other app seems to change the brightness or colors which causes issues.\n\nTo solve this, you need to quit the other app or disable gamma control for your displays in MonitorControl!" = "An other app seems to change the brightness or colors which causes issues.\n\nTo solve this, you need to quit the other app or disable gamma control for your displays in MonitorControl!";

/* Shown in the main prefs window */
"App menu" = "App menu";

Expand Down Expand Up @@ -34,6 +37,9 @@
/* Shown in record shortcut box */
"Decrease" = "Diminiusci";

/* Shown in the alert dialog */
"Disable gamma control for my displays" = "Disable gamma control for my displays";

/* Shown in the main prefs window */
"Displays" = "Monitor";

Expand All @@ -52,6 +58,9 @@
/* Shown in the Display Preferences */
"Hardware (DDC)" = "Hardware (DDC)";

/* Shown in the alert dialog */
"I'll quit the other app" = "I'll quit the other app";

/* Shown in the alert dialog */
"Incompatible previous version" = "Versione precedente incompatibile";

Expand All @@ -61,6 +70,9 @@
/* Intel designation (shown after the version number in Preferences) */
"Intel" = "Intel";

/* Shown in the alert dialog */
"Is f.lux or similar running?" = "Is f.lux or similar running?";

/* Shown in the main prefs window */
"Keyboard" = "Tastiera";

Expand Down
Loading