@@ -19,33 +19,32 @@ enum PanelPosition: Int, Codable, CaseIterable {
1919 case centerLarge = 6
2020 case fullScreen = 7
2121
22- var frame : NSRect {
23- // TODO: Use NSEvent.mouseLocation to choose which screen
22+ public func getFrame( forScreen screen: NSScreen ) -> NSRect {
2423 switch self {
2524 case . right:
26- return NSRect ( x: NSScreen . main! . frame. maxX - Constants. panel. menuWidth, y: 0 , width: Constants . panel. menuWidth, height: NSScreen . main! . frame. maxY)
25+ return NSRect ( x: screen . frame. maxX - Constants. panel. menuWidth, y: screen . frame . minY , width: Constants . panel. menuWidth, height: screen . frame. maxY)
2726 case . left:
28- return NSRect ( x: 0 , y: 0 , width: Constants . panel. menuWidth, height: NSScreen . main! . frame. maxY)
27+ return NSRect ( x: screen . frame . minX , y: screen . frame . minY , width: Constants . panel. menuWidth, height: screen . frame. maxY)
2928 case . top:
30- return NSRect ( x: 0 , y: NSScreen . main! . frame. maxY - Constants. panel. menuHeight, width: NSScreen . main! . frame. width, height: Constants . panel. menuHeight)
29+ return NSRect ( x: screen . frame . minX , y: screen . frame. maxY - Constants. panel. menuHeight, width: screen . frame. width, height: Constants . panel. menuHeight)
3130 case . bottom:
32- return NSRect ( x: 0 , y: 0 , width: NSScreen . main! . frame. width, height: Constants . panel. menuHeight)
31+ return NSRect ( x: screen . frame . minX , y: screen . frame . minY , width: screen . frame. width, height: Constants . panel. menuHeight)
3332 case . centerSmall:
34- let size = NSSize ( width: NSScreen . main! . frame. width / 2 , height: NSScreen . main! . frame. height / 2 )
35- return Self . centerRect ( ofSize: size, inRect: NSScreen . main! . frame)
33+ let size = NSSize ( width: screen . frame. width / 2 , height: screen . frame. height / 2 )
34+ return Self . centerRect ( ofSize: size, inRect: screen . frame)
3635 case . centerMedium:
37- let size = NSSize ( width: NSScreen . main! . frame. width * 0.7 , height: NSScreen . main! . frame. height * 0.7 )
38- return Self . centerRect ( ofSize: size, inRect: NSScreen . main! . frame)
36+ let size = NSSize ( width: screen . frame. width * 0.7 , height: screen . frame. height * 0.7 )
37+ return Self . centerRect ( ofSize: size, inRect: screen . frame)
3938 case . centerLarge:
40- let size = NSSize ( width: NSScreen . main! . frame. width * 0.85 , height: NSScreen . main! . frame. height * 0.85 )
41- return Self . centerRect ( ofSize: size, inRect: NSScreen . main! . frame)
39+ let size = NSSize ( width: screen . frame. width * 0.85 , height: screen . frame. height * 0.85 )
40+ return Self . centerRect ( ofSize: size, inRect: screen . frame)
4241 case . fullScreen:
43- return NSScreen . main! . frame
42+ return screen . frame
4443 }
4544 }
4645
4746 private static func centerRect( ofSize size: NSSize , inRect rect: NSRect ) -> NSRect {
48- return NSRect ( origin: NSPoint ( x: ( rect. width - size. width) / 2 , y: ( rect. height - size. height) / 2 ) , size: size)
47+ return NSRect ( origin: NSPoint ( x: ( rect. width - size. width) / 2 + rect . minX , y: ( rect. height - size. height) / 2 + rect . minY ) , size: size)
4948 }
5049
5150 var title : String {
0 commit comments