mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-03-15 05:33:58 -04:00
render: pace title updates
Synchronize window title updates with window rendering.
This commit is contained in:
parent
b46ad6a50a
commit
9bbbd26c7a
4 changed files with 34 additions and 16 deletions
44
render.c
44
render.c
|
|
@ -1602,6 +1602,24 @@ render_search_box(struct terminal *term)
|
||||||
quirk_weston_subsurface_desync_off(term->window->search_sub_surface);
|
quirk_weston_subsurface_desync_off(term->window->search_sub_surface);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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
|
static void
|
||||||
frame_callback(void *data, struct wl_callback *wl_callback, uint32_t callback_data)
|
frame_callback(void *data, struct wl_callback *wl_callback, uint32_t callback_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 grid = term->render.pending.grid;
|
||||||
bool csd = term->render.pending.csd;
|
bool csd = term->render.pending.csd;
|
||||||
bool search = term->render.pending.search;
|
bool search = term->render.pending.search;
|
||||||
|
bool title = term->render.pending.title;
|
||||||
|
|
||||||
term->render.pending.grid = false;
|
term->render.pending.grid = false;
|
||||||
term->render.pending.csd = false;
|
term->render.pending.csd = false;
|
||||||
term->render.pending.search = false;
|
term->render.pending.search = false;
|
||||||
|
term->render.pending.title = false;
|
||||||
|
|
||||||
if (csd && term->window->use_csd == CSD_YES) {
|
if (csd && term->window->use_csd == CSD_YES) {
|
||||||
quirk_weston_csd_on(term);
|
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);
|
quirk_weston_csd_off(term);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (title)
|
||||||
|
render_update_title(term);
|
||||||
|
|
||||||
if (search && term->is_searching)
|
if (search && term->is_searching)
|
||||||
render_search_box(term);
|
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 grid = term->render.refresh.grid;
|
||||||
bool csd = term->render.refresh.csd;
|
bool csd = term->render.refresh.csd;
|
||||||
bool search = term->render.refresh.search;
|
bool search = term->render.refresh.search;
|
||||||
|
bool title = term->render.refresh.title;
|
||||||
|
|
||||||
term->render.refresh.grid = false;
|
term->render.refresh.grid = false;
|
||||||
term->render.refresh.csd = false;
|
term->render.refresh.csd = false;
|
||||||
term->render.refresh.search = false;
|
term->render.refresh.search = false;
|
||||||
|
term->render.refresh.title = false;
|
||||||
|
|
||||||
if (term->window->frame_callback == NULL) {
|
if (term->window->frame_callback == NULL) {
|
||||||
if (csd && term->window->use_csd == CSD_YES) {
|
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);
|
render_csd(term);
|
||||||
quirk_weston_csd_off(term);
|
quirk_weston_csd_off(term);
|
||||||
}
|
}
|
||||||
|
if (title)
|
||||||
|
render_update_title(term);
|
||||||
if (search)
|
if (search)
|
||||||
render_search_box(term);
|
render_search_box(term);
|
||||||
if (grid)
|
if (grid)
|
||||||
|
|
@ -1977,6 +2004,7 @@ fdm_hook_refresh_pending_terminals(struct fdm *fdm, void *data)
|
||||||
term->render.pending.grid |= grid;
|
term->render.pending.grid |= grid;
|
||||||
term->render.pending.csd |= csd;
|
term->render.pending.csd |= csd;
|
||||||
term->render.pending.search |= search;
|
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
|
void
|
||||||
render_set_title(struct terminal *term, const char *_title)
|
render_refresh_title(struct terminal *term)
|
||||||
{
|
{
|
||||||
/* TODO: figure out what the limit actually is */
|
term->render.refresh.title = true;
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
||||||
2
render.h
2
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(struct terminal *term, int width, int height);
|
||||||
bool render_resize_force(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(struct terminal *term);
|
||||||
void render_refresh_csd(struct terminal *term);
|
void render_refresh_csd(struct terminal *term);
|
||||||
void render_refresh_search(struct terminal *term);
|
void render_refresh_search(struct terminal *term);
|
||||||
|
void render_refresh_title(struct terminal *term);
|
||||||
bool render_xcursor_set(struct terminal *term);
|
bool render_xcursor_set(struct terminal *term);
|
||||||
|
|
||||||
struct render_worker_context {
|
struct render_worker_context {
|
||||||
|
|
|
||||||
|
|
@ -1943,7 +1943,7 @@ term_set_window_title(struct terminal *term, const char *title)
|
||||||
{
|
{
|
||||||
free(term->window_title);
|
free(term->window_title);
|
||||||
term->window_title = strdup(title);
|
term->window_title = strdup(title);
|
||||||
render_set_title(term, term->window_title);
|
render_refresh_title(term);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
||||||
|
|
@ -336,6 +336,7 @@ struct terminal {
|
||||||
bool grid;
|
bool grid;
|
||||||
bool csd;
|
bool csd;
|
||||||
bool search;
|
bool search;
|
||||||
|
bool title;
|
||||||
} refresh;
|
} refresh;
|
||||||
|
|
||||||
/* Scheduled for rendering, in the next frame callback */
|
/* Scheduled for rendering, in the next frame callback */
|
||||||
|
|
@ -343,6 +344,7 @@ struct terminal {
|
||||||
bool grid;
|
bool grid;
|
||||||
bool csd;
|
bool csd;
|
||||||
bool search;
|
bool search;
|
||||||
|
bool title;
|
||||||
} pending;
|
} pending;
|
||||||
|
|
||||||
int scrollback_lines; /* Number of scrollback lines, from conf (TODO: move out from render struct?) */
|
int scrollback_lines; /* Number of scrollback lines, from conf (TODO: move out from render struct?) */
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue