Only reset tooltip timer when mouse actually moved

InputEventMouseMotion isn't guaranteed to fire only on actual mouse
movement. It's not uncommon for the underlying OS motion event to be
sent either by the OS itself or another application even though the
mouse hasn't moved.  Godot will generate such zero-motion
InputEventMouseMotion events itself for things like cursor shape
changes.

Once started, the tooltip timer is reset only after a mouse movement of
at least 5 pixels in one frame.
This commit is contained in:
Alex Docauer 2024-08-19 19:31:24 -07:00
parent 1bd740d18d
commit 125ff3213a
No known key found for this signature in database
GPG Key ID: 6F4A5C5714C0A0E1

View File

@ -1933,7 +1933,12 @@ void Viewport::_gui_input_event(Ref<InputEvent> p_event) {
}
}
if (!is_tooltip_shown && over->can_process()) {
// If the tooltip timer isn't running, start it.
// Otherwise, only reset the timer if the mouse has moved more than 5 pixels.
if (!is_tooltip_shown && over->can_process() &&
(gui.tooltip_timer.is_null() ||
Math::is_zero_approx(gui.tooltip_timer->get_time_left()) ||
mm->get_relative().length() > 5.0)) {
if (gui.tooltip_timer.is_valid()) {
gui.tooltip_timer->release_connections();
gui.tooltip_timer = Ref<SceneTreeTimer>();