mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-02-04 04:06:06 -05:00
render: scrollback indicator: improve handling of very small window sizes
This commit is contained in:
parent
e259f460f3
commit
628fd39098
2 changed files with 19 additions and 10 deletions
|
|
@ -57,6 +57,8 @@
|
|||
rows.
|
||||
* Some box-drawing characters were rendered incorrectly on big-endian
|
||||
architectures.
|
||||
* Scrollback indicator being incorrectly rendered when window size is
|
||||
very small.
|
||||
|
||||
|
||||
### Security
|
||||
|
|
|
|||
27
render.c
27
render.c
|
|
@ -2047,10 +2047,6 @@ render_scrollback_position(struct terminal *term)
|
|||
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(
|
||||
term->wl->shm, width, height, cookie, false, 1);
|
||||
|
||||
/* *Where* to render - parent relative coordinates */
|
||||
int surf_top = 0;
|
||||
switch (term->conf->scrollback.indicator.position) {
|
||||
|
|
@ -2068,18 +2064,30 @@ render_scrollback_position(struct terminal *term)
|
|||
/* Make sure we don't collide with the scrollback search box */
|
||||
lines--;
|
||||
}
|
||||
xassert(lines > 0);
|
||||
|
||||
int pixels = lines * term->cell_height - height + 2 * margin;
|
||||
lines = max(lines, 0);
|
||||
|
||||
int pixels = max(lines * term->cell_height - height + 2 * margin, 0);
|
||||
surf_top = term->cell_height - margin + (int)(percent * pixels);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
const int x = (term->width - margin - width) / scale * scale;
|
||||
const int y = (term->margins.top + surf_top) / scale * scale;
|
||||
|
||||
if (y + height > term->height) {
|
||||
wl_surface_attach(win->scrollback_indicator.surf, NULL, 0, 0);
|
||||
wl_surface_commit(win->scrollback_indicator.surf);
|
||||
return;
|
||||
}
|
||||
|
||||
unsigned long cookie = shm_cookie_scrollback_indicator(term);
|
||||
struct buffer *buf = shm_get_buffer(
|
||||
term->wl->shm, width, height, cookie, false, 1);
|
||||
|
||||
wl_subsurface_set_position(
|
||||
win->scrollback_indicator.sub,
|
||||
(term->width - margin - width) / scale,
|
||||
(term->margins.top + surf_top) / scale);
|
||||
win->scrollback_indicator.sub, x / scale, y / scale);
|
||||
|
||||
render_osd(
|
||||
term,
|
||||
|
|
@ -2088,7 +2096,6 @@ render_scrollback_position(struct terminal *term)
|
|||
buf, text,
|
||||
term->colors.table[0], term->colors.table[8 + 4],
|
||||
width - margin - wcslen(text) * term->cell_width, margin);
|
||||
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue