diff options
author | Matthias Clasen <mclasen@redhat.com> | 2020-11-03 12:37:07 -0500 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2020-11-03 12:37:39 -0500 |
commit | ddd16dd31258b1ca5757cf53713ac5d1aeacd29d (patch) | |
tree | 1c8a36ad7b468ff606e846f532fc3867cd29fa00 /gtk/gtktexthandle.c | |
parent | 7624f66feccdd29df9d026d3821e3e21de173d16 (diff) | |
download | gtk+-ddd16dd31258b1ca5757cf53713ac5d1aeacd29d.tar.gz |
texthandle: Fix positioning
Use the same approach we use for popovers, using
gtk_widget_get_surface_allocation. It works.
Fixes: #3319
Diffstat (limited to 'gtk/gtktexthandle.c')
-rw-r--r-- | gtk/gtktexthandle.c | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/gtk/gtktexthandle.c b/gtk/gtktexthandle.c index 4353a6226d..5953e4da5f 100644 --- a/gtk/gtktexthandle.c +++ b/gtk/gtktexthandle.c @@ -116,22 +116,19 @@ gtk_text_handle_present_surface (GtkTextHandle *handle) GdkPopupLayout *layout; GdkRectangle rect; GtkRequisition req; - double x, y; + GtkWidget *parent; gtk_widget_get_preferred_size (widget, NULL, &req); gtk_text_handle_get_padding (handle, &handle->border); - rect.x = handle->pointing_to.x; - rect.y = handle->pointing_to.y + handle->pointing_to.height - handle->border.top; + parent = gtk_widget_get_parent (widget); + gtk_widget_get_surface_allocation (parent, &rect); + + rect.x += handle->pointing_to.x; + rect.y += handle->pointing_to.y + handle->pointing_to.height - handle->border.top; rect.width = req.width - handle->border.left - handle->border.right; rect.height = 1; - gtk_widget_translate_coordinates (gtk_widget_get_parent (widget), - gtk_widget_get_ancestor (widget, GTK_TYPE_WINDOW), - rect.x, rect.y, &x, &y); - rect.x = x; - rect.y = y; - if (handle->role == GTK_TEXT_HANDLE_ROLE_CURSOR) rect.x -= rect.width / 2; else if ((handle->role == GTK_TEXT_HANDLE_ROLE_SELECTION_END && |