Window Resizing

I’m playing with Godot 4.4.1, trying to make a desktop tool. What I’d like to do is make it so that if the window is resized, the contents do not scale, there’s just more space for stuff.

I’ve set the stretch mode to disabled, and I can resize the window without scaling the contents, so that much works. The problem I’m having is resizing the controls inside the window.

It doesn’t seem like you can tell a container to just “be the size of the window”, though that would be the ideal solution. I’ve done:

func _ready() -> void:
    get_window().size_changed.connect(_handle_resized)

func _handle_resized() -> void:
    var w: Node = get_window()
    print("%d %d" % [w.size.x, w.size.y])

This works if it winds up scaling the viewport inside the window, but if the window gets bigger than the viewport, the viewport just centers in the window and no size_changed signal is sent.

I guess I could just poll DisplayServer.window_get_size(), but it feels like there ought to be a better way. How should I do this?

EDIT: Apparently DisplayServer.window_get_size() has the same problem; it returns the size of the viewport, not the window client area, despite what the docs say.

1 Like

Full Rect anchor presets should scale up with the window in a “be the size of the window” way. Can you post screenshots?

2 Likes

I’ll try to get some screenshots up later.

I’m seeing different behavior between Godot 4.3 on windows (which behaves as you say) and Godot 4.4.1 on linux (X11), which is misbehaving. I need to try 4.3 on linux and 4.4.1 on windows…

I’m seeing this same behaviour in godot 4.5. Has anyone found a solution, or another way to get the actual window size?

edit: downgraded to 4.3 and DisplayServer.window_get_size() and get_viewport().size works as expected.