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.
This commit is contained in:
Daniel Eklöf 2020-01-12 12:19:38 +01:00
parent 5ef55a7f52
commit b2935e2b89
No known key found for this signature in database
GPG key ID: 5BBD4992C116573F
3 changed files with 27 additions and 0 deletions

View file

@ -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)
{

View file

@ -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);

View file

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