From e8ffb05bc7fb3b996752f345b77af4b757f69776 Mon Sep 17 00:00:00 2001 From: Daniel Eklöf Date: Tue, 23 Mar 2021 13:03:07 +0100 Subject: ime: move preedit state from terminal struct to the seat struct MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This ensures different seat’s don’t step on each others IME pre-edit state. It also removes most dependencies on having a valid term pointer for many IME operations. We’re still not all the way, since we support disabling IME with a private mode, which is per terminal, not seat. Thus, we still require the seat to have keyboard focus on one of our windows. Closes #324. But note that *rendering* of multiple seat’s IME pre-edit strings is still broken. --- render.c | 90 ++++++++++++++++++++++++++++++++++++++++------------------------ 1 file changed, 56 insertions(+), 34 deletions(-) (limited to 'render.c') diff --git a/render.c b/render.c index fcd07f56..79f90cc7 100644 --- a/render.c +++ b/render.c @@ -1114,12 +1114,12 @@ render_sixel_images(struct terminal *term, pixman_image_t *pix, } } +#if defined(FOOT_IME_ENABLED) && FOOT_IME_ENABLED static void -render_ime_preedit(struct terminal *term, struct buffer *buf) +render_ime_preedit_for_seat(struct terminal *term, struct seat *seat, + struct buffer *buf) { -#if defined(FOOT_IME_ENABLED) && FOOT_IME_ENABLED - - if (likely(term->ime.preedit.cells == NULL)) + if (likely(seat->ime.preedit.cells == NULL)) return; if (unlikely(term->is_searching)) @@ -1135,10 +1135,10 @@ render_ime_preedit(struct terminal *term, struct buffer *buf) if (cursor.row < 0 || cursor.row >= term->rows) return; - int cells_needed = term->ime.preedit.count; + int cells_needed = seat->ime.preedit.count; - if (term->ime.preedit.cursor.start == cells_needed && - term->ime.preedit.cursor.end == cells_needed) + if (seat->ime.preedit.cursor.start == cells_needed && + seat->ime.preedit.cursor.end == cells_needed) { /* Cursor will be drawn *after* the pre-edit string, i.e. in * the cell *after*. This means we need to copy, and dirty, @@ -1160,8 +1160,8 @@ render_ime_preedit(struct terminal *term, struct buffer *buf) col_idx -= cells_used - cells_left; if (cells_needed > cells_used) { - int start = term->ime.preedit.cursor.start; - int end = term->ime.preedit.cursor.end; + int start = seat->ime.preedit.cursor.start; + int end = seat->ime.preedit.cursor.end; if (start == end) { /* Ensure *end* of pre-edit string is visible */ @@ -1177,7 +1177,7 @@ render_ime_preedit(struct terminal *term, struct buffer *buf) /* Make sure we don't start in the middle of a character */ while (ime_ofs < cells_needed && - term->ime.preedit.cells[ime_ofs].wc == CELL_MULT_COL_SPACER) + seat->ime.preedit.cells[ime_ofs].wc == CELL_MULT_COL_SPACER) { ime_ofs++; } @@ -1208,9 +1208,9 @@ render_ime_preedit(struct terminal *term, struct buffer *buf) row->dirty = true; /* Render pre-edit text */ - xassert(term->ime.preedit.cells[ime_ofs].wc != CELL_MULT_COL_SPACER); - for (int i = 0, idx = ime_ofs; idx < term->ime.preedit.count; i++, idx++) { - const struct cell *cell = &term->ime.preedit.cells[idx]; + xassert(seat->ime.preedit.cells[ime_ofs].wc != CELL_MULT_COL_SPACER); + for (int i = 0, idx = ime_ofs; idx < seat->ime.preedit.count; i++, idx++) { + const struct cell *cell = &seat->ime.preedit.cells[idx]; if (cell->wc == CELL_MULT_COL_SPACER) continue; @@ -1223,11 +1223,11 @@ render_ime_preedit(struct terminal *term, struct buffer *buf) render_cell(term, buf->pix[0], row, col_idx + i, row_idx, false); } - int start = term->ime.preedit.cursor.start - ime_ofs; - int end = term->ime.preedit.cursor.end - ime_ofs; + int start = seat->ime.preedit.cursor.start - ime_ofs; + int end = seat->ime.preedit.cursor.end - ime_ofs; - if (!term->ime.preedit.cursor.hidden) { - const struct cell *start_cell = &term->ime.preedit.cells[0]; + if (!seat->ime.preedit.cursor.hidden) { + const struct cell *start_cell = &seat->ime.preedit.cells[0]; pixman_color_t fg = color_hex_to_pixman(term->colors.fg); pixman_color_t bg = color_hex_to_pixman(term->colors.bg); @@ -1271,6 +1271,17 @@ render_ime_preedit(struct terminal *term, struct buffer *buf) term->margins.top + row_idx * term->cell_height, term->width - term->margins.left - term->margins.right, 1 * term->cell_height); +} +#endif + +static void +render_ime_preedit(struct terminal *term, struct buffer *buf) +{ +#if defined(FOOT_IME_ENABLED) && FOOT_IME_ENABLED + tll_foreach(term->wl->seats, it) { + if (it->item.kbd_focus == term) + render_ime_preedit_for_seat(term, &it->item, buf); + } #endif } @@ -2238,9 +2249,18 @@ render_search_box(struct terminal *term) */ #if defined(FOOT_IME_ENABLED) && FOOT_IME_ENABLED + /* TODO: do we want to/need to handle multi-seat? */ + struct seat *ime_seat = NULL; + tll_foreach(term->wl->seats, it) { + if (it->item.kbd_focus == term) { + ime_seat = &it->item; + break; + } + } + size_t text_len = term->search.len; - if (term->ime.preedit.text != NULL) - text_len += wcslen(term->ime.preedit.text); + if (ime_seat != NULL && ime_seat->ime.preedit.text != NULL) + text_len += wcslen(ime_seat->ime.preedit.text); wchar_t *text = xmalloc((text_len + 1) * sizeof(wchar_t)); text[0] = L'\0'; @@ -2250,8 +2270,8 @@ render_search_box(struct terminal *term) text[term->search.cursor] = L'\0'; /* Insert pre-edit text at cursor */ - if (term->ime.preedit.text != NULL) - wcscat(text, term->ime.preedit.text); + if (ime_seat != NULL && ime_seat->ime.preedit.text != NULL) + wcscat(text, ime_seat->ime.preedit.text); /* And finally everything after the cursor */ wcsncat(text, &term->search.buf[term->search.cursor], @@ -2319,18 +2339,18 @@ render_search_box(struct terminal *term) continue; #if (FOOT_IME_ENABLED) && FOOT_IME_ENABLED - if (term->ime.preedit.cells != NULL) { - if (term->ime.preedit.cursor.start == term->ime.preedit.cursor.end) { + if (ime_seat != NULL && ime_seat->ime.preedit.cells != NULL) { + if (ime_seat->ime.preedit.cursor.start == ime_seat->ime.preedit.cursor.end) { /* All IME's I've seen so far keeps the cursor at * index 0, so ensure the *end* of the pre-edit string * is visible */ - cell_idx += term->ime.preedit.count; + cell_idx += ime_seat->ime.preedit.count; } else { /* Try to predict in which direction we'll shift the text */ - if (cell_idx + term->ime.preedit.cursor.start > glyph_offset) - cell_idx += term->ime.preedit.cursor.end; + if (cell_idx + ime_seat->ime.preedit.cursor.start > glyph_offset) + cell_idx += ime_seat->ime.preedit.cursor.end; else - cell_idx += term->ime.preedit.cursor.start; + cell_idx += ime_seat->ime.preedit.cursor.start; } } #endif @@ -2383,8 +2403,10 @@ render_search_box(struct terminal *term) /* Render cursor */ if (i == term->search.cursor) { #if defined(FOOT_IME_ENABLED) && FOOT_IME_ENABLED - bool have_preedit = term->ime.preedit.cells != NULL; - bool hidden = term->ime.preedit.cursor.hidden; + bool have_preedit = + ime_seat != NULL && ime_seat->ime.preedit.cells != NULL; + bool hidden = + ime_seat != NULL && ime_seat->ime.preedit.cursor.hidden; if (have_preedit && !hidden) { /* Cursor may be outside the visible area: @@ -2394,13 +2416,13 @@ render_search_box(struct terminal *term) /* If cursor is outside the visible area, we need to * adjust our rectangle's position */ - int start = term->ime.preedit.cursor.start + int start = ime_seat->ime.preedit.cursor.start + min((ssize_t)(cell_idx - glyph_offset), 0); - int end = term->ime.preedit.cursor.end + int end = ime_seat->ime.preedit.cursor.end + min((ssize_t)(cell_idx - glyph_offset), 0); if (start == end) { - int count = min(term->ime.preedit.count, cells_left); + int count = min(ime_seat->ime.preedit.count, cells_left); /* Underline the entire (visible part of) pre-edit text */ draw_underline(term, buf->pix[0], font, &fg, x, y, count); @@ -2415,7 +2437,7 @@ render_search_box(struct terminal *term) /* Underline everything before and after the cursor */ int count1 = min(start, cells_left); int count2 = max( - min(term->ime.preedit.count - term->ime.preedit.cursor.end, + min(ime_seat->ime.preedit.count - ime_seat->ime.preedit.cursor.end, cells_left - end), 0); draw_underline(term, buf->pix[0], font, &fg, x, y, count1); @@ -2487,7 +2509,7 @@ render_search_box(struct terminal *term) } #if defined(FOOT_IME_ENABLED) && FOOT_IME_ENABLED - if (term->ime.preedit.cells != NULL) + if (ime_seat != NULL && ime_seat->ime.preedit.cells != NULL) /* Already rendered */; else #endif -- cgit v1.3 From 13b45db13e134c81ea72d1d70bf782ecd2445900 Mon Sep 17 00:00:00 2001 From: Daniel Eklöf Date: Tue, 23 Mar 2021 13:56:33 +0100 Subject: ime: don’t pass ‘term’ to ime_update_cursor_rect() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In all instances where we call ime_update_cursor_rect(), the ‘term’ argument is the same as seat->kbd_focus. So, let ime_update_cursor_rect() use that directly instead. Also make ime_send_cursor_rect() static (i.e. local to ime.c). --- ime.c | 15 +++++++++------ ime.h | 3 +-- render.c | 4 ++-- 3 files changed, 12 insertions(+), 10 deletions(-) (limited to 'render.c') diff --git a/ime.c b/ime.c index 6c65265d..a224d570 100644 --- a/ime.c +++ b/ime.c @@ -344,8 +344,8 @@ ime_reset_preedit(struct seat *seat) seat->ime.preedit.count = 0; } -void -ime_send_cursor_rect(struct seat *seat, struct terminal *term) +static void +ime_send_cursor_rect(struct seat *seat) { if (unlikely(seat->wayl->text_input_manager == NULL)) return; @@ -353,6 +353,8 @@ ime_send_cursor_rect(struct seat *seat, struct terminal *term) if (!seat->ime.focused) return; + struct terminal *term = seat->kbd_focus; + if (!term->ime_enabled) return; @@ -437,8 +439,10 @@ ime_disable(struct seat *seat) } void -ime_update_cursor_rect(struct seat *seat, struct terminal *term) +ime_update_cursor_rect(struct seat *seat) { + struct terminal *term = seat->kbd_focus; + /* Set in render_ime_preedit() */ if (seat->ime.preedit.cells != NULL) goto update; @@ -469,7 +473,7 @@ ime_update_cursor_rect(struct seat *seat, struct terminal *term) seat->ime.cursor_rect.pending.height = height; update: - ime_send_cursor_rect(seat, term); + ime_send_cursor_rect(seat); } const struct zwp_text_input_v3_listener text_input_listener = { @@ -485,12 +489,11 @@ const struct zwp_text_input_v3_listener text_input_listener = { void ime_enable(struct seat *seat) {} void ime_disable(struct seat *seat) {} -void ime_update_cursor_rect(struct seat *seat, struct terminal *term) {} +void ime_update_cursor_rect(struct seat *seat) {} void ime_reset_pending_preedit(struct seat *seat) {} void ime_reset_pending_commit(struct seat *seat) {} void ime_reset_pending(struct seat *seat) {} void ime_reset_preedit(struct seat *seat) {} -void ime_send_cursor_rect(struct seat *seat, struct terminal *term) {} #endif diff --git a/ime.h b/ime.h index 01438a5a..2aa4efe4 100644 --- a/ime.h +++ b/ime.h @@ -13,10 +13,9 @@ struct terminal; void ime_enable(struct seat *seat); void ime_disable(struct seat *seat); -void ime_update_cursor_rect(struct seat *seat, struct terminal *term); +void ime_update_cursor_rect(struct seat *seat); void ime_reset_pending_preedit(struct seat *seat); void ime_reset_pending_commit(struct seat *seat); void ime_reset_pending(struct seat *seat); void ime_reset_preedit(struct seat *seat); -void ime_send_cursor_rect(struct seat *seat, struct terminal *term); diff --git a/render.c b/render.c index 79f90cc7..dd8070e0 100644 --- a/render.c +++ b/render.c @@ -2739,7 +2739,7 @@ frame_callback(void *data, struct wl_callback *wl_callback, uint32_t callback_da tll_foreach(term->wl->seats, it) { if (it->item.kbd_focus == term) - ime_update_cursor_rect(&it->item, term); + ime_update_cursor_rect(&it->item); } term->grid = original_grid; @@ -3195,7 +3195,7 @@ fdm_hook_refresh_pending_terminals(struct fdm *fdm, void *data) tll_foreach(term->wl->seats, it) { if (it->item.kbd_focus == term) - ime_update_cursor_rect(&it->item, term); + ime_update_cursor_rect(&it->item); } term->grid = original_grid; -- cgit v1.3 From 8111ff4be8335c73b93717ba6b948ee57395a740 Mon Sep 17 00:00:00 2001 From: Daniel Eklöf Date: Wed, 24 Mar 2021 20:46:51 +0100 Subject: render: draw sixels before taking the render worker lock MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This fixes a possible deadlock; render_sixels_images() may call render_cell(), which may need to take the worker lock (when rendering either a blinking cell, or a box drawing glyph that isn’t yet in the glyph cache). --- CHANGELOG.md | 1 + render.c | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) (limited to 'render.c') diff --git a/CHANGELOG.md b/CHANGELOG.md index 04b0fe7f..7c7a6b1f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -40,6 +40,7 @@ * Crash when compositor send `text-input-v3::enter` events without first having sent a `keyboard::enter` event (https://codeberg.org/dnkl/foot/issues/411). +* Deadlock when rendering sixel images. ### Security diff --git a/render.c b/render.c index dd8070e0..d8e1a009 100644 --- a/render.c +++ b/render.c @@ -2090,6 +2090,8 @@ grid_render(struct terminal *term) cursor.row &= term->grid->num_rows - 1; } + render_sixel_images(term, buf->pix[0], &cursor); + if (term->render.workers.count > 0) { mtx_lock(&term->render.workers.lock); term->render.workers.buf = buf; @@ -2099,8 +2101,6 @@ grid_render(struct terminal *term) xassert(tll_length(term->render.workers.queue) == 0); } - render_sixel_images(term, buf->pix[0], &cursor); - int first_dirty_row = -1; for (int r = 0; r < term->rows; r++) { struct row *row = grid_row_in_view(term->grid, r); -- cgit v1.3 From 5b8b3baa6537d56de5a4c78dfd505a851da25aa8 Mon Sep 17 00:00:00 2001 From: Daniel Eklöf Date: Wed, 24 Mar 2021 20:51:18 +0100 Subject: render: render_osd(): no need to pass width/height as parameters All uses of render_osd() passes buf->width/buf->height as width/height. Thus, we can simply remove the width/height parameters and have render_osd() use buf->width and buf->height directly. --- render.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'render.c') diff --git a/render.c b/render.c index d8e1a009..f250560a 100644 --- a/render.c +++ b/render.c @@ -1751,12 +1751,12 @@ render_osd(struct terminal *term, struct wl_surface *surf, struct wl_subsurface *sub_surf, struct buffer *buf, const wchar_t *text, uint32_t _fg, uint32_t _bg, - unsigned width, unsigned height, unsigned x, unsigned y) + unsigned x, unsigned y) { pixman_color_t bg = color_hex_to_pixman(_bg); pixman_image_fill_rectangles( PIXMAN_OP_SRC, buf->pix[0], &bg, 1, - &(pixman_rectangle16_t){0, 0, width, height}); + &(pixman_rectangle16_t){0, 0, buf->width, buf->height}); struct fcft_font *font = term->fonts[0]; pixman_color_t fg = color_hex_to_pixman(_fg); @@ -1782,12 +1782,12 @@ render_osd(struct terminal *term, quirk_weston_subsurface_desync_on(sub_surf); wl_surface_attach(surf, buf->wl_buf, 0, 0); - wl_surface_damage_buffer(surf, 0, 0, width, height); + wl_surface_damage_buffer(surf, 0, 0, buf->width, buf->height); wl_surface_set_buffer_scale(surf, term->scale); struct wl_region *region = wl_compositor_create_region(term->wl->compositor); if (region != NULL) { - wl_region_add(region, 0, 0, width, height); + wl_region_add(region, 0, 0, buf->width, buf->height); wl_surface_set_opaque_region(surf, region); wl_region_destroy(region); } @@ -1916,7 +1916,7 @@ render_scrollback_position(struct terminal *term) win->scrollback_indicator.sub, buf, text, term->colors.table[0], term->colors.table[8 + 4], - width, height, width - margin - wcslen(text) * term->cell_width, margin); + width - margin - wcslen(text) * term->cell_width, margin); } @@ -1949,7 +1949,7 @@ render_render_timer(struct terminal *term, struct timeval render_time) win->render_timer.sub, buf, text, term->colors.table[0], term->colors.table[8 + 1], - width, height, margin, margin); + margin, margin); } static void frame_callback( @@ -2670,8 +2670,8 @@ render_urls(struct terminal *term) ? term->conf->colors.jump_label.bg : term->colors.table[3]; - render_osd(term, surf, sub_surf, buf, label, - fg, bg, width, height, x_margin, y_margin); + render_osd( + term, surf, sub_surf, buf, label, fg, bg, x_margin, y_margin); } } -- cgit v1.3 From 1a0f13640e6f007cd08220dc54fed8b6dd8eec3c Mon Sep 17 00:00:00 2001 From: Daniel Eklöf Date: Wed, 24 Mar 2021 20:52:58 +0100 Subject: render: make sure surface buffer sizes are a multiple of the scaling factor The buffer attached to a surface with wl_surface_attach() must have a width and height that both are a multiple of the scale configured for that buffer: The new size of the surface is calculated based on the buffer size transformed by the inverse buffer_transform and the inverse buffer_scale. This means that at commit time the supplied buffer size must be an integer multiple of the buffer_scale. If that's not the case, an invalid_size error is sent. Due to a libwayland bug[^1], this is currently *not* being reported as an error. However, recent versions of Sway have started enforcing this, and is e.g. dropping (not rendering) sub-surfaces that does not adhere to this. [^1]: https://gitlab.freedesktop.org/wayland/wayland/-/issues/194 Closes #409 --- render.c | 52 +++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 41 insertions(+), 11 deletions(-) (limited to 'render.c') diff --git a/render.c b/render.c index f250560a..b857e360 100644 --- a/render.c +++ b/render.c @@ -1409,6 +1409,9 @@ get_csd_data(const struct terminal *term, enum csd_surface surf_idx) static void csd_commit(struct terminal *term, struct wl_surface *surf, struct buffer *buf) { + xassert(buf->width % term->scale == 0); + xassert(buf->height % term->scale == 0); + wl_surface_attach(surf, buf->wl_buf, 0, 0); wl_surface_damage_buffer(surf, 0, 0, buf->width, buf->height); wl_surface_set_buffer_scale(surf, term->scale); @@ -1440,6 +1443,9 @@ render_csd_title(struct terminal *term) xassert(info.width > 0 && info.height > 0); + xassert(info.width % term->scale == 0); + xassert(info.height % term->scale == 0); + unsigned long cookie = shm_cookie_csd(term, CSD_SURF_TITLE); struct buffer *buf = shm_get_buffer( term->wl->shm, info.width, info.height, cookie, false, 1); @@ -1472,6 +1478,9 @@ render_csd_border(struct terminal *term, enum csd_surface surf_idx) if (info.width == 0 || info.height == 0) return; + xassert(info.width % term->scale == 0); + xassert(info.height % term->scale == 0); + unsigned long cookie = shm_cookie_csd(term, surf_idx); struct buffer *buf = shm_get_buffer( term->wl->shm, info.width, info.height, cookie, false, 1); @@ -1641,6 +1650,9 @@ render_csd_button(struct terminal *term, enum csd_surface surf_idx) if (info.width == 0 || info.height == 0) return; + xassert(info.width % term->scale == 0); + xassert(info.height % term->scale == 0); + unsigned long cookie = shm_cookie_csd(term, surf_idx); struct buffer *buf = shm_get_buffer( term->wl->shm, info.width, info.height, cookie, false, 1); @@ -1780,6 +1792,9 @@ render_osd(struct terminal *term, x += term->cell_width; } + xassert(buf->width % term->scale == 0); + xassert(buf->height % term->scale == 0); + quirk_weston_subsurface_desync_on(sub_surf); wl_surface_attach(surf, buf->wl_buf, 0, 0); wl_surface_damage_buffer(surf, 0, 0, buf->width, buf->height); @@ -1873,8 +1888,11 @@ render_scrollback_position(struct terminal *term) const int scale = term->scale; const int margin = 3 * scale; - const int width = 2 * margin + cell_count * term->cell_width; - const int height = 2 * margin + term->cell_height; + + const int width = + (2 * margin + cell_count * term->cell_width + scale - 1) / scale * scale; + const int height = + (2 * margin + term->cell_height + scale - 1) / scale * scale; unsigned long cookie = shm_cookie_scrollback_indicator(term); struct buffer *buf = shm_get_buffer( @@ -1929,10 +1947,13 @@ render_render_timer(struct terminal *term, struct timeval render_time) double usecs = render_time.tv_sec * 1000000 + render_time.tv_usec; swprintf(text, sizeof(text) / sizeof(text[0]), L"%.2f µs", usecs); + const int scale = term->scale; const int cell_count = wcslen(text); - const int margin = 3 * term->scale; - const int width = 2 * margin + cell_count * term->cell_width; - const int height = 2 * margin + term->cell_height; + const int margin = 3 * scale; + const int width = + (2 * margin + cell_count * term->cell_width + scale - 1) / scale * scale; + const int height = + (2 * margin + term->cell_height + scale - 1) / scale * scale; unsigned long cookie = shm_cookie_render_timer(term); struct buffer *buf = shm_get_buffer( @@ -2227,6 +2248,9 @@ grid_render(struct terminal *term) term->window->surface, 0, 0, INT32_MAX, INT32_MAX); } + xassert(buf->width % term->scale == 0); + xassert(buf->height % term->scale == 0); + wl_surface_attach(term->window->surface, buf->wl_buf, 0, 0); quirk_kde_damage_before_attach(term->window->surface); wl_surface_commit(term->window->surface); @@ -2298,10 +2322,10 @@ render_search_box(struct terminal *term) const size_t width = term->width - 2 * margin; const size_t visible_width = min( term->width - 2 * margin, - 2 * margin + wanted_visible_cells * term->cell_width); + (2 * margin + wanted_visible_cells * term->cell_width + scale - 1) / scale * scale); const size_t height = min( term->height - 2 * margin, - 2 * margin + 1 * term->cell_height); + (2 * margin + 1 * term->cell_height + scale - 1) / scale * scale); const size_t visible_cells = (visible_width - 2 * margin) / term->cell_width; size_t glyph_offset = term->render.search_glyph_offset; @@ -2527,6 +2551,9 @@ render_search_box(struct terminal *term) margin / scale, max(0, (int32_t)term->height - height - margin) / scale); + xassert(buf->width % scale == 0); + xassert(buf->height % scale == 0); + wl_surface_attach(term->window->search.surf, buf->wl_buf, 0, 0); wl_surface_damage_buffer(term->window->search.surf, 0, 0, width, height); wl_surface_set_buffer_scale(term->window->search.surf, scale); @@ -2634,10 +2661,13 @@ render_urls(struct terminal *term) size_t len = wcslen(label); int cols = wcswidth(label, len); - const int x_margin = 2 * term->scale; - const int y_margin = 1 * term->scale; - int width = 2 * x_margin + cols * term->cell_width; - int height = 2 * y_margin + term->cell_height; + const int scale = term->scale; + const int x_margin = 2 * scale; + const int y_margin = 1 * scale; + const int width = + (2 * x_margin + cols * term->cell_width + scale - 1) / scale * scale; + const int height = + (2 * y_margin + term->cell_height + scale - 1) / scale * scale; struct buffer *buf = shm_get_buffer( term->wl->shm, width, height, shm_cookie_url(url), false, 1); -- cgit v1.3