ctlIME // Optimizing modifier key conditions (Rebased).

- Flag Change Conditioning shall not get removed. Otherwise, when in the empty state, the first character being input won't be parsed by the IME.
- "return false" is the one that passing trash data to the "still nothing" section of the KeyHandler. Removing the "still nothing" allows these trash data to be passed to IMK but can lead to problems like misbehaved F1-F12 keys, etc., plus triggering "NSInternalInconsistencyException" for each modifier key input.
This commit is contained in:
ShikiSuen 2022-03-20 12:57:17 +08:00
parent a3ce7e71cd
commit e946014bce
1 changed files with 11 additions and 14 deletions

View File

@ -188,25 +188,22 @@ class ctlInputMethod: IMKInputController {
override func handle(_ event: NSEvent!, client: Any!) -> Bool { override func handle(_ event: NSEvent!, client: Any!) -> Bool {
if event.type == .flagsChanged { // flags使 KeyHandler
let functionKeyKeyboardLayoutID = mgrPrefs.functionKeyboardLayout // flags
let basisKeyboardLayoutID = mgrPrefs.basisKeyboardLayout // event.type == .flagsChanged return false
// NSInternalInconsistencyException
if functionKeyKeyboardLayoutID == basisKeyboardLayoutID { if (mgrPrefs.functionKeyboardLayout != mgrPrefs.basisKeyboardLayout) && (event.type == .flagsChanged) {
return false
}
let includeShift = mgrPrefs.functionKeyKeyboardLayoutOverrideIncludeShiftKey let includeShift = mgrPrefs.functionKeyKeyboardLayoutOverrideIncludeShiftKey
if (event.modifierFlags == .capsLock ||
if event.modifierFlags.contains(.capsLock) || event.modifierFlags.contains(.command) ||
event.modifierFlags.contains(.option) || event.modifierFlags.contains(.option) ||
event.modifierFlags.contains(.control) || event.modifierFlags.contains(.control) ||
event.modifierFlags.contains(.function) || event.modifierFlags.contains(.function) ||
(event.modifierFlags.contains(.shift) && includeShift) { (event.modifierFlags.contains(.shift) && includeShift)) {
(client as? IMKTextInput)?.overrideKeyboard(withKeyboardNamed: functionKeyKeyboardLayoutID) (client as? IMKTextInput)?.overrideKeyboard(withKeyboardNamed: mgrPrefs.functionKeyboardLayout)
return false } else {
(client as? IMKTextInput)?.overrideKeyboard(withKeyboardNamed: mgrPrefs.basisKeyboardLayout)
} }
(client as? IMKTextInput)?.overrideKeyboard(withKeyboardNamed: basisKeyboardLayoutID)
return false return false
} }