mirror of
https://github.com/MonitorControl/MonitorControl.git
synced 2026-05-15 22:01:08 -06:00
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:
parent
9f0bcae004
commit
bfeb5fc5f5
3 changed files with 20 additions and 22 deletions
|
|
@ -231,31 +231,29 @@ extension AppDelegate: MediaKeyTapDelegate {
|
||||||
// Introduce a small delay to handle the media key being held down
|
// Introduce a small delay to handle the media key being held down
|
||||||
let delay = isRepeat ? 0.05 : 0
|
let delay = isRepeat ? 0.05 : 0
|
||||||
|
|
||||||
for display in allDisplays where display.isEnabled {
|
self.keyRepeatTimers[mediaKey] = Timer.scheduledTimer(withTimeInterval: delay, repeats: false, block: { _ in
|
||||||
switch mediaKey {
|
for display in allDisplays where display.isEnabled {
|
||||||
case .brightnessUp, .brightnessDown:
|
switch mediaKey {
|
||||||
self.keyRepeatTimers[mediaKey] = Timer.scheduledTimer(withTimeInterval: delay, repeats: false, block: { _ in
|
case .brightnessUp, .brightnessDown:
|
||||||
display.stepBrightness(isUp: mediaKey == .brightnessUp, isSmallIncrement: isSmallIncrement)
|
display.stepBrightness(isUp: mediaKey == .brightnessUp, isSmallIncrement: isSmallIncrement)
|
||||||
})
|
case .mute:
|
||||||
case .mute:
|
// The mute key should not respond to press + hold
|
||||||
// The mute key should not respond to press + hold
|
if !isRepeat {
|
||||||
if !isRepeat {
|
// mute only matters for external displays
|
||||||
// mute only matters for external displays
|
if let display = display as? ExternalDisplay {
|
||||||
if let display = display as? ExternalDisplay {
|
display.toggleMute()
|
||||||
display.toggleMute()
|
}
|
||||||
}
|
}
|
||||||
}
|
case .volumeUp, .volumeDown:
|
||||||
case .volumeUp, .volumeDown:
|
// volume only matters for external displays
|
||||||
// volume only matters for external displays
|
if let display = display as? ExternalDisplay {
|
||||||
if let display = display as? ExternalDisplay {
|
|
||||||
self.keyRepeatTimers[mediaKey] = Timer.scheduledTimer(withTimeInterval: delay, repeats: false, block: { _ in
|
|
||||||
display.stepVolume(isUp: mediaKey == .volumeUp, isSmallIncrement: isSmallIncrement)
|
display.stepVolume(isUp: mediaKey == .volumeUp, isSmallIncrement: isSmallIncrement)
|
||||||
})
|
}
|
||||||
|
default:
|
||||||
|
return
|
||||||
}
|
}
|
||||||
default:
|
|
||||||
return
|
|
||||||
}
|
}
|
||||||
}
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARK: - Prefs notification
|
// MARK: - Prefs notification
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@
|
||||||
<key>CFBundleShortVersionString</key>
|
<key>CFBundleShortVersionString</key>
|
||||||
<string>$(MARKETING_VERSION)</string>
|
<string>$(MARKETING_VERSION)</string>
|
||||||
<key>CFBundleVersion</key>
|
<key>CFBundleVersion</key>
|
||||||
<string>636</string>
|
<string>637</string>
|
||||||
<key>LSApplicationCategoryType</key>
|
<key>LSApplicationCategoryType</key>
|
||||||
<string>public.app-category.utilities</string>
|
<string>public.app-category.utilities</string>
|
||||||
<key>LSMinimumSystemVersion</key>
|
<key>LSMinimumSystemVersion</key>
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@
|
||||||
<key>CFBundleShortVersionString</key>
|
<key>CFBundleShortVersionString</key>
|
||||||
<string>$(MARKETING_VERSION)</string>
|
<string>$(MARKETING_VERSION)</string>
|
||||||
<key>CFBundleVersion</key>
|
<key>CFBundleVersion</key>
|
||||||
<string>636</string>
|
<string>637</string>
|
||||||
<key>LSApplicationCategoryType</key>
|
<key>LSApplicationCategoryType</key>
|
||||||
<string>public.app-category.utilities</string>
|
<string>public.app-category.utilities</string>
|
||||||
<key>LSBackgroundOnly</key>
|
<key>LSBackgroundOnly</key>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue