Commit graph

112 commits

Author SHA1 Message Date
Daniel Eklöf
4ee5a81d1a
input: toggle maximized state when double-clicking the title bar 2020-02-29 11:56:16 +01:00
Daniel Eklöf
7b51d6919d
input: handle double/triple click state regardless of surface 2020-02-29 11:55:43 +01:00
Daniel Eklöf
d48a789412
input: handle CSD border corners correctly
That is, change to correct cursor, and do resize correctly.
2020-02-29 09:32:22 +01:00
Daniel Eklöf
d863ea8a46
input: temporary code to trigger maximize/minimize 2020-02-26 13:23:11 +01:00
Daniel Eklöf
c0e3db1712
input: wip: trigger move/resize when left-clicking CSD 2020-02-25 20:31:13 +01:00
Daniel Eklöf
551170d940
input: pointer-motion/button: ignore actions in non-main surfaces 2020-02-24 22:42:04 +01:00
Daniel Eklöf
7b18f8394e
input: pointer-leave: reset 'active-surface' in terminal 2020-02-24 22:41:46 +01:00
Daniel Eklöf
d303084a81
input: pointer-enter: differentiate between the surfaces 2020-02-24 22:40:24 +01:00
Daniel Eklöf
d804bc8579
term: resize: pre-calculate right/bottom margins 2020-02-24 18:38:11 +01:00
Daniel Eklöf
e5253ca737
input: fix xcursor getting stuck
Apparently, a frame callback for the cursor surface is *never*
triggered if we get a pointer-leave event *before* the callback is
triggered. At least on Sway 1.4.

This caused the cursor being stuck, and never updating once this state
was reached.

Fix by destroying the cursor frame callback on pointer-leave.
2020-02-15 19:02:43 +01:00
Daniel Eklöf
8716430450
input: ctrl+= increases font size, not resets it 2020-02-10 21:57:55 +01:00
Daniel Eklöf
1b81c700f9
input: hook ctrl+{=,0} to term_font_size_reset() 2020-02-08 17:58:06 +01:00
Daniel Eklöf
7ca8f85cd0
input: hook ctrl+{plus/KP-Add/minus/KP-Subtract} to term_font_size_{increase,decrease} 2020-02-08 14:09:28 +01:00
Daniel Eklöf
d6ea676ef2
presentation: store input timestamp in a per-commit context
This should reduce the risk of mixing up an input timestamp with the
corresponding rendered frame.
2020-01-21 18:51:04 +01:00
Daniel Eklöf
a3d919a90d
input: implement metaSendsEscape and eightBitMeta 2020-01-20 18:45:14 +01:00
Daniel Eklöf
c645a4b180
input: reset XKB compose state on keyboard leave 2020-01-14 19:32:02 +01:00
Daniel Eklöf
3a108499ce
Revert "input: generate key down events on keyboard-enter"
This reverts commit 84739d78c6.
2020-01-14 19:28:37 +01:00
Daniel Eklöf
84739d78c6
input: generate key down events on keyboard-enter 2020-01-13 19:59:18 +01:00
Daniel Eklöf
c80cbc9a79
input: reset modifier state on keyboard-leave 2020-01-13 19:58:57 +01:00
Daniel Eklöf
53a437007e
input: comments 2020-01-11 18:59:46 +01:00
Daniel Eklöf
fed0e5c853
input: keymap_lookup: only do lookup, don't sent to client 2020-01-11 18:40:27 +01:00
Daniel Eklöf
e658fe3da7
input: add a switch-based function that translates XKB keysym to escape data 2020-01-11 18:18:31 +01:00
Daniel Eklöf
8efedc9655
input: break out keymap lookup to a separate function 2020-01-11 17:55:45 +01:00
Daniel Eklöf
040a1cd00d
input: scroll: call term_mouse_up() once, after all term_mouse_down()
Note that scroll button release events are not actually sent to the
client, but this makes the code more correct, logically.
2020-01-04 21:35:38 +01:00
Daniel Eklöf
d706e68280
selection: track selection type; normal or block selection 2020-01-03 23:29:45 +01:00
Daniel Eklöf
4be3c04999
input: keyboard-leave: move comment to where it belongs 2020-01-02 19:30:34 +01:00
Daniel Eklöf
e9325b958f
term: rename term_focus_{in,out} -> term_kbd_focus_{in,out} 2020-01-02 19:29:42 +01:00
Daniel Eklöf
4ecb0ecf4d
wayland: rename focused/moused to kbd_focus/mouse_focus 2020-01-02 15:58:52 +01:00
Daniel Eklöf
5a07419096
wayland: optionally use the presentation time protocol to measure input lag
This adds a flag, -p,--presentation-timings, that enables input lag
measuring using the presentation time Wayland protocol.

When enabled, we store a timestamp when we *send* a key to the
slave. Then, when we commit a frame for rendering to the compositor,
we request presentation feedback. We also store a timestamp for when
the frame was committed.

The 'presented' callback then looks at the input and commit
timestamps, and compares it with the presented timestamp.

The delay is logged at INFO when the delay was less than one frame
interval, at WARN when it was one frame interval, and at ERR when it
was two or more frame intervals.

We also update statistic counters that we log when foot is shut down.
2019-12-31 15:39:40 +01:00
Daniel Eklöf
57de9feaa5
term: term_spawn_new(): new function, spawns a new foot/footclient process
Bind ctrl+shift+return to it
2019-12-21 15:27:17 +01:00
Daniel Eklöf
81840b4e8e
cursor blink: move reset to pty input 2019-12-19 07:23:58 +01:00
Daniel Eklöf
66b948750e
input: restart cursor blink on keyboard input
This makes the cursor stay unblinking while typing.
2019-12-16 21:33:44 +01:00
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