From 6b824713d56bf105cede71daa186593aa9906718 Mon Sep 17 00:00:00 2001 From: Simon Tatham Date: Sun, 1 Oct 2017 21:53:32 +0100 Subject: [PATCH] term_mouse: make special treatment of x < 0 more selective. A mouse drag which manages to reach x < 0 (via SetCapture or equivalent) was treated as having the coordinates of (x_max, y-1). This is intended to be useful when the mouse drag is part of ordinary raster-ordered selection. But we were leaving that treatment enabled even for mouse actions that went to xterm mouse tracking mode - thanks to Markus Gans for reporting that - and when I investigated, I realised that this isn't a sensible transformation in _rectangular_ selection mode either. Fixed both. --- terminal.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/terminal.c b/terminal.c index 0eb1a9a6..433b3fa5 100644 --- a/terminal.c +++ b/terminal.c @@ -6088,7 +6088,18 @@ void term_mouse(Terminal *term, Mouse_Button braw, Mouse_Button bcooked, term_scroll(term, 0, +1); } if (x < 0) { - if (y > 0) { + if (y > 0 && !raw_mouse && term->seltype != RECTANGULAR) { + /* + * When we're using the mouse for normal raster-based + * selection, dragging off the left edge of a terminal row + * is treated the same as the right-hand end of the + * previous row, in that it's considered to identify a + * point _before_ the first character on row y. + * + * But if the mouse action is going to be used for + * anything else - rectangular selection, or xterm mouse + * tracking - then we disable this special treatment. + */ x = term->cols - 1; y--; } else