aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Eklöf <daniel@ekloef.se>2020-03-25 17:23:55 +0000
committerDaniel Eklöf <daniel@ekloef.se>2020-03-25 17:23:55 +0000
commit9bbbd26c7a2bad131b093cfd559a68fb59613af0 (patch)
treecd07bcf445bcb683776ac7082007c4489c8b9455
parentrender: explain _why_ we set a clip region (diff)
render: pace title updates
Synchronize window title updates with window rendering.
-rw-r--r--render.c44
-rw-r--r--render.h2
-rw-r--r--terminal.c2
-rw-r--r--terminal.h2
4 files changed, 34 insertions, 16 deletions
diff --git a/render.c b/render.c
index 2b86fe69..4238a4b8 100644
--- a/render.c
+++ b/render.c
@@ -1603,6 +1603,24 @@ render_search_box(struct terminal *term)
}
static void
+render_update_title(struct terminal *term)
+{
+ /* TODO: figure out what the limit actually is */
+ static const size_t max_len = 100;
+
+ const char *title = term->window_title != NULL ? term->window_title : "foot";
+ char *copy = NULL;
+
+ if (strlen(title) > max_len) {
+ copy = strndup(title, max_len);
+ title = copy;
+ }
+
+ xdg_toplevel_set_title(term->window->xdg_toplevel, title);
+ free(copy);
+}
+
+static void
frame_callback(void *data, struct wl_callback *wl_callback, uint32_t callback_data)
{
struct terminal *term = data;
@@ -1614,10 +1632,12 @@ frame_callback(void *data, struct wl_callback *wl_callback, uint32_t callback_da
bool grid = term->render.pending.grid;
bool csd = term->render.pending.csd;
bool search = term->render.pending.search;
+ bool title = term->render.pending.title;
term->render.pending.grid = false;
term->render.pending.csd = false;
term->render.pending.search = false;
+ term->render.pending.title = false;
if (csd && term->window->use_csd == CSD_YES) {
quirk_weston_csd_on(term);
@@ -1625,6 +1645,9 @@ frame_callback(void *data, struct wl_callback *wl_callback, uint32_t callback_da
quirk_weston_csd_off(term);
}
+ if (title)
+ render_update_title(term);
+
if (search && term->is_searching)
render_search_box(term);
@@ -1957,10 +1980,12 @@ fdm_hook_refresh_pending_terminals(struct fdm *fdm, void *data)
bool grid = term->render.refresh.grid;
bool csd = term->render.refresh.csd;
bool search = term->render.refresh.search;
+ bool title = term->render.refresh.title;
term->render.refresh.grid = false;
term->render.refresh.csd = false;
term->render.refresh.search = false;
+ term->render.refresh.title = false;
if (term->window->frame_callback == NULL) {
if (csd && term->window->use_csd == CSD_YES) {
@@ -1968,6 +1993,8 @@ fdm_hook_refresh_pending_terminals(struct fdm *fdm, void *data)
render_csd(term);
quirk_weston_csd_off(term);
}
+ if (title)
+ render_update_title(term);
if (search)
render_search_box(term);
if (grid)
@@ -1977,6 +2004,7 @@ fdm_hook_refresh_pending_terminals(struct fdm *fdm, void *data)
term->render.pending.grid |= grid;
term->render.pending.csd |= csd;
term->render.pending.search |= search;
+ term->render.pending.title |= title;
}
}
@@ -1991,21 +2019,9 @@ fdm_hook_refresh_pending_terminals(struct fdm *fdm, void *data)
}
void
-render_set_title(struct terminal *term, const char *_title)
+render_refresh_title(struct terminal *term)
{
- /* TODO: figure out what the limit actually is */
- static const size_t max_len = 100;
-
- const char *title = _title;
- char *copy = NULL;
-
- if (strlen(title) > max_len) {
- copy = strndup(_title, max_len);
- title = copy;
- }
-
- xdg_toplevel_set_title(term->window->xdg_toplevel, title);
- free(copy);
+ term->render.refresh.title = true;
}
void
diff --git a/render.h b/render.h
index 99246f17..0c03f125 100644
--- a/render.h
+++ b/render.h
@@ -12,10 +12,10 @@ void render_destroy(struct renderer *renderer);
bool render_resize(struct terminal *term, int width, int height);
bool render_resize_force(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_refresh_csd(struct terminal *term);
void render_refresh_search(struct terminal *term);
+void render_refresh_title(struct terminal *term);
bool render_xcursor_set(struct terminal *term);
struct render_worker_context {
diff --git a/terminal.c b/terminal.c
index 36f0e42b..0418b688 100644
--- a/terminal.c
+++ b/terminal.c
@@ -1943,7 +1943,7 @@ term_set_window_title(struct terminal *term, const char *title)
{
free(term->window_title);
term->window_title = strdup(title);
- render_set_title(term, term->window_title);
+ render_refresh_title(term);
}
void
diff --git a/terminal.h b/terminal.h
index 3685c0d7..9b97cf4e 100644
--- a/terminal.h
+++ b/terminal.h
@@ -336,6 +336,7 @@ struct terminal {
bool grid;
bool csd;
bool search;
+ bool title;
} refresh;
/* Scheduled for rendering, in the next frame callback */
@@ -343,6 +344,7 @@ struct terminal {
bool grid;
bool csd;
bool search;
+ bool title;
} pending;
int scrollback_lines; /* Number of scrollback lines, from conf (TODO: move out from render struct?) */