SessionCtl // GCD the init() and IMK-related methods.

This commit is contained in:
ShikiSuen 2022-11-05 08:11:49 +08:00
parent bd0fe1bacc
commit 8f7d452a1d
1 changed files with 41 additions and 33 deletions

View File

@ -136,19 +136,21 @@ public class SessionCtl: IMKInputController {
/// - inputClient:
override public init!(server: IMKServer!, delegate: Any!, client inputClient: Any!) {
super.init(server: server, delegate: delegate, client: inputClient)
DispatchQueue.main.async { [self] in
inputHandler.delegate = self
syncBaseLMPrefs()
//
activateServer(inputClient)
// GCD didSet
inputMode = .init(rawValue: PrefMgr.shared.mostRecentInputMode) ?? .imeModeNULL
}
}
}
// MARK: -
extension SessionCtl {
/// 使
/// - Remark:
public func setKeyLayout() {
guard let client = client(), let myID = Bundle.main.bundleIdentifier, !myID.isEmpty,
clientBundleIdentifier != myID
@ -184,6 +186,7 @@ extension SessionCtl {
/// - Parameter sender: 使
public override func activateServer(_ sender: Any!) {
_ = sender //
DispatchQueue.main.async { [self] in
UserDefaults.standard.synchronize()
if Self.allInstances.contains(self) { return }
@ -209,16 +212,19 @@ extension SessionCtl {
Self.allInstances.insert(self)
setKeyLayout()
}
}
///
/// - Parameter sender: 使
public override func deactivateServer(_ sender: Any!) {
_ = sender //
DispatchQueue.main.async { [self] in
isActivated = false
resetInputHandler() // Empty
switchState(IMEState.ofDeactivated())
Self.allInstances.remove(self)
}
}
///
/// - Remark: activateServer() setValue()
@ -230,10 +236,12 @@ extension SessionCtl {
public override func setValue(_ value: Any!, forTag tag: Int, client sender: Any!) {
_ = tag //
_ = sender //
DispatchQueue.main.async { [self] in
let mostRecentInputMode = PrefMgr.shared.mostRecentInputMode
inputMode = .init(rawValue: value as? String ?? mostRecentInputMode) ?? .imeModeNULL
Self.isVerticalTyping = isVerticalTyping
}
}
///
public func syncBaseLMPrefs() {