Commit graph

203 commits

Author SHA1 Message Date
Daniel Eklöf
4d2bc54fa2
config: mouse bindings: add select-begin-block and select-row 2020-08-14 07:38:56 +02:00
Daniel Eklöf
20f0334e13
config: add mouse specific bind actions
This extends the "normal" bind action enum with mouse specific
actions.

When parsing key bindings, we only check up to the last valid keyboard
binding, while mouse bindings support *both* key actions and mouse
actions.

The new actions are:

* select-begin: starts an interactive selection
* select-extend: interactively extend an existing selection
* select-word: select word under cursor
* select-word-whitespace: select word under cursor, where the only
  word separating characters are whitespace characters.

The old hard-coded selection "bindings" have been converted to instead
use these actions, via default bindings added to the configuration.
2020-08-14 07:38:55 +02:00
Daniel Eklöf
9b65531d6a
Merge branch 'modifiers-in-mouse-bindings' into master 2020-08-14 07:36:34 +02:00
Daniel Eklöf
44557dc7cf
input: don't crash on mouse motion events on the render timer surface 2020-08-14 07:35:01 +02:00
Daniel Eklöf
b97ef5819f
config: key/mouse bindings: refactor: less parsing in keyboard_enter()
This simplifies the handling of mouse and keyboard bindings.

Before, the bindings where parsed *both* when loading the
configuration, and then on every keyboard enter event. This was done
since keys require a keymap to be decoded. Something we don't have at
configuration time. The idea was that at config time, we used a
default keymap just to verify the key combo strings were valid.

The following has changed:

* The bindings in the config struct is now *one* key combo per
  entry. Previously, it was one *action* per entry, and each entry
  had one or more key combos.

  Doing it this way makes it easier when converting the binding in the
  keyboard enter event (which previously had to expand the combos
  anyway).

* The bindings in the config struct no longer contains any unparsed
  strings.

  A key binding contains a decoded 'modifier' struct (which specifies
  whether e.g. ctrl, or shift, or ctrl+shift must be pressed for the
  binding to be used).

  It also contains a decoded XKB keysym.

* A mouse binding in the config struct is similar to a key binding,
  except it contains the button, and click count instead of the XKB
  key sym.

* The modifiers in the user-specified key combo is decoded at config
  time, by using the pre-defined XKB constants
  XKB_MOD_NAME_<modifier>.

  The result is stored in a 'modifiers' struct, which is just a
  collection of booleans; one for each supported modifier.

  The supported modifiers are: shift, ctrl, alt and meta/super.

* The key sym is decoded at config time using
  xkb_keysym_from_name(). This call does *not* depend on a keymap.

* The mouse button is decoded at config time using a hardcoded mapping
  table (just like before).

* The click count is currently hard-coded to 1.

* In the keyboard enter event, all we need to do is pre-compute the
  xkb_mod_mask_t variable for each key/mouse binding, and find all the
  *key codes* that map to the (already decoded) symbol.

  For mouse bindings, the modifiers are the *only* reason we convert
  the mouse bindings at all.

  In fact, on button events, we check if the seat has a keyboard. If
  not, we use the mouse bindings from the configuration directly, and
  simply filter out those with a non-empty set of modifiers.
2020-08-13 18:47:19 +02:00
Daniel Eklöf
375dcf0810
input: pointer-leave: don't reset mouse properties with memset()
Using memset() also clears the mouse bindings. This is both incorrect,
and leaked memory.
2020-08-13 18:47:19 +02:00
Daniel Eklöf
544c1b1976
config: wip: add support for modifiers in mouse bindings
Mouse bindings can now include modifiers. They are specified in pretty
much the same way as in keyboard bindings:

  Control+BTN_LEFT
