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] 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;