From f8d235ecc22808e64131026a373d4a92b7d47f2f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timm=20B=C3=A4der?= Date: Sat, 13 Jan 2018 10:38:13 +0100 Subject: [PATCH] tooltip: Fix tooltip positions Since gtk_widget_get_allocation doesn't return x/y values relative to the GdkWindow anymore, we need to manually translate the widget coordinates here. --- gtk/gtktooltip.c | 32 ++++++++++++++++++++++++++------ 1 file changed, 26 insertions(+), 6 deletions(-) diff --git a/gtk/gtktooltip.c b/gtk/gtktooltip.c index 9ad7a1b6a7..91f1d54b75 100644 --- a/gtk/gtktooltip.c +++ b/gtk/gtktooltip.c @@ -621,8 +621,8 @@ static void get_bounding_box (GtkWidget *widget, GdkRectangle *bounds) { + GtkWidget *toplevel; GtkAllocation allocation; - GtkBorder border = { 0, }; GdkWindow *window; gint x, y; gint w, h; @@ -636,12 +636,32 @@ get_bounding_box (GtkWidget *widget, window = gtk_widget_get_window (widget); gtk_widget_get_allocation (widget, &allocation); + + x = allocation.x; + y = allocation.y; + w = allocation.width; + h = allocation.height; + + toplevel = gtk_widget_get_toplevel (widget); + if (GTK_IS_WINDOW (toplevel) && !GTK_IS_WINDOW (widget)) + { + GtkWidget *parent = gtk_widget_get_parent (widget); + + gtk_widget_translate_coordinates (parent, toplevel, + x, y, + &x, &y); + } + if (GTK_IS_WINDOW (widget)) - _gtk_window_get_shadow_width (GTK_WINDOW (widget), &border); - x = allocation.x + border.left; - y = allocation.y + border.right; - w = allocation.width - border.left - border.right; - h = allocation.height - border.top - border.bottom; + { + GtkBorder border = { 0, }; + + _gtk_window_get_shadow_width (GTK_WINDOW (widget), &border); + x += border.left; + y += border.right; + w -= border.left + border.right; + h -= border.top + border.bottom; + } gdk_window_get_root_coords (window, x, y, &x1, &y1); gdk_window_get_root_coords (window, x + w, y, &x2, &y2);