From eb0b244c891f3cb6d5ba08fb3ea8af4bc421398e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Mon, 1 Feb 2021 10:04:25 +0100 Subject: [PATCH] =?UTF-8?q?render:=20url=20labels:=20don=E2=80=99t=20posit?= =?UTF-8?q?ion=20outside=20window?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- render.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/render.c b/render.c index 40e6b698..00b6290d 100644 --- a/render.c +++ b/render.c @@ -2563,10 +2563,19 @@ render_urls(struct terminal *term) term->wl->shm, width, height, shm_cookie_url(url), false, 1); const struct coord *pos = &url->start; + int x = pos->col * term->cell_width - 2 * term->cell_width; + int y = pos->row * term->cell_height - term->cell_height; + + if (x < 0) + x += 4 * term->cell_width; + if (y < 0) + y += 2 * term->cell_height; + wl_subsurface_set_position( sub_surf, - (term->margins.left + pos->col * term->cell_width - 2 * term->cell_width) / term->scale, - (term->margins.top + pos->row * term->cell_height - term->cell_height) / term->scale); + (term->margins.left + x) / term->scale, + (term->margins.top + y) / term->scale); + render_osd(term, surf, sub_surf, buf, label, term->colors.table[0], term->colors.table[3], 0xf000, width, height, margin, margin);