Skip to content

Commit 6b12e3c

Browse files
committed
Fix hideDisplayOsd lag.
1 parent c8608b1 commit 6b12e3c

File tree

4 files changed

+34
-26
lines changed

4 files changed

+34
-26
lines changed

Cartfile.resolved

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
github "reitermarkus/DDC.swift" "a29f1975f46745580990269a3dc26873737f24bb"
1+
github "reitermarkus/DDC.swift" "05141d5bb5d5fd77b22701d03fbec7586aad8fd7"
22
github "rnine/AMCoreAudio" "3.2.1"
33
github "shpakovski/MASPreferences" "1.3"
44
github "the0neyouseek/MediaKeyTap" "abfe09f53ccabb1aa14a0f4ab99cfb8812f41919"

MonitorControl/Display.swift

Lines changed: 31 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -28,18 +28,7 @@ class Display {
2828
}
2929

3030
_ = self.ddc?.write(command: .onScreenDisplay, value: 1)
31-
32-
DispatchQueue.global(qos: .background).asyncAfter(deadline: DispatchTime.now() + 0.000001) {
33-
_ = self.ddc?.write(command: .onScreenDisplay, value: 1)
34-
}
35-
36-
DispatchQueue.global(qos: .background).asyncAfter(deadline: DispatchTime.now() + 0.00001) {
37-
_ = self.ddc?.write(command: .onScreenDisplay, value: 1)
38-
}
39-
40-
DispatchQueue.global(qos: .background).asyncAfter(deadline: DispatchTime.now() + 0.0001) {
41-
_ = self.ddc?.write(command: .onScreenDisplay, value: 1)
42-
}
31+
_ = self.ddc?.write(command: .onScreenDisplay, value: 1)
4332
}
4433

4534
func mute() {
@@ -51,53 +40,72 @@ class Display {
5140
self.isMuted = true
5241
}
5342

54-
_ = self.ddc?.write(command: .audioSpeakerVolume, value: UInt8(value))
55-
self.hideDisplayOsd()
43+
DispatchQueue.global(qos: .userInitiated).async {
44+
guard self.ddc?.write(command: .audioSpeakerVolume, value: UInt8(value)) == true else {
45+
return
46+
}
47+
48+
self.hideDisplayOsd()
49+
self.showOsd(command: .audioSpeakerVolume, value: value)
50+
}
5651

5752
if let slider = volumeSliderHandler?.slider {
5853
slider.intValue = Int32(value)
5954
}
60-
61-
self.showOsd(command: .audioSpeakerVolume, value: value)
6255
}
6356

6457
func setVolume(to value: Int) {
6558
if value > 0 {
6659
self.isMuted = false
6760
}
6861

69-
_ = self.ddc?.write(command: .audioSpeakerVolume, value: UInt8(value))
70-
self.hideDisplayOsd()
62+
DispatchQueue.global(qos: .userInitiated).async {
63+
guard self.ddc?.write(command: .audioSpeakerVolume, value: UInt8(value)) == true else {
64+
return
65+
}
66+
67+
self.hideDisplayOsd()
68+
self.showOsd(command: .audioSpeakerVolume, value: value)
69+
}
7170

7271
if let slider = volumeSliderHandler?.slider {
7372
slider.intValue = Int32(value)
7473
}
7574

76-
self.showOsd(command: .audioSpeakerVolume, value: value)
7775
self.saveValue(value, for: .audioSpeakerVolume)
7876
}
7977

8078
func setBrightness(to value: Int) {
8179
if self.prefs.bool(forKey: Utils.PrefKeys.lowerContrast.rawValue) {
8280
if value == 0 {
83-
_ = self.ddc?.write(command: .contrast, value: UInt8(value))
81+
DispatchQueue.global(qos: .userInitiated).async {
82+
_ = self.ddc?.write(command: .contrast, value: UInt8(value))
83+
}
8484

8585
if let slider = contrastSliderHandler?.slider {
8686
slider.intValue = Int32(value)
8787
}
8888
} else if self.prefs.integer(forKey: "\(DDC.Command.brightness.value)-\(self.identifier)") == 0 {
8989
let contrastValue = self.prefs.integer(forKey: "\(DDC.Command.contrast.value)-\(self.identifier)")
90-
_ = self.ddc?.write(command: .contrast, value: UInt8(contrastValue))
90+
91+
DispatchQueue.global(qos: .userInitiated).async {
92+
_ = self.ddc?.write(command: .contrast, value: UInt8(contrastValue))
93+
}
9194
}
9295
}
9396

94-
_ = self.ddc?.write(command: .brightness, value: UInt8(value))
97+
DispatchQueue.global(qos: .userInitiated).async {
98+
guard self.ddc?.write(command: .brightness, value: UInt8(value)) == true else {
99+
return
100+
}
101+
102+
self.showOsd(command: .brightness, value: value)
103+
}
95104

96105
if let slider = brightnessSliderHandler?.slider {
97106
slider.intValue = Int32(value)
98107
}
99108

100-
self.showOsd(command: .brightness, value: value)
101109
self.saveValue(value, for: .brightness)
102110
}
103111

MonitorControl/Info.plist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
<key>CFBundleShortVersionString</key>
2020
<string>1.5.1</string>
2121
<key>CFBundleVersion</key>
22-
<string>289</string>
22+
<string>318</string>
2323
<key>LSApplicationCategoryType</key>
2424
<string>public.app-category.utilities</string>
2525
<key>LSMinimumSystemVersion</key>

MonitorControlHelper/Info.plist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
<key>CFBundleShortVersionString</key>
2020
<string>1.5.1</string>
2121
<key>CFBundleVersion</key>
22-
<string>289</string>
22+
<string>318</string>
2323
<key>LSApplicationCategoryType</key>
2424
<string>public.app-category.utilities</string>
2525
<key>LSBackgroundOnly</key>

0 commit comments

Comments
 (0)