mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-04-08 08:20:59 -04:00
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:
parent
d49d1fd59d
commit
7497e44826
1 changed files with 6 additions and 4 deletions
10
input.c
10
input.c
|
|
@ -1247,17 +1247,19 @@ wl_pointer_motion(void *data, struct wl_pointer *wl_pointer,
|
||||||
bool cursor_is_on_new_cell
|
bool cursor_is_on_new_cell
|
||||||
= old_col != seat->mouse.col || old_row != seat->mouse.row;
|
= 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 */
|
/* 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)
|
if (cursor_is_on_new_cell || term->selection.end.row < 0)
|
||||||
selection_update(term, selection_col, selection_row);
|
selection_update(term, selection_col, selection_row);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Send mouse event to client application */
|
/* Send mouse event to client application */
|
||||||
if (!term_mouse_grabbed(term, seat) &&
|
if (!term_mouse_grabbed(term, seat) &&
|
||||||
cursor_is_on_new_cell &&
|
cursor_is_on_new_cell && cursor_is_on_grid)
|
||||||
seat->mouse.col >= 0 &&
|
|
||||||
seat->mouse.row >= 0)
|
|
||||||
{
|
{
|
||||||
assert(seat->mouse.col < term->cols);
|
assert(seat->mouse.col < term->cols);
|
||||||
assert(seat->mouse.row < term->rows);
|
assert(seat->mouse.row < term->rows);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue