mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-12-28 22:41:43 +00:00
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.
This commit is contained in:
parent
e64028b41d
commit
f8d235ecc2
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user