mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-03-15 05:33:58 -04:00
render: never render CSD and/or search box "immediately"
Handle the CSDs and the search box the same way we handle the main
grid; when we need to redraw them, call
render_refresh_{csd,search}(). This sets a flag that is checked after
each FDM iteration. All actual rendering is done here.
This also ties the commits of the Wayland sub-surfaces to the commit
of the main surface.
This commit is contained in:
parent
e5540a0d2e
commit
c5a1af4e53
6 changed files with 118 additions and 81 deletions
11
input.c
11
input.c
|
|
@ -711,13 +711,9 @@ wl_pointer_enter(void *data, struct wl_pointer *wl_pointer,
|
||||||
case TERM_SURF_BUTTON_MINIMIZE:
|
case TERM_SURF_BUTTON_MINIMIZE:
|
||||||
case TERM_SURF_BUTTON_MAXIMIZE:
|
case TERM_SURF_BUTTON_MAXIMIZE:
|
||||||
case TERM_SURF_BUTTON_CLOSE:
|
case TERM_SURF_BUTTON_CLOSE:
|
||||||
quirk_weston_csd_on(term);
|
|
||||||
render_csd(term);
|
|
||||||
quirk_weston_csd_off(term);
|
|
||||||
render_refresh(term);
|
|
||||||
|
|
||||||
term->xcursor = "left_ptr";
|
term->xcursor = "left_ptr";
|
||||||
render_xcursor_set(term);
|
render_xcursor_set(term);
|
||||||
|
render_refresh_csd(term);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TERM_SURF_NONE:
|
case TERM_SURF_NONE:
|
||||||
|
|
@ -771,10 +767,7 @@ wl_pointer_leave(void *data, struct wl_pointer *wl_pointer,
|
||||||
if (old_moused->is_shutting_down)
|
if (old_moused->is_shutting_down)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
quirk_weston_csd_on(old_moused);
|
render_refresh_csd(old_moused);
|
||||||
render_csd(old_moused);
|
|
||||||
quirk_weston_csd_off(old_moused);
|
|
||||||
render_refresh(old_moused);
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TERM_SURF_NONE:
|
case TERM_SURF_NONE:
|
||||||
|
|
|
||||||
145
render.c
145
render.c
|
|
@ -730,14 +730,10 @@ render_csd_part(struct terminal *term,
|
||||||
pixman_image_unref(src);
|
pixman_image_unref(src);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
static void
|
||||||
render_csd_title(struct terminal *term)
|
render_csd_title(struct terminal *term)
|
||||||
{
|
{
|
||||||
if (term->window->use_csd != CSD_YES)
|
assert(term->window->use_csd == CSD_YES);
|
||||||
return;
|
|
||||||
|
|
||||||
if (term->is_shutting_down)
|
|
||||||
return;
|
|
||||||
|
|
||||||
struct csd_data info = get_csd_data(term, CSD_SURF_TITLE);
|
struct csd_data info = get_csd_data(term, CSD_SURF_TITLE);
|
||||||
struct wl_surface *surf = term->window->csd.surface[CSD_SURF_TITLE];
|
struct wl_surface *surf = term->window->csd.surface[CSD_SURF_TITLE];
|
||||||
|
|
@ -766,11 +762,9 @@ render_csd_title(struct terminal *term)
|
||||||
static void
|
static void
|
||||||
render_csd_border(struct terminal *term, enum csd_surface surf_idx)
|
render_csd_border(struct terminal *term, enum csd_surface surf_idx)
|
||||||
{
|
{
|
||||||
|
assert(term->window->use_csd == CSD_YES);
|
||||||
assert(surf_idx >= CSD_SURF_LEFT && surf_idx <= CSD_SURF_BOTTOM);
|
assert(surf_idx >= CSD_SURF_LEFT && surf_idx <= CSD_SURF_BOTTOM);
|
||||||
|
|
||||||
if (term->window->use_csd != CSD_YES)
|
|
||||||
return;
|
|
||||||
|
|
||||||
struct csd_data info = get_csd_data(term, surf_idx);
|
struct csd_data info = get_csd_data(term, surf_idx);
|
||||||
struct wl_surface *surf = term->window->csd.surface[surf_idx];
|
struct wl_surface *surf = term->window->csd.surface[surf_idx];
|
||||||
|
|
||||||
|
|
@ -934,16 +928,11 @@ render_csd_button_close(struct terminal *term, struct buffer *buf)
|
||||||
pixman_image_unref(src);
|
pixman_image_unref(src);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
static void
|
||||||
render_csd_button(struct terminal *term, enum csd_surface surf_idx)
|
render_csd_button(struct terminal *term, enum csd_surface surf_idx)
|
||||||
{
|
{
|
||||||
assert(surf_idx >= CSD_SURF_MINIMIZE);
|
assert(term->window->use_csd == CSD_YES);
|
||||||
|
assert(surf_idx >= CSD_SURF_MINIMIZE && surf_idx <= CSD_SURF_CLOSE);
|
||||||
if (term->window->use_csd != CSD_YES)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (term->is_shutting_down)
|
|
||||||
return;
|
|
||||||
|
|
||||||
struct csd_data info = get_csd_data(term, surf_idx);
|
struct csd_data info = get_csd_data(term, surf_idx);
|
||||||
struct wl_surface *surf = term->window->csd.surface[surf_idx];
|
struct wl_surface *surf = term->window->csd.surface[surf_idx];
|
||||||
|
|
@ -1017,14 +1006,10 @@ render_csd_button(struct terminal *term, enum csd_surface surf_idx)
|
||||||
csd_commit(term, surf, buf);
|
csd_commit(term, surf, buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
static void
|
||||||
render_csd(struct terminal *term)
|
render_csd(struct terminal *term)
|
||||||
{
|
{
|
||||||
if (term->window->use_csd != CSD_YES)
|
assert(term->window->use_csd == CSD_YES);
|
||||||
return;
|
|
||||||
|
|
||||||
if (term->is_shutting_down)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (term->window->is_fullscreen)
|
if (term->window->is_fullscreen)
|
||||||
return;
|
return;
|
||||||
|
|
@ -1365,21 +1350,6 @@ grid_render(struct terminal *term)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
frame_callback(void *data, struct wl_callback *wl_callback, uint32_t callback_data)
|
|
||||||
{
|
|
||||||
struct terminal *term = data;
|
|
||||||
|
|
||||||
assert(term->window->frame_callback == wl_callback);
|
|
||||||
wl_callback_destroy(wl_callback);
|
|
||||||
term->window->frame_callback = NULL;
|
|
||||||
|
|
||||||
if (term->render.pending) {
|
|
||||||
term->render.pending = false;
|
|
||||||
grid_render(term);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
render_search_box(struct terminal *term)
|
render_search_box(struct terminal *term)
|
||||||
{
|
{
|
||||||
assert(term->window->search_sub_surface != NULL);
|
assert(term->window->search_sub_surface != NULL);
|
||||||
|
|
@ -1479,6 +1449,38 @@ 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
|
||||||
|
frame_callback(void *data, struct wl_callback *wl_callback, uint32_t callback_data)
|
||||||
|
{
|
||||||
|
struct terminal *term = data;
|
||||||
|
|
||||||
|
assert(term->window->frame_callback == wl_callback);
|
||||||
|
wl_callback_destroy(wl_callback);
|
||||||
|
term->window->frame_callback = NULL;
|
||||||
|
|
||||||
|
if (term->render.pending.csd) {
|
||||||
|
term->render.pending.csd = false;
|
||||||
|
|
||||||
|
if (term->window->use_csd == CSD_YES) {
|
||||||
|
quirk_weston_csd_on(term);
|
||||||
|
render_csd(term);
|
||||||
|
quirk_weston_csd_off(term);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (term->render.pending.search) {
|
||||||
|
term->render.pending.search = false;
|
||||||
|
|
||||||
|
if (term->is_searching)
|
||||||
|
render_search_box(term);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (term->render.pending.grid) {
|
||||||
|
term->render.pending.grid = false;
|
||||||
|
grid_render(term);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* Move to terminal.c? */
|
/* Move to terminal.c? */
|
||||||
static bool
|
static bool
|
||||||
maybe_resize(struct terminal *term, int width, int height, bool force)
|
maybe_resize(struct terminal *term, int width, int height, bool force)
|
||||||
|
|
@ -1651,8 +1653,6 @@ damage_view:
|
||||||
term->unmaximized_height = term->height;
|
term->unmaximized_height = term->height;
|
||||||
}
|
}
|
||||||
|
|
||||||
render_csd(term);
|
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
/* TODO: doesn't include CSD title bar */
|
/* TODO: doesn't include CSD title bar */
|
||||||
xdg_toplevel_set_min_size(
|
xdg_toplevel_set_min_size(
|
||||||
|
|
@ -1672,14 +1672,13 @@ damage_view:
|
||||||
term->height / term->scale + title_height);
|
term->height / term->scale + title_height);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (term->is_searching)
|
|
||||||
render_search_box(term);
|
|
||||||
|
|
||||||
tll_free(term->normal.scroll_damage);
|
tll_free(term->normal.scroll_damage);
|
||||||
tll_free(term->alt.scroll_damage);
|
tll_free(term->alt.scroll_damage);
|
||||||
|
|
||||||
term->render.last_buf = NULL;
|
term->render.last_buf = NULL;
|
||||||
term_damage_view(term);
|
term_damage_view(term);
|
||||||
|
render_refresh_csd(term);
|
||||||
|
render_refresh_search(term);
|
||||||
render_refresh(term);
|
render_refresh(term);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
@ -1767,20 +1766,50 @@ fdm_hook_refresh_pending_terminals(struct fdm *fdm, void *data)
|
||||||
tll_foreach(renderer->wayl->terms, it) {
|
tll_foreach(renderer->wayl->terms, it) {
|
||||||
struct terminal *term = it->item;
|
struct terminal *term = it->item;
|
||||||
|
|
||||||
if (!term->render.refresh_needed)
|
if (!term->render.refresh.grid &&
|
||||||
|
!term->render.refresh.csd &&
|
||||||
|
!term->render.refresh.search)
|
||||||
|
{
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (term->render.app_sync_updates.enabled)
|
if (term->render.app_sync_updates.enabled &&
|
||||||
|
!term->render.refresh.csd &&
|
||||||
|
!term->render.refresh.search)
|
||||||
|
{
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (term->render.refresh.csd || term->render.refresh.search) {
|
||||||
|
/* Force update of parent surface */
|
||||||
|
term->render.refresh.grid = true;
|
||||||
|
}
|
||||||
|
|
||||||
assert(term->window->is_configured);
|
assert(term->window->is_configured);
|
||||||
term->render.refresh_needed = false;
|
|
||||||
|
|
||||||
if (term->window->frame_callback == NULL)
|
bool grid = term->render.refresh.grid;
|
||||||
grid_render(term);
|
bool csd = term->render.refresh.csd;
|
||||||
else {
|
bool search = term->render.refresh.search;
|
||||||
|
|
||||||
|
term->render.refresh.grid = false;
|
||||||
|
term->render.refresh.csd = false;
|
||||||
|
term->render.refresh.search = false;
|
||||||
|
|
||||||
|
if (term->window->frame_callback == NULL) {
|
||||||
|
if (csd && term->window->use_csd == CSD_YES) {
|
||||||
|
quirk_weston_csd_on(term);
|
||||||
|
render_csd(term);
|
||||||
|
quirk_weston_csd_off(term);
|
||||||
|
}
|
||||||
|
if (search)
|
||||||
|
render_search_box(term);
|
||||||
|
if (grid)
|
||||||
|
grid_render(term);
|
||||||
|
} else {
|
||||||
/* Tells the frame callback to render again */
|
/* Tells the frame callback to render again */
|
||||||
term->render.pending = true;
|
term->render.pending.grid = grid;
|
||||||
|
term->render.pending.csd = csd;
|
||||||
|
term->render.pending.search = search;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1815,7 +1844,21 @@ render_set_title(struct terminal *term, const char *_title)
|
||||||
void
|
void
|
||||||
render_refresh(struct terminal *term)
|
render_refresh(struct terminal *term)
|
||||||
{
|
{
|
||||||
term->render.refresh_needed = true;
|
term->render.refresh.grid = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
render_refresh_csd(struct terminal *term)
|
||||||
|
{
|
||||||
|
if (term->window->use_csd == CSD_YES)
|
||||||
|
term->render.refresh.csd = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
render_refresh_search(struct terminal *term)
|
||||||
|
{
|
||||||
|
if (term->is_searching)
|
||||||
|
term->render.refresh.search = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
|
|
|
||||||
7
render.h
7
render.h
|
|
@ -14,13 +14,10 @@ bool render_resize_force(struct terminal *term, int width, int height);
|
||||||
|
|
||||||
void render_set_title(struct terminal *term, const char *title);
|
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_search(struct terminal *term);
|
||||||
bool render_xcursor_set(struct terminal *term);
|
bool render_xcursor_set(struct terminal *term);
|
||||||
|
|
||||||
void render_search_box(struct terminal *term);
|
|
||||||
void render_csd(struct terminal *term);
|
|
||||||
void render_csd_title(struct terminal *term);
|
|
||||||
void render_csd_button(struct terminal *term, enum csd_surface surf_idx);
|
|
||||||
|
|
||||||
struct render_worker_context {
|
struct render_worker_context {
|
||||||
int my_id;
|
int my_id;
|
||||||
struct terminal *term;
|
struct terminal *term;
|
||||||
|
|
|
||||||
6
search.c
6
search.c
|
|
@ -86,8 +86,7 @@ search_begin(struct terminal *term)
|
||||||
term->is_searching = true;
|
term->is_searching = true;
|
||||||
|
|
||||||
term_xcursor_update(term);
|
term_xcursor_update(term);
|
||||||
render_search_box(term);
|
render_refresh_search(term);
|
||||||
render_refresh(term);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
@ -616,6 +615,5 @@ search_input(struct terminal *term, uint32_t key, xkb_keysym_t sym, xkb_mod_mask
|
||||||
|
|
||||||
LOG_DBG("search: buffer: %S", term->search.buf);
|
LOG_DBG("search: buffer: %S", term->search.buf);
|
||||||
search_find_next(term);
|
search_find_next(term);
|
||||||
render_search_box(term);
|
render_refresh_search(term);
|
||||||
render_refresh(term);
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
14
terminal.c
14
terminal.c
|
|
@ -199,7 +199,7 @@ fdm_ptmx(struct fdm *fdm, int fd, int events, void *data)
|
||||||
*/
|
*/
|
||||||
if (term->window->frame_callback == NULL) {
|
if (term->window->frame_callback == NULL) {
|
||||||
if (term->render.app_sync_updates.enabled)
|
if (term->render.app_sync_updates.enabled)
|
||||||
term->render.refresh_needed = true;
|
term->render.refresh.grid = true;
|
||||||
|
|
||||||
else {
|
else {
|
||||||
/* First timeout - reset each time we receive input. */
|
/* First timeout - reset each time we receive input. */
|
||||||
|
|
@ -235,7 +235,7 @@ fdm_ptmx(struct fdm *fdm, int fd, int events, void *data)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
term->render.pending = true;
|
term->render.pending.grid = true;
|
||||||
|
|
||||||
if (hup) {
|
if (hup) {
|
||||||
if (term->hold_at_exit) {
|
if (term->hold_at_exit) {
|
||||||
|
|
@ -1637,10 +1637,7 @@ term_visual_focus_in(struct terminal *term)
|
||||||
if (term->cursor_blink.active)
|
if (term->cursor_blink.active)
|
||||||
cursor_blink_start_timer(term);
|
cursor_blink_start_timer(term);
|
||||||
|
|
||||||
quirk_weston_csd_on(term);
|
render_refresh_csd(term);
|
||||||
render_csd(term);
|
|
||||||
quirk_weston_csd_off(term);
|
|
||||||
|
|
||||||
cursor_refresh(term);
|
cursor_refresh(term);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1654,10 +1651,7 @@ term_visual_focus_out(struct terminal *term)
|
||||||
if (term->cursor_blink.active)
|
if (term->cursor_blink.active)
|
||||||
cursor_blink_stop_timer(term);
|
cursor_blink_stop_timer(term);
|
||||||
|
|
||||||
quirk_weston_csd_on(term);
|
render_refresh_csd(term);
|
||||||
render_csd(term);
|
|
||||||
quirk_weston_csd_off(term);
|
|
||||||
|
|
||||||
cursor_refresh(term);
|
cursor_refresh(term);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
16
terminal.h
16
terminal.h
|
|
@ -331,7 +331,20 @@ struct terminal {
|
||||||
enum term_surface active_surface;
|
enum term_surface active_surface;
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
bool refresh_needed; /* Terminal needs to be re-rendered, as soon-as-possible */
|
/* Scheduled for rendering, as soon-as-possible */
|
||||||
|
struct {
|
||||||
|
bool grid;
|
||||||
|
bool csd;
|
||||||
|
bool search;
|
||||||
|
} refresh;
|
||||||
|
|
||||||
|
/* Scheduled for rendering, in the next frame callback */
|
||||||
|
struct {
|
||||||
|
bool grid;
|
||||||
|
bool csd;
|
||||||
|
bool search;
|
||||||
|
} 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?) */
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
|
|
@ -358,7 +371,6 @@ struct terminal {
|
||||||
struct cell *cell; /* For easy access to content */
|
struct cell *cell; /* For easy access to content */
|
||||||
} last_cursor;
|
} last_cursor;
|
||||||
|
|
||||||
bool pending; /* Need to re-render again, after next frame-callback */
|
|
||||||
struct buffer *last_buf; /* Buffer we rendered to last time */
|
struct buffer *last_buf; /* Buffer we rendered to last time */
|
||||||
bool was_flashing; /* Flash was active last time we rendered */
|
bool was_flashing; /* Flash was active last time we rendered */
|
||||||
bool was_searching;
|
bool was_searching;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue