From b286f23c69ec0712de7c0d58b18d7ae5927caeb7 Mon Sep 17 00:00:00 2001 From: ShikiSuen Date: Fri, 30 Sep 2022 12:14:27 +0800 Subject: [PATCH] SessionCtl // Use GCD for Caps Lock processing. --- Source/Modules/SessionCtl_HandleEvent.swift | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/Source/Modules/SessionCtl_HandleEvent.swift b/Source/Modules/SessionCtl_HandleEvent.swift index 73caac25..cebf4250 100644 --- a/Source/Modules/SessionCtl_HandleEvent.swift +++ b/Source/Modules/SessionCtl_HandleEvent.swift @@ -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 有效。