Commit graph

186 commits

Author SHA1 Message Date
Daniel Eklöf
2560e83c54
term: reduce max number of iterations when trying to drain client 2020-02-05 20:24:46 +01:00
Daniel Eklöf
92376eae01
term: language 2020-02-05 20:23:20 +01:00
Daniel Eklöf
9d52c422e1
term: always read *all* we can from the client before updating state
But place an upper limit on the number of iterations we read, to
prevent starvation caused by a bad behaving client to constantly
writes data.
2020-02-05 19:50:49 +01:00
Daniel Eklöf
8f4ec9aa47
Implement --hold
When specified, we don't exit when the slave/client process exits.
2020-02-03 19:58:32 +01:00
Daniel Eklöf
31baf334b3
fcft: update to 1.1.0 2020-02-01 20:20:22 +01:00
Daniel Eklöf
08eb0532ad
terminal: regression: char printed to wrong column
When term_print() was implemented, it introduced a regression where
printing a character when the last cursor was in the last column on a
line would print the character in the wrong column.

This is because term_print() retrieved a pointer to the current
cell *before* line wrapping (and possibly inserting empty cells).
2020-01-22 18:22:15 +01:00
Daniel Eklöf
a3d919a90d
input: implement metaSendsEscape and eightBitMeta 2020-01-20 18:45:14 +01:00
Daniel Eklöf
0c11459eef
term: fix reset state of VT state 2020-01-20 18:35:13 +01:00
Daniel Eklöf
300f83e66b
term: factor out character printing to new function term_print() 2020-01-20 18:34:32 +01:00
Daniel Eklöf
767a0ec232
fcft: update to 1.0.0
Allow/disallow subpixel antialiasing in font_glyph_for_wc(), not using
font_enable_subpixel_antialias().
2020-01-19 12:44:21 +01:00
Daniel Eklöf
7a00c7ddf4
term: enable subpixel antialiasing if background is opaque 2020-01-18 19:58:14 +01:00
Daniel Eklöf
1623fc0c0a
term: shorten application_synchronized_updates -> app_sync_updates 2020-01-12 12:55:19 +01:00
Daniel Eklöf
02c310d241
term: enable_application_synchronized_updates: not a noop if already enabled
If synchronized updates are already enabled when we receive a request
to enable them, extend the timeout.
2020-01-12 12:51:21 +01:00
Daniel Eklöf
95d2ee0cc1
term: app sync updates: disable delayed rendering timers once only
Disable the delayed rendering timers when enabling application
synchronized updates, not every time we've received ptmx data.
2020-01-12 12:45:34 +01:00
Daniel Eklöf
bdf127fc7e
term/render: move {enable,disable}_application_synchronized_updates()
From render -> terminal
2020-01-12 12:43:28 +01:00
Daniel Eklöf
afa1dbb7cc
render: add a timeout for application synchronized updates
This ensures we can recover from a crashing (or bad behaving)
application that sends a BSU but then never sends an ESU.
2020-01-12 12:40:42 +01:00
Daniel Eklöf
cb8a0260f3
term: rename refresh_prohibited -> application_synchronized_updates 2020-01-12 12:25:58 +01:00
Daniel Eklöf
84f836c0c8
term: ptmx: cancel, and don't re-arm, delay timers when refresh has been disabled 2020-01-12 12:23:29 +01:00
Daniel Eklöf
5956faac01
term/wayland: use MONOTONIC timers 2020-01-10 21:33:40 +01:00
Daniel Eklöf
5bfc560451
Revert "terminal: use edge-triggered FDM handler for the PTY"
This reverts commit f5e27b49eb.
2020-01-10 19:51:16 +01:00
Daniel Eklöf
3762f1f205
terminal: make the event FD used to delay shutdown non-blocking 2020-01-10 19:25:56 +01:00
Daniel Eklöf
f5e27b49eb
terminal: use edge-triggered FDM handler for the PTY
This means that the read handler now has to keep reading until we get
EAGAIN.

But it also means we don't have to flip the EPOLLOUT flag in the FDM
handler back and forth when writing to the PTY.
2020-01-10 19:24:45 +01:00
Daniel Eklöf
5ec447697c
render: throttle xcursor updates
With a bad behaving client (e.g. 'less' with mouse support enabled),
we can end up with a *lot* of xcursor updates (so much, that we
flooded the wayland socket before we implemented a blocking
wayl_flush()).

Since there's little point in updating the cursor more than once per
frame interval, use frame callbacks to throttle the updates.

This works more or lesslike normal terminal refreshes:

render_xcursor_set() stores the last terminal (window) that had (and
updated) the cursor.

The renderer's FDM hook checks if we have such a pending terminal set,
and if so, tries to refresh the cursor.

This is done by first checking if we're already waiting for a callback
from a previous cursor update, and if so we do nothing; the callback
will update the cursor for the next frame. If we're *not* already
waiting for a callback, we update the cursor immediately.
2020-01-04 22:58:32 +01:00
Daniel Eklöf
b7c970010d
term: mouse_grabbed: ctrl may be pressed too (for block selection) 2020-01-04 12:09:26 +01:00
Daniel Eklöf
0ea0323d0f
wayland: don't use wl_display_dispatch()
wl_display_dispatch() calls poll(), which is unnecessary since we
already know the FD is readable.

