godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
89.92k stars 21.06k forks source link

Window changes position when editor is resized #94023

Open anniryynanen opened 3 months ago

anniryynanen commented 3 months ago

Edit: Found an easier way to reproduce

Tested versions

Reproduces in:

System information

Windows 10.0.22631 - GLES3 (Compatibility) - AMD Radeon RX 7700 XT (Advanced Micro Devices, Inc.; 31.0.24033.1003) - AMD Ryzen 7 5700X3D 8-Core Processor (16 Threads)

Issue description

When a window is absolutely positioned at (0, 0), its position changes to (0, 36) when the editor window is resized. This happens with any Y less than 36.

Steps to reproduce

Minimal reproduction project (MRP)

window-move.zip

sys010611 commented 3 months ago

It seems the reason is the line, int title_height = get_flag(Window::FLAG_BORDERLESS) ? 0 : theme_cache.title_height; in Rect2i Window::fit_rect_in_parent.

anniryynanen commented 3 months ago

I found an easier way to reproduce this, all you need to do is resize the editor window. I'll edit the issue.

anniryynanen commented 3 months ago

Looks like the window doesn't need to be scene root either.

anniryynanen commented 3 months ago

After reading the code a bit, I think this behavior is actually correct. It's trying to stop you from positioning a window so that its decorations (along with the close button) are offscreen.

The windows where I spotted this are shown with popup_centered() so it was never an issue for me, I was just trying to keep them at (0, 0) in the .tscn and was confused at why they wouldn't stay put. ^^;;

I wonder, should the editor even let you position a window like that with Y below the title height? It could force a minimum Y, like labels that don't let you to set their height below what the font needs.