Commit graph

80 commits

Author SHA1 Message Date
Daniel Eklöf
f1c876884a
input: discard canceled compose sequences 2019-12-02 21:32:09 +01:00
Daniel Eklöf
fbeb1e9610
term: mouse reporting functions no longer take modifier state
The mouse reporting functions are called from input when we receive
Wayland mouse events.

We used to pass the current keyboard modifier (shift, alt, ctrl, etc)
to the terminal functions.

This however is wrong, since we may receive Wayland mouse events
without having keyboard focus. When we don't have keyboard focus, the
modifier state doesn't apply to us.

Remove the modifier arguments from the terminal mouse reporting
functions. These functions now read this state directly instead, but
only when the terminal instance in question has keyboard focus.
2019-11-30 17:11:00 +01:00
Daniel Eklöf
664041d04f
input: doh! mouse_scroll: first argument to keyboard_key() is a struct wayland
This is the problem with void* user data pointers in callbacks...
2019-11-30 16:54:41 +01:00
Daniel Eklöf
6aa14ccdfc
input: mouse_scroll: cache XKB_KEY_Up and XKB_KEY_Down 2019-11-30 16:48:58 +01:00
Daniel Eklöf
841e20b75b
input: update xcursor on terminal with *keyboard* focus when modifiers change 2019-11-30 12:02:45 +01:00
Daniel Eklöf
2c12549f93
input: pointer-leave: reset moused *before* doing anything else
And update xcursor. This is currently not necessary, but doesn't hurt.
2019-11-29 22:13:19 +01:00
Daniel Eklöf
6947928a7f
input: pointer-enter: add debug log 2019-11-29 22:12:54 +01:00
Daniel Eklöf
6b9837056e
input: keyboard_leave: reset focused *before* doing anything else
And update xcursor. This is necessary since we may still have mouse
focus. But without keyboard focus, we don't display the 'text'
xcursor.
2019-11-29 22:11:41 +01:00
Daniel Eklöf
2956a7d472
input: keyboard/pointer_leave: warn if we didn't see corresponding enter event 2019-11-28 19:47:00 +01:00
Daniel Eklöf
a319cc813c
input: keyboard/pointer_enter: assert surface != NULL 2019-11-28 19:46:27 +01:00
Daniel Eklöf
0dd37f0a36
terminal: use the 'text' xcursor pointer whenever selection is possible 2019-11-28 19:35:47 +01:00
Daniel Eklöf
729ba8b8ac
input: pointer_button: apply same workaround as in pointer_motion
Sway 1.2 has been seen to send pointer_button events without first
having sent pointer_enter.
2019-11-28 19:26:52 +01:00
Daniel Eklöf
9efa28b4c6
input: sway 1.2 bug: keyboard_leave() called with surface == NULL 2019-11-28 19:24:16 +01:00
Daniel Eklöf
e333bd2176
input: document why wayl->focused may be NULL 2019-11-24 00:06:50 +01:00
Daniel Eklöf
1a68a7cf0b
input: improve behavior when sway bugs out
When we receive a keyboard_key or pointer_motion event without first
having received a keyboard_enter or pointer_enter event (that being
the "sway bugs" part), we generally don't know _which_ terminal window
the event was intended for.

However, if we only have *one* window open (always the case for a
regular 'foot' process, or when there's a single footclient connected
to a foot server process), then obviously we can "guess" which window
the event was intended for... so do that.

Now, the only time the event is ignored is when we're a server process
with more than one window open (= more than one footclient connected).
2019-11-22 22:28:41 +01:00
Daniel Eklöf
937fd6933b
input: use xkb_keymap_key_repeats() to determine if we should start repeat timer 2019-11-22 22:19:00 +01:00
Daniel Eklöf
fd82ffdf52
input: keyboard_key: don't start repeater unless we generated output
I.e. what we're effectively doing is *not* repeating modifier
keys.

