From 7497e448265c2924031f7e2feca7373a34578994 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Sat, 8 Aug 2020 10:00:18 +0200 Subject: [PATCH] input: motion: regression: check for RMB when updating selection While refactoring this code, the check for LMB or RMB got changed to LMB or "any button". This fixes that. It also adds a boolean 'cursor_is_on_grid', which should make the code easier to read and understand. --- input.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/input.c b/input.c index 8eca83bd..38e8e8dd 100644 --- a/input.c +++ b/input.c @@ -1247,17 +1247,19 @@ wl_pointer_motion(void *data, struct wl_pointer *wl_pointer, bool cursor_is_on_new_cell = old_col != seat->mouse.col || old_row != seat->mouse.row; + /* Cursor is inside the grid, or in the margins (or even + * outside the terminal window) */ + bool cursor_is_on_grid = seat->mouse.col >= 0 && seat->mouse.row >= 0; + /* Update selection */ - if (seat->mouse.button == BTN_LEFT || seat->mouse.button) { + if (seat->mouse.button == BTN_LEFT || seat->mouse.button == BTN_RIGHT) { if (cursor_is_on_new_cell || term->selection.end.row < 0) selection_update(term, selection_col, selection_row); } /* Send mouse event to client application */ if (!term_mouse_grabbed(term, seat) && - cursor_is_on_new_cell && - seat->mouse.col >= 0 && - seat->mouse.row >= 0) + cursor_is_on_new_cell && cursor_is_on_grid) { assert(seat->mouse.col < term->cols); assert(seat->mouse.row < term->rows);