From cbdcb1a7c81b17bdc2f5a7b11f9fed6ab043ce8a Mon Sep 17 00:00:00 2001 From: ShikiSuen Date: Wed, 21 Jun 2023 22:44:05 +0800 Subject: [PATCH] SessionCtl // Add isBootingUp(). --- Source/Modules/SessionCtl_Core.swift | 11 +++++++++++ Source/Modules/SessionCtl_IMKCandidatesData.swift | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/Source/Modules/SessionCtl_Core.swift b/Source/Modules/SessionCtl_Core.swift index eedd1a4d..f4e7d367 100644 --- a/Source/Modules/SessionCtl_Core.swift +++ b/Source/Modules/SessionCtl_Core.swift @@ -58,6 +58,16 @@ public class SessionCtl: IMKInputController { /// 用來標記當前副本是否已處於活動狀態。 public var isActivated = false + /// 用来記錄當前副本是否處於開機階段(activateServer 執行後 0.1 秒以內都算)。 + public private(set) var isBootingUp: Bool = true { + didSet { + guard isBootingUp else { return } + DispatchQueue.main.asyncAfter(deadline: .now() + 0.1) { + self.isBootingUp = false + } + } + } + /// 當前副本的客體是否是輸入法本體? public var isServingIMEItself: Bool = false @@ -274,6 +284,7 @@ public extension SessionCtl { /// - Parameter sender: 呼叫了該函式的客體。 override func activateServer(_ sender: Any!) { super.activateServer(sender) + isBootingUp = true DispatchQueue.main.async { [self] in if let senderBundleID: String = (sender as? IMKTextInput)?.bundleIdentifier() { vCLog("activateServer(\(senderBundleID))") diff --git a/Source/Modules/SessionCtl_IMKCandidatesData.swift b/Source/Modules/SessionCtl_IMKCandidatesData.swift index 77def6a3..19577ff5 100644 --- a/Source/Modules/SessionCtl_IMKCandidatesData.swift +++ b/Source/Modules/SessionCtl_IMKCandidatesData.swift @@ -183,7 +183,7 @@ public extension SessionCtl { /// 雖然所有在這個函式內影響到的變數都改為動態變數了(不會出現跨副本波及的情況), /// 但 IMKCandidates 是有內部共用副本的、會被波及。所以在這裡糾偏一下。 internal func keepIMKCandidatesShownUp() { - guard PrefMgr.shared.useIMKCandidateWindow else { return } + guard PrefMgr.shared.useIMKCandidateWindow, isBootingUp else { return } guard let imkC = candidateUI as? CtlCandidateIMK else { return } var i: Double = 0 while i < 1 {