diff options
author | bruvzg <7645683+bruvzg@users.noreply.github.com> | 2024-02-02 09:46:01 +0200 |
---|---|---|
committer | bruvzg <7645683+bruvzg@users.noreply.github.com> | 2024-02-02 10:40:26 +0200 |
commit | 0d88aadd53fe966942fb0aa13bce2d177648a897 (patch) | |
tree | c05e7f4916e3f48645372ea6ee02ec9544b71ec9 | |
parent | 9adb7c7d130c6d4eb0e80b92d6eebd71fac3384d (diff) | |
download | redot-engine-0d88aadd53fe966942fb0aa13bce2d177648a897.tar.gz |
Automatically set viewport background to transparent when window flag is set.
-rw-r--r-- | doc/classes/Window.xml | 2 | ||||
-rw-r--r-- | scene/main/window.cpp | 8 |
2 files changed, 8 insertions, 2 deletions
diff --git a/doc/classes/Window.xml b/doc/classes/Window.xml index 618a774aae..ab14f64aa1 100644 --- a/doc/classes/Window.xml +++ b/doc/classes/Window.xml @@ -675,7 +675,7 @@ <member name="transparent" type="bool" setter="set_flag" getter="get_flag" default="false"> If [code]true[/code], the [Window]'s background can be transparent. This is best used with embedded windows. [b]Note:[/b] Transparency support is implemented on Linux, macOS and Windows, but availability might vary depending on GPU driver, display manager, and compositor capabilities. - [b]Note:[/b] This property has no effect if either [member ProjectSettings.display/window/per_pixel_transparency/allowed], or the window's [member Viewport.transparent_bg] is set to [code]false[/code]. + [b]Note:[/b] This property has no effect if [member ProjectSettings.display/window/per_pixel_transparency/allowed] is set to [code]false[/code]. </member> <member name="unfocusable" type="bool" setter="set_flag" getter="get_flag" default="false"> If [code]true[/code], the [Window] can't be focused nor interacted with. It can still be visible. diff --git a/scene/main/window.cpp b/scene/main/window.cpp index 99f9e11b1f..fd64220c2c 100644 --- a/scene/main/window.cpp +++ b/scene/main/window.cpp @@ -484,9 +484,12 @@ void Window::set_flag(Flags p_flag, bool p_enabled) { ERR_FAIL_INDEX(p_flag, FLAG_MAX); flags[p_flag] = p_enabled; + if (p_flag == FLAG_TRANSPARENT) { + set_transparent_background(p_enabled); + } + if (embedder) { embedder->_sub_window_update(this); - } else if (window_id != DisplayServer::INVALID_WINDOW_ID) { if (!is_in_edited_scene_root()) { DisplayServer::get_singleton()->window_set_flag(DisplayServer::WindowFlags(p_flag), p_enabled, window_id); @@ -1285,6 +1288,9 @@ void Window::_notification(int p_what) { _update_viewport_size(); // Then feed back to the viewport. _update_window_callbacks(); RS::get_singleton()->viewport_set_update_mode(get_viewport_rid(), RS::VIEWPORT_UPDATE_WHEN_VISIBLE); + if (DisplayServer::get_singleton()->window_get_flag(DisplayServer::WindowFlags(FLAG_TRANSPARENT), window_id)) { + set_transparent_background(true); + } } else { // Create. if (visible) { |