diff options
| author | Daniel Eklöf <daniel@ekloef.se> | 2020-08-14 05:39:11 +0000 |
|---|---|---|
| committer | Daniel Eklöf <daniel@ekloef.se> | 2020-08-14 05:39:11 +0000 |
| commit | 394db77b04294c505e0a66560e5d8b13150f1191 (patch) | |
| tree | a01d72bd6abed970261fb5c4fa4fb331c7ff5d64 /input.c | |
| parent | Merge branch 'click-count-in-mouse-bindings' into master (diff) | |
| parent | input: mouse motion: don't update selection while scrollback searching (diff) | |
Merge branch 'mouse-binding-actions' into master
Closes #79. Closes #75.
Diffstat (limited to 'input.c')
| -rw-r--r-- | input.c | 88 |
1 files changed, 52 insertions, 36 deletions
@@ -81,6 +81,8 @@ execute_binding(struct seat *seat, struct terminal *term, enum bind_action_normal action, char *const *pipe_argv, uint32_t serial) { + const bool cursor_is_on_grid = seat->mouse.col >= 0 && seat->mouse.row >= 0; + switch (action) { case BIND_ACTION_NONE: break; @@ -254,6 +256,46 @@ execute_binding(struct seat *seat, struct terminal *term, break; } + case BIND_ACTION_SELECT_BEGIN: + 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: + 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: + if (selection_enabled(term, seat) && cursor_is_on_grid) { + selection_extend( + seat, term, seat->mouse.col, seat->mouse.row, serial); + } + break; + + case BIND_ACTION_SELECT_WORD: + 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: + 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: + 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); break; @@ -1254,7 +1296,7 @@ wl_pointer_motion(void *data, struct wl_pointer *wl_pointer, bool cursor_is_on_grid = seat->mouse.col >= 0 && seat->mouse.row >= 0; /* Update selection */ - if (seat->mouse.button == BTN_LEFT || seat->mouse.button == BTN_RIGHT) { + if (!term->is_searching) { if (cursor_is_on_new_cell || term->selection.end.row < 0) selection_update(term, selection_col, selection_row); } @@ -1437,44 +1479,19 @@ wl_pointer_button(void *data, struct wl_pointer *wl_pointer, bool cursor_is_on_grid = seat->mouse.col >= 0 && seat->mouse.row >= 0; - xkb_mod_mask_t mods = xkb_state_serialize_mods( - seat->kbd.xkb_state, XKB_STATE_MODS_DEPRESSED); - switch (state) { case WL_POINTER_BUTTON_STATE_PRESSED: { - if (button == BTN_LEFT && seat->mouse.count <= 3 && mods == 0) { - selection_cancel(term); - - if (selection_enabled(term, seat) && cursor_is_on_grid) { - switch (seat->mouse.count) { - case 1: - selection_start( - term, seat->mouse.col, seat->mouse.row, - seat->kbd.ctrl ? SELECTION_BLOCK : SELECTION_NORMAL); - break; - - case 2: - selection_mark_word( - seat, term, seat->mouse.col, seat->mouse.row, - seat->kbd.ctrl, serial); - break; + if (seat->wl_keyboard != NULL) { + /* Seat has keyboard - use mouse bindings *with* modifiers */ - case 3: - selection_mark_row(seat, term, seat->mouse.row, serial); - break; - } - } - } + xkb_mod_mask_t mods = xkb_state_serialize_mods( + seat->kbd.xkb_state, XKB_STATE_MODS_DEPRESSED); - else if (button == BTN_RIGHT && seat->mouse.count == 1 && mods == 0) { - if (selection_enabled(term, seat) && cursor_is_on_grid) { - selection_extend( - seat, term, seat->mouse.col, seat->mouse.row, serial); - } - } + /* Ignore Shift when matching modifiers, since it is + * used to enable selection in mouse grabbing client + * applications */ + mods &= ~(1 << seat->kbd.mod_shift); - else if (seat->wl_keyboard != NULL) { - /* Seat has keyboard - use mouse bindings *with* modifiers */ tll_foreach(seat->mouse.bindings, it) { const struct mouse_binding *binding = &it->item; @@ -1533,8 +1550,7 @@ wl_pointer_button(void *data, struct wl_pointer *wl_pointer, } case WL_POINTER_BUTTON_STATE_RELEASED: - if (button == BTN_LEFT && term->selection.end.col != -1) - selection_finalize(seat, term, serial); + selection_finalize(seat, term, serial); if (!term_mouse_grabbed(term, seat) && cursor_is_on_grid) { term_mouse_up( |
