mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-10-26 12:27:29 +00:00
macos: handle multiple monitors properly
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
import Cocoa
|
||||
|
||||
enum QuickTerminalScreen {
|
||||
case main
|
||||
case mouse
|
||||
case menuBar
|
||||
|
||||
init?(fromGhosttyConfig string: String) {
|
||||
switch (string) {
|
||||
case "main":
|
||||
self = .main
|
||||
|
||||
case "mouse":
|
||||
self = .mouse
|
||||
|
||||
case "macos-menu-bar":
|
||||
self = .menuBar
|
||||
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
var screen: NSScreen? {
|
||||
switch (self) {
|
||||
case .main:
|
||||
return NSScreen.main
|
||||
|
||||
case .mouse:
|
||||
let mouseLoc = NSEvent.mouseLocation
|
||||
return NSScreen.screens.first(where: { $0.frame.contains(mouseLoc) })
|
||||
|
||||
case .menuBar:
|
||||
return NSScreen.screens.first
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user