Fix keyRepeatTimer issue with multiple displays while holding down a MediaKey

When holding down a mediakey, we'd get stuck inside the specific keyRepeatTimer block in the display loop. This caused only one display (the first one in the array) to be controlled while holding down a mediakey.
This commit is contained in:
JoniVR 2020-02-01 14:34:40 +01:00
parent 9f0bcae004
commit bfeb5fc5f5
3 changed files with 20 additions and 22 deletions

View file

@ -231,31 +231,29 @@ extension AppDelegate: MediaKeyTapDelegate {
// Introduce a small delay to handle the media key being held down
let delay = isRepeat ? 0.05 : 0
for display in allDisplays where display.isEnabled {
switch mediaKey {
case .brightnessUp, .brightnessDown:
self.keyRepeatTimers[mediaKey] = Timer.scheduledTimer(withTimeInterval: delay, repeats: false, block: { _ in
self.keyRepeatTimers[mediaKey] = Timer.scheduledTimer(withTimeInterval: delay, repeats: false, block: { _ in
for display in allDisplays where display.isEnabled {
switch mediaKey {
case .brightnessUp, .brightnessDown:
display.stepBrightness(isUp: mediaKey == .brightnessUp, isSmallIncrement: isSmallIncrement)
})
case .mute:
// The mute key should not respond to press + hold
if !isRepeat {
// mute only matters for external displays
if let display = display as? ExternalDisplay {
display.toggleMute()
case .mute:
// The mute key should not respond to press + hold
if !isRepeat {
// mute only matters for external displays
if let display = display as? ExternalDisplay {
display.toggleMute()
}
}
}
case .volumeUp, .volumeDown:
// volume only matters for external displays
if let display = display as? ExternalDisplay {
self.keyRepeatTimers[mediaKey] = Timer.scheduledTimer(withTimeInterval: delay, repeats: false, block: { _ in
case .volumeUp, .volumeDown:
// volume only matters for external displays
if let display = display as? ExternalDisplay {
display.stepVolume(isUp: mediaKey == .volumeUp, isSmallIncrement: isSmallIncrement)
})
}
default:
return
}
default:
return
}
}
})
}
// MARK: - Prefs notification

View file

@ -19,7 +19,7 @@
<key>CFBundleShortVersionString</key>
<string>$(MARKETING_VERSION)</string>
<key>CFBundleVersion</key>
<string>636</string>
<string>637</string>
<key>LSApplicationCategoryType</key>
<string>public.app-category.utilities</string>
<key>LSMinimumSystemVersion</key>

View file

@ -19,7 +19,7 @@
<key>CFBundleShortVersionString</key>
<string>$(MARKETING_VERSION)</string>
<key>CFBundleVersion</key>
<string>636</string>
<string>637</string>
<key>LSApplicationCategoryType</key>
<string>public.app-category.utilities</string>
<key>LSBackgroundOnly</key>