Override window size results in a not centered window

Godot Version

v4.5.stable.official [876b29033]

Problem

We’re creating and updating an override.cfg file whenever the user changes our game’s window resolution. We do this so the game launches immediately to the user’s preferred resolution.

[display]

window/size/window_width_override=2560.0
window/size/window_height_override=1440.0

We have set the initial_position_type to Center of Primary Screen.

However, when running the game from the editor, the window is not properly centered. It’s top left corner is at the same place as it would be when centering the window without the override.

Now I’m also hesitant on the whole override.cfg as it’s pretty ugly to have a separate file in the game’s folder. But as far as I know, it’s the only way to launch the game with desired settings. MacOS doesn’t even seem to respect the window/size/mode used to set the initial window mode to windowed or full screen.

Do you have the Game Workspace still embedded? I.E., did you not turn it off?

image

If so, certain window manipulations don’t work. One of them is fullscreen. Another may be the centering.

Click the three dots and the end and select Embed Game on Next Play to turn it off.

I imagine what’s happening is it’s placing the window at the initial size specified in project settings (and that’s centered) and then you resize it. If you subtract half the difference in width and height from the window position, it should center it.

Your override.cfg should be in "user://", which would put it in ~/Library/Application Support/, which is where that stuff is supposed to be on a mac.

1 Like