Open mhsmith opened 2 weeks ago
Originally posted by @freakboy3742 in https://github.com/beeware/toga/issues/2155#issuecomment-2467406280
The "invisible window border" issue you mentioned [is] definitely an oddity, but if the Windows native API considers "window position 0,0" to include space for invisible border elements, then I'm not sure we should be bending over backwards to fix it.
We've discussed the origin/position changes in person, but for the record - I agree that's the general direction we should head. As nice as the idea of "absolute window positioning" is, it clearly doesn't work for the multi-DPI case unless the underlying window system operates entirely in CSS pixels (or any other consistent coordinate space); and given that the use case is pretty eclectic to start with, I'm happy to lose the feature in the name of having a solution that works reliably.
The current design assumes that all the following properties operate in a single CSS-pixel coordinate system:
Window.screen_position is then simply defined as Window.position - Screen.origin.
However, it isn't possible to define a consistent CSS-pixel coordinate system that covers different screens with different DPIs. Imagine you have four screens laid out like this:
If screens 2 and 3 have the same physical resolution, but different DPIs, then what is the distance between screens 1 and 4 in CSS pixels? There are two answers, both equally valid.
As discussed in https://github.com/beeware/toga/pull/2155#issuecomment-2466962577, our current workaround is:
So on the primary screen, and any other screen with the same DPI, everything works correctly. But on a screen with a different DPI to the primary one, the position and size properties will be in different scales, so you won’t be able to position windows relative to the bottom or right edges of the screen or of other windows.
I doubt many people are doing things like this, so it's not urgent to fix, but in the future we can implement a proper solution, which I think would look like this:
The examples/window app can be used to test this area. Note that the "screen edge" commands are always slightly inaccurate because they don't take the thickness of the title bar and invisible borders into account, but that's not relevant to this issue.