SessionCtl // Disable setMarkedText() on deactivateServer().

This commit is contained in:
ShikiSuen 2022-11-04 16:30:39 +08:00
parent b203e46398
commit 4d213f569b
2 changed files with 7 additions and 2 deletions

View File

@ -48,6 +48,9 @@ public class SessionCtl: IMKInputController {
///
public var popupCompositionBuffer = PopupCompositionBuffer()
///
public var isActivated = false
// MARK: -
/// Caps Lock
@ -207,6 +210,7 @@ extension SessionCtl {
}
switchState(IMEState.ofEmpty())
isActivated = true //
Self.allInstances.insert(self)
}
@ -214,6 +218,7 @@ extension SessionCtl {
/// - Parameter sender: 使
public override func deactivateServer(_ sender: Any!) {
_ = sender //
isActivated = false
resetInputHandler() // Empty
switchState(IMEState.ofDeactivated())
Self.allInstances.remove(self)

View File

@ -48,7 +48,7 @@ extension SessionCtl {
if previous.hasComposition {
commit(text: previous.displayedText)
}
clearInlineDisplay() // client guard-let #346
// clearInlineDisplay() //
//
inputHandler.clear()
// deactivateServer() activateServer()
@ -150,7 +150,7 @@ extension SessionCtl {
/// setMarkedText GCD
public func doSetMarkedText(_ string: Any!, selectionRange: NSRange, replacementRange: NSRange) {
guard let client = client() else { return }
guard isActivated, let client = client() else { return }
if let myID = Bundle.main.bundleIdentifier, let clientID = client.bundleIdentifier(), myID == clientID {
DispatchQueue.main.async {
client.setMarkedText(string, selectionRange: selectionRange, replacementRange: replacementRange)