From 715df3f263309d438554e7f58acf3e1184a76e89 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Mon, 7 Oct 2024 05:41:04 -1000 Subject: [PATCH] macos: global keybind event tap only handles events when app is inactive Fixes #2403 --- macos/Sources/Features/Global Keybinds/GlobalEventTap.swift | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/macos/Sources/Features/Global Keybinds/GlobalEventTap.swift b/macos/Sources/Features/Global Keybinds/GlobalEventTap.swift index f1bb93506..935c2fb03 100644 --- a/macos/Sources/Features/Global Keybinds/GlobalEventTap.swift +++ b/macos/Sources/Features/Global Keybinds/GlobalEventTap.swift @@ -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 }