Commit graph

186 commits

Author SHA1 Message Date
Craig Barnes
7eb70a453b Replace GCC "unused" and "format" attributes with portable macros 2020-08-07 20:42:34 +01: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
Daniel Eklöf
be2490022d
multi-seat: enable xcursor theme support again 2020-07-08 18:08:39 +02:00
Daniel Eklöf
c470825067
wip: multi-seat support
Compiles and runs, but mouse, clipboard and other things have been
disabled.
2020-07-08 16:45:26 +02:00
Daniel Eklöf
26528f6a73
input: add key mapping for XKB_KEY_KP_Decimal 2020-06-27 20:03:41 +02:00
Daniel Eklöf
e4a2d41f51
selection: don't automatically no-op operations if selection isn't enabled
When the client is capturing the mouse, selection can only be done by
holding done shift.

This is why a lot of selection functions are no-ops if selection isn't
currently enabled.

However, there are many cases where we actually need to modify the
selection. In particular, selection_cancel().

Thus, only check for enabled selection when we're dealing with user
input.

Bonus: this also fixes a bug where an ongoing selection were finalized
as soon as the user released shift, even if he was still holding down
the mouse button.
2020-05-16 21:16:11 +02:00
Daniel Eklöf
69c3e74498
util.h: new header file defining commonly used macros 2020-05-01 11:46:24 +02:00
Daniel Eklöf
c96a0b3b3c
misc: replace all explicit zero-initializers with empty initializers 2020-04-13 12:03:11 +02:00
Daniel Eklöf
d67f437458
mbstate: fix compile warning on systems where mbstate_t isn't an integral
An empty initializer still ensures the entire object is
zero-initialized.
2020-04-13 11:58:38 +02:00
Daniel Eklöf
00dbe12e41
input: slow trackpad scrolling now eventually scroll a line
Before, we converted each axis event's scroll amount to an integer and
scrolled that many lines.

However, axis events are speed sensitive - very slow scrolling will
result in events with a scroll amount that is < 1.0.

For us, this meant we never scrolled a single line. You could slow
scroll all day if you wanted, and still we would never scroll a single
line.

Fix this by aggregating the scroll amount from axis events until the
scroll amount is > 1.0, and then scroll.
2020-04-10 18:43:29 +02:00
Daniel Eklöf
fac4b73107
input: right mouse click extends the current selection 2020-04-04 12:02:07 +02:00
Daniel Eklöf
2344f153d9
input: hardcoded left mouse button handler requires click-count <= 3
This enables user mappings for the left mouse button with click count
> 3

I.e. it is now possible to create custom quad-click mappings (except
we don't yet support this in footrc).
2020-04-04 11:57:33 +02:00
Daniel Eklöf
210c0ee5cd
input: only cancel selection on left mouse button clicks 2020-04-04 11:57:08 +02:00
Daniel Eklöf
0419156494
search: replace hard-coded key bindings with "user configurable" ones
They aren't really user configurable. At least not yet.

However, with this, we now handle raw key codes just like the normal
key bindings. Meaning, e.g. ctrl+g, ctrl+a, ctrl+e etc now works while
searching with e.g. a russian layout.
2020-03-18 15:30:14 +01:00
Daniel Eklöf
a69b818a62
input: bindings: don't match raw key code alone - mods must also match 2020-03-18 14:52:39 +01:00
Daniel Eklöf
6d30e7d15d
input: bind key bindings to raw key codes too
Before, when looking for a matching user key binding, we only
matched *symbols*.

This means that the physical keys that generate a specific key binding
is layout dependent. What's worse, it may not even be possible to
generate the key binding at all.

Russian is one such layout, where all the "normal" (us) symbols are
replaced.

By using raw key codes, we can get around this - the key code has a
direct mapping to the physical key.

However, matching raw key codes **only** doesn't always make sense
either. For now, match **both** symbols _and_ key codes. Symbols take
precedence.

TODO: we might have to make this configurable _per binding_.

Note: 'search' mode still uses mostly hardcoded shortcuts that still
have this problem (i.e. ctrl+g doesn't work with a russian layout).
2020-03-18 14:29:34 +01:00
Daniel Eklöf
fb5ab022de
input: key-binding: log error when we fail to translate to XKB symbol 2020-03-18 10:48:42 +01:00
Daniel Eklöf
c10399694e
input: remove Sway 1.2 keyboard/pointer workarounds
Sway 1.4 is better than 1.2, in that we always have keyboard focus
when we get a keyboard_key() event.

That however is because it doesn't send keyboard_leave() on e.g. a TTY
switch.

Still, this is good enough - foot handles this and doesn't crash. We
are also able to process input without having to refocus the window.

And, Sway master (what will become Sway 1.5) has fixed this for real -
we now get a keyboard_leave() and pointer_leave() event on a TTY
switch. And the corresponding enter events when switching back.
2020-03-14 11:54:23 +01:00
Daniel Eklöf
53b681c6f4
input: add debug logs to all keyboard/pointer enter/leave/action events 2020-03-14 11:51:47 +01:00