[vte/wip/egmont/bidi: 2/3] vte-75-more-fine-grained-check-v2.patch



commit 8e94ef5914940cc6b017b46d49ab501fc1eef6b8
Author: Egmont Koblinger <egmont gmail com>
Date:   Sat May 25 15:58:46 2019 +0200

    vte-75-more-fine-grained-check-v2.patch

 src/vte.cc         | 23 ++++++++++++++++++-----
 src/vteinternal.hh |  1 +
 2 files changed, 19 insertions(+), 5 deletions(-)
---
diff --git a/src/vte.cc b/src/vte.cc
index 781cb763..6463360a 100644
--- a/src/vte.cc
+++ b/src/vte.cc
@@ -229,6 +229,21 @@ Terminal::last_displayed_row() const
         return r;
 }
 
+/* Checks if the cursor in its current row might need to be displayed.
+ * An outline cursor has an additional height of VTE_LINE_WIDTH pixels.
+ * It's also intentionally painted over the padding, up to VTE_LINE_WIDTH
+ * pixels under the real contents area. This method takes these into account.
+ * Only checks the cursor's row; not its visibility, shape, or offscreen column.
+ */
+inline bool
+Terminal::cursor_might_be_displayed() const
+{
+        /* Note: the cursor can only be offscreen below the visible area, not above. */
+        vte::grid::row_t cursor_top = row_to_pixel (m_screen->cursor.row) - VTE_LINE_WIDTH;
+        vte::grid::row_t display_bottom = m_view_usable_extents.height() + MIN(m_padding.bottom, 
VTE_LINE_WIDTH);
+        return cursor_top < display_bottom;
+}
+
 /* Note that end_row is inclusive. This is not as nice as end-exclusive,
  * but saves us from a +1 almost everywhere where this method is called. */
 void
@@ -9339,9 +9354,7 @@ Terminal::paint_cursor()
        width = m_cell_width;
        height = m_cell_height;
 
-        /* Show a tiny bit of an outline rectangle cursor just under the last displayed row,
-         * hence the +1. The cursor can't be offscreen in the other direction vertically. */
-        if (drow > last_displayed_row() + 1)
+        if (!cursor_might_be_displayed())
                 return;
        if (CLAMP(col, 0, m_column_count - 1) != col)
                return;
@@ -9678,10 +9691,10 @@ Terminal::widget_draw(cairo_t *cr)
 
         cairo_restore(cr);
 
-        /* Re-clip, allowing 1 more pixel row for the outline cursor. */
+        /* Re-clip, allowing VTE_LINE_WIDTH more pixel rows for the outline cursor. */
         /* TODOegmont: It's really ugly to do it here. */
         cairo_save(cr);
-        extra_area_for_cursor = (decscusr_cursor_shape() == VTE_CURSOR_SHAPE_BLOCK && !m_has_focus) ? 1 : 0;
+        extra_area_for_cursor = (decscusr_cursor_shape() == VTE_CURSOR_SHAPE_BLOCK && !m_has_focus) ? 
VTE_LINE_WIDTH : 0;
         cairo_rectangle(cr, 0, m_padding.top - extra_area_for_cursor, allocated_width, allocated_height - 
m_padding.top - m_padding.bottom + 2 * extra_area_for_cursor);
         cairo_clip(cr);
 
diff --git a/src/vteinternal.hh b/src/vteinternal.hh
index 946b6c4a..84d3b482 100644
--- a/src/vteinternal.hh
+++ b/src/vteinternal.hh
@@ -626,6 +626,7 @@ public:
         inline vte::view::coord_t row_to_pixel(vte::grid::row_t row) const;
         inline vte::grid::row_t first_displayed_row() const;
         inline vte::grid::row_t last_displayed_row() const;
+        inline bool cursor_might_be_displayed() const;
 
         inline VteRowData *insert_rows (guint cnt);
         VteRowData *ensure_row();


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