From bb1d5e7de7c04a3e6f18315d23c846abbbe49202 Mon Sep 17 00:00:00 2001 From: velsinki <112010-velsinki@users.noreply.gitlab.gnome.org> Date: Thu, 28 Sep 2023 23:29:25 +0200 Subject: [PATCH] GtkTooltip: Fix tooltip positioning on X11 On X11, gdk_window_move_to_rect() uses the position of the window to calculate how it should be moved. However, any pending resizes that will be executed on show() are not taken into account, resulting in incorrectly positioned tooltips in case a tooltip window is re-used often. This is not solved by gtk_widget_realize(), as this will do nothing if the window is already realized. Let's add a call to the private gtk_window_move_resize() function, so that the size is always recalculated before the window is sent to gdk_window_move_to_rect(). This exact fix was also needed in GtkMenu (7298e73c), with similar reasoning. Fixes #2142 Fixes #2227 --- gtk/gtktooltip.c | 1 + 1 file changed, 1 insertion(+) diff --git a/gtk/gtktooltip.c b/gtk/gtktooltip.c index ca149fc48e..1bf72f1986 100644 --- a/gtk/gtktooltip.c +++ b/gtk/gtktooltip.c @@ -880,6 +880,7 @@ gtk_tooltip_position (GtkTooltip *tooltip, int anchor_rect_padding; gtk_widget_realize (GTK_WIDGET (tooltip->current_window)); + gtk_window_move_resize (tooltip->current_window); window = _gtk_widget_get_window (GTK_WIDGET (tooltip->current_window)); tooltip->tooltip_widget = new_tooltip_widget;