ctlIME // Stop detecting flagsChanged when handling layouts.

- Also optimizing modifier key conditions.
This commit is contained in:
ShikiSuen 2022-03-20 12:57:17 +08:00
parent 7e10aca1f6
commit 73f95e0d9c
1 changed files with 7 additions and 14 deletions

View File

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