[gtk+/wip/baedert/drawing] label: Fix get_layout_index
- From: Timm Bäder <baedert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/wip/baedert/drawing] label: Fix get_layout_index
- Date: Sun, 2 Jul 2017 12:15:39 +0000 (UTC)
commit d266a6fbc6f48c3945e432e4c2ff7470d6b6c379
Author: Timm Bäder <mail baedert org>
Date: Sun Jul 2 14:16:09 2017 +0200
label: Fix get_layout_index
Properly translate the given coordinates to layout coordinates. Fixes
clicking links and selecting text.
gtk/gtklabel.c | 25 +++++--------------------
1 files changed, 5 insertions(+), 20 deletions(-)
---
diff --git a/gtk/gtklabel.c b/gtk/gtklabel.c
index be2249b..d012ffe 100644
--- a/gtk/gtklabel.c
+++ b/gtk/gtklabel.c
@@ -4183,25 +4183,6 @@ gtk_label_unmap (GtkWidget *widget)
GTK_WIDGET_CLASS (gtk_label_parent_class)->unmap (widget);
}
-static void
-window_to_layout_coords (GtkLabel *label,
- gint *x,
- gint *y)
-{
- GtkAllocation allocation;
- gint lx, ly;
-
- /* get layout location in widget->window coords */
- get_layout_location (label, &lx, &ly);
- _gtk_widget_get_allocation (GTK_WIDGET (label), &allocation);
-
- *x += allocation.x; /* go to widget->window */
- *x -= lx; /* go to layout */
-
- *y += allocation.y; /* go to widget->window */
- *y -= ly; /* go to layout */
-}
-
static gboolean
get_layout_index (GtkLabel *label,
gint x,
@@ -4213,12 +4194,16 @@ get_layout_index (GtkLabel *label,
const gchar *cluster;
const gchar *cluster_end;
gboolean inside;
+ int lx, ly;
*index = 0;
gtk_label_ensure_layout (label);
+ get_layout_location (label, &lx, &ly);
- window_to_layout_coords (label, &x, &y);
+ /* Translate x/y to layout position */
+ x -= lx;
+ y -= ly;
x *= PANGO_SCALE;
y *= PANGO_SCALE;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]