Use the more lower level wl_display_read_events() +
wl_display_dispatch_pending().

These require wl_display_prepare_read() to have been called.

The idea is to call wl_display_prepare_read() **before** calling
poll().

Thus, we do this more or less last in wayl_init(), and at the **end**
of the FDM handler.

However, having taking this lock also means we no longer can call
wl_display_roundtrip() directly (it will hang).

So, add a wrapper, wayl_roundtrip(), that cancels the read intent,
does the roundtrip, and then re-acquires the read intent.
2020-01-03 21:02:12 +01:00
Daniel Eklöf
ef3c7d7e0a
term: init: don't resize if compositor has already resized us 2020-01-03 19:31:09 +01:00
Daniel Eklöf
782da0f8e9
term: no need to call render_refresh() when starting/stopping blink timer 2020-01-03 19:27:57 +01:00
Daniel Eklöf
d07fd7de39
render: remove 'refresh' from render_resize() 2020-01-03 13:56:10 +01:00
Daniel Eklöf
9a0238bb52
wayland: window now keeps pointer to owning terminal, not wayland 2020-01-03 13:37:03 +01:00
Daniel Eklöf
bd13c2c86a
term: render_resize() now takes a 'refresh' argument 2020-01-03 12:45:30 +01:00
Daniel Eklöf
80dfd5b645
term: visual_focus_{in,out}: do nothing if already focused/defocused 2020-01-03 11:19:56 +01:00
Daniel Eklöf
913c684844
term: term_init() calls wl_display_roundtrip()
Instead of having `wayl_win_init()` call
`wl_display_roundtrip()` (which it itself doesn't need), call it from
`term_init()`.

This allows us to add ourselves (the new terminal instance) to the
terminal list in the wayland backend, before triggering the wayland
events caused by `wayl_win_init()`.

This is turn allows the wayland backend to find/lookup the new
terminal when those events occur..
2020-01-03 11:16:06 +01:00
Daniel Eklöf
4451f4ad62
term: spell 'initialize' correctly 2020-01-03 11:15:35 +01:00
Daniel Eklöf
6f281cebfb
term: add term_visual_focus_{in,out}
These functions should be called when the terminal gets or loses
visual focus.

Note that this isn't necessarily the same as having keyboard focus.
2020-01-02 19:35:32 +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
b8960f930d
term: bump lower delay limit to 500µs
Emacs with a split screen often goes above 200µs. 500µs is still much
better than 2000µs...
2019-12-31 20:39:16 +01:00
Daniel Eklöf
c5bdf7c27e
term: ptmx timing: use a define instead of #if 0 2019-12-31 20:37:43 +01:00
Daniel Eklöf
3912638141
term: lower the lower delay timeout from 2ms to 200µs 2019-12-31 20:29:47 +01:00
Daniel Eklöf
60b27a9686
term: commented out code to measure time between slave output
This allows us to measure the time between to refresh delays. That is,
when we decide to delay a refresh, we store the current time.

If we hit that code path _again_, without having refreshed, we
calculate the time that has passed.

This gives us an estimate for how we should set our lower delay
timeout.

This is of course application dependent, but is still much better than
simply guessing a value...
2019-12-31 20:26:30 +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
39146fac5c
term: term_init: add 'cwd' argument
This is used when spawning the slave, to set its current working
directory just before we exec() the client.

In a regular foot instance, we set the cwd from getcwd().

In a foot server instance, each connecting client sends its cwd to the
server, and we use that.
2019-12-21 19:57:28 +01:00
Daniel Eklöf
016bde1bd4
term: wip: track current working directory
This sets the initial current working directory, as it is when the
terminal is instantiated.

We chdir() to it just before spawning a new terminal.
2019-12-21 15:35:54 +01:00
Daniel Eklöf
a484a65fef
term: term_spawn_new: always spawn foot/footclient from PATH 2019-12-21 15:29:42 +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
2a95f2949b
term: experimental: tweak delay timeouts
Increase the low timeout, to try to give clients/slaves more time to
emit data.

Decrease the upper timeout. On average, we should have ~½ frame left
until the next frame. So a maximum delay of a whole frame *will* delay
the update one extra frame in many cases.

Hopefully, the low timeout is still low enough that we don't miss the
next frame, on average.
2019-12-21 00:12:00 +01:00
Daniel Eklöf
f8009b549a
term: cursor blink reset doesn't force-refresh the cursor 2019-12-19 07:27:41 +01:00
Daniel Eklöf
0efcb66f3a
term/render: check for is_shutting_down in grid_render() 2019-12-19 07:27:14 +01:00
Daniel Eklöf
a366bc9ace
term: remove TODO 2019-12-19 07:24:46 +01:00
Daniel Eklöf
81840b4e8e
cursor blink: move reset to pty input 2019-12-19 07:23:58 +01:00