macos: surface focus follow mouse

This commit is contained in:
Cameron Dart
2024-06-10 16:07:33 -07:00
parent 97bb595505
commit 29fb70197c
3 changed files with 9 additions and 2 deletions

View File

@ -199,6 +199,7 @@ class TerminalController: NSWindowController, NSWindowDelegate,
} }
window.hasShadow = ghostty.config.macosWindowShadow window.hasShadow = ghostty.config.macosWindowShadow
window.focusFollowsMouse = ghostty.config.focusFollowsMouse
guard window.hasStyledTabs else { return } guard window.hasStyledTabs else { return }

View File

@ -369,6 +369,8 @@ class TerminalWindow: NSWindow {
} }
} }
var focusFollowsMouse: Bool = false
// Find the NSTextField responsible for displaying the titlebar's title. // Find the NSTextField responsible for displaying the titlebar's title.
private var titlebarTextField: NSTextField? { private var titlebarTextField: NSTextField? {
guard let titlebarContainer = contentView?.superview?.subviews guard let titlebarContainer = contentView?.superview?.subviews

View File

@ -480,6 +480,10 @@ extension Ghostty {
let pos = self.convert(event.locationInWindow, from: nil) let pos = self.convert(event.locationInWindow, from: nil)
ghostty_surface_mouse_pos(surface, pos.x, frame.height - pos.y) 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) { override func mouseDragged(with event: NSEvent) {