Merge branch 'osc4-refresh-scheduling' into master

Closes #141
This commit is contained in:
Daniel Eklöf 2020-09-29 19:38:56 +02:00
commit 70f1274171
No known key found for this signature in database
GPG key ID: 5BBD4992C116573F
6 changed files with 32 additions and 33 deletions

View file

@ -25,6 +25,8 @@
than specified in the binding. This allows you to, for example,
quickly press the middle-button to paste multiple times
(https://codeberg.org/dnkl/foot/issues/146).
* Color flashes when changing the color palette with OSC 4,10,11
(https://codeberg.org/dnkl/foot/issues/141).
### Security

14
osc.c
View file

@ -589,7 +589,6 @@ osc_dispatch(struct terminal *term)
}
}
render_refresh(term);
break;
}
@ -635,8 +634,7 @@ osc_dispatch(struct terminal *term)
}
term_damage_view(term);
render_refresh(term);
render_refresh_margins(term);
term_damage_margins(term);
break;
}
@ -664,7 +662,8 @@ osc_dispatch(struct terminal *term)
term->cursor_color.cursor = 0; /* Invert fg/bg */
else
term->cursor_color.cursor = 1u << 31 | color;
render_refresh(term);
term_damage_cursor(term);
break;
case 30: /* Set tab title */
@ -705,7 +704,6 @@ osc_dispatch(struct terminal *term)
}
}
render_refresh(term);
break;
}
@ -716,22 +714,20 @@ osc_dispatch(struct terminal *term)
LOG_DBG("resetting foreground");
term->colors.fg = term->colors.default_fg;
term_damage_view(term);
render_refresh(term);
break;
case 111: /* Reset default text background color */
LOG_DBG("resetting background");
term->colors.bg = term->colors.default_bg;
term_damage_view(term);
render_refresh(term);
render_refresh_margins(term);
term_damage_margins(term);
break;
case 112:
LOG_DBG("resetting cursor color");
term->cursor_color.text = term->default_cursor_color.text;
term->cursor_color.cursor = term->default_cursor_color.cursor;
render_refresh(term);
term_damage_cursor(term);
break;
case 555:

View file

@ -1568,7 +1568,7 @@ static const struct wl_callback_listener frame_listener = {
};
static void
grid_render(struct terminal *term, bool redraw_margins)
grid_render(struct terminal *term)
{
if (term->is_shutting_down)
return;
@ -1588,7 +1588,7 @@ grid_render(struct terminal *term, bool redraw_margins)
if (term->render.last_buf != buf ||
term->flash.active || term->render.was_flashing ||
term->is_searching != term->render.was_searching ||
redraw_margins)
term->render.margins)
{
if (term->render.last_buf != NULL &&
term->render.last_buf->width == buf->width &&
@ -1596,7 +1596,7 @@ grid_render(struct terminal *term, bool redraw_margins)
!term->flash.active &&
!term->render.was_flashing &&
term->is_searching == term->render.was_searching &&
!redraw_margins)
!term->render.margins)
{
static bool has_warned = false;
if (!has_warned) {
@ -1972,13 +1972,11 @@ frame_callback(void *data, struct wl_callback *wl_callback, uint32_t callback_da
term->window->frame_callback = NULL;
bool grid = term->render.pending.grid;
bool margins = term->render.pending.margins;
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.margins = false;
term->render.pending.csd = false;
term->render.pending.search = false;
term->render.pending.title = false;
@ -1995,11 +1993,8 @@ frame_callback(void *data, struct wl_callback *wl_callback, uint32_t callback_da
if (search && term->is_searching)
render_search_box(term);
if ((grid || margins) &&
(!term->delayed_render_timer.is_armed || csd || search))
{
grid_render(term, margins);
}
if (grid && (!term->delayed_render_timer.is_armed || csd || search))
grid_render(term);
}
/* Move to terminal.c? */
@ -2336,13 +2331,11 @@ fdm_hook_refresh_pending_terminals(struct fdm *fdm, void *data)
assert(term->window->is_configured);
bool grid = term->render.refresh.grid;
bool margins = term->render.refresh.margins;
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.margins = false;
term->render.refresh.csd = false;
term->render.refresh.search = false;
term->render.refresh.title = false;
@ -2357,12 +2350,11 @@ fdm_hook_refresh_pending_terminals(struct fdm *fdm, void *data)
render_update_title(term);
if (search)
render_search_box(term);
if (grid || margins)
grid_render(term, margins);
if (grid)
grid_render(term);
} else {
/* Tells the frame callback to render again */
term->render.pending.grid |= grid;
term->render.pending.margins |= margins;
term->render.pending.csd |= csd;
term->render.pending.search |= search;
term->render.pending.title |= title;
@ -2393,12 +2385,6 @@ render_refresh(struct terminal *term)
term->render.refresh.grid = true;
}
void
render_refresh_margins(struct terminal *term)
{
term->render.refresh.margins = true;
}
void
render_refresh_csd(struct terminal *term)
{

View file

@ -13,7 +13,6 @@ bool render_resize(struct terminal *term, int width, int height);
bool render_resize_force(struct terminal *term, int width, int height);
void render_refresh(struct terminal *term);
void render_refresh_margins(struct terminal *term);
void render_refresh_csd(struct terminal *term);
void render_refresh_search(struct terminal *term);
void render_refresh_title(struct terminal *term);

View file

@ -1626,6 +1626,19 @@ term_damage_view(struct terminal *term)
term_damage_rows_in_view(term, 0, term->rows - 1);
}
void
term_damage_cursor(struct terminal *term)
{
term->grid->cur_row->cells[term->grid->cursor.point.col].attrs.clean = 0;
term->grid->cur_row->dirty = true;
}
void
term_damage_margins(struct terminal *term)
{
term->render.margins = true;
}
void
term_damage_scroll(struct terminal *term, enum damage_type damage_type,
struct scroll_region region, int lines)

View file

@ -373,7 +373,6 @@ struct terminal {
/* Scheduled for rendering, as soon-as-possible */
struct {
bool grid;
bool margins;
bool csd;
bool search;
bool title;
@ -382,12 +381,13 @@ struct terminal {
/* Scheduled for rendering, in the next frame callback */
struct {
bool grid;
bool margins;
bool csd;
bool search;
bool title;
} pending;
bool margins; /* Someone explicitly requested a refresh of the margins */
int scrollback_lines; /* Number of scrollback lines, from conf (TODO: move out from render struct?) */
struct {
@ -512,6 +512,9 @@ void term_damage_rows_in_view(struct terminal *term, int start, int end);
void term_damage_all(struct terminal *term);
void term_damage_view(struct terminal *term);
void term_damage_cursor(struct terminal *term);
void term_damage_margins(struct terminal *term);
void term_reset_view(struct terminal *term);
void term_damage_scroll(