mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-06-05 06:58:38 +03:00
macos: reuse original event if translation mods changes nothing
Fixes #766 (again) This is a repeat fix of 766 after fixing a number of other regressions from the original fix. See the comment for reasons.
This commit is contained in:
@ -750,19 +750,28 @@ extension Ghostty {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Build a new NSEvent we use only for translation
|
// If the translation modifiers are not equal to our original modifiers
|
||||||
let translationEvent = NSEvent.keyEvent(
|
// then we need to construct a new NSEvent. If they are equal we reuse the
|
||||||
with: event.type,
|
// old one. IMPORTANT: we MUST reuse the old event if they're equal because
|
||||||
location: event.locationInWindow,
|
// this keeps things like Korean input working. There must be some object
|
||||||
modifierFlags: translationMods,
|
// equality happening in AppKit somewhere because this is required.
|
||||||
timestamp: event.timestamp,
|
let translationEvent: NSEvent
|
||||||
windowNumber: event.windowNumber,
|
if (translationMods == event.modifierFlags) {
|
||||||
context: nil,
|
translationEvent = event
|
||||||
characters: event.characters(byApplyingModifiers: translationMods) ?? "",
|
} else {
|
||||||
charactersIgnoringModifiers: event.charactersIgnoringModifiers ?? "",
|
translationEvent = NSEvent.keyEvent(
|
||||||
isARepeat: event.isARepeat,
|
with: event.type,
|
||||||
keyCode: event.keyCode
|
location: event.locationInWindow,
|
||||||
) ?? event
|
modifierFlags: translationMods,
|
||||||
|
timestamp: event.timestamp,
|
||||||
|
windowNumber: event.windowNumber,
|
||||||
|
context: nil,
|
||||||
|
characters: event.characters(byApplyingModifiers: translationMods) ?? "",
|
||||||
|
charactersIgnoringModifiers: event.charactersIgnoringModifiers ?? "",
|
||||||
|
isARepeat: event.isARepeat,
|
||||||
|
keyCode: event.keyCode
|
||||||
|
) ?? event
|
||||||
|
}
|
||||||
|
|
||||||
// By setting this to non-nil, we note that we'rein a keyDown event. From here,
|
// By setting this to non-nil, we note that we'rein a keyDown event. From here,
|
||||||
// we call interpretKeyEvents so that we can handle complex input such as Korean
|
// we call interpretKeyEvents so that we can handle complex input such as Korean
|
||||||
|
Reference in New Issue
Block a user