ctlIME // Fix IME-windows hang when regaining focus.
- Certain IMK functions could result in infinite loops when an IME-domestic Window is being focused regardless whether the current IME is switched to something else).
This commit is contained in:
parent
f0d6ade3c7
commit
27af2f569d
|
@ -65,8 +65,9 @@ class ctlInputMethod: IMKInputController {
|
||||||
// MARK: - Keyboard Layout Specifier
|
// MARK: - Keyboard Layout Specifier
|
||||||
|
|
||||||
@objc func setKeyLayout() {
|
@objc func setKeyLayout() {
|
||||||
let client = client().self as IMKTextInput
|
if let client = currentClient {
|
||||||
client.overrideKeyboard(withKeyboardNamed: mgrPrefs.basicKeyboardLayout)
|
(client as? IMKTextInput)?.overrideKeyboard(withKeyboardNamed: mgrPrefs.basicKeyboardLayout)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARK: - IMKInputController methods
|
// MARK: - IMKInputController methods
|
||||||
|
@ -90,14 +91,18 @@ class ctlInputMethod: IMKInputController {
|
||||||
override func activateServer(_ client: Any!) {
|
override func activateServer(_ client: Any!) {
|
||||||
UserDefaults.standard.synchronize()
|
UserDefaults.standard.synchronize()
|
||||||
|
|
||||||
// Override the keyboard layout to the basic one.
|
|
||||||
setKeyLayout()
|
|
||||||
// reset the state
|
// reset the state
|
||||||
currentClient = client
|
currentClient = client
|
||||||
|
|
||||||
keyHandler.clear()
|
keyHandler.clear()
|
||||||
keyHandler.syncWithPreferences()
|
keyHandler.syncWithPreferences()
|
||||||
self.handle(state: .Empty(), client: client)
|
if let bundleCheckID = (client as? IMKTextInput)?.bundleIdentifier() {
|
||||||
|
if bundleCheckID != Bundle.main.bundleIdentifier {
|
||||||
|
// Override the keyboard layout to the basic one.
|
||||||
|
setKeyLayout()
|
||||||
|
self.handle(state: .Empty(), client: client)
|
||||||
|
}
|
||||||
|
}
|
||||||
(NSApp.delegate as? AppDelegate)?.checkForUpdate()
|
(NSApp.delegate as? AppDelegate)?.checkForUpdate()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -120,14 +125,18 @@ class ctlInputMethod: IMKInputController {
|
||||||
}
|
}
|
||||||
mgrLangModel.loadDataModel(newInputMode)
|
mgrLangModel.loadDataModel(newInputMode)
|
||||||
|
|
||||||
// Remember to override the keyboard layout again -- treat this as an activate event.
|
|
||||||
setKeyLayout()
|
|
||||||
|
|
||||||
if keyHandler.inputMode != newInputMode {
|
if keyHandler.inputMode != newInputMode {
|
||||||
|
|
||||||
UserDefaults.standard.synchronize()
|
UserDefaults.standard.synchronize()
|
||||||
keyHandler.clear()
|
keyHandler.clear()
|
||||||
keyHandler.inputMode = newInputMode
|
keyHandler.inputMode = newInputMode
|
||||||
self.handle(state: .Empty(), client: client)
|
if let bundleCheckID = (client as? IMKTextInput)?.bundleIdentifier() {
|
||||||
|
if bundleCheckID != Bundle.main.bundleIdentifier {
|
||||||
|
// Remember to override the keyboard layout again -- treat this as an activate event.
|
||||||
|
setKeyLayout()
|
||||||
|
self.handle(state: .Empty(), client: client)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 讓外界知道目前的簡繁體輸入模式。
|
// 讓外界知道目前的簡繁體輸入模式。
|
||||||
|
|
Loading…
Reference in New Issue