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

Fix get_position_with_decorations and get_size_with_decorations for embedded windows. #92317

Merged
merged 1 commit into from
May 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions doc/classes/Window.xml
Original file line number Diff line number Diff line change
Expand Up @@ -118,12 +118,14 @@
<return type="Vector2i" />
<description>
Returns the window's position including its border.
[b]Note:[/b] If [member visible] is [code]false[/code], this method returns the same value as [member position].
</description>
</method>
<method name="get_size_with_decorations" qualifiers="const">
<return type="Vector2i" />
<description>
Returns the window's size including its border.
[b]Note:[/b] If [member visible] is [code]false[/code], this method returns the same value as [member size].
</description>
</method>
<method name="get_theme_color" qualifiers="const">
Expand Down
20 changes: 20 additions & 0 deletions scene/main/window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,16 @@ Point2i Window::get_position_with_decorations() const {
if (window_id != DisplayServer::INVALID_WINDOW_ID) {
return DisplayServer::get_singleton()->window_get_position_with_decorations(window_id);
}
if (visible && is_embedded() && !get_flag(Window::FLAG_BORDERLESS)) {
Size2 border_offset;
if (theme_cache.embedded_border.is_valid()) {
border_offset = theme_cache.embedded_border->get_offset();
}
if (theme_cache.embedded_unfocused_border.is_valid()) {
border_offset = border_offset.max(theme_cache.embedded_unfocused_border->get_offset());
}
return position - border_offset;
}
return position;
}

Expand All @@ -405,6 +415,16 @@ Size2i Window::get_size_with_decorations() const {
if (window_id != DisplayServer::INVALID_WINDOW_ID) {
return DisplayServer::get_singleton()->window_get_size_with_decorations(window_id);
}
if (visible && is_embedded() && !get_flag(Window::FLAG_BORDERLESS)) {
Size2 border_size;
if (theme_cache.embedded_border.is_valid()) {
border_size = theme_cache.embedded_border->get_minimum_size();
}
if (theme_cache.embedded_unfocused_border.is_valid()) {
border_size = border_size.max(theme_cache.embedded_unfocused_border->get_minimum_size());
}
return size + border_size;
}
return size;
}

Expand Down
Loading