2020-08-13 18:47:19 +02:00
Craig Barnes
7a77958ba2 Convert most dynamic allocations to use functions from xmalloc.h 2020-08-08 20:37:57 +01:00
Daniel Eklöf
e391658d72
Merge branch 'selection-improvements' into master
Closes #70
2020-08-08 10:19:04 +02:00
Daniel Eklöf
4156a64044
input: motion: improve comment 2020-08-08 10:08:47 +02:00
Daniel Eklöf
a3d5626256
input: pointer-enter: add comment describing what we're doing 2020-08-08 10:07:25 +02:00
Daniel Eklöf
7497e44826
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.
2020-08-08 10:00:18 +02:00
Daniel Eklöf
d49d1fd59d
input: scrolling: don't send events to client if cursor is outside grid 2020-08-07 22:07:16 +02:00
Daniel Eklöf
76c3629cbf
input: mouse: motion/enter: cleanup inside/outside grid handling 2020-08-07 22:04:37 +02:00
Craig Barnes
7eb70a453b Replace GCC "unused" and "format" attributes with portable macros 2020-08-07 20:42:34 +01:00
Daniel Eklöf
4178418010
input: button: button events aren't passed to clients, when cursor is outside grid
Don't send mouse button escapes to a mouse grabbing client when the
cursor is outside the grid (i.e. when it is inside the margins).

Also don't do *any* kind of selection when the cursor is outside the
grid. Previously, we only checked this for selection_start(), but
e.g. double clicking would run selection_extend(), or
selection_mark_word() etc.
2020-08-07 19:59:03 +02:00
Daniel Eklöf
721ca80abe
input: motion: do selection update even if cursor is outside the grid
Previously, the selection was only updated when the mouse cursor was
inside the grid. This makes it difficult to e.g. do large selections
fast, since you often end up moving the cursor outside the grid, or
outside the terminal window even.

Now, we update the selection regardless of *where* the cursor is. This
is done by bounding the row/col we pass to 'selection_update()' to the
grid, while still setting the seat's row/col to -1 when the cursor is
outside the grid, to ensure the xcursor etc are set correctly.

Care must also be taken to *not* pass any motion events to a mouse
grabbing client, when the cursor is outside the grid.

Closes #70.
2020-08-07 19:58:56 +02:00
Daniel Eklöf
158722b642
input: fix col/row calculation when cursor is in the top or left margin
This fixes an issue where the col/row were incorrectly set to 0
instead of -1, when the mouse cursor was inside the grid margins.

This resulted in e.g. the mouse cursor having the wrong shape, and
foot incorrectly handling mouse events as if they were inside the
grid.
2020-08-07 19:51:34 +02:00
Daniel Eklöf
32a155fbf4
input: disable debug loggin 2020-08-04 18:07:41 +02:00
Daniel Eklöf
a371ea0f02
input: ignore ISO Level 3 Shift (AltGr) when hiding the mouse cursor 2020-08-04 07:38:21 +02:00
Daniel Eklöf
d929862245
config: move cursor.hide-when-typing to mouse.hide-when-typing 2020-08-04 07:33:15 +02:00
Daniel Eklöf
36468b0406
config: add scrollback.multiplier option
This option is used to multiply the mouse scroll amount for mouse and
trackpad based scrollback scrolling.

Closes #54.
2020-08-03 20:08:39 +02:00
Daniel Eklöf
93b03c91ed
input: hide-when-typing: ignore modifiers 2020-08-03 18:19:43 +02:00
Daniel Eklöf
a026938547
input: don't hide cursor if key is 'shift'
Since shift is used to enable selecting text in mouse-grabbing
applications, hiding the cursor in this case is counter productive.
2020-08-01 15:39:25 +02:00
Daniel Eklöf
d4ee9be4d7
config: add 'hide-when-typing'
When enabled, the mouse cursor is hidden when the user types in the
terminal. It is un-hidden when the user moves the mouse, or when the
window loses keyboard focus.
2020-07-31 17:09:06 +02:00
Daniel Eklöf
639a61abd8
config: add 'pipe-selected' key binding
This works just like pipe-visible and pipe-scrollback, but pipes the
user-selected text, if any, to the external tool.

Closes #51
2020-07-31 17:04:30 +02:00
Daniel Eklöf
7767041c2c
config: tokenize key bindings' pipe command when loading the configuration
This allows us to detect syntax errors early on, and is also more
efficient since we don't have to re-tokenize the command line every
time the binding is executed.
2020-07-30 18:53:51 +02:00
Daniel Eklöf
5c20069588
Merge branch 'master' into scrollback-position-indicator 2020-07-27 16:51:39 +02:00
Daniel Eklöf
7127a0a6c3
selection: extending a selection is now interactive
That is, a selection extension can be resized just like an ordinary
extension.
2020-07-27 16:44:41 +02:00
Daniel Eklöf
1a65b161dc
input: handle the scrollback indicator surface in pointer events 2020-07-26 12:37:35 +02:00
Daniel Eklöf
c1f35731e0
input: margins are not selectable
* Fix col/row calculation in pointer-enter event; we did not take the
  margins into account.
