aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Eklöf <daniel@ekloef.se>2020-08-11 08:42:23 +0000
committerDaniel Eklöf <daniel@ekloef.se>2020-08-14 05:38:56 +0000
commit28410f1b998d1b298941530355d1e6bb37f269a0 (patch)
treee50f17b9f098a48dce7ee100e55b5f32c211999a
parentdoc: footrc: mouse-bindings: clean up description (diff)
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).
-rw-r--r--input.c46
1 files changed, 33 insertions, 13 deletions
diff --git a/input.c b/input.c
index 518a690b..e1e061ed 100644
--- a/input.c
+++ b/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);