[vte] widget: Report correct mouse coordinates if viewport is scrolled back



commit ac3438cbdffd7886a93e6adbd8283e15d241bb50
Author: Egmont Koblinger <egmont gmail com>
Date:   Sat Oct 3 21:26:11 2015 +0200

    widget: Report correct mouse coordinates if viewport is scrolled back
    
    https://bugzilla.gnome.org/show_bug.cgi?id=755187

 src/vte.cc |   12 ++++++++++--
 1 files changed, 10 insertions(+), 2 deletions(-)
---
diff --git a/src/vte.cc b/src/vte.cc
index 014edd2..7fa282f 100644
--- a/src/vte.cc
+++ b/src/vte.cc
@@ -6052,7 +6052,11 @@ vte_terminal_send_mouse_button_internal(VteTerminal *terminal,
        int width = terminal->pvt->char_width;
        int height = terminal->pvt->char_height;
        long col = (x - terminal->pvt->padding.left) / width;
-       long row = (y - terminal->pvt->padding.top) / height;
+        long row = (y - terminal->pvt->padding.top) / height -
+                   (terminal->pvt->screen->insert_delta - terminal->pvt->screen->scroll_delta);
+
+        if (row < 0)
+                return;
 
        vte_terminal_feed_mouse_event(terminal, button, FALSE /* not drag */, is_release, col, row);
 }
@@ -6132,9 +6136,13 @@ vte_terminal_maybe_send_mouse_drag(VteTerminal *terminal, GdkEventMotion *event)
        int width = terminal->pvt->char_width;
        int height = terminal->pvt->char_height;
        long col = ((long) event->x - terminal->pvt->padding.left) / width;
-       long row = ((long) event->y - terminal->pvt->padding.top) / height;
+        long row = ((long) event->y - terminal->pvt->padding.top) / height -
+                   (terminal->pvt->screen->insert_delta - terminal->pvt->screen->scroll_delta);
         int button;
 
+        if (row < 0)
+                return FALSE;
+
        /* First determine if we even want to send notification. */
        switch (event->type) {
        case GDK_MOTION_NOTIFY:


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