* seat->mouse.col,row are now set to -1 if the cursor is inside the
  margins. That is, col/row are only ever valid when the mouse is
  actually over the grid, and not in the margins.
* Use regular 'left-ptr' mouse cursor when mouse is inside the
  margins, to not make the user think he/she can start a selection.

Besides making things clearer, this also fixes a crash that occurred
if you started a selection in e.g. the right margin.
2020-07-26 12:37:02 +02:00
Daniel Eklöf
10f53325e1
input: pipe: avoid goto's where variables may be uninitialized 2020-07-22 19:34:07 +02:00
Daniel Eklöf
22c73eaf4b
input: pipe-{visible,scrollback}: redirect stdout/stderr to /dev/null 2020-07-15 18:17:28 +02:00
Daniel Eklöf
be9c566622
input: comments 2020-07-15 16:47:01 +02:00
Daniel Eklöf
1541531765
conf: bindings: allow several mappings for the same action
If the bindings has different pipe command associated with them, treat
them as different actions.
2020-07-15 16:43:11 +02:00
Daniel Eklöf
062b0eb7ab
input: wip: initial support for piping scrollback/view to external tools 2020-07-15 13:34:32 +02:00
Daniel Eklöf
f21ea97037
input: parse_key_binding: free key-codes list if 'bindings' is NULL 2020-07-15 13:26:13 +02:00
Daniel Eklöf
85c50099af
conf: add definitions for pipe-{scrollback,view} bindings 2020-07-15 09:46:13 +02:00
Daniel Eklöf
21674ab382
input: keyboard: keymap: close(fd) on early-return when failing to mmap 2020-07-14 08:55:20 +02:00
Daniel Eklöf
0ed02e9676
input: keyboard: keymap: use xkb_keymap_new_from_buffer() 2020-07-14 08:52:42 +02:00
Daniel Eklöf
307eead987
input: keyboard: detect failure to mmap keymap 2020-07-14 08:52:11 +02:00
Daniel Eklöf
b5776487ab
input: include seat name in debug log output 2020-07-11 11:13:45 +02:00
Daniel Eklöf
71584aed38
seat: use separate 'enter' serials for keyboard and mouse 2020-07-09 11:20:46 +02:00
Daniel Eklöf
4e48d550ef
multi-seat: improve handling of multiple (mouse) pointers
* xcursor always set for all pointers
* xcursor sometimes not updated when it should be
* mouse grabbed state wasn't per seat, but global (i.e. "does at least
  one seat enable mouse grabbing")
* selection enabled state wasn't per seat
2020-07-09 09:52:11 +02:00
Daniel Eklöf
6bbd4a5110
focus in/out: terminal checks whether it is a state change or not 2020-07-09 09:16:54 +02:00
Daniel Eklöf
fc9fde88c3
input: only call term_kbd_focus_{in,out}() on actual state change
That is, only call term_kbd_focus_in() if we're the *first* seat
focusing that terminal, and only call term_kbd_focus_out() if we're
the *last* seat that focused it.
2020-07-09 08:46:25 +02:00
Daniel Eklöf
d377221e24
xcursor: trigger theme reload in pointer-enter event
Previously, we triggered a theme reload on output changes. This is
completely wrong. We may get a new output with a scale different from
the output the pointer is actually on.

Now, we store the current scale along with the theme. We then trigger
a call to reload the xcursor theme *every* time the pointer enters a
surface. When it does, we use the current scale factor of the terminal
that owns that surface.

If the terminal covers multiple outputs, with different scale factors,
we'll use the largest scale factor. This may not be 100% correct. But
to fix that, we'd need to track which regions of a surface are mapped
on which outputs. Too complicated I say.
2020-07-08 19:52:17 +02:00
Daniel Eklöf
4c7d29f7eb
multi-seat: re-enable selection support (excluding OSC 52) 2020-07-08 18:41:09 +02:00
Daniel Eklöf
04e566492c
multi-seat: re-enable scrollback search support 2020-07-08 18:20:34 +02:00
Daniel Eklöf
58415428cf
multi-seat: re-enable mouse button+motion reporting support 2020-07-08 18:16:43 +02:00