From 607df23a92ca904a14b8858d5128703b144d4be1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Tue, 2 Jul 2019 12:51:43 +0200 Subject: [PATCH] render: fix cursor not always being rendered In case the only difference between this and the last frame was cursor movement, the cursor was not rendered. --- main.c | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/main.c b/main.c index 81cd4656..feaa7f25 100644 --- a/main.c +++ b/main.c @@ -369,18 +369,27 @@ grid_render_scroll_reverse(struct context *c, struct buffer *buf, static void grid_render(struct context *c) { - struct buffer *buf = shm_get_buffer(c->wl.shm, c->width, c->height); - cairo_set_operator(buf->cairo, CAIRO_OPERATOR_SOURCE); + static struct cursor last_cursor = {.linear = 0, .col = 0, .row = 0}; if (tll_length(c->term.grid->damage) == 0 && - tll_length(c->term.grid->scroll_damage) == 0) + tll_length(c->term.grid->scroll_damage) == 0 && + last_cursor.linear == c->term.cursor.linear) { - goto render_cursor; + return; } assert(c->width > 0); assert(c->height > 0); + struct buffer *buf = shm_get_buffer(c->wl.shm, c->width, c->height); + cairo_set_operator(buf->cairo, CAIRO_OPERATOR_SOURCE); + + static struct buffer *last_buf = NULL; + if (last_buf != buf) { + if (last_buf != NULL) + LOG_WARN("new buffer"); + last_buf = buf; + } tll_foreach(c->term.grid->scroll_damage, it) { @@ -416,12 +425,8 @@ grid_render(struct context *c) tll_remove(c->term.grid->damage, it); } -render_cursor: - ; - /* TODO: break out to function */ /* Re-render last cursor cell and current cursor cell */ - static struct cursor last_cursor = {.linear = 0, .col = 0, .row = 0}; if (last_cursor.linear != c->term.cursor.linear) { struct damage prev_cursor = {