mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-02-10 04:27:45 -05:00
term: ptmx: don't enqueue extra frame render when app sync updates have been changed
Track whether app-sync updates were enabled or disabled while handling the current chunk of PTMX data. This fixes and issue where we called render_refresh() unnecessarily under (at least) the following conditions: * Application sent "BSU <data> ESU" in the *same* chunk. In this case we never saw that app sync was enabled and triggered delayed rendering as usual. * Application sent ESU. While we had noticed app sync updates being enabled in earlier PTMX reads, when it was disabled *in the current* PTMX read, we treated it as if it had not been enabled at all. This caused us to trigger delayed rendering. Now we call render_refresh() directly from ESU, and detect the "flip off" case in PTMX read and avoid triggering a delayed rendering. The end result of all this is that each key press (for e.g. scrolling in a pager application) went from two frames being rendered, to a single frame.
This commit is contained in:
parent
1006608093
commit
233a909160
2 changed files with 13 additions and 2 deletions
14
terminal.c
14
terminal.c
|
|
@ -153,6 +153,8 @@ fdm_ptmx(struct fdm *fdm, int fd, int events, void *data)
|
|||
/* Prevent blinking while typing */
|
||||
term_cursor_blink_restart(term);
|
||||
|
||||
term->render.app_sync_updates.flipped = false;
|
||||
|
||||
uint8_t buf[24 * 1024];
|
||||
ssize_t count = sizeof(buf);
|
||||
|
||||
|
|
@ -198,8 +200,11 @@ fdm_ptmx(struct fdm *fdm, int fd, int events, void *data)
|
|||
* has any effect when the renderer is idle.
|
||||
*/
|
||||
if (term->window->frame_callback == NULL) {
|
||||
if (term->render.app_sync_updates.enabled)
|
||||
term->render.refresh.grid = true;
|
||||
if (term->render.app_sync_updates.enabled ||
|
||||
term->render.app_sync_updates.flipped)
|
||||
{
|
||||
;
|
||||
}
|
||||
|
||||
else {
|
||||
/* First timeout - reset each time we receive input. */
|
||||
|
|
@ -2032,6 +2037,9 @@ term_spawn_new(const struct terminal *term)
|
|||
void
|
||||
term_enable_app_sync_updates(struct terminal *term)
|
||||
{
|
||||
if (!term->render.app_sync_updates.enabled)
|
||||
term->render.app_sync_updates.flipped = true;
|
||||
|
||||
term->render.app_sync_updates.enabled = true;
|
||||
|
||||
if (timerfd_settime(
|
||||
|
|
@ -2057,6 +2065,8 @@ term_disable_app_sync_updates(struct terminal *term)
|
|||
return;
|
||||
|
||||
term->render.app_sync_updates.enabled = false;
|
||||
term->render.app_sync_updates.flipped = true;
|
||||
render_refresh(term);
|
||||
|
||||
/* Reset timers */
|
||||
timerfd_settime(
|
||||
|
|
|
|||
|
|
@ -350,6 +350,7 @@ struct terminal {
|
|||
struct {
|
||||
bool enabled;
|
||||
int timer_fd;
|
||||
bool flipped;
|
||||
} app_sync_updates;
|
||||
|
||||
/* Render threads + synchronization primitives */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue