Fix windows not being centered properly when system interface is scaled#8903
Fix windows not being centered properly when system interface is scaled#8903alice-i-cecile merged 3 commits intobevyengine:mainfrom
Conversation
|
Good fix, good comments :) |
|
This doesn't take into account For example this doesn't spawn at the center of the screen (when default scale_factor is 1., before and after this PR so not a regression at least): Window {
position: WindowPosition::Centered(MonitorSelection::Primary),
resolution: WindowResolution::new(500., 300.).with_scale_factor_override(2.0),
..default()
} |
Yeah, that is true. And I thought a bit about this when I worked on this, but to be honest I also had a hard time figuring out what the override should and shouldn't affect so I went with how the original code handled it. (It used Now that I have thought about it a bit more, I think the logical thing here should be that the centering code should account for override if the window size code does and vice versa. I will do some more testing and see if that is the case |
|
I think But yeah not sure at all and even if scale_factor_override should be taken into account your PR would still be better as it is than before the PR so. Taking it into account might not be an easy fix too. Maybe we can merge this PR and open an issue for this. |
|
Even if it's not a complete fix I think this behaviour is better than the existing. |
Objective
Fixes #8765
Solution
When windows are created during plugin setup, the scale_factor of a WindowResolution struct will always be 1.0 (default). The correct scale factor is set later in flow. To get correct center calculations use the monitors scale factor directly instead.
Results
System: Windows 10 Pro (125% scaling)
main
This PR