From cf48f5a102bc74f29f28fc05301301c4f417537f Mon Sep 17 00:00:00 2001 From: Dery Almas Date: Mon, 14 Jul 2025 15:18:21 +0200 Subject: [PATCH] Disable tooltip fitting if FEATURE_SELF_FITTING_WINDOWS is available --- editor/doc/editor_help.cpp | 32 +++++++++++++++++--------------- scene/main/viewport.cpp | 32 +++++++++++++++++--------------- 2 files changed, 34 insertions(+), 30 deletions(-) diff --git a/editor/doc/editor_help.cpp b/editor/doc/editor_help.cpp index 63208a60740..ddc8a0f610e 100644 --- a/editor/doc/editor_help.cpp +++ b/editor/doc/editor_help.cpp @@ -4655,26 +4655,28 @@ void EditorHelpBitTooltip::popup_under_cursor() { vr = window->get_usable_parent_rect(); } - 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. - r.position.x = mouse_pos.x - r.size.x - tooltip_offset.x; + if (!DisplayServer::get_singleton()->has_feature(DisplayServer::FEATURE_SELF_FITTING_WINDOWS) || is_embedded()) { + 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. + r.position.x = mouse_pos.x - r.size.x - tooltip_offset.x; - if (r.position.x < vr.position.x) { - r.position.x = vr.position.x + vr.size.x - r.size.x; + if (r.position.x < vr.position.x) { + r.position.x = vr.position.x + vr.size.x - r.size.x; + } + } else if (r.position.x < vr.position.x) { + r.position.x = vr.position.x; } - } else if (r.position.x < vr.position.x) { - r.position.x = vr.position.x; - } - if (r.size.y + r.position.y > vr.size.y + vr.position.y) { - // Same as above. - r.position.y = mouse_pos.y - r.size.y - tooltip_offset.y; + if (r.size.y + r.position.y > vr.size.y + vr.position.y) { + // Same as above. + r.position.y = mouse_pos.y - r.size.y - tooltip_offset.y; - if (r.position.y < vr.position.y) { - r.position.y = vr.position.y + vr.size.y - r.size.y; + if (r.position.y < vr.position.y) { + r.position.y = vr.position.y + vr.size.y - r.size.y; + } + } else if (r.position.y < vr.position.y) { + r.position.y = vr.position.y; } - } else if (r.position.y < vr.position.y) { - r.position.y = vr.position.y; } // When `FLAG_POPUP` is false, it prevents the editor from losing focus when displaying the tooltip. diff --git a/scene/main/viewport.cpp b/scene/main/viewport.cpp index 3d2dd6dcc7c..f02ab52a9d0 100644 --- a/scene/main/viewport.cpp +++ b/scene/main/viewport.cpp @@ -1678,26 +1678,28 @@ void Viewport::_gui_show_tooltip_at(const Point2i &p_pos) { r.size = r.size.ceil(); 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. - r.position.x = gui.tooltip_pos.x - r.size.x - tooltip_offset.x; + if (!DisplayServer::get_singleton()->has_feature(DisplayServer::FEATURE_SELF_FITTING_WINDOWS) || gui.tooltip_popup->is_embedded()) { + 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. + r.position.x = gui.tooltip_pos.x - r.size.x - tooltip_offset.x; - if (r.position.x < vr.position.x) { - r.position.x = vr.position.x + vr.size.x - r.size.x; + if (r.position.x < vr.position.x) { + r.position.x = vr.position.x + vr.size.x - r.size.x; + } + } else if (r.position.x < vr.position.x) { + r.position.x = vr.position.x; } - } else if (r.position.x < vr.position.x) { - r.position.x = vr.position.x; - } - if (r.size.y + r.position.y > vr.size.y + vr.position.y) { - // Same as above. - r.position.y = gui.tooltip_pos.y - r.size.y - tooltip_offset.y; + if (r.size.y + r.position.y > vr.size.y + vr.position.y) { + // Same as above. + r.position.y = gui.tooltip_pos.y - r.size.y - tooltip_offset.y; - if (r.position.y < vr.position.y) { - r.position.y = vr.position.y + vr.size.y - r.size.y; + if (r.position.y < vr.position.y) { + r.position.y = vr.position.y + vr.size.y - r.size.y; + } + } else if (r.position.y < vr.position.y) { + r.position.y = vr.position.y; } - } else if (r.position.y < vr.position.y) { - r.position.y = vr.position.y; } DisplayServer::WindowID active_popup = DisplayServer::get_singleton()->window_get_active_popup();