diff --git a/Source/Modules/SessionCtl_Core.swift b/Source/Modules/SessionCtl_Core.swift index 1a898266..d850dad1 100644 --- a/Source/Modules/SessionCtl_Core.swift +++ b/Source/Modules/SessionCtl_Core.swift @@ -167,15 +167,6 @@ public class SessionCtl: IMKInputController { /// 將輸入法偏好設定同步至語言模組內。 syncBaseLMPrefs() } - // 特殊處理:deactivateServer() 可能會遲於另一個客體會話的 activateServer() 執行。 - // 雖然所有在這個函式內影響到的變數都改為動態變數了(不會出現跨副本波及的情況), - // 但 IMKCandidates 是有內部共用副本的、會被波及。所以在這裡糾偏一下。 - if PrefMgr.shared.useIMKCandidateWindow { - guard let imkC = candidateUI as? CtlCandidateIMK else { return } - if state.isCandidateContainer, !imkC.visible { - handle(state: state, replace: false) - } - } } } diff --git a/Source/Modules/SessionCtl_HandleDisplay.swift b/Source/Modules/SessionCtl_HandleDisplay.swift index 132c8b2f..88b0b3e0 100644 --- a/Source/Modules/SessionCtl_HandleDisplay.swift +++ b/Source/Modules/SessionCtl_HandleDisplay.swift @@ -74,6 +74,7 @@ public extension SessionCtl { func showCandidates() { guard client() != nil else { return } + defer { keepIMKCandidatesShownUp() } updateVerticalTypingStatus() isVerticalCandidateWindow = (isVerticalTyping || !PrefMgr.shared.useHorizontalCandidateList) diff --git a/Source/Modules/SessionCtl_IMKCandidatesData.swift b/Source/Modules/SessionCtl_IMKCandidatesData.swift index cb5b5014..3799f0f3 100644 --- a/Source/Modules/SessionCtl_IMKCandidatesData.swift +++ b/Source/Modules/SessionCtl_IMKCandidatesData.swift @@ -169,4 +169,21 @@ public extension SessionCtl { } } } + + /// 特殊處理:deactivateServer() 可能會遲於另一個客體會話的 activateServer() 執行。 + /// 雖然所有在這個函式內影響到的變數都改為動態變數了(不會出現跨副本波及的情況), + /// 但 IMKCandidates 是有內部共用副本的、會被波及。所以在這裡糾偏一下。 + internal func keepIMKCandidatesShownUp() { + guard PrefMgr.shared.useIMKCandidateWindow else { return } + guard let imkC = candidateUI as? CtlCandidateIMK else { return } + var i: Double = 0 + while i < 1 { + DispatchQueue.main.asyncAfter(deadline: .now() + i) { [self] in + if state.isCandidateContainer, !imkC.visible { + imkC.visible = true + } + } + i += 0.3 + } + } }