1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-14 13:41:12 +00:00

Fix mouse position with screen transform

When a Viewport is not directly attached to the screen, the
function `Viewport::get_mouse_position` can't rely on
`get_screen_transform`, because that function is ambiguous in
these situations.
In these cases it is necessary to use the mouse position from
the most recent mouse IputEvent.
This commit is contained in:
Markus Sauermann
2023-06-06 20:42:41 +02:00
parent ed63b9ea23
commit d1fa284e65
4 changed files with 21 additions and 1 deletions

View File

@@ -2475,6 +2475,14 @@ Transform2D Window::get_popup_base_transform() const {
return popup_base_transform;
}
bool Window::is_directly_attached_to_screen() const {
if (get_embedder()) {
return get_embedder()->is_directly_attached_to_screen();
}
// Distinguish between the case that this is a native Window and not inside the tree.
return is_inside_tree();
}
void Window::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_title", "title"), &Window::set_title);
ClassDB::bind_method(D_METHOD("get_title"), &Window::get_title);