SessionCtl // Use GCD for Caps Lock processing.

This commit is contained in:
ShikiSuen 2022-09-30 12:14:27 +08:00
parent 030a8cb776
commit b286f23c69
1 changed files with 9 additions and 7 deletions

View File

@ -37,16 +37,18 @@ extension SessionCtl {
// Caps Lock
if event.type == .flagsChanged, event.keyCode == KeyCode.kCapsLock.rawValue {
let isCapsLockTurnedOn = event.modifierFlags.intersection(.deviceIndependentFlagsMask).contains(.capsLock)
let status = NSLocalizedString("NotificationSwitchASCII", comment: "")
if PrefMgr.shared.showNotificationsWhenTogglingCapsLock {
Notifier.notify(
message: isCapsLockTurnedOn
DispatchQueue.main.async {
let isCapsLockTurnedOn = event.modifierFlags.intersection(.deviceIndependentFlagsMask).contains(.capsLock)
let status = NSLocalizedString("NotificationSwitchASCII", comment: "")
if PrefMgr.shared.showNotificationsWhenTogglingCapsLock {
Notifier.notify(
message: isCapsLockTurnedOn
? "Caps Lock" + NSLocalizedString("Alphanumerical Input Mode", comment: "") + "\n" + status
: NSLocalizedString("Chinese Input Mode", comment: "") + "\n" + status
)
)
}
self.isASCIIMode = isCapsLockTurnedOn
}
isASCIIMode = isCapsLockTurnedOn
}
// Shift macOS 10.15 macOS