diff --git a/scene/main/viewport.cpp b/scene/main/viewport.cpp index 89ec5636ab73..673ca9a4891d 100644 --- a/scene/main/viewport.cpp +++ b/scene/main/viewport.cpp @@ -1519,6 +1519,8 @@ void Viewport::_gui_show_tooltip() { panel->set_flag(Window::FLAG_NO_FOCUS, true); panel->set_flag(Window::FLAG_POPUP, false); panel->set_flag(Window::FLAG_MOUSE_PASSTHROUGH, true); + panel->set_flag(Window::FLAG_TRANSPARENT, true); + // A non-embedded tooltip window will only be transparent if per_pixel_transparency is allowed in the main Viewport. panel->set_wrap_controls(true); panel->add_child(base_tooltip); panel->gui_parent = this; @@ -1527,17 +1529,22 @@ void Viewport::_gui_show_tooltip() { tooltip_owner->add_child(gui.tooltip_popup); + Window *window = gui.tooltip_popup->get_parent_visible_window(); + float win_scale = window->content_scale_factor; Point2 tooltip_offset = GLOBAL_GET("display/mouse_cursor/tooltip_position_offset"); + if (!gui.tooltip_popup->is_embedded()) { + tooltip_offset = tooltip_offset * win_scale; + } Rect2 r(gui.tooltip_pos + tooltip_offset, gui.tooltip_popup->get_contents_minimum_size()); - r.size = r.size.min(panel->get_max_size()); - - Window *window = gui.tooltip_popup->get_parent_visible_window(); Rect2i vr; if (gui.tooltip_popup->is_embedded()) { vr = gui.tooltip_popup->get_embedder()->get_visible_rect(); } else { + panel->content_scale_factor = win_scale; + r.size = r.size * win_scale; vr = window->get_usable_parent_rect(); } + r.size = r.size.min(panel->get_max_size()); if (r.size.x + r.position.x > vr.size.x + vr.position.x) { // Place it in the opposite direction. If it fails, just hug the border.