From 8b0283cf5195a811e2e913fc81be3caa7ff213d6 Mon Sep 17 00:00:00 2001 From: ShikiSuen Date: Thu, 9 Feb 2023 16:43:17 +0800 Subject: [PATCH] SessionCtl // Make clientBundleIdentifier into a stored variable. --- Source/Modules/SessionCtl_Core.swift | 5 +++++ Source/Modules/SessionCtl_Delegates.swift | 5 ----- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Source/Modules/SessionCtl_Core.swift b/Source/Modules/SessionCtl_Core.swift index fee52c18..f433f23f 100644 --- a/Source/Modules/SessionCtl_Core.swift +++ b/Source/Modules/SessionCtl_Core.swift @@ -43,6 +43,10 @@ public class SessionCtl: IMKInputController { /// 當前副本的客體是否是輸入法本體? public var isServingIMEItself: Bool = false + /// 用以存儲客體的 bundleIdentifier。 + /// 由於每次動態獲取都會耗時,所以這裡直接靜態記載之。 + public var clientBundleIdentifier: String = "" + // MARK: - /// 當前 Caps Lock 按鍵是否被摁下。 @@ -216,6 +220,7 @@ public extension SessionCtl { if let senderBundleID: String = (sender as? IMKTextInput)?.bundleIdentifier() { vCLog("activateServer(\(senderBundleID))") isServingIMEItself = Bundle.main.bundleIdentifier == senderBundleID + clientBundleIdentifier = senderBundleID } } DispatchQueue.main.async { diff --git a/Source/Modules/SessionCtl_Delegates.swift b/Source/Modules/SessionCtl_Delegates.swift index 51ede93c..ed63d513 100644 --- a/Source/Modules/SessionCtl_Delegates.swift +++ b/Source/Modules/SessionCtl_Delegates.swift @@ -11,11 +11,6 @@ import Shared // MARK: - InputHandler Delegate extension SessionCtl: InputHandlerDelegate { - public var clientBundleIdentifier: String { - guard let client = client() else { return "" } - return client.bundleIdentifier() ?? "" - } - public func candidateController() -> CtlCandidateProtocol? { candidateUI } public func candidateSelectionCalledByInputHandler(at index: Int) {