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.
This commit is contained in:
Daniel Eklöf 2020-08-08 10:00:18 +02:00
parent d49d1fd59d
commit 7497e44826
No known key found for this signature in database
GPG key ID: 5BBD4992C116573F

10
input.c
View file

@ -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);