GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Fixing software dimming and custom keyboard issues (#671) · MonitorControl/MonitorControl@08c41c1

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • MonitorControlHelper
    • Info.plist
  • MonitorControl
    • Enums
      • PrefKey.swift
    • Info.plist
    • Model
      • Display.swift
      • OtherDisplay.swift
    • Support
      • KeyboardShortcutsManager.swift
    • UI
      • Base.lproj
        • Main.storyboard
      • de.lproj
        • Localizable.strings
        • Main.strings
      • en.lproj
        • Localizable.strings
        • Main.strings
      • es-419.lproj
        • Localizable.strings
        • Main.strings
      • fr.lproj
        • Localizable.strings
        • Main.strings
      • hu.lproj
        • Localizable.strings
        • Main.strings
      • it.lproj
        • Localizable.strings
        • Main.strings
      • ja.lproj
        • Localizable.strings
        • Main.strings
      • ko.lproj
        • Localizable.strings
        • Main.strings
      • nl.lproj
        • Localizable.strings
        • Main.strings
      • pl.lproj
        • Localizable.strings
        • Main.strings
      • ru.lproj
        • Localizable.strings
        • Main.strings
      • tr.lproj
        • Localizable.strings
        • Main.strings
      • uk.lproj
        • Localizable.strings
        • Main.strings
      • zh-Hans.lproj
        • Localizable.strings
        • Main.strings
      • zh-Hant-TW.lproj
        • Localizable.strings
        • Main.strings
    • View Controllers
      • DisplaysPrefsCellView.swift
      • DisplaysPrefsViewController.swift
      • MainPrefsViewController.swift
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎MonitorControl/Enums/PrefKey.swift‎

Copy file name to clipboardExpand all lines: MonitorControl/Enums/PrefKey.swift
+6Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ enum PrefKey: String {
2222
// DDC polling count for display
2323
case pollingCount
2424

25+
// Display should avoid gamma table manipulation and use shades instead (to coexist with other apps doing gamma manipulation)
26+
case avoidGamma
27+
2528
// Command value display
2629
case value
2730

@@ -127,6 +130,9 @@ enum PrefKey: String {
127130
// Change Brightness for all screens
128131
case allScreensBrightness
129132

133+
// Allow zero software brightness
134+
case allowZeroSwBrightness
135+
130136
// Use focus instead of mouse position to determine which display to control for brightness
131137
case useFocusInsteadOfMouse
132138

Collapse file

‎MonitorControl/Info.plist‎

Copy file name to clipboardExpand all lines: MonitorControl/Info.plist
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
<key>CFBundleShortVersionString</key>
2020
<string>$(MARKETING_VERSION)</string>
2121
<key>CFBundleVersion</key>
22-
<string>6395</string>
22+
<string>6421</string>
2323
<key>LSApplicationCategoryType</key>
2424
<string>public.app-category.utilities</string>
2525
<key>LSMinimumSystemVersion</key>
Collapse file

‎MonitorControl/Model/Display.swift‎

Copy file name to clipboardExpand all lines: MonitorControl/Model/Display.swift
+7-6Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ class Display: Equatable {
191191
}
192192

193193
func swBrightnessTransform(value: Float, reverse: Bool = false) -> Float {
194-
let lowTreshold: Float = 0.0 // If we don't want to allow zero brightness for safety reason, this value can be modified (for example to 0.1 for a 10% minimum)
194+
let lowTreshold: Float = prefs.bool(forKey: PrefKey.allowZeroSwBrightness.rawValue) ? 0.0 : 0.15
195195
if !reverse {
196196
return value * (1 - lowTreshold) + lowTreshold
197197
} else {
@@ -214,7 +214,7 @@ class Display: Equatable {
214214
guard app.reconfigureID == 0 else {
215215
return
216216
}
217-
if self.isVirtual {
217+
if self.isVirtual || self.readPrefAsBool(key: .avoidGamma) {
218218
_ = DisplayManager.shared.setShadeAlpha(value: 1 - transientValue, displayID: self.identifier)
219219
} else {
220220
let gammaTableRed = self.defaultGammaTableRed.map { $0 * transientValue }
@@ -227,8 +227,8 @@ class Display: Equatable {
227227
self.swBrightnessSemaphore.signal()
228228
}
229229
} else {
230-
if self.isVirtual {
231-
return DisplayManager.shared.setShadeAlpha(value: 1 - value, displayID: self.identifier)
230+
if self.isVirtual || self.readPrefAsBool(key: .avoidGamma) {
231+
return DisplayManager.shared.setShadeAlpha(value: 1 - newValue, displayID: self.identifier)
232232
} else {
233233
let gammaTableRed = self.defaultGammaTableRed.map { $0 * newValue }
234234
let gammaTableGreen = self.defaultGammaTableGreen.map { $0 * newValue }
@@ -242,8 +242,9 @@ class Display: Equatable {
242242
}
243243

244244
func getSwBrightness() -> Float {
245-
if self.isVirtual {
246-
return 1 - (DisplayManager.shared.getShadeAlpha(displayID: self.identifier) ?? 1)
245+
if self.isVirtual || self.readPrefAsBool(key: .avoidGamma) {
246+
let rawBrightnessValue = 1 - (DisplayManager.shared.getShadeAlpha(displayID: self.identifier) ?? 1)
247+
return self.swBrightnessTransform(value: rawBrightnessValue, reverse: true)
247248
}
248249
var gammaTableRed = [CGGammaValue](repeating: 0, count: 256)
249250
var gammaTableGreen = [CGGammaValue](repeating: 0, count: 256)
Collapse file

‎MonitorControl/Model/OtherDisplay.swift‎

Copy file name to clipboardExpand all lines: MonitorControl/Model/OtherDisplay.swift
+7-2Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,12 @@ class OtherDisplay: Display {
7676
func setupCurrentAndMaxValues(command: Command, firstrun: Bool = false) {
7777
var ddcValues: (UInt16, UInt16)?
7878
var maxDDCValue = UInt16(DDC_MAX_DETECT_LIMIT)
79-
var currentDDCValue = UInt16(Float(DDC_MAX_DETECT_LIMIT) * 1)
79+
var currentDDCValue: UInt16
80+
switch command {
81+
case .audioSpeakerVolume: currentDDCValue = UInt16(Float(self.DDC_MAX_DETECT_LIMIT) * 0.125)
82+
case .contrast: currentDDCValue = UInt16(Float(self.DDC_MAX_DETECT_LIMIT) * 0.750)
83+
default: currentDDCValue = UInt16(Float(self.DDC_MAX_DETECT_LIMIT) * 1.000)
84+
}
8085
if command == .audioSpeakerVolume {
8186
currentDDCValue = UInt16(Float(self.DDC_MAX_DETECT_LIMIT) * 0.125) // lower default audio value as high volume might rattle the user.
8287
}
@@ -114,7 +119,7 @@ class OtherDisplay: Display {
114119
_ = self.writeDDCValues(command: command, value: currentDDCValue)
115120
}
116121
} else {
117-
self.savePref(max(0.1, self.prefExists(for: command) ? self.readPrefAsFloat(for: command) : Float(1)), for: command)
122+
self.savePref(self.prefExists(for: command) ? self.readPrefAsFloat(for: command) : Float(1), for: command)
118123
self.savePref(self.readPrefAsFloat(for: command), key: .SwBrightness)
119124
self.brightnessSyncSourceValue = self.readPrefAsFloat(for: command)
120125
self.smoothBrightnessTransient = self.readPrefAsFloat(for: command)
Collapse file

‎MonitorControl/Support/KeyboardShortcutsManager.swift‎

Copy file name to clipboardExpand all lines: MonitorControl/Support/KeyboardShortcutsManager.swift
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@ class KeyboardShortcutsManager {
5656
}
5757

5858
func engage(_ shortcut: KeyboardShortcuts.Name) {
59-
self.initialKeyRepeat = UserDefaults.standard.double(forKey: "InitialKeyRepeat") * 0.014
60-
self.keyRepeat = UserDefaults.standard.double(forKey: "KeyRepeat") * 0.014
59+
self.initialKeyRepeat = max(15, UserDefaults.standard.double(forKey: "InitialKeyRepeat")) * 0.014
60+
self.keyRepeat = max(2, UserDefaults.standard.double(forKey: "KeyRepeat")) * 0.014
6161
self.currentCommand = shortcut
6262
self.isFirstKeypress = true
6363
self.isHold = true

0 commit comments

Comments
0 (0)
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.