Skip to content

Save window size in DisplayServerHeadless. - #125828

Open
bruvzg wants to merge 1 commit into
godotengine:masterfrom
bruvzg:ds_size_move
Open

bruvzg wants to merge 1 commit into
godotengine:masterfrom
bruvzg:ds_size_move

Conversation

@bruvzg

@bruvzg bruvzg commented Nov 26, 2026

Copy link
Copy Markdown
Member

What problem(s) does this PR solve?

Additional information

Moves window size code from DisplayServerMock to DisplayServerHeadless.

@bruvzg bruvzg added this to the 4.8 milestone Nov 26, 2026
@bruvzg
bruvzg requested a review from a team as a code owner November 26, 2026 06:42
@bruvzg bruvzg added the bug label Nov 26, 2026
@bruvzg
bruvzg requested a review from a team as a code owner November 26, 2026 06:42

@akien-mga akien-mga left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense. The headless window size being hardcoded to 64x64 is something I've been struggling with at times for some automated testing scenarios.

I guess the 64x64 and 1920x1080 defaults are arbitrary though, should we align them somehow with the non dummy/mock servers?

@ELginas

ELginas commented Nov 26, 2026

Copy link
Copy Markdown
Contributor

I agree with @akien-mga . One way we could do is to use parameters, which are passed to the DisplayServer constructor. I've checked, X11 and Wayland have quite a few parameters passed to their constructors, including p_resolution, Their constructor is called in create_func, and it is called from DisplayServer::create. Then test_main.cpp would need to be updated to use better constants, similarly to main.cpp. Another way is to use Size2i(1152, 648) or GLOBAL_GET("display/window/size/viewport_width") directly, which are already defined in main.cpp.

@bruvzg

bruvzg commented Nov 26, 2026

Copy link
Copy Markdown
Member Author

Maybe, but this might break something that expect it ro be 64x64, so it's probably better to do for 4.9.

@ELginas ELginas left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does fix the repro from the issue, only I was not able to reproduce failing tests. New PR behaviour is slightly different than from 4.7.2, just something to keep in mind, but I hope that's not an issue.

> godot --path ~/pr/godot-demos --headless
Godot Engine v4.7.2.stable.arch_linux.ed1daf0bf (2026-08-17 01:18:38 UTC) - https://godotengine.org

version: 4.7.2-stable (arch_linux)
DisplayServer.window_get_size: (0, 0)
root.size before: (64, 64)
root.size after setting 1280x720: (1280, 720)
root.size after window_set_size + 1 frame: (1280, 720)
visible rect: [P: (0.0, 0.0), S: (1280.0, 720.0)]
canvas transform: [X: (1.0, 0.0), Y: (0.0, 1.0), O: (0.0, 0.0)]
full-rect Control size: (0.0, 0.0)
Control global xform affine_inverse: [X: (1.0, 0.0), Y: (0.0, 1.0), O: (0.0, 0.0)]
> ./bin/godot.linuxbsd.editor.dev.x86_64.llvm --path ~/pr/godot-demos --headless
Godot Engine v4.8.beta.custom_build.98d5be8a2 (2026-11-25 19:03:35 UTC) - https://godotengine.org

version: 4.8-beta (custom_build)
DisplayServer.window_get_size: (64, 64)
root.size before: (64, 64)
root.size after setting 1280x720: (1280, 720)
root.size after window_set_size + 1 frame: (1280, 720)
visible rect: [P: (0.0, 0.0), S: (1280.0, 720.0)]
canvas transform: [X: (1.0, 0.0), Y: (0.0, 1.0), O: (0.0, 0.0)]
full-rect Control size: (0.0, 0.0)
Control global xform affine_inverse: [X: (1.0, 0.0), Y: (0.0, 1.0), O: (0.0, 0.0)]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Headless root Window is 0x0 and can't be resized in 4.8.beta5, giving a NaN visible rect with canvas_items/expand stretch (regression from 4.7)

3 participants