From 9352befd13d42199f9c9b67fb6b147df5d2998c3 Mon Sep 17 00:00:00 2001 From: Daniel Eklöf Date: Tue, 11 Aug 2020 10:03:14 +0200 Subject: doc: footrc: document the new mouse actions --- doc/footrc.5.scd | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'doc') diff --git a/doc/footrc.5.scd b/doc/footrc.5.scd index 5f39f72d..4476daa1 100644 --- a/doc/footrc.5.scd +++ b/doc/footrc.5.scd @@ -385,6 +385,24 @@ e.g. *primary-paste=none*. All actions listed under *key-bindings* can be user here as well. +*select-begin* + Begin an interactive selection. The selection is finalized, and + copied to the _primary selection_, when the button is + released..Default: _BTN\_LEFT_. + +*select-extend* + Interactively extend an existing selection. The selection is + finalized, and copied to the _primary selection_, when the button + is released. Default: _BTN\_RIGHT_. + +*select-word* + Select the _word_ (separated by spaces, period, comma, parenthesis + etc) under the pointer. Default: _BTN\_LEFT-2_. + +*select-word-whitespace* + Select the _word_ (separated by spaces _only_) under the + pointer. Default: Control+_BTN\_LEFT-2_. + *primary-paste* Pastes from the _primary selection_. Default: _BTN\_MIDDLE_. -- cgit v1.3 From 4d2bc54fa216dfda98c4b228b9576dcad471858c Mon Sep 17 00:00:00 2001 From: Daniel Eklöf Date: Tue, 11 Aug 2020 10:17:19 +0200 Subject: config: mouse bindings: add select-begin-block and select-row --- config.c | 8 ++++++-- doc/footrc.5.scd | 10 +++++++++- footrc | 4 +++- input.c | 33 +++++++++++++++++++-------------- wayland.h | 4 +++- 5 files changed, 40 insertions(+), 19 deletions(-) (limited to 'doc') diff --git a/config.c b/config.c index 69883b68..d46b5f8e 100644 --- a/config.c +++ b/config.c @@ -72,9 +72,11 @@ static const char *const binding_action_map[] = { /* Mouse-specific actions */ [BIND_ACTION_SELECT_BEGIN] = "select-begin", + [BIND_ACTION_SELECT_BEGIN_BLOCK] = "select-begin-block", + [BIND_ACTION_SELECT_EXTEND] = "select-extend", [BIND_ACTION_SELECT_WORD] = "select-word", [BIND_ACTION_SELECT_WORD_WS] = "select-word-whitespace", - [BIND_ACTION_SELECT_EXTEND] = "select-extend", + [BIND_ACTION_SELECT_ROW] = "select-row", }; static_assert(ALEN(binding_action_map) == BIND_ACTION_COUNT, @@ -1534,9 +1536,11 @@ add_default_mouse_bindings(struct config *conf) add_binding(BIND_ACTION_PRIMARY_PASTE, none, BTN_MIDDLE, 1); add_binding(BIND_ACTION_SELECT_BEGIN, none, BTN_LEFT, 1); + add_binding(BIND_ACTION_SELECT_BEGIN_BLOCK, ctrl, BTN_LEFT, 1); + add_binding(BIND_ACTION_SELECT_EXTEND, none, BTN_RIGHT, 1); add_binding(BIND_ACTION_SELECT_WORD, none, BTN_LEFT, 2); add_binding(BIND_ACTION_SELECT_WORD_WS, ctrl, BTN_LEFT, 2); - add_binding(BIND_ACTION_SELECT_EXTEND, none, BTN_RIGHT, 1); + add_binding(BIND_ACTION_SELECT_ROW, none, BTN_LEFT, 3); #undef add_binding } diff --git a/doc/footrc.5.scd b/doc/footrc.5.scd index 4476daa1..a5792671 100644 --- a/doc/footrc.5.scd +++ b/doc/footrc.5.scd @@ -388,7 +388,12 @@ All actions listed under *key-bindings* can be user here as well. *select-begin* Begin an interactive selection. The selection is finalized, and copied to the _primary selection_, when the button is - released..Default: _BTN\_LEFT_. + released. Default: _BTN\_LEFT_. + +*select-begin-block* + Begin an interactive block selection. The selection is finalized, + and copied to the _primary selection_, when the button is + released. Default: _Control+BTN\_LEFT_. *select-extend* Interactively extend an existing selection. The selection is @@ -403,6 +408,9 @@ All actions listed under *key-bindings* can be user here as well. Select the _word_ (separated by spaces _only_) under the pointer. Default: Control+_BTN\_LEFT-2_. +*select-row* + Select the whole row under the pointer. Default: _BTN\_LEFT-3_. + *primary-paste* Pastes from the _primary selection_. Default: _BTN\_MIDDLE_. diff --git a/footrc b/footrc index 062b9177..a76c71e9 100644 --- a/footrc +++ b/footrc @@ -94,6 +94,8 @@ [mouse-bindings] # primary-paste=BTN_MIDDLE # select-begin=BTN_LEFT +# select-begin-block=Control=BTN_LEFT +# select-extend=BTN_RIGHT # select-word=BTN_LEFT-2 # select-word-whitespace=Control+BTN_LEFT-2 -# select-extend=BTN_RIGHT +# select-row=BTN_LEFT-3 diff --git a/input.c b/input.c index 9e260e69..518a690b 100644 --- a/input.c +++ b/input.c @@ -255,11 +255,22 @@ execute_binding(struct seat *seat, struct terminal *term, } case BIND_ACTION_SELECT_BEGIN: - selection_start( - term, seat->mouse.col, seat->mouse.row, - seat->kbd.ctrl ? SELECTION_BLOCK : SELECTION_NORMAL); + 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); + break; + + case BIND_ACTION_SELECT_EXTEND: { + bool cursor_is_on_grid = seat->mouse.col >= 0 && seat->mouse.row >= 0; + 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: selection_mark_word( seat, term, seat->mouse.col, seat->mouse.row, false, serial); @@ -270,14 +281,10 @@ execute_binding(struct seat *seat, struct terminal *term, seat, term, seat->mouse.col, seat->mouse.row, true, serial); break; - case BIND_ACTION_SELECT_EXTEND: { - bool cursor_is_on_grid = seat->mouse.col >= 0 && seat->mouse.row >= 0; - if (selection_enabled(term, seat) && cursor_is_on_grid) { - selection_extend( - seat, term, seat->mouse.col, seat->mouse.row, serial); - } + case BIND_ACTION_SELECT_ROW: + selection_mark_row(seat, term, seat->mouse.row, serial); break; - } + case BIND_ACTION_COUNT: assert(false); @@ -1279,10 +1286,8 @@ 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 (cursor_is_on_new_cell || term->selection.end.row < 0) - selection_update(term, selection_col, selection_row); - } + 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) && diff --git a/wayland.h b/wayland.h index b7528a7f..85cc1ca7 100644 --- a/wayland.h +++ b/wayland.h @@ -47,9 +47,11 @@ enum bind_action_normal { /* Mouse specific actions - i.e. they require a mouse coordinate */ BIND_ACTION_SELECT_BEGIN, + BIND_ACTION_SELECT_BEGIN_BLOCK, + BIND_ACTION_SELECT_EXTEND, BIND_ACTION_SELECT_WORD, BIND_ACTION_SELECT_WORD_WS, - BIND_ACTION_SELECT_EXTEND, + BIND_ACTION_SELECT_ROW, BIND_ACTION_COUNT, }; -- cgit v1.3 From 24ee6d836be6ce3952fecfb5edc44386046a1b9d Mon Sep 17 00:00:00 2001 From: Daniel Eklöf Date: Tue, 11 Aug 2020 10:30:27 +0200 Subject: doc: footrc: mouse-bindings: clean up description --- doc/footrc.5.scd | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) (limited to 'doc') diff --git a/doc/footrc.5.scd b/doc/footrc.5.scd index a5792671..64f9c500 100644 --- a/doc/footrc.5.scd +++ b/doc/footrc.5.scd @@ -364,24 +364,20 @@ This section lets you override the default mouse bindings. The general format is _action=combo1...comboN_. That is, each action may have one or more key combinations, space separated. Each -combination is on the form _mod1+mod2+BTN\__[-COUNT]. The names -of the modifiers and the key *must* be valid XKB key names. You can -find the button names using *libinput debug-events*. +combination is on the form _mod1+mod2+BTN\_[-COUNT]_. The names +of the modifiers *must* be valid XKB key names, and the button name +*must* be a valid libinput name. You can find the button names using +*libinput debug-events*. The trailing *COUNT* is optional and specifies the click count -required to trigger the binding. The default is *COUNT* is omitted is +required to trigger the binding. The default if *COUNT* is omitted is _1_. -Example: *primary-paste=Control+BTN_LEFT-2* - -Trigger _primary-paste_ when *ctrl* is pressed, and the left mouse -button is double clicked. - -A button can only be mapped to *one* action. Lets say you want to bind -*BTN\_MIDDLE* to *fullscreen*. Since *BTN\_MIDDLE* is the default -binding for *primary-paste*, you first need to unmap the default -binding. This can be done by setting _action=none_; -e.g. *primary-paste=none*. +A modifier+button combination can only be mapped to *one* action. Lets +say you want to bind *BTN\_MIDDLE* to *fullscreen*. Since +*BTN\_MIDDLE* is the default binding for *primary-paste*, you first +need to unmap the default binding. This can be done by setting +_action=none_; e.g. *primary-paste=none*. All actions listed under *key-bindings* can be user here as well. -- cgit v1.3 From 517d13fbce3ae56f154343671c325c000a7de040 Mon Sep 17 00:00:00 2001 From: Daniel Eklöf Date: Tue, 11 Aug 2020 10:44:27 +0200 Subject: config: don't allow Shift in mouse bindings Shift is a special modifier that is used to enable selection when the client application is grabbing the mouse. --- config.c | 5 +++++ doc/footrc.5.scd | 4 ++++ 2 files changed, 9 insertions(+) (limited to 'doc') diff --git a/config.c b/config.c index d46b5f8e..40a7e81b 100644 --- a/config.c +++ b/config.c @@ -1026,6 +1026,11 @@ parse_mouse_combos(struct config *conf, const char *combos, key_combo_list_t *ke *key = '\0'; if (!parse_modifiers(conf, combo, key - combo, &modifiers, path, lineno)) goto err; + if (modifiers.shift) { + LOG_AND_NOTIFY_ERR("%s:%d: Shift cannot be used in mosue bindings", + path, lineno); + goto err; + } key++; /* Skip past the '+' */ } diff --git a/doc/footrc.5.scd b/doc/footrc.5.scd index 64f9c500..d5ea808d 100644 --- a/doc/footrc.5.scd +++ b/doc/footrc.5.scd @@ -369,6 +369,10 @@ of the modifiers *must* be valid XKB key names, and the button name *must* be a valid libinput name. You can find the button names using *libinput debug-events*. +Note that *Shift* cannot be used as a modifier in mouse bindings since +it is used to enable selection when the client application is grabbing +the mouse. + The trailing *COUNT* is optional and specifies the click count required to trigger the binding. The default if *COUNT* is omitted is _1_. -- cgit v1.3