From 550a9be241d2431760200ca656b306588e2ef9ed Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Fri, 7 Jun 2024 12:46:14 -0700 Subject: [PATCH] config: introduce macos-window-shadow --- .../Features/Terminal/TerminalController.swift | 6 +++--- macos/Sources/Ghostty/Ghostty.Config.swift | 16 ++++++++++++++++ src/config/Config.zig | 5 +++++ 3 files changed, 24 insertions(+), 3 deletions(-) diff --git a/macos/Sources/Features/Terminal/TerminalController.swift b/macos/Sources/Features/Terminal/TerminalController.swift index dae31a7c3..d1624a8e4 100644 --- a/macos/Sources/Features/Terminal/TerminalController.swift +++ b/macos/Sources/Features/Terminal/TerminalController.swift @@ -186,8 +186,7 @@ class TerminalController: NSWindowController, NSWindowDelegate, // If we have window transparency then set it transparent. Otherwise set it opaque. if (ghostty.config.backgroundOpacity < 1) { window.isOpaque = false - window.hasShadow = false - + // This is weird, but we don't use ".clear" because this creates a look that // matches Terminal.app much more closer. This lets users transition from // Terminal.app more easily. @@ -196,10 +195,11 @@ class TerminalController: NSWindowController, NSWindowDelegate, ghostty_set_window_background_blur(ghostty.app, Unmanaged.passUnretained(window).toOpaque()) } else { window.isOpaque = true - window.hasShadow = true window.backgroundColor = .windowBackgroundColor } + window.hasShadow = ghostty.config.macosWindowShadow + guard window.hasStyledTabs else { return } // The titlebar is always updated. We don't need to worry about opacity diff --git a/macos/Sources/Ghostty/Ghostty.Config.swift b/macos/Sources/Ghostty/Ghostty.Config.swift index 2f455e578..e2baa3478 100644 --- a/macos/Sources/Ghostty/Ghostty.Config.swift +++ b/macos/Sources/Ghostty/Ghostty.Config.swift @@ -236,6 +236,14 @@ extension Ghostty { return v } + var macosWindowShadow: Bool { + guard let config = self.config else { return false } + var v = false; + let key = "macos-window-shadow" + _ = ghostty_config_get(config, &v, key, UInt(key.count)) + return v + } + var backgroundColor: Color { var rgb: UInt32 = 0 let bg_key = "background" @@ -268,6 +276,14 @@ extension Ghostty { return v; } + var backgroundBlurRadius: Int { + guard let config = self.config else { return 1 } + var v: Int = 0 + let key = "background-blur-radius" + _ = ghostty_config_get(config, &v, key, UInt(key.count)) + return v; + } + var unfocusedSplitOpacity: Double { guard let config = self.config else { return 1 } var opacity: Double = 0.85 diff --git a/src/config/Config.zig b/src/config/Config.zig index 6b6f19b05..10b874ed2 100644 --- a/src/config/Config.zig +++ b/src/config/Config.zig @@ -985,6 +985,11 @@ keybind: Keybinds = .{}, /// This does not work with GLFW builds. @"macos-option-as-alt": OptionAsAlt = .false, +/// Whether to enable the macOS window shadow. The default value is true. +/// With some window managers and window transparency settings, you may +/// find false more visually appealing. +@"macos-window-shadow": bool = true, + /// Put every surface (tab, split, window) into a dedicated Linux cgroup. /// /// This makes it so that resource management can be done on a per-surface