mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-08-02 14:57:31 +03:00
Prevent Cmd+H from sending 'h' character when app is last visible
This commit is contained in:
@ -956,6 +956,30 @@ extension Ghostty {
|
|||||||
|
|
||||||
let equivalent: String
|
let equivalent: String
|
||||||
switch (event.charactersIgnoringModifiers) {
|
switch (event.charactersIgnoringModifiers) {
|
||||||
|
case "h":
|
||||||
|
// Special handling for Cmd+H (hide application)
|
||||||
|
// Only handle if it's exactly Cmd+H with no other modifiers
|
||||||
|
if (event.modifierFlags.contains(.command) &&
|
||||||
|
event.modifierFlags.isDisjoint(with: [.shift, .control, .option])) {
|
||||||
|
|
||||||
|
let visibleWindowCount = NSApp.windows.filter { $0.isVisible }.count
|
||||||
|
let isLastVisibleApp = NSWorkspace.shared.runningApplications
|
||||||
|
.filter { $0.activationPolicy == .regular && $0.isHidden == false }
|
||||||
|
.count <= 1
|
||||||
|
|
||||||
|
// If we're likely the last visible app, consume the event and don't pass it to the terminal
|
||||||
|
if isLastVisibleApp {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
// Otherwise, let macOS handle it normally
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
// For other combinations with 'h', continue with normal processing
|
||||||
|
// This allows combinations like Shift+Cmd+H to be processed normally
|
||||||
|
equivalent = "h"
|
||||||
|
|
||||||
case "/":
|
case "/":
|
||||||
// Treat C-/ as C-_. We do this because C-/ makes macOS make a beep
|
// Treat C-/ as C-_. We do this because C-/ makes macOS make a beep
|
||||||
// sound and we don't like the beep sound.
|
// sound and we don't like the beep sound.
|
||||||
@ -1252,7 +1276,7 @@ extension Ghostty {
|
|||||||
AppDelegate.logger.warning("action failed action=\(action)")
|
AppDelegate.logger.warning("action failed action=\(action)")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@IBAction func changeTitle(_ sender: Any) {
|
@IBAction func changeTitle(_ sender: Any) {
|
||||||
promptTitle()
|
promptTitle()
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user