aboutsummaryrefslogtreecommitdiff
path: root/input.c
diff options
context:
space:
mode:
authorDaniel Eklöf <daniel@ekloef.se>2020-08-08 08:00:18 +0000
committerDaniel Eklöf <daniel@ekloef.se>2020-08-08 08:00:18 +0000
commit7497e448265c2924031f7e2feca7373a34578994 (patch)
tree9429fa5384735aa1c92a7348e793de060e849130 /input.c
parentinput: scrolling: don't send events to client if cursor is outside grid (diff)
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.
Diffstat (limited to 'input.c')
-rw-r--r--input.c10
1 files 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);