[gtk/matthiasc/for-master] texthandle: Fix positioning
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/matthiasc/for-master] texthandle: Fix positioning
- Date: Tue, 3 Nov 2020 17:39:07 +0000 (UTC)
commit ddd16dd31258b1ca5757cf53713ac5d1aeacd29d
Author: Matthias Clasen <mclasen redhat com>
Date: Tue Nov 3 12:37:07 2020 -0500
texthandle: Fix positioning
Use the same approach we use for popovers, using
gtk_widget_get_surface_allocation. It works.
Fixes: #3319
gtk/gtktexthandle.c | 15 ++++++---------
1 file 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 &&
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]