From 25034b6f872af5c7a5d4e8e1f7d453566c35a649 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timm=20B=C3=A4der?= Date: Thu, 15 Jun 2017 17:04:42 +0200 Subject: [PATCH] label: Fix layout snapshot coordinates No need to convert anything to "window coordinates" anymore. --- gtk/gtklabel.c | 32 ++++---------------------------- 1 file changed, 4 insertions(+), 28 deletions(-) diff --git a/gtk/gtklabel.c b/gtk/gtklabel.c index bda0db7744..95c82a730a 100644 --- a/gtk/gtklabel.c +++ b/gtk/gtklabel.c @@ -3664,7 +3664,7 @@ get_layout_location (GtkLabel *label, baseline = gtk_widget_get_allocated_baseline (widget); - x = floor (allocation.x + xalign * (allocation.width - req_width) - logical.x); + x = floor ((xalign * (allocation.width - req_width)) - logical.x); baseline_offset = 0; if (baseline != -1) @@ -3688,9 +3688,9 @@ get_layout_location (GtkLabel *label, * middle". You want to read the first line, at least, to get some context. */ if (pango_layout_get_line_count (priv->layout) == 1) - y = floor (allocation.y + (allocation.height - req_height) * yalign) - logical.y + baseline_offset; + y = floor ((allocation.height - req_height) * yalign) + baseline_offset; else - y = floor (allocation.y + MAX ((allocation.height - req_height) * yalign, 0)) - logical.y + baseline_offset; + y = floor (MAX ((allocation.height - req_height) * yalign, 0)) + baseline_offset; if (xp) *xp = x; @@ -3894,12 +3894,8 @@ gtk_label_get_focus_link (GtkLabel *label) return NULL; } -static void layout_to_window_coords (GtkLabel *label, - gint *x, - gint *y); #define GRAPHENE_RECT_FROM_RECT(_r) (GRAPHENE_RECT_INIT ((_r)->x, (_r)->y, (_r)->width, (_r)->height)) - static void gtk_label_snapshot (GtkWidget *widget, GtkSnapshot *snapshot) @@ -3927,8 +3923,7 @@ gtk_label_snapshot (GtkWidget *widget, if (priv->text && (*priv->text != '\0')) { - lx = ly = 0; - layout_to_window_coords (label, &lx, &ly); + get_layout_location (label, &lx, &ly); gtk_snapshot_render_layout (snapshot, context, lx, ly, priv->layout); @@ -4210,25 +4205,6 @@ window_to_layout_coords (GtkLabel *label, *y -= ly; /* go to layout */ } -static void -layout_to_window_coords (GtkLabel *label, - gint *x, - gint *y) -{ - gint lx, ly; - GtkAllocation allocation; - - /* get layout location in widget->window coords */ - get_layout_location (label, &lx, &ly); - _gtk_widget_get_allocation (GTK_WIDGET (label), &allocation); - - *x += lx; /* go to widget->window */ - *x -= allocation.x; /* go to selection window */ - - *y += ly; /* go to widget->window */ - *y -= allocation.y; /* go to selection window */ -} - static gboolean get_layout_index (GtkLabel *label, gint x,