[vte/vte-0-50] widget: Fix a crash with hyperlinks if the mouse is over the padding



commit cc49215999c81430efd35ebef6182cf761ff2822
Author: Egmont Koblinger <egmont gmail com>
Date:   Mon Oct 2 19:20:42 2017 +0200

    widget: Fix a crash with hyperlinks if the mouse is over the padding
    
    https://bugzilla.gnome.org/show_bug.cgi?id=788426
    (cherry picked from commit 291b36519dc94de2c35bfba63c2af2e48663e786)

 src/vte.cc |   20 ++++++++++++--------
 1 files changed, 12 insertions(+), 8 deletions(-)
---
diff --git a/src/vte.cc b/src/vte.cc
index dfcb7f2..e52f726 100644
--- a/src/vte.cc
+++ b/src/vte.cc
@@ -5599,6 +5599,8 @@ void
 VteTerminalPrivate::hyperlink_hilite_update(vte::view::coords const& pos)
 {
         const VteRowData *rowdata;
+        bool coords_visible;
+        vte::grid::coords rowcol;
         hyperlink_idx_t new_hyperlink_hover_idx = 0;
         GdkRectangle bbox;
         const char *separator;
@@ -5606,16 +5608,18 @@ VteTerminalPrivate::hyperlink_hilite_update(vte::view::coords const& pos)
         if (!m_allow_hyperlink)
                 return;
 
-        glong col = pos.x / m_char_width;
-        glong row = pixel_to_row(pos.y);
-
         _vte_debug_print (VTE_DEBUG_HYPERLINK,
                          "hyperlink_hilite_update\n");
 
-        rowdata = find_row_data(row);
-        if (rowdata && col < rowdata->len) {
-                new_hyperlink_hover_idx = rowdata->cells[col].attr.hyperlink_idx;
+        coords_visible = view_coords_visible(pos);
+        if (coords_visible) {
+                rowcol = grid_coords_from_view_coords(pos);
+                rowdata = find_row_data(rowcol.row());
+                if (rowdata && rowcol.column() < rowdata->len) {
+                        new_hyperlink_hover_idx = rowdata->cells[rowcol.column()].attr.hyperlink_idx;
+                }
         }
+
         if (new_hyperlink_hover_idx == m_hyperlink_hover_idx) {
                 _vte_debug_print (VTE_DEBUG_HYPERLINK,
                                   "hyperlink did not change\n");
@@ -5630,8 +5634,8 @@ VteTerminalPrivate::hyperlink_hilite_update(vte::view::coords const& pos)
         /* This might be different from new_hyperlink_hover_idx. If in the stream, that one contains
          * the pseudo idx VTE_HYPERLINK_IDX_TARGET_IN_STREAM and now a real idx is allocated.
          * Plus, the ring's internal belief of the hovered hyperlink is also updated. */
-        if (view_coords_visible(pos))
-                m_hyperlink_hover_idx = _vte_ring_get_hyperlink_at_position(m_screen->row_data, row, col, 
true, &m_hyperlink_hover_uri);
+        if (coords_visible)
+                m_hyperlink_hover_idx = _vte_ring_get_hyperlink_at_position(m_screen->row_data, 
rowcol.row(), rowcol.column(), true, &m_hyperlink_hover_uri);
         else
                 m_hyperlink_hover_idx = 0;
 


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