From b2935e2b89cf999d64a6322f58d6bf4307371463 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Sun, 12 Jan 2020 12:19:38 +0100 Subject: [PATCH 1/8] render: add render_{enable,disable}_refresh() Calling render_disable_refresh() causes update requests to that terminal to be ignored. Calling render_enable_refresh() re-enables updates. --- render.c | 24 ++++++++++++++++++++++++ render.h | 2 ++ terminal.h | 1 + 3 files changed, 27 insertions(+) diff --git a/render.c b/render.c index 5f2aff69..26da8d83 100644 --- a/render.c +++ b/render.c @@ -1015,6 +1015,9 @@ render_resize(struct terminal *term, int width, int height) if (width == term->width && height == term->height && scale == term->scale) return; + /* Cancel an application initiated "Synchronized Update" */ + render_enable_refresh(term); + term->width = width; term->height = height; term->scale = scale; @@ -1190,6 +1193,9 @@ fdm_hook_refresh_pending_terminals(struct fdm *fdm, void *data) if (!term->render.refresh_needed) continue; + if (term->render.refresh_prohibited) + continue; + assert(term->window->is_configured); term->render.refresh_needed = false; @@ -1235,6 +1241,24 @@ render_refresh(struct terminal *term) term->render.refresh_needed = true; } +void +render_disable_refresh(struct terminal *term) +{ + if (term->render.refresh_prohibited) + return; + + term->render.refresh_prohibited = true; +} + +void +render_enable_refresh(struct terminal *term) +{ + if (!term->render.refresh_prohibited) + return; + + term->render.refresh_prohibited = false; +} + bool render_xcursor_set(struct terminal *term) { diff --git a/render.h b/render.h index 43f5314e..59bae895 100644 --- a/render.h +++ b/render.h @@ -11,6 +11,8 @@ void render_destroy(struct renderer *renderer); void render_resize(struct terminal *term, int width, int height); void render_set_title(struct terminal *term, const char *title); void render_refresh(struct terminal *term); +void render_disable_refresh(struct terminal *term); +void render_enable_refresh(struct terminal *term); bool render_xcursor_set(struct terminal *term); void render_search_box(struct terminal *term); diff --git a/terminal.h b/terminal.h index 8e47826b..0296ff66 100644 --- a/terminal.h +++ b/terminal.h @@ -292,6 +292,7 @@ struct terminal { bool refresh_needed; /* Terminal needs to be re-rendered, as soon-as-possible */ int scrollback_lines; /* Number of scrollback lines, from conf (TODO: move out from render struct?) */ + bool refresh_prohibited; /* Render threads + synchronization primitives */ struct { size_t count; From 7b27fa857f74a884925f3b94b8604313f732a635 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Sun, 12 Jan 2020 12:21:31 +0100 Subject: [PATCH 2/8] dcs: bsu/esu: call render_{disable,enable}_refresh() --- dcs.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/dcs.c b/dcs.c index 40d9a8b0..f8354e88 100644 --- a/dcs.c +++ b/dcs.c @@ -3,22 +3,24 @@ #define LOG_MODULE "dcs" #define LOG_ENABLE_DBG 0 #include "log.h" +#include "render.h" #include "vt.h" static void bsu(struct terminal *term) { - LOG_WARN("unimplemented: BSU - Begin Synchronized Update (params: %.*s)", - (int)term->vt.dcs.idx, term->vt.dcs.data); - abort(); + LOG_DBG("BSU - Begin Synchronized Update (params: %.*s)", + (int)term->vt.dcs.idx, term->vt.dcs.data); + + render_disable_refresh(term); } static void esu(struct terminal *term) { - LOG_WARN("unimplemented: ESU - Begin Synchronized Update (params: %.*s)", - (int)term->vt.dcs.idx, term->vt.dcs.data); - abort(); + LOG_DBG("ESU - Begin Synchronized Update (params: %.*s)", + (int)term->vt.dcs.idx, term->vt.dcs.data); + render_enable_refresh(term); } void From 84f836c0c8d00978e52a45c7554f0a55b596ed8f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Sun, 12 Jan 2020 12:23:29 +0100 Subject: [PATCH 3/8] term: ptmx: cancel, and don't re-arm, delay timers when refresh has been disabled --- terminal.c | 66 ++++++++++++++++++++++++++++++++---------------------- 1 file changed, 39 insertions(+), 27 deletions(-) diff --git a/terminal.c b/terminal.c index 6550b164..db1ba1fa 100644 --- a/terminal.c +++ b/terminal.c @@ -186,36 +186,48 @@ 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) { - /* First timeout - reset each time we receive input. */ - -#if PTMX_TIMING - struct timespec now; - - clock_gettime(1, &now); - if (last.tv_sec > 0 || last.tv_nsec > 0) { - struct timeval diff; - struct timeval l = {last.tv_sec, last.tv_nsec / 1000}; - struct timeval n = {now.tv_sec, now.tv_nsec / 1000}; - - timersub(&n, &l, &diff); - LOG_INFO("waited %lu µs for more input", diff.tv_usec); - } - last = now; -#endif - - timerfd_settime( - term->delayed_render_timer.lower_fd, 0, - &(struct itimerspec){.it_value = {.tv_nsec = 500000}}, - NULL); - - /* Second timeout - only reset when we render. Set to one - * frame (assuming 60Hz) */ - if (!term->delayed_render_timer.is_armed) { + if (term->render.refresh_prohibited) { + timerfd_settime( + term->delayed_render_timer.lower_fd, 0, + &(struct itimerspec){{0}}, NULL); timerfd_settime( term->delayed_render_timer.upper_fd, 0, - &(struct itimerspec){.it_value = {.tv_nsec = 16666666 / 2}}, + &(struct itimerspec){{0}}, NULL); + term->render.refresh_needed = true; + } + + else { + /* First timeout - reset each time we receive input. */ + +#if PTMX_TIMING + struct timespec now; + + clock_gettime(1, &now); + if (last.tv_sec > 0 || last.tv_nsec > 0) { + struct timeval diff; + struct timeval l = {last.tv_sec, last.tv_nsec / 1000}; + struct timeval n = {now.tv_sec, now.tv_nsec / 1000}; + + timersub(&n, &l, &diff); + LOG_INFO("waited %lu µs for more input", diff.tv_usec); + } + last = now; +#endif + + timerfd_settime( + term->delayed_render_timer.lower_fd, 0, + &(struct itimerspec){.it_value = {.tv_nsec = 500000}}, NULL); - term->delayed_render_timer.is_armed = true; + + /* Second timeout - only reset when we render. Set to one + * frame (assuming 60Hz) */ + if (!term->delayed_render_timer.is_armed) { + timerfd_settime( + term->delayed_render_timer.upper_fd, 0, + &(struct itimerspec){.it_value = {.tv_nsec = 16666666 / 2}}, + NULL); + term->delayed_render_timer.is_armed = true; + } } } else term->render.pending = true; From cb8a0260f347cd73c7942030aa2bd12f9355ab17 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Sun, 12 Jan 2020 12:25:58 +0100 Subject: [PATCH 4/8] term: rename refresh_prohibited -> application_synchronized_updates --- render.c | 10 +++++----- terminal.c | 2 +- terminal.h | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/render.c b/render.c index 26da8d83..f7841d8d 100644 --- a/render.c +++ b/render.c @@ -1193,7 +1193,7 @@ fdm_hook_refresh_pending_terminals(struct fdm *fdm, void *data) if (!term->render.refresh_needed) continue; - if (term->render.refresh_prohibited) + if (term->render.application_synchronized_updates) continue; assert(term->window->is_configured); @@ -1244,19 +1244,19 @@ render_refresh(struct terminal *term) void render_disable_refresh(struct terminal *term) { - if (term->render.refresh_prohibited) + if (term->render.application_synchronized_updates) return; - term->render.refresh_prohibited = true; + term->render.application_synchronized_updates = true; } void render_enable_refresh(struct terminal *term) { - if (!term->render.refresh_prohibited) + if (!term->render.application_synchronized_updates) return; - term->render.refresh_prohibited = false; + term->render.application_synchronized_updates = false; } bool diff --git a/terminal.c b/terminal.c index db1ba1fa..afd004de 100644 --- a/terminal.c +++ b/terminal.c @@ -186,7 +186,7 @@ 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.refresh_prohibited) { + if (term->render.application_synchronized_updates) { timerfd_settime( term->delayed_render_timer.lower_fd, 0, &(struct itimerspec){{0}}, NULL); diff --git a/terminal.h b/terminal.h index 0296ff66..83468e5f 100644 --- a/terminal.h +++ b/terminal.h @@ -292,7 +292,7 @@ struct terminal { bool refresh_needed; /* Terminal needs to be re-rendered, as soon-as-possible */ int scrollback_lines; /* Number of scrollback lines, from conf (TODO: move out from render struct?) */ - bool refresh_prohibited; + bool application_synchronized_updates; /* Render threads + synchronization primitives */ struct { size_t count; From 6e474e77e50510d825bc6bf8fd60fad17b66a40d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Sun, 12 Jan 2020 12:28:00 +0100 Subject: [PATCH 5/8] render: rename render_{enable,disable}_refresh() --- dcs.c | 5 +++-- render.c | 6 +++--- render.h | 5 +++-- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/dcs.c b/dcs.c index f8354e88..b0ff50ed 100644 --- a/dcs.c +++ b/dcs.c @@ -12,7 +12,7 @@ bsu(struct terminal *term) LOG_DBG("BSU - Begin Synchronized Update (params: %.*s)", (int)term->vt.dcs.idx, term->vt.dcs.data); - render_disable_refresh(term); + render_enable_application_synchronized_updates(term); } static void @@ -20,7 +20,8 @@ esu(struct terminal *term) { LOG_DBG("ESU - Begin Synchronized Update (params: %.*s)", (int)term->vt.dcs.idx, term->vt.dcs.data); - render_enable_refresh(term); + + render_disable_application_synchronized_updates(term); } void diff --git a/render.c b/render.c index f7841d8d..7024a50e 100644 --- a/render.c +++ b/render.c @@ -1016,7 +1016,7 @@ render_resize(struct terminal *term, int width, int height) return; /* Cancel an application initiated "Synchronized Update" */ - render_enable_refresh(term); + render_disable_application_synchronized_updates(term); term->width = width; term->height = height; @@ -1242,7 +1242,7 @@ render_refresh(struct terminal *term) } void -render_disable_refresh(struct terminal *term) +render_enable_application_synchronized_updates(struct terminal *term) { if (term->render.application_synchronized_updates) return; @@ -1251,7 +1251,7 @@ render_disable_refresh(struct terminal *term) } void -render_enable_refresh(struct terminal *term) +render_disable_application_synchronized_updates(struct terminal *term) { if (!term->render.application_synchronized_updates) return; diff --git a/render.h b/render.h index 59bae895..6a2ddafa 100644 --- a/render.h +++ b/render.h @@ -11,12 +11,13 @@ void render_destroy(struct renderer *renderer); void render_resize(struct terminal *term, int width, int height); void render_set_title(struct terminal *term, const char *title); void render_refresh(struct terminal *term); -void render_disable_refresh(struct terminal *term); -void render_enable_refresh(struct terminal *term); bool render_xcursor_set(struct terminal *term); void render_search_box(struct terminal *term); +void render_enable_application_synchronized_updates(struct terminal *term); +void render_disable_application_synchronized_updates(struct terminal *term); + struct render_worker_context { int my_id; struct terminal *term; From afa1dbb7cc98277d8ee22e4bc5a2b3ee2c774662 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Sun, 12 Jan 2020 12:40:42 +0100 Subject: [PATCH 6/8] 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. --- render.c | 22 +++++++++++++++++----- terminal.c | 40 ++++++++++++++++++++++++++++++++++++++-- terminal.h | 6 +++++- 3 files changed, 60 insertions(+), 8 deletions(-) diff --git a/render.c b/render.c index 7024a50e..98b208df 100644 --- a/render.c +++ b/render.c @@ -1193,7 +1193,7 @@ fdm_hook_refresh_pending_terminals(struct fdm *fdm, void *data) if (!term->render.refresh_needed) continue; - if (term->render.application_synchronized_updates) + if (term->render.application_synchronized_updates.enabled) continue; assert(term->window->is_configured); @@ -1244,19 +1244,31 @@ render_refresh(struct terminal *term) void render_enable_application_synchronized_updates(struct terminal *term) { - if (term->render.application_synchronized_updates) + if (term->render.application_synchronized_updates.enabled) return; - term->render.application_synchronized_updates = true; + term->render.application_synchronized_updates.enabled = true; + + if (timerfd_settime( + term->render.application_synchronized_updates.timer_fd, 0, + &(struct itimerspec){.it_value = {.tv_sec = 1}}, NULL) < 0) + { + LOG_ERR("failed to arm timer for application synchronized updates"); + } } void render_disable_application_synchronized_updates(struct terminal *term) { - if (!term->render.application_synchronized_updates) + if (!term->render.application_synchronized_updates.enabled) return; - term->render.application_synchronized_updates = false; + term->render.application_synchronized_updates.enabled = false; + + /* Reset timers */ + timerfd_settime( + term->render.application_synchronized_updates.timer_fd, 0, + &(struct itimerspec){{0}}, NULL); } bool diff --git a/terminal.c b/terminal.c index afd004de..a0467f85 100644 --- a/terminal.c +++ b/terminal.c @@ -186,7 +186,7 @@ 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.application_synchronized_updates) { + if (term->render.application_synchronized_updates.enabled) { timerfd_settime( term->delayed_render_timer.lower_fd, 0, &(struct itimerspec){{0}}, NULL); @@ -424,6 +424,29 @@ fdm_delayed_render(struct fdm *fdm, int fd, int events, void *data) return true; } +static bool +fdm_application_synchronized_updates_timeout( + struct fdm *fdm, int fd, int events, void *data) +{ + if (events & EPOLLHUP) + return false; + + struct terminal *term = data; + uint64_t unused; + ssize_t ret = read(term->render.application_synchronized_updates.timer_fd, + &unused, sizeof(unused)); + + if (ret < 0) { + if (errno == EAGAIN) + return true; + LOG_ERRNO("failed to read application synchronized updates timeout timer"); + return false; + } + + render_disable_application_synchronized_updates(term); + return true; +} + static void initialize_color_cube(struct terminal *term) { @@ -518,6 +541,7 @@ term_init(const struct config *conf, struct fdm *fdm, struct wayland *wayl, int cursor_blink_fd = -1; int delay_lower_fd = -1; int delay_upper_fd = -1; + int application_synchronized_updates_fd = -1; struct terminal *term = malloc(sizeof(*term)); @@ -544,6 +568,12 @@ term_init(const struct config *conf, struct fdm *fdm, struct wayland *wayl, goto close_fds; } + if ((application_synchronized_updates_fd = timerfd_create(CLOCK_MONOTONIC, TFD_CLOEXEC | TFD_NONBLOCK)) == -1) + { + LOG_ERRNO("failed to create application synchronized updates timer FD"); + goto close_fds; + } + int ptmx_flags; if ((ptmx_flags = fcntl(ptmx, F_GETFL)) < 0 || fcntl(ptmx, F_SETFL, ptmx_flags | O_NONBLOCK) < 0) @@ -557,7 +587,8 @@ term_init(const struct config *conf, struct fdm *fdm, struct wayland *wayl, !fdm_add(fdm, blink_fd, EPOLLIN, &fdm_blink, term) || !fdm_add(fdm, cursor_blink_fd, EPOLLIN, &fdm_cursor_blink, term) || !fdm_add(fdm, delay_lower_fd, EPOLLIN, &fdm_delayed_render, term) || - !fdm_add(fdm, delay_upper_fd, EPOLLIN, &fdm_delayed_render, term)) + !fdm_add(fdm, delay_upper_fd, EPOLLIN, &fdm_delayed_render, term) || + !fdm_add(fdm, application_synchronized_updates_fd, EPOLLIN, &fdm_application_synchronized_updates_timeout, term)) { goto err; } @@ -632,6 +663,7 @@ term_init(const struct config *conf, struct fdm *fdm, struct wayland *wayl, .wl = wayl, .render = { .scrollback_lines = conf->scrollback_lines, + .application_synchronized_updates.timer_fd = application_synchronized_updates_fd, .workers = { .count = conf->render_worker_count, .queue = tll_init(), @@ -707,6 +739,7 @@ close_fds: fdm_del(fdm, cursor_blink_fd); fdm_del(fdm, delay_lower_fd); fdm_del(fdm, delay_upper_fd); + fdm_del(fdm, application_synchronized_updates_fd); free(term); return NULL; @@ -767,6 +800,7 @@ term_shutdown(struct terminal *term) term_cursor_blink_disable(term); + fdm_del(term->fdm, term->render.application_synchronized_updates.timer_fd); fdm_del(term->fdm, term->delayed_render_timer.lower_fd); fdm_del(term->fdm, term->delayed_render_timer.upper_fd); fdm_del(term->fdm, term->cursor_blink.fd); @@ -774,6 +808,7 @@ term_shutdown(struct terminal *term) fdm_del(term->fdm, term->flash.fd); fdm_del(term->fdm, term->ptmx); + term->render.application_synchronized_updates.timer_fd = -1; term->delayed_render_timer.lower_fd = -1; term->delayed_render_timer.upper_fd = -1; term->cursor_blink.fd = -1; @@ -823,6 +858,7 @@ term_destroy(struct terminal *term) } } + fdm_del(term->fdm, term->render.application_synchronized_updates.timer_fd); fdm_del(term->fdm, term->delayed_render_timer.lower_fd); fdm_del(term->fdm, term->delayed_render_timer.upper_fd); fdm_del(term->fdm, term->cursor_blink.fd); diff --git a/terminal.h b/terminal.h index 83468e5f..9bb335dd 100644 --- a/terminal.h +++ b/terminal.h @@ -292,7 +292,11 @@ struct terminal { bool refresh_needed; /* Terminal needs to be re-rendered, as soon-as-possible */ int scrollback_lines; /* Number of scrollback lines, from conf (TODO: move out from render struct?) */ - bool application_synchronized_updates; + struct { + bool enabled; + int timer_fd; + } application_synchronized_updates; + /* Render threads + synchronization primitives */ struct { size_t count; From bdf127fc7e26585cfddc73193751996033bbe88c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Sun, 12 Jan 2020 12:43:28 +0100 Subject: [PATCH 7/8] term/render: move {enable,disable}_application_synchronized_updates() From render -> terminal --- dcs.c | 5 ++--- render.c | 32 +------------------------------- render.h | 3 --- terminal.c | 32 +++++++++++++++++++++++++++++++- terminal.h | 3 +++ 5 files changed, 37 insertions(+), 38 deletions(-) diff --git a/dcs.c b/dcs.c index b0ff50ed..73a371c0 100644 --- a/dcs.c +++ b/dcs.c @@ -3,7 +3,6 @@ #define LOG_MODULE "dcs" #define LOG_ENABLE_DBG 0 #include "log.h" -#include "render.h" #include "vt.h" static void @@ -12,7 +11,7 @@ bsu(struct terminal *term) LOG_DBG("BSU - Begin Synchronized Update (params: %.*s)", (int)term->vt.dcs.idx, term->vt.dcs.data); - render_enable_application_synchronized_updates(term); + term_enable_application_synchronized_updates(term); } static void @@ -21,7 +20,7 @@ esu(struct terminal *term) LOG_DBG("ESU - Begin Synchronized Update (params: %.*s)", (int)term->vt.dcs.idx, term->vt.dcs.data); - render_disable_application_synchronized_updates(term); + term_disable_application_synchronized_updates(term); } void diff --git a/render.c b/render.c index 98b208df..ae623940 100644 --- a/render.c +++ b/render.c @@ -1016,7 +1016,7 @@ render_resize(struct terminal *term, int width, int height) return; /* Cancel an application initiated "Synchronized Update" */ - render_disable_application_synchronized_updates(term); + term_disable_application_synchronized_updates(term); term->width = width; term->height = height; @@ -1241,36 +1241,6 @@ render_refresh(struct terminal *term) term->render.refresh_needed = true; } -void -render_enable_application_synchronized_updates(struct terminal *term) -{ - if (term->render.application_synchronized_updates.enabled) - return; - - term->render.application_synchronized_updates.enabled = true; - - if (timerfd_settime( - term->render.application_synchronized_updates.timer_fd, 0, - &(struct itimerspec){.it_value = {.tv_sec = 1}}, NULL) < 0) - { - LOG_ERR("failed to arm timer for application synchronized updates"); - } -} - -void -render_disable_application_synchronized_updates(struct terminal *term) -{ - if (!term->render.application_synchronized_updates.enabled) - return; - - term->render.application_synchronized_updates.enabled = false; - - /* Reset timers */ - timerfd_settime( - term->render.application_synchronized_updates.timer_fd, 0, - &(struct itimerspec){{0}}, NULL); -} - bool render_xcursor_set(struct terminal *term) { diff --git a/render.h b/render.h index 6a2ddafa..43f5314e 100644 --- a/render.h +++ b/render.h @@ -15,9 +15,6 @@ bool render_xcursor_set(struct terminal *term); void render_search_box(struct terminal *term); -void render_enable_application_synchronized_updates(struct terminal *term); -void render_disable_application_synchronized_updates(struct terminal *term); - struct render_worker_context { int my_id; struct terminal *term; diff --git a/terminal.c b/terminal.c index a0467f85..af2d7109 100644 --- a/terminal.c +++ b/terminal.c @@ -443,7 +443,7 @@ fdm_application_synchronized_updates_timeout( return false; } - render_disable_application_synchronized_updates(term); + term_disable_application_synchronized_updates(term); return true; } @@ -1812,3 +1812,33 @@ term_spawn_new(const struct terminal *term) waitpid(pid, &result, 0); return WIFEXITED(result) && WEXITSTATUS(result) == 0; } + +void +term_enable_application_synchronized_updates(struct terminal *term) +{ + if (term->render.application_synchronized_updates.enabled) + return; + + term->render.application_synchronized_updates.enabled = true; + + if (timerfd_settime( + term->render.application_synchronized_updates.timer_fd, 0, + &(struct itimerspec){.it_value = {.tv_sec = 1}}, NULL) < 0) + { + LOG_ERR("failed to arm timer for application synchronized updates"); + } +} + +void +term_disable_application_synchronized_updates(struct terminal *term) +{ + if (!term->render.application_synchronized_updates.enabled) + return; + + term->render.application_synchronized_updates.enabled = false; + + /* Reset timers */ + timerfd_settime( + term->render.application_synchronized_updates.timer_fd, 0, + &(struct itimerspec){{0}}, NULL); +} diff --git a/terminal.h b/terminal.h index 9bb335dd..f30352ae 100644 --- a/terminal.h +++ b/terminal.h @@ -410,3 +410,6 @@ void term_xcursor_update(struct terminal *term); void term_set_window_title(struct terminal *term, const char *title); void term_flash(struct terminal *term, unsigned duration_ms); bool term_spawn_new(const struct terminal *term); + +void term_enable_application_synchronized_updates(struct terminal *term); +void term_disable_application_synchronized_updates(struct terminal *term); From 95d2ee0cc1f80e94d8420ad4d68a49527e4d1cc7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Sun, 12 Jan 2020 12:45:34 +0100 Subject: [PATCH 8/8] 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. --- terminal.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/terminal.c b/terminal.c index af2d7109..10e8cf7c 100644 --- a/terminal.c +++ b/terminal.c @@ -186,15 +186,8 @@ 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.application_synchronized_updates.enabled) { - timerfd_settime( - term->delayed_render_timer.lower_fd, 0, - &(struct itimerspec){{0}}, NULL); - timerfd_settime( - term->delayed_render_timer.upper_fd, 0, - &(struct itimerspec){{0}}, NULL); + if (term->render.application_synchronized_updates.enabled) term->render.refresh_needed = true; - } else { /* First timeout - reset each time we receive input. */ @@ -1827,6 +1820,14 @@ term_enable_application_synchronized_updates(struct terminal *term) { LOG_ERR("failed to arm timer for application synchronized updates"); } + + /* Disarm delayed rendering timers */ + timerfd_settime( + term->delayed_render_timer.lower_fd, 0, + &(struct itimerspec){{0}}, NULL); + timerfd_settime( + term->delayed_render_timer.upper_fd, 0, + &(struct itimerspec){{0}}, NULL); } void