From d665274eb1846b1842ef647d46461e4a97f7319a Mon Sep 17 00:00:00 2001 From: "g.willems" Date: Tue, 7 May 2024 19:32:15 +0200 Subject: [PATCH] tooltip: query tooltip on widget under pointer only When changing the tooltip text or markup of widget A, we simulate a motion event on that widget to update the display. But if there is an active tooltip on widget B, then the current code belives we moved the pointer from B to A thus hides/shows the tooltip of B alternatively. Instead, simulate the motion event on the widget currently under the pointer. This will avoid flickering if we keep the pointer over widget B. Fixes #6674 Closes #6674 --- gtk/gtktooltip.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/gtk/gtktooltip.c b/gtk/gtktooltip.c index 7bc11a694c..a7aa163673 100644 --- a/gtk/gtktooltip.c +++ b/gtk/gtktooltip.c @@ -366,9 +366,10 @@ gtk_tooltip_trigger_tooltip_query (GtkWidget *widget) GdkSeat *seat; GdkDevice *device; GdkSurface *surface; - double x, y; - graphene_point_t p; + double px, py; + int x, y; GtkWidget *toplevel; + GtkWidget *target_widget; g_return_if_fail (GTK_IS_WIDGET (widget)); @@ -381,7 +382,7 @@ gtk_tooltip_trigger_tooltip_query (GtkWidget *widget) else device = NULL; if (device) - surface = gdk_device_get_surface_at_position (device, &x, &y); + surface = gdk_device_get_surface_at_position (device, &px, &py); else surface = NULL; if (!surface) @@ -395,10 +396,12 @@ gtk_tooltip_trigger_tooltip_query (GtkWidget *widget) if (gtk_native_get_surface (GTK_NATIVE (toplevel)) != surface) return; - if (!gtk_widget_compute_point (toplevel, widget, &GRAPHENE_POINT_INIT (x, y), &p)) - graphene_point_init (&p, x, y); + x = round (px); + y = round (py); - gtk_tooltip_handle_event_internal (GDK_MOTION_NOTIFY, surface, widget, p.x, p.y); + target_widget = _gtk_widget_find_at_coords (surface, x, y, &x, &y); + + gtk_tooltip_handle_event_internal (GDK_MOTION_NOTIFY, surface, target_widget, x, y); } static void