Skip to content

Commit

Permalink
Merge pull request #87856 from bruvzg/transpbg
Browse files Browse the repository at this point in the history
Automatically set viewport background to transparent when window flag is set.
  • Loading branch information
akien-mga committed Feb 2, 2024
2 parents 0d1fa8d + 0d88aad commit 10e1114
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion doc/classes/Window.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
8 changes: 7 additions & 1 deletion scene/main/window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 10e1114

Please sign in to comment.