[gtk+] entry: Draw selection the same way as GtkLabel
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] entry: Draw selection the same way as GtkLabel
- Date: Mon, 25 Jan 2016 14:51:57 +0000 (UTC)
commit a363fd5fd39ee0c6f2c624da0d6bf0ca23f8f3fa
Author: Benjamin Otte <otte redhat com>
Date: Mon Jan 25 00:00:41 2016 +0100
entry: Draw selection the same way as GtkLabel
gtk/gtkentry.c | 21 ++++++++-------------
1 files changed, 8 insertions(+), 13 deletions(-)
---
diff --git a/gtk/gtkentry.c b/gtk/gtkentry.c
index dc0d298..67b14c5 100644
--- a/gtk/gtkentry.c
+++ b/gtk/gtkentry.c
@@ -6505,22 +6505,18 @@ gtk_entry_draw_text (GtkEntry *entry,
if (gtk_editable_get_selection_bounds (GTK_EDITABLE (entry), &start_pos, &end_pos))
{
- gint *ranges;
- gint n_ranges, i;
- PangoRectangle logical_rect;
- GdkRGBA text_color;
- GtkStyleContext *context;
+ cairo_region_t *clip;
+ gint range[2];
+
+ range[0] = MIN (start_pos, end_pos);
+ range[1] = MAX (start_pos, end_pos);
- context = gtk_widget_get_style_context (GTK_WIDGET (entry));
gtk_style_context_save_to_node (context, priv->selection_node);
- pango_layout_get_pixel_extents (layout, NULL, &logical_rect);
- gtk_entry_get_pixel_ranges (entry, &ranges, &n_ranges);
- for (i = 0; i < n_ranges; ++i)
- cairo_rectangle (cr,
- - priv->scroll_offset + ranges[2 * i], y,
- ranges[2 * i + 1], logical_rect.height);
+ clip = gdk_pango_layout_get_clip_region (layout, x, y, range, 1);
+ gdk_cairo_region (cr, clip);
cairo_clip (cr);
+ cairo_region_destroy (clip);
gtk_render_background (context, cr,
0, 0,
@@ -6531,7 +6527,6 @@ gtk_entry_draw_text (GtkEntry *entry,
gdk_cairo_set_source_rgba (cr, &text_color);
pango_cairo_show_layout (cr, layout);
- g_free (ranges);
gtk_style_context_restore (context);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]