Revert "SessionCtl // Use GCD for certain state tasks."

This reverts commit 852eed07e2.
This commit is contained in:
ShikiSuen 2023-04-01 09:20:22 +08:00
parent c52e869f0c
commit 0639e9e289
2 changed files with 10 additions and 24 deletions

View File

@ -43,9 +43,6 @@ public class SessionCtl: IMKInputController {
///
public var isServingIMEItself: Bool = false
///
public var stateQueueSet = [String]()
/// bundleIdentifier
///
public var clientBundleIdentifier: String = "" {

View File

@ -12,20 +12,6 @@ import Shared
// MARK: - 調 (State Handling)
public extension SessionCtl {
private func performStateTask(_ doTask: @escaping () -> Void) {
let queueID = UUID().uuidString
DispatchQueue.main.async { [self] in
stateQueueSet.append(queueID)
while stateQueueSet.first != queueID {
Thread.sleep(forTimeInterval: 0.001)
}
doTask()
if stateQueueSet.first == queueID {
stateQueueSet.removeFirst()
}
}
}
/// 調
///
///
@ -57,8 +43,11 @@ public extension SessionCtl {
switch newState.type {
case .ofDeactivated:
// commitComposition()
// clearInlineDisplay()
// IMK inputMode.didSet()
hidePalettes()
candidateUI?.visible = false
popupCompositionBuffer.hide()
tooltipInstance.hide()
inputHandler?.clear()
if ![.ofAbortion, .ofEmpty].contains(previous.type), !previous.displayedText.isEmpty {
clearInlineDisplay()
@ -79,23 +68,23 @@ public extension SessionCtl {
commit(text: previous.displayedText)
}
//
performStateTask { self.showTooltip(newState.tooltip, duration: newState.tooltipDuration) }
showTooltip(newState.tooltip, duration: newState.tooltipDuration)
clearInlineDisplay()
inputHandler?.clear()
case .ofInputting:
candidateUI?.visible = false
if !newState.textToCommit.isEmpty { commit(text: newState.textToCommit) }
//
performStateTask { self.showTooltip(newState.tooltip, duration: newState.tooltipDuration) }
setInlineDisplayWithCursor()
//
showTooltip(newState.tooltip, duration: newState.tooltipDuration)
case .ofMarking:
candidateUI?.visible = false
performStateTask { self.showTooltip(newState.tooltip) }
setInlineDisplayWithCursor()
showTooltip(newState.tooltip)
case .ofCandidates, .ofAssociates, .ofSymbolTable:
performStateTask { self.showCandidates() }
setInlineDisplayWithCursor()
tooltipInstance.hide()
setInlineDisplayWithCursor()
showCandidates()
}
//
updatePopupDisplayWithCursor()