render: delay reflow for ‘resize-delay-ms’ milliseconds

Reflowing a large scrollback is *slow*. During an interactive resize,
it can easily take long enough that the compositor fills the Wayland
socket with configure events. Eventually, the socket becomes full and
the compositor terminates the connection, causing foot to exit.

This patch is work-in-progress, and the first step towards alleviating
this.

It delays the reflow by:

* Snapshotting (copying) the original grid when an interactive resize
  is started.
* While resizing, we apply a simple truncation resize of the
  grid (like we handle the alt screen).
* When the resize is done, or paused for ‘resize-delay-ms’, the grid
  is reflowed.

TODO: we *must* not allow any changes to the temporary (truncated)
grid during the resize. Any changes to the grid would be lost when the
final reflow is applied. That is, we must completely pause the ptmx
pipe while a resize is in progress.

Future improvements:

The initial copy can be slow. We should be able to avoid it by
rewriting the reflow algorithm to not free anything. This is
complicated by the fact that some resources (e.g. sixel images) are
currently *moved* to the new grid. They’d instead have to be copied.
This commit is contained in:
Daniel Eklöf 2022-10-05 17:05:44 +02:00
parent a9fc7ce180
commit 8179d73daa
No known key found for this signature in database
GPG key ID: 5BBD4992C116573F
4 changed files with 123 additions and 20 deletions

View file

@ -213,15 +213,19 @@ commented out will usually be installed to */etc/xdg/foot/foot.ini*.
Default: _0x0_.
*resize-delay-ms*
Time, in milliseconds, of "idle time" before foot sends the new
window dimensions to the client application while doing an
interactive resize of a foot window. Idle time in this context is
a period of time where the window size is not changing.
Time, in milliseconds, of "idle time" before foot performs text
reflow, and sends the new window dimensions to the client
application while doing an interactive resize of a foot
window. Idle time in this context is a period of time where the
window size is not changing.
In other words, while you are fiddling with the window size, foot
does not send the updated dimensions to the client. Only when you
pause the fiddling for *resize-delay-ms* milliseconds is the
client updated.
does not send the updated dimensions to the client. It also does a
fast "truncating" resize of the grid, instead of actually
reflowing the contents. Only when you pause the fiddling for
*resize-delay-ms* milliseconds is the client updated, and the
contents properly reflowed.
Emphasis is on _while_ here; as soon as the interactive resize
ends (i.e. when you let go of the window border), the final