robotools / vanilla

A Pythonic wrapper around Cocoa.
MIT License
78 stars 28 forks source link

Opening windows on extended screen #196

Open typemytype opened 1 year ago

typemytype commented 1 year ago

The window on the extended screen opens at the bottom of the screen instead of positioned at the top, honouring the vanilla posSize (the default when no left and top are given is 100 for both)

This is using the _calcFrame (which is used everywhere, and works perfect, only with screen frames it gives a wrong top value.

import vanilla
import AppKit
from vanilla.vanillaBase import _calcFrame

w = vanilla.Window((0,0, 300, 300))

screen = AppKit.NSScreen.mainScreen()
frame = screen.visibleFrame()
print(frame.origin.x, frame.origin.y, frame.size.width, frame.size.height)
frame = _calcFrame(screen.visibleFrame(), ((100, 100), (300, 300)))
print(frame)
for other in AppKit.NSApp().orderedWindows():
    (oL, oB), (oW, oH) = other.frame()
print(oL, oB)            
# w.open()

output on the main screen:

0.0 48.0 2560.0 1367.0
((100, 967.0), (300, 300))  # top is different
0.0 1067.0

output on the extended screen:

-2560.0 0.0 2560.0 1415.0
((100, 1015.0), (300, 300)) # top is different
-2560.0 283.0

interestingly the top from the frame being calculated with _calcFrame is different from the oB from the window frame. (without cascading as the posSize has 4 values)

I have no solution for now, but it should be fixed within vanilla...

something similar https://github.com/robotools/vanilla/issues/60