Besides being the "right" thing to do, this also works around another
Sway 1.2 bug, where being in a focused foot window and then switching
to a vt and back would cause us to be stuck in an endless key repeat
loop that would only stop when unfocusing, focusing back and then
unfocusing once again.
2019-11-22 22:02:50 +01:00
Daniel Eklöf
9d24e68e62
input: workaround buggy Sway sending bad input events
Sway 1.2 has been seen sending keyboard_key() events without first
sending a keyboard_enter() event.

This can be triggered by:

1. start a foot terminal
2. unfocus it (move focus to another window)
3. switch to a vt
4. switch back to sway
5. focus the foot terminal

At this point, Sway will *not* send the keyboard_enter() event, but
instead send a keyboard_key() event.

(furthermore, if you now unfocus the window again, sway will send a
keyboard_leave() event, still without having sent a keyboard_enter()
event).

Sway has _also_ been seen crashing in wl_pointer_motion(). Though this
was in a build without proper debug information, everything points to
a similar issue - i.e. sway is sending a motion event without first
having sent an enter event.

Workaround this by detecting this and logging a warning the first time
it happens. The event is then ignored.
2019-11-22 22:00:26 +01:00
Daniel Eklöf
34eac2dbe3
keyboard repeat: pass current input serial to keyboard_key()
This fixes an assertion when holding in ctrl+shift+c (copy to
clipboard); subsequent "presses" would set the clipboard serial to 0,
which we would then assert on in the next iteration when we tried to
cancel the previous copy.
2019-11-22 21:55:46 +01:00
Daniel Eklöf
8c945c9832
input: may get keyboard_exit() event with no focused terminal
This happens on Sway when exiting a screen locker. Or at least that's
when we see the problem; it's unclear if the event occurs when
starting the screen locker, or when exiting it. Or maybe its both.

Anyway, don't try to unfocus a NULL-terminal.
2019-11-21 18:17:02 +01:00
Daniel Eklöf
1bc9835246
Revert "input: remove unneeded(?) term_reset_view() calls"
This reverts commit 739c5cf7f0.

The original commit stated:

  Not sure why these were added here; they don't appear to be
  needed (we're writing to the client - it's up to the client to echo
  stuff, in which case we redraw as usual).

But, client output doesn't cause a scrollback/view reset.
2019-11-20 10:41:40 +01:00
Daniel Eklöf
739c5cf7f0
input: remove unneeded(?) term_reset_view() calls
Not sure why these were added here; they don't appear to be
needed (we're writing to the client - it's up to the client to echo
stuff, in which case we redraw as usual).
2019-11-04 14:10:37 +01:00
Daniel Eklöf
9f1525aef7
Rename: vt_to_slave() -> term_to_slave() 2019-11-03 00:52:24 +01:00
Daniel Eklöf
957fb25559
wayland: move reload_cursor_theme() and update_cursor_surface() to wayland 2019-10-27 19:36:45 +01:00
Daniel Eklöf
8c534d0520
input: input_repeat() takes a 'struct wayland' pointer 2019-10-27 18:44:58 +01:00
Daniel Eklöf
9f0b1f94c2
wayland: change all wayland callbacks to take a wayland pointer
Instead of passing the terminal to the wayland callbacks, pass a
'struct wayland' pointer.
2019-10-27 18:43:07 +01:00
Daniel Eklöf
c9455d5f21
kbd: move into wayland 2019-10-27 17:10:32 +01:00
Daniel Eklöf
f862f173f5
input: scale coordinates in wl_pointer_enter() 2019-09-26 18:41:26 +02:00
Daniel Eklöf
2d6369482e
main: initialize scale to '1'
This ensures we always have a valid (but possibly incorrect) scaling
value. This allows us to simplify code that uses the scale - it
doesn't have to verify the scale if valid.

Furthermore, since render_resize() is the function that actually
updates term->scale, make sure to call it *before* updating the
cursor (otherwise, the cursor will use the old scaling value).
2019-09-26 18:39:49 +02:00
Daniel Eklöf
37d941f57a
input: take scale into account when converting mouse coords to row/col 2019-08-30 21:31:14 +02:00
Daniel Eklöf
05888b4706
input: bug: account for margins when converting mouse coords to row/col 2019-08-30 21:30:27 +02:00
Daniel Eklöf
551d51bf9d
input: call term_reset_view() instead of duplicating code 2019-08-28 17:28:26 +02:00
Daniel Eklöf
3f767be500
input: cancel search on mouse button events 2019-08-27 19:48:29 +02:00
Daniel Eklöf
61cabdac13
search: wip: re-direct input while searching, and build a search buffer
This adds a new state, 'is_searching'. While active, input is
re-directed, and stored in a search buffer. In the future, we'll use
this buffer and search for its content in the scrollback buffer, and
move the view and create a selection on matches.

When rendering in 'is_searching', everything is dimmed. In the future,
we'll render the current search buffer on-top of the dimmed "regular"
terminal output.
2019-08-27 17:23:28 +02:00
Daniel Eklöf
71c6f11e86
input: back out accidental commit of debug code 2019-08-19 21:18:43 +02:00
Daniel Eklöf
4168f91d40
csi: implement CSI ? 1007 h/l - alternateScroll
When enabled, mouse scrolls in the alternate screen are converted to
up/down key presses.
2019-08-19 21:16:47 +02:00
Daniel Eklöf
6f1cf8af34
input: remove debug output 2019-08-15 20:09:24 +02:00
Daniel Eklöf
44112e5591
input: handle meta modifier when modifying "other" keys
When handling keys without a specific map defined (i.e. keys
corresponding roughly to xterm's "otherKeys"), recognize the meta
modifier and report the correct modifier code.
2019-08-15 19:38:50 +02:00
Daniel Eklöf
9ca01436ee
input: track meta modifier 2019-08-15 19:38:28 +02:00
Daniel Eklöf
4b06360681
input: free previous XKB state when we get a new one 2019-08-12 21:33:24 +02:00
Daniel Eklöf
70b6d9d7d2
input: don't paste from primary if client is mouse tracking 2019-08-09 21:26:34 +02:00
Daniel Eklöf
481a1cd678
selection/input: triple click selects an entire row 2019-08-06 19:32:06 +02:00
Daniel Eklöf
a82f12dd2b
input: use a timer fd to handle keyboard key repeat
Instead of running a repeater thread that writes the key to repeat
over a pipe, use a simple timer fd.

No more locking or condition signalling. No need to track
start/stop/exist states.

We simply set up the initial timeout value to be the 'delay', and the
interval to be the repeat 'rate'.
2019-08-05 19:33:01 +02:00
Daniel Eklöf
c62ce72778
selection: mark-word using spaces only as word separator
When the user double-clicks with ctrl pressed, we now select the word
under the cursor using spaces only as word separator.
2019-08-05 19:02:27 +02:00
Daniel Eklöf
4d7993b36f
cell: pack more efficiently and store glyph as a wchar
The 'attributes' struct is now 8 bytes and naturally packed (used to
be 9 bytes, artificially packed).

'cell' struct is now 12 bytes, naturally packed (used to be 13 bytes,
artificially packed).

Furthermore, the glyph is stored as a wchar instead of a char*. This
makes it easier (faster) to do glyph lookup when rendering.
2019-08-02 18:19:07 +02:00
Daniel Eklöf
263d3bb2ba
input: fix 'comparison ... is always true' warning (clang) 2019-07-30 20:27:19 +02:00
Daniel Eklöf
f5e9b7b048
input: use keyboard enter serial only for selection serial 2019-07-30 19:29:04 +02:00
Daniel Eklöf
3e06dca12d
input: generate escape sequences for "other" keys
This corresponds to xterm's modifyOtherKeys option, though the code
needs more testing and cleanup.
2019-07-26 18:49:09 +02:00
Daniel Eklöf
e88cf4c8c8
mouse: use discrete axis event if available
This improves the scroll experience with certain devices
2019-07-26 18:48:59 +02:00
Daniel Eklöf
32f397d9b0
input: store last seen wayland input serial
We need this for clipboard data
2019-07-19 11:11:48 +02:00