aboutsummaryrefslogtreecommitdiff
path: root/render.c
diff options
context:
space:
mode:
authorDaniel Eklöf <daniel@ekloef.se>2019-11-01 23:33:37 +0000
committerDaniel Eklöf <daniel@ekloef.se>2019-11-01 23:33:37 +0000
commit00b46455a065d33cb01dc6345637b38c3309596d (patch)
tree49c74942782cb88fa7f68d19f564ae2dcde2116d /render.c
parentshm: get_buffer(): remove 'copies' argument; it's not used (diff)
shm: associate a 'cookie' with each buffer
When re-using a buffer from cache, only re-use ones with a matching cookie. This prevents contention between multiple terminal windows.
Diffstat (limited to 'render.c')
-rw-r--r--render.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/render.c b/render.c
index 37d1aee1..0b0c6d5b 100644
--- a/render.c
+++ b/render.c
@@ -441,10 +441,13 @@ grid_render(struct terminal *term)
assert(term->width > 0);
assert(term->height > 0);
- struct buffer *buf = shm_get_buffer(term->wl->shm, term->width, term->height);
+ unsigned long cookie = (uintptr_t)term;
+ struct buffer *buf = shm_get_buffer(
+ term->wl->shm, term->width, term->height, cookie);
+
wl_surface_attach(term->window->surface, buf->wl_buf, 0, 0);
- pixman_image_t *pix = buf->pix;
+ pixman_image_t *pix = buf->pix;
bool all_clean = tll_length(term->grid->scroll_damage) == 0;
/* If we resized the window, or is flashing, or just stopped flashing */
@@ -754,7 +757,8 @@ render_search_box(struct terminal *term)
const int width = 2 * margin + max(20, term->search.len) * term->cell_width;
const int height = 2 * margin + 1 * term->cell_height;
- struct buffer *buf = shm_get_buffer(term->wl->shm, width, height);
+ unsigned long cookie = (uintptr_t)term;
+ struct buffer *buf = shm_get_buffer(term->wl->shm, width, height, cookie);
/* Background - yellow on empty/match, red on mismatch */
pixman_color_t color = color_hex_to_pixman(