diff options
author | Zae <zaevi@live.com> | 2022-11-08 18:33:24 +0800 |
---|---|---|
committer | Zae <zaevi@live.com> | 2022-11-08 18:33:24 +0800 |
commit | bc9bf00e4a7488d8a691031b759073151c29b11c (patch) | |
tree | 0af1b018fb685e712f29988314eebe34f421b547 /platform/web | |
parent | 40ed34f6dc1422fb440d60306afb9778f7a7d07b (diff) |
Fix viewport doesn't auto-resize on Web.
Diffstat (limited to 'platform/web')
-rw-r--r-- | platform/web/display_server_web.cpp | 12 | ||||
-rw-r--r-- | platform/web/display_server_web.h | 1 |
2 files changed, 11 insertions, 2 deletions
diff --git a/platform/web/display_server_web.cpp b/platform/web/display_server_web.cpp index 5a1a56b9da..f704124704 100644 --- a/platform/web/display_server_web.cpp +++ b/platform/web/display_server_web.cpp @@ -54,7 +54,15 @@ DisplayServerWeb *DisplayServerWeb::get_singleton() { // Window (canvas) bool DisplayServerWeb::check_size_force_redraw() { - return godot_js_display_size_update() != 0; + bool size_changed = godot_js_display_size_update() != 0; + if (size_changed && !rect_changed_callback.is_null()) { + Variant size = Rect2i(Point2i(), window_get_size()); // TODO use window_get_position if implemented. + Variant *vp = &size; + Variant ret; + Callable::CallError ce; + rect_changed_callback.callp((const Variant **)&vp, 1, ret, ce); + } + return size_changed; } void DisplayServerWeb::fullscreen_change_callback(int p_fullscreen) { @@ -903,7 +911,7 @@ ObjectID DisplayServerWeb::window_get_attached_instance_id(WindowID p_window) co } void DisplayServerWeb::window_set_rect_changed_callback(const Callable &p_callable, WindowID p_window) { - // Not supported. + rect_changed_callback = p_callable; } void DisplayServerWeb::window_set_window_event_callback(const Callable &p_callable, WindowID p_window) { diff --git a/platform/web/display_server_web.h b/platform/web/display_server_web.h index 3222e2483e..1919736802 100644 --- a/platform/web/display_server_web.h +++ b/platform/web/display_server_web.h @@ -60,6 +60,7 @@ private: WindowMode window_mode = WINDOW_MODE_WINDOWED; ObjectID window_attached_instance_id = {}; + Callable rect_changed_callback; Callable window_event_callback; Callable input_event_callback; Callable input_text_callback; |