From 6854fe91abc5a685615e05286164e2dceb075861 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Fri, 15 Mar 2024 14:11:46 -0700 Subject: [PATCH] macos: only process key equivalents if we're focused Fixes #1581 --- macos/Sources/Ghostty/SurfaceView_AppKit.swift | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/macos/Sources/Ghostty/SurfaceView_AppKit.swift b/macos/Sources/Ghostty/SurfaceView_AppKit.swift index 9effc33ac..c6cddd30f 100644 --- a/macos/Sources/Ghostty/SurfaceView_AppKit.swift +++ b/macos/Sources/Ghostty/SurfaceView_AppKit.swift @@ -702,6 +702,13 @@ extension Ghostty { if (event.type != .keyDown) { return false } + + // Only process events if we're focused. Some key events like C-/ macOS + // appears to send to the first view in the hierarchy rather than the + // the first responder (I don't know why). This prevents us from handling it. + if (!focused) { + return false + } let equivalent: String switch (event.charactersIgnoringModifiers) {