From 6beb86db3c450cfa34dd6c64932e36dff5fffa81 Mon Sep 17 00:00:00 2001 From: Benno Schulenberg Date: Tue, 22 Dec 2020 12:20:42 +0100 Subject: [PATCH] mouse: do not offset the shortcuts by 'margin' when using --linenumbers The bottom window (the prompt bar and the shortcuts) does not shift its position when line numbers are active, so mouse clicks in this window should be not be compensated for the line-numbers margin. This fixes https://savannah.gnu.org/bugs/?59749. Indirectly-reported-by: ObeliX Bug existed since version 2.7.0, since line numbers were introduced. --- src/winio.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/winio.c b/src/winio.c index e4083d2a..9d7003c8 100644 --- a/src/winio.c +++ b/src/winio.c @@ -1488,14 +1488,16 @@ char *get_verbatim_kbinput(WINDOW *win, size_t *count) int get_mouseinput(int *mouse_y, int *mouse_x, bool allow_shortcuts) { MEVENT mevent; - bool in_bottomwin; + bool in_editwin, in_bottomwin; /* First, get the actual mouse event. */ if (getmouse(&mevent) == ERR) return -1; + in_editwin = wenclose(edit, mevent.y, mevent.x); + /* Save the screen coordinates where the mouse event took place. */ - *mouse_x = mevent.x - margin; + *mouse_x = mevent.x - (in_editwin ? margin : 0); *mouse_y = mevent.y; in_bottomwin = wenclose(bottomwin, *mouse_y, *mouse_x); @@ -1521,7 +1523,7 @@ int get_mouseinput(int *mouse_y, int *mouse_x, bool allow_shortcuts) /* Clicks on the status bar are handled elsewhere, so * restore the untranslated mouse-event coordinates. */ if (*mouse_y == 0) { - *mouse_x = mevent.x - margin; + *mouse_x = mevent.x; *mouse_y = mevent.y; return 0; } -- 2.29.2