[gtk/wip/exalm/textview-selection: 4/4] textlayout: Clip selection bounds to the line extents




commit 20985bc7e7e955bef74b7f93fc2157473e15ae70
Author: Alexander Mikhaylenko <alexm gnome org>
Date:   Tue May 4 00:32:25 2021 +0500

    textlayout: Clip selection bounds to the line extents
    
    The rest of the line will be painted separately.

 gtk/gtktextlayout.c | 11 +++++++++++
 1 file changed, 11 insertions(+)
---
diff --git a/gtk/gtktextlayout.c b/gtk/gtktextlayout.c
index 2037eab426..9344c9a831 100644
--- a/gtk/gtktextlayout.c
+++ b/gtk/gtktextlayout.c
@@ -3951,6 +3951,17 @@ render_para (GskPangoRenderer   *crenderer,
                   bounds.size.width = PANGO_PIXELS (ranges[2*i + 1]) - PANGO_PIXELS (ranges[2*i]);
                   bounds.size.height = selection_height;
 
+                  if (bounds.origin.x < PANGO_PIXELS (line_rect.x))
+                    {
+                      bounds.size.width += PANGO_PIXELS (line_rect.x) - bounds.origin.x;
+                      bounds.origin.x = PANGO_PIXELS (line_rect.x);
+                    }
+
+                  bounds.size.width = MIN (bounds.size.width,
+                                           PANGO_PIXELS (line_rect.x) +
+                                           PANGO_PIXELS (line_rect.width) -
+                                           bounds.origin.x);
+
                   gtk_snapshot_append_color (crenderer->snapshot, selection, &bounds);
 
                   if (draw_selection_text)


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]