mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-02-05 04:06:08 -05:00
input: mouse-bindings: check selection is enabled/possible and that pointer is on grid
We shouldn't start or modify a selection if selection isn't possible (i.e. client application is grabbing the mouse, and user isn't holding Shift). We also shouldn't start or modify a selection if the pointer is outside the grid (updating an ongoing selection on motion events is an exception to this).
This commit is contained in:
parent
24ee6d836b
commit
28410f1b99
1 changed files with 33 additions and 13 deletions
46
input.c
46
input.c
|
|
@ -254,13 +254,23 @@ execute_binding(struct seat *seat, struct terminal *term,
|
|||
break;
|
||||
}
|
||||
|
||||
case BIND_ACTION_SELECT_BEGIN:
|
||||
selection_start(term, seat->mouse.col, seat->mouse.row, SELECTION_NORMAL);
|
||||
case BIND_ACTION_SELECT_BEGIN: {
|
||||
bool cursor_is_on_grid = seat->mouse.col >= 0 && seat->mouse.row >= 0;
|
||||
if (selection_enabled(term, seat) && cursor_is_on_grid) {
|
||||
selection_start(
|
||||
term, seat->mouse.col, seat->mouse.row, SELECTION_NORMAL);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case BIND_ACTION_SELECT_BEGIN_BLOCK:
|
||||
selection_start(term, seat->mouse.col, seat->mouse.row, SELECTION_BLOCK);
|
||||
case BIND_ACTION_SELECT_BEGIN_BLOCK: {
|
||||
bool cursor_is_on_grid = seat->mouse.col >= 0 && seat->mouse.row >= 0;
|
||||
if (selection_enabled(term, seat) && cursor_is_on_grid) {
|
||||
selection_start(
|
||||
term, seat->mouse.col, seat->mouse.row, SELECTION_BLOCK);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case BIND_ACTION_SELECT_EXTEND: {
|
||||
bool cursor_is_on_grid = seat->mouse.col >= 0 && seat->mouse.row >= 0;
|
||||
|
|
@ -271,20 +281,30 @@ execute_binding(struct seat *seat, struct terminal *term,
|
|||
break;
|
||||
}
|
||||
|
||||
case BIND_ACTION_SELECT_WORD:
|
||||
selection_mark_word(
|
||||
seat, term, seat->mouse.col, seat->mouse.row, false, serial);
|
||||
case BIND_ACTION_SELECT_WORD: {
|
||||
bool cursor_is_on_grid = seat->mouse.col >= 0 && seat->mouse.row >= 0;
|
||||
if (selection_enabled(term, seat) && cursor_is_on_grid) {
|
||||
selection_mark_word(
|
||||
seat, term, seat->mouse.col, seat->mouse.row, false, serial);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case BIND_ACTION_SELECT_WORD_WS:
|
||||
selection_mark_word(
|
||||
seat, term, seat->mouse.col, seat->mouse.row, true, serial);
|
||||
case BIND_ACTION_SELECT_WORD_WS: {
|
||||
bool cursor_is_on_grid = seat->mouse.col >= 0 && seat->mouse.row >= 0;
|
||||
if (selection_enabled(term, seat) && cursor_is_on_grid) {
|
||||
selection_mark_word(
|
||||
seat, term, seat->mouse.col, seat->mouse.row, true, serial);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case BIND_ACTION_SELECT_ROW:
|
||||
selection_mark_row(seat, term, seat->mouse.row, serial);
|
||||
case BIND_ACTION_SELECT_ROW: {
|
||||
bool cursor_is_on_grid = seat->mouse.col >= 0 && seat->mouse.row >= 0;
|
||||
if (selection_enabled(term, seat) && cursor_is_on_grid)
|
||||
selection_mark_row(seat, term, seat->mouse.row, serial);
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
case BIND_ACTION_COUNT:
|
||||
assert(false);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue