Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

root window.size_changed is not emitted when Stretch Mode is set to "viewport" #94495

Closed
Efra-EMX opened this issue Jul 18, 2024 · 2 comments
Closed

Comments

@Efra-EMX
Copy link

Tested versions

  • Reproducible in: v4.3.beta3.official [82cedc8], v4.2.2.stable.official [15073af], v4.0.stable.official [92bee43]

System information

Godot v4.3.beta3 - Linux Mint 21.3 (Virginia) - X11 - GLES3 (Compatibility) - KABINI (, LLVM 15.0.7, DRM 2.50, 5.15.0-112-generic) - AMD E2-7015 APU with AMD Radeon R2 Graphics (2 Threads)

Issue description

In the project settings, if stretch mode (display/window/stretch/mode) is set to viewport, the root window (get_tree().root) will not emit its size_changed signal.

This doesn't happen when stretch mode is set to disabled or canvas_items. It also only happens to the root window specifically, as children windows will still emit their size_changed signal normally even when their content_scale_mode is set to viewport.

Tested and reproducible in v4.3.beta3, v4.2.2.stable, and v4.0.stable.

Recording-2024-07-18_13.03.01.mp4

Steps to reproduce

  1. Create a new project
  2. Make a new script that connects with get_tree().root.size_changed signal. For example:
func _ready():
	get_tree().root.size_changed.connect(on_window_size_changed)

func on_window_size_changed():
	print("Window resized")

  1. Run the project and try resizing the game window. The signal should emit and execute the connected Callable normally.
  2. Close the game.
  3. Go to Project Settings > Display > WIndow > Stretch > Mode and set it to viewport
  4. Run the project again and try resizing the game window. Now the signal doesn't emit and execute the connected Callable anymore.

Minimal reproduction project (MRP)

window-signal-mrp.zip

@etacarinaea
Copy link

etacarinaea commented Jul 18, 2024

if stretch mode (display/window/stretch/mode) is set to viewport, the root window (get_tree().root) will not emit its size_changed signal.

This only happens when display/window/stretch/mode is set to viewport and display/window/stretch/aspect is set to ignore or keep (but I assume this also happens with keep_width/keep_height when the height/width isn't being changed). When aspect is set to expand, the size_changed signal will be emitted when the window is resized through the window manager.

only happens to the root window

This does also happen for child windows with the same attributes, although both components of the content_scale_size vector need to be non-zero, otherwise the viewport will be resized. Also, setting content_scale_size on a window will emit the size_changed signal, even with the attributes set as above.

I'm wondering if this is technically a bug or if it's actually "working as intended" since the stretch mode tooltip mentions that "the size of the root Viewport is set precisely to the base size" and "finally, this viewport is scaled to fit the screen", so I guess the base size (I assume that means content_scale_size) of the viewport never really changes when the aspect ratio is kept. But the size attribute changes, so it would make sense that the size_changed signal is emitted, unless it really is only supposed to emit when the base size is changed, but then there should be two signals imo, size_changed for the size and content_scale_size_changed for the content_scale_size.

EDIT: I just saw that this is probably a duplicate of #79336

@Calinou
Copy link
Member

Calinou commented Jul 18, 2024

Thanks for the report! Consolidating in godotengine/godot-proposals#8788, as this is intended behavior (the viewport size does not actually change when resizing the window). Therefore, implementing a notification for this is feature proposal territory.

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

No branches or pull requests

3 participants