macos: have macos-dock-drop-behavior apply to all drops

pull/8114/head
Mitchell Hashimoto 2025-08-21 10:45:12 -07:00
parent f9ad061ea8
commit e01ff4093a
No known key found for this signature in database
GPG Key ID: 523D5DC389D273BC
5 changed files with 26 additions and 29 deletions

View File

@ -405,14 +405,6 @@ class AppDelegate: NSObject,
// When opening a directory, check the configuration to decide
// whether to open in a new tab or new window.
config.workingDirectory = filename
let behavior = ghostty.config.macosDockDropFolderBehavior
if behavior == .window {
_ = TerminalController.newWindow(ghostty, withBaseConfig: config)
} else {
// Default to tab behavior
_ = TerminalController.newTab(ghostty, withBaseConfig: config)
}
} else {
// When opening a file, we want to execute the file. To do this, we
// don't override the command directly, because it won't load the
@ -424,8 +416,11 @@ class AppDelegate: NSObject,
// Set the parent directory to our working directory so that relative
// paths in scripts work.
config.workingDirectory = (filename as NSString).deletingLastPathComponent
_ = TerminalController.newWindow(ghostty, withBaseConfig: config)
}
switch ghostty.config.macosDockDropBehavior {
case .new_tab: _ = TerminalController.newTab(ghostty, withBaseConfig: config)
case .new_window: _ = TerminalController.newWindow(ghostty, withBaseConfig: config)
}
return true

View File

@ -282,15 +282,15 @@ extension Ghostty {
return MacOSTitlebarProxyIcon(rawValue: str) ?? defaultValue
}
var macosDockDropFolderBehavior: MacOSDockDropFolderBehavior {
let defaultValue = MacOSDockDropFolderBehavior.tab
var macosDockDropBehavior: MacDockDropBehavior {
let defaultValue = MacDockDropBehavior.new_tab
guard let config = self.config else { return defaultValue }
var v: UnsafePointer<Int8>? = nil
let key = "macos-dock-drop-folder-behavior"
let key = "macos-dock-drop-behavior"
guard ghostty_config_get(config, &v, key, UInt(key.count)) else { return defaultValue }
guard let ptr = v else { return defaultValue }
let str = String(cString: ptr)
return MacOSDockDropFolderBehavior(rawValue: str) ?? defaultValue
return MacDockDropBehavior(rawValue: str) ?? defaultValue
}
var macosWindowShadow: Bool {
@ -618,6 +618,11 @@ extension Ghostty.Config {
static let attention = BellFeatures(rawValue: 1 << 2)
static let title = BellFeatures(rawValue: 1 << 3)
}
enum MacDockDropBehavior: String {
case new_tab = "new-tab"
case new_window = "new-window"
}
enum MacHidden : String {
case never

View File

@ -304,12 +304,6 @@ extension Ghostty {
case hidden
}
/// Enum for the macos-dock-drop-folder-behavior config option
enum MacOSDockDropFolderBehavior: String {
case tab
case window
}
/// Enum for auto-update-channel config option
enum AutoUpdateChannel: String {
case tip

View File

@ -2631,19 +2631,20 @@ keybind: Keybinds = .{},
/// editor, etc.
@"macos-titlebar-proxy-icon": MacTitlebarProxyIcon = .visible,
/// Controls the behavior when dropping a folder onto the Ghostty dock icon
/// on macOS.
/// Controls the windowing behavior when dropping a file or folder
/// onto the Ghostty icon in the macOS dock.
///
/// Valid values are:
///
/// * `tab` - Open the folder in a new tab in the main window (default).
/// * `window` - Open the folder in a new window.
/// * `new-tab` - Create a new tab in the current window, or open
/// a new window if none exist.
/// * `new-window` - Create a new window unconditionally.
///
/// The default value is `tab`.
/// The default value is `new-tab`.
///
/// This setting is only supported on macOS and has no effect on other
/// platforms.
@"macos-dock-drop-folder-behavior": MacOSDockDropFolderBehavior = .tab,
@"macos-dock-drop-behavior": MacOSDockDropBehavior = .@"new-tab",
/// macOS doesn't have a distinct "alt" key and instead has the "option"
/// key which behaves slightly differently. On macOS by default, the
@ -7096,9 +7097,9 @@ pub const WindowNewTabPosition = enum {
end,
};
/// See macos-dock-drop-folder-behavior
pub const MacOSDockDropFolderBehavior = enum {
tab,
/// See macos-dock-drop-behavior
pub const MacOSDockDropBehavior = enum {
@"new-tab",
window,
};

View File

@ -147,6 +147,8 @@ pub const FileFormatter = struct {
opts: std.fmt.FormatOptions,
writer: anytype,
) !void {
@setEvalBranchQuota(10_000);
_ = layout;
_ = opts;