macos: global keybind event tap only handles events when app is inactive

Fixes #2403
This commit is contained in:
Mitchell Hashimoto
2024-10-07 05:41:04 -10:00
parent 481e249958
commit 715df3f263

View File

@ -128,6 +128,11 @@ fileprivate func cgEventFlagsChangedHandler(
// We only care about keydown events
guard type == .keyDown else { return result }
// If our app is currently active then we don't process the key event.
// This is because we already have a local event handler in AppDelegate
// that processes all local events.
guard !NSApp.isActive else { return result }
// We need an app delegate to get the Ghostty app instance
guard let appDelegate = NSApplication.shared.delegate as? AppDelegate else { return result }
guard let ghostty = appDelegate.ghostty.app else { return result }