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