Skip to content

Commit af4e96b

Browse files
committed
Merge pull request #108604 from deralmas/fitting-shenanigans
Wayland: Workaround tooltip issues
2 parents 281ce84 + cf48f5a commit af4e96b

File tree

3 files changed

+35
-31
lines changed

3 files changed

+35
-31
lines changed

editor/doc/editor_help.cpp

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4655,26 +4655,28 @@ void EditorHelpBitTooltip::popup_under_cursor() {
46554655
vr = window->get_usable_parent_rect();
46564656
}
46574657

4658-
if (r.size.x + r.position.x > vr.size.x + vr.position.x) {
4659-
// Place it in the opposite direction. If it fails, just hug the border.
4660-
r.position.x = mouse_pos.x - r.size.x - tooltip_offset.x;
4658+
if (!DisplayServer::get_singleton()->has_feature(DisplayServer::FEATURE_SELF_FITTING_WINDOWS) || is_embedded()) {
4659+
if (r.size.x + r.position.x > vr.size.x + vr.position.x) {
4660+
// Place it in the opposite direction. If it fails, just hug the border.
4661+
r.position.x = mouse_pos.x - r.size.x - tooltip_offset.x;
46614662

4662-
if (r.position.x < vr.position.x) {
4663-
r.position.x = vr.position.x + vr.size.x - r.size.x;
4663+
if (r.position.x < vr.position.x) {
4664+
r.position.x = vr.position.x + vr.size.x - r.size.x;
4665+
}
4666+
} else if (r.position.x < vr.position.x) {
4667+
r.position.x = vr.position.x;
46644668
}
4665-
} else if (r.position.x < vr.position.x) {
4666-
r.position.x = vr.position.x;
4667-
}
46684669

4669-
if (r.size.y + r.position.y > vr.size.y + vr.position.y) {
4670-
// Same as above.
4671-
r.position.y = mouse_pos.y - r.size.y - tooltip_offset.y;
4670+
if (r.size.y + r.position.y > vr.size.y + vr.position.y) {
4671+
// Same as above.
4672+
r.position.y = mouse_pos.y - r.size.y - tooltip_offset.y;
46724673

4673-
if (r.position.y < vr.position.y) {
4674-
r.position.y = vr.position.y + vr.size.y - r.size.y;
4674+
if (r.position.y < vr.position.y) {
4675+
r.position.y = vr.position.y + vr.size.y - r.size.y;
4676+
}
4677+
} else if (r.position.y < vr.position.y) {
4678+
r.position.y = vr.position.y;
46754679
}
4676-
} else if (r.position.y < vr.position.y) {
4677-
r.position.y = vr.position.y;
46784680
}
46794681

46804682
// When `FLAG_POPUP` is false, it prevents the editor from losing focus when displaying the tooltip.

platform/linuxbsd/wayland/display_server_wayland.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1049,7 +1049,7 @@ void DisplayServerWayland::window_set_drop_files_callback(const Callable &p_call
10491049
}
10501050

10511051
int DisplayServerWayland::window_get_current_screen(DisplayServer::WindowID p_window_id) const {
1052-
ERR_FAIL_COND_V(p_window_id != MAIN_WINDOW_ID, INVALID_SCREEN);
1052+
ERR_FAIL_COND_V(!windows.has(p_window_id), INVALID_SCREEN);
10531053
// Standard Wayland APIs don't support getting the screen of a window.
10541054
return 0;
10551055
}

scene/main/viewport.cpp

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1678,26 +1678,28 @@ void Viewport::_gui_show_tooltip_at(const Point2i &p_pos) {
16781678
r.size = r.size.ceil();
16791679
r.size = r.size.min(panel->get_max_size());
16801680

1681-
if (r.size.x + r.position.x > vr.size.x + vr.position.x) {
1682-
// Place it in the opposite direction. If it fails, just hug the border.
1683-
r.position.x = gui.tooltip_pos.x - r.size.x - tooltip_offset.x;
1681+
if (!DisplayServer::get_singleton()->has_feature(DisplayServer::FEATURE_SELF_FITTING_WINDOWS) || gui.tooltip_popup->is_embedded()) {
1682+
if (r.size.x + r.position.x > vr.size.x + vr.position.x) {
1683+
// Place it in the opposite direction. If it fails, just hug the border.
1684+
r.position.x = gui.tooltip_pos.x - r.size.x - tooltip_offset.x;
16841685

1685-
if (r.position.x < vr.position.x) {
1686-
r.position.x = vr.position.x + vr.size.x - r.size.x;
1686+
if (r.position.x < vr.position.x) {
1687+
r.position.x = vr.position.x + vr.size.x - r.size.x;
1688+
}
1689+
} else if (r.position.x < vr.position.x) {
1690+
r.position.x = vr.position.x;
16871691
}
1688-
} else if (r.position.x < vr.position.x) {
1689-
r.position.x = vr.position.x;
1690-
}
16911692

1692-
if (r.size.y + r.position.y > vr.size.y + vr.position.y) {
1693-
// Same as above.
1694-
r.position.y = gui.tooltip_pos.y - r.size.y - tooltip_offset.y;
1693+
if (r.size.y + r.position.y > vr.size.y + vr.position.y) {
1694+
// Same as above.
1695+
r.position.y = gui.tooltip_pos.y - r.size.y - tooltip_offset.y;
16951696

1696-
if (r.position.y < vr.position.y) {
1697-
r.position.y = vr.position.y + vr.size.y - r.size.y;
1697+
if (r.position.y < vr.position.y) {
1698+
r.position.y = vr.position.y + vr.size.y - r.size.y;
1699+
}
1700+
} else if (r.position.y < vr.position.y) {
1701+
r.position.y = vr.position.y;
16981702
}
1699-
} else if (r.position.y < vr.position.y) {
1700-
r.position.y = vr.position.y;
17011703
}
17021704

17031705
DisplayServer::WindowID active_popup = DisplayServer::get_singleton()->window_get_active_popup();

0 commit comments

Comments
 (0)