From ac3438cbdffd7886a93e6adbd8283e15d241bb50 Mon Sep 17 00:00:00 2001 From: Egmont Koblinger Date: Sat, 3 Oct 2015 21:26:11 +0200 Subject: widget: Report correct mouse coordinates if viewport is scrolled back https://bugzilla.gnome.org/show_bug.cgi?id=755187 --- src/vte.cc | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/vte.cc b/src/vte.cc index 014edd26..7fa282f5 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: -- cgit v1.2.1