diff --git a/macos/Sources/Features/Terminal/TerminalController.swift b/macos/Sources/Features/Terminal/TerminalController.swift index 86fb02442..98e90e565 100644 --- a/macos/Sources/Features/Terminal/TerminalController.swift +++ b/macos/Sources/Features/Terminal/TerminalController.swift @@ -197,9 +197,10 @@ class TerminalController: NSWindowController, NSWindowDelegate, window.isOpaque = true window.backgroundColor = .windowBackgroundColor } - + window.hasShadow = ghostty.config.macosWindowShadow - + window.focusFollowsMouse = ghostty.config.focusFollowsMouse + guard window.hasStyledTabs else { return } // The titlebar is always updated. We don't need to worry about opacity diff --git a/macos/Sources/Features/Terminal/TerminalWindow.swift b/macos/Sources/Features/Terminal/TerminalWindow.swift index 9e4d3600e..2d54db321 100644 --- a/macos/Sources/Features/Terminal/TerminalWindow.swift +++ b/macos/Sources/Features/Terminal/TerminalWindow.swift @@ -369,6 +369,8 @@ class TerminalWindow: NSWindow { } } + var focusFollowsMouse: Bool = false + // Find the NSTextField responsible for displaying the titlebar's title. private var titlebarTextField: NSTextField? { guard let titlebarContainer = contentView?.superview?.subviews diff --git a/macos/Sources/Ghostty/SurfaceView_AppKit.swift b/macos/Sources/Ghostty/SurfaceView_AppKit.swift index a5347e1ad..3c5cd71ef 100644 --- a/macos/Sources/Ghostty/SurfaceView_AppKit.swift +++ b/macos/Sources/Ghostty/SurfaceView_AppKit.swift @@ -480,6 +480,10 @@ extension Ghostty { let pos = self.convert(event.locationInWindow, from: nil) ghostty_surface_mouse_pos(surface, pos.x, frame.height - pos.y) + guard let window = self.window as? TerminalWindow else { return } + if !self.focused && window.focusFollowsMouse { + Ghostty.moveFocus(to: self) + } } override func mouseDragged(with event: NSEvent) {