SessionCtl // Revamp setKeyLayout().

This commit is contained in:
ShikiSuen 2022-11-04 16:47:02 +08:00
parent 9fc54412cc
commit f57238f380
1 changed files with 6 additions and 16 deletions

View File

@ -121,7 +121,6 @@ public class SessionCtl: IMKInputController {
syncBaseLMPrefs() syncBaseLMPrefs()
// ---------------------------- // ----------------------------
Self.isVerticalTyping = isVerticalTyping Self.isVerticalTyping = isVerticalTyping
// 使
switchState(IMEState.ofEmpty()) switchState(IMEState.ofEmpty())
} }
} }
@ -142,30 +141,25 @@ public class SessionCtl: IMKInputController {
// //
activateServer(inputClient) activateServer(inputClient)
if PrefMgr.shared.onlyLoadFactoryLangModelsIfNeeded { LMMgr.loadDataModel(IMEApp.currentInputMode) } if PrefMgr.shared.onlyLoadFactoryLangModelsIfNeeded { LMMgr.loadDataModel(IMEApp.currentInputMode) }
if let myID = Bundle.main.bundleIdentifier, !myID.isEmpty, !clientBundleIdentifier.contains(myID) {
setKeyLayout()
}
} }
} }
// MARK: - // MARK: -
extension SessionCtl { extension SessionCtl {
/// /// 使
public func setKeyLayout() { public func setKeyLayout() {
guard let client = client() else { return } guard let client = client(), let myID = Bundle.main.bundleIdentifier, !myID.isEmpty,
clientBundleIdentifier != myID
else { return }
func doSetKeyLayout() { DispatchQueue.main.async { [self] in
if isASCIIMode, IMKHelper.isDynamicBasicKeyboardLayoutEnabled { if isASCIIMode, IMKHelper.isDynamicBasicKeyboardLayoutEnabled {
client.overrideKeyboard(withKeyboardNamed: PrefMgr.shared.alphanumericalKeyboardLayout) client.overrideKeyboard(withKeyboardNamed: PrefMgr.shared.alphanumericalKeyboardLayout)
return return
} }
client.overrideKeyboard(withKeyboardNamed: PrefMgr.shared.basicKeyboardLayout) client.overrideKeyboard(withKeyboardNamed: PrefMgr.shared.basicKeyboardLayout)
} }
DispatchQueue.main.async {
doSetKeyLayout()
}
} }
/// 調 /// 調
@ -212,6 +206,7 @@ extension SessionCtl {
switchState(IMEState.ofEmpty()) switchState(IMEState.ofEmpty())
isActivated = true // isActivated = true //
Self.allInstances.insert(self) Self.allInstances.insert(self)
setKeyLayout()
} }
/// ///
@ -235,11 +230,6 @@ extension SessionCtl {
let newInputMode: Shared.InputMode = .init(rawValue: value as? String ?? "") ?? .imeModeNULL let newInputMode: Shared.InputMode = .init(rawValue: value as? String ?? "") ?? .imeModeNULL
if PrefMgr.shared.onlyLoadFactoryLangModelsIfNeeded { LMMgr.loadDataModel(newInputMode) } if PrefMgr.shared.onlyLoadFactoryLangModelsIfNeeded { LMMgr.loadDataModel(newInputMode) }
inputMode = newInputMode inputMode = newInputMode
if let rawValString = value as? String, let bundleID = Bundle.main.bundleIdentifier,
!bundleID.isEmpty, !rawValString.contains(bundleID)
{
setKeyLayout()
}
} }
/// ///