mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-08-02 14:57:31 +03:00
macos: surface focus follow mouse
This commit is contained in:
@ -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 }
|
||||||
|
|
||||||
|
@ -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
|
||||||
|
@ -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) {
|
||||||
|
Reference in New Issue
Block a user