aboutsummaryrefslogtreecommitdiff
path: root/render.c
diff options
context:
space:
mode:
authorDaniel Eklöf <daniel@ekloef.se>2019-07-21 17:14:19 +0000
committerDaniel Eklöf <daniel@ekloef.se>2019-07-21 17:14:19 +0000
commit0dd8951cb3d3b260575162ebbd1914c61a10d876 (patch)
treee05b6e5584516e97a285780c9fec8e114a2123fc /render.c
parentcsi: remove erronous final (diff)
flash: implement 'flash'
Use our own escape sequence for the 'flash' terminfo entry. Implemented by arming a timer FD and setting a boolean that indicates we're currently "flashing". The renderer draws a semi-transparent yellowish layer over the entire window when "flashing" is active.
Diffstat (limited to 'render.c')
-rw-r--r--render.c58
1 files changed, 37 insertions, 21 deletions
diff --git a/render.c b/render.c
index db9881a3..9664cd20 100644
--- a/render.c
+++ b/render.c
@@ -296,34 +296,40 @@ grid_render(struct terminal *term)
struct buffer *buf = shm_get_buffer(term->wl.shm, term->width, term->height);
cairo_set_operator(buf->cairo, CAIRO_OPERATOR_SOURCE);
+ if (term->flash_active)
+ term_damage_view(term);
+
static struct buffer *last_buf = NULL;
- if (last_buf != buf || false) {
- if (last_buf != NULL) {
- LOG_DBG("new buffer");
+ static bool last_flash = false;
- /* Fill area outside the cell grid with the default background color */
- int rmargin = term->cols * term->cell_width;
- int bmargin = term->rows * term->cell_height;
- int rmargin_width = term->width - rmargin;
- int bmargin_height = term->height - bmargin;
+ /* If we resized the window, or is flashing, or just stopped flashing */
+ if (last_buf != buf || term->flash_active || last_flash) {
+ LOG_DBG("new buffer");
- uint32_t _bg = !term->reverse ? term->colors.bg : term->colors.fg;
- struct rgb bg = color_hex_to_rgb(_bg);
- cairo_set_source_rgb(buf->cairo, bg.r, bg.g, bg.b);
+ /* Fill area outside the cell grid with the default background color */
+ int rmargin = term->cols * term->cell_width;
+ int bmargin = term->rows * term->cell_height;
+ int rmargin_width = term->width - rmargin;
+ int bmargin_height = term->height - bmargin;
- cairo_rectangle(buf->cairo, rmargin, 0, rmargin_width, term->height);
- cairo_rectangle(buf->cairo, 0, bmargin, term->width, bmargin_height);
- cairo_fill(buf->cairo);
+ uint32_t _bg = !term->reverse ? term->colors.bg : term->colors.fg;
+ struct rgb bg = color_hex_to_rgb(_bg);
+ cairo_set_source_rgb(buf->cairo, bg.r, bg.g, bg.b);
- wl_surface_damage_buffer(
- term->wl.surface, rmargin, 0, rmargin_width, term->height);
- wl_surface_damage_buffer(
- term->wl.surface, 0, bmargin, term->width, bmargin_height);
+ cairo_rectangle(buf->cairo, rmargin, 0, rmargin_width, term->height);
+ cairo_rectangle(buf->cairo, 0, bmargin, term->width, bmargin_height);
+ cairo_fill(buf->cairo);
+
+ wl_surface_damage_buffer(
+ term->wl.surface, rmargin, 0, rmargin_width, term->height);
+ wl_surface_damage_buffer(
+ term->wl.surface, 0, bmargin, term->width, bmargin_height);
+
+ /* Force a full grid refresh */
+ term_damage_view(term);
- /* Force a full grid refresh */
- term_damage_all(term);
- }
last_buf = buf;
+ last_flash = term->flash_active;
}
bool all_clean = tll_length(term->grid->scroll_damage) == 0;
@@ -419,6 +425,16 @@ grid_render(struct terminal *term)
if (gseq.count > 0)
gseq_flush(term, buf);
+ if (term->flash_active) {
+ cairo_set_source_rgba(buf->cairo, 1.0, 1.0, 0.0, 0.5);
+ cairo_set_operator(buf->cairo, CAIRO_OPERATOR_OVER);
+ cairo_rectangle(buf->cairo, 0, 0, term->width, term->height);
+ cairo_fill(buf->cairo);
+
+ wl_surface_damage_buffer(
+ term->wl.surface, 0, 0, term->width, term->height);
+ }
+
assert(term->grid->offset >= 0 && term->grid->offset < term->grid->num_rows);
assert(term->grid->view >= 0 && term->grid->view < term->grid->num_rows);