From 99f471d738e0c2a0dcb61a559be3be512659d113 Mon Sep 17 00:00:00 2001 From: Daniel Eklöf Date: Sat, 4 Jan 2020 19:49:26 +0100 Subject: render: trigger terminal refreshes in an FDM hook In some cases, we end up calling render_refresh() multiple times in the same FDM iteration. This means will render the first update immediately, and then set the 'pending' flag, causing the updated content to be rendered in the next frame. This can cause flicker, or flashes, since we're presenting one or more intermediate frames until the final content is shown. Not to mention that it is inefficient to render multiple frames like this. Fix by: * render_refresh() only sets a flag in the terminal * install an FDM hook; this hook loops all terminals and executes what render_refresh() _used_ to do (that is, render immediately if we're not waiting for a frame callback, otherwise set 'pending' flag). for all terminals that have the 'refresh_needed' flag set. --- terminal.h | 1 + 1 file changed, 1 insertion(+) (limited to 'terminal.h') diff --git a/terminal.h b/terminal.h index 9d28ff41..fe33ff98 100644 --- a/terminal.h +++ b/terminal.h @@ -283,6 +283,7 @@ struct terminal { bool visual_focus; struct { + bool refresh_needed; int scrollback_lines; struct { -- cgit v1.3 From 1060a4250b969b41dbb6ca00223d2ad3563d8ade Mon Sep 17 00:00:00 2001 From: Daniel Eklöf Date: Sat, 4 Jan 2020 19:56:59 +0100 Subject: term: more comments in the 'render' sub-struct --- terminal.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'terminal.h') diff --git a/terminal.h b/terminal.h index fe33ff98..e12a914e 100644 --- a/terminal.h +++ b/terminal.h @@ -283,9 +283,10 @@ struct terminal { bool visual_focus; struct { - bool refresh_needed; - int scrollback_lines; + 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?) */ + /* Render threads + synchronization primitives */ struct { size_t count; sem_t start; @@ -304,7 +305,7 @@ struct terminal { struct cell *cell; /* For easy access to content */ } last_cursor; - bool pending; + bool pending; /* Need to re-render again, after next frame-callback */ struct buffer *last_buf; /* Buffer we rendered to last time */ bool was_flashing; /* Flash was active last time we rendered */ bool was_searching; -- cgit v1.3