SessionCtl // Implement the alternative init().

This commit is contained in:
ShikiSuen 2023-03-08 14:59:37 +08:00
parent 44dc2ee267
commit 164366d8fa
1 changed files with 14 additions and 1 deletions

View File

@ -169,6 +169,12 @@ public class SessionCtl: IMKInputController {
}
}
///
override public init() {
super.init()
construct(client: client())
}
///
///
/// inputClient IMKServer IMKTextInput
@ -179,6 +185,12 @@ public class SessionCtl: IMKInputController {
/// - inputClient:
override public init!(server: IMKServer!, delegate: Any!, client inputClient: Any!) {
super.init(server: server, delegate: delegate, client: inputClient)
let theClient = inputClient as? (IMKTextInput & NSObjectProtocol)
construct(client: theClient)
}
/// super.init()
private func construct(client theClient: (IMKTextInput & NSObjectProtocol)? = nil) {
DispatchQueue.main.async { [self] in
inputHandler = InputHandler(
lm: LMMgr.currentLM, uom: LMMgr.currentUOM, pref: PrefMgr.shared
@ -186,7 +198,8 @@ public class SessionCtl: IMKInputController {
inputHandler?.delegate = self
syncBaseLMPrefs()
//
activateServer(inputClient)
let maybeClient = theClient ?? client()
activateServer(maybeClient)
// GCD didSet
inputMode = .init(rawValue: PrefMgr.shared.mostRecentInputMode) ?? .imeModeNULL
}