mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-03-27 07:58:07 -04:00
term: convert ‘scale’ to a float
This commit is contained in:
parent
a9ecf1449e
commit
c1f374cc8d
3 changed files with 25 additions and 21 deletions
20
csi.c
20
csi.c
|
|
@ -1206,8 +1206,10 @@ csi_dispatch(struct terminal *term, uint8_t final)
|
||||||
|
|
||||||
if (width >= 0 && height >= 0) {
|
if (width >= 0 && height >= 0) {
|
||||||
char reply[64];
|
char reply[64];
|
||||||
size_t n = xsnprintf(reply, sizeof(reply), "\033[4;%d;%dt",
|
size_t n = xsnprintf(
|
||||||
height / term->scale, width / term->scale);
|
reply, sizeof(reply), "\033[4;%d;%dt",
|
||||||
|
(int)round(height / term->scale),
|
||||||
|
(int)(width / term->scale));
|
||||||
term_to_slave(term, reply, n);
|
term_to_slave(term, reply, n);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
@ -1229,9 +1231,10 @@ csi_dispatch(struct terminal *term, uint8_t final)
|
||||||
|
|
||||||
case 16: { /* report cell size in pixels */
|
case 16: { /* report cell size in pixels */
|
||||||
char reply[64];
|
char reply[64];
|
||||||
size_t n = xsnprintf(reply, sizeof(reply), "\033[6;%d;%dt",
|
size_t n = xsnprintf(
|
||||||
term->cell_height / term->scale,
|
reply, sizeof(reply), "\033[6;%d;%dt",
|
||||||
term->cell_width / term->scale);
|
(int)round(term->cell_height / term->scale),
|
||||||
|
(int)round(term->cell_width / term->scale));
|
||||||
term_to_slave(term, reply, n);
|
term_to_slave(term, reply, n);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
@ -1247,9 +1250,10 @@ csi_dispatch(struct terminal *term, uint8_t final)
|
||||||
case 19: { /* report screen size in chars */
|
case 19: { /* report screen size in chars */
|
||||||
tll_foreach(term->window->on_outputs, it) {
|
tll_foreach(term->window->on_outputs, it) {
|
||||||
char reply[64];
|
char reply[64];
|
||||||
size_t n = xsnprintf(reply, sizeof(reply), "\033[9;%d;%dt",
|
size_t n = xsnprintf(
|
||||||
it->item->dim.px_real.height / term->cell_height / term->scale,
|
reply, sizeof(reply), "\033[9;%d;%dt",
|
||||||
it->item->dim.px_real.width / term->cell_width / term->scale);
|
(int)round(it->item->dim.px_real.height / term->cell_height / term->scale),
|
||||||
|
(int)round(it->item->dim.px_real.width / term->cell_width / term->scale));
|
||||||
term_to_slave(term, reply, n);
|
term_to_slave(term, reply, n);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
24
render.c
24
render.c
|
|
@ -1830,8 +1830,8 @@ get_csd_data(const struct terminal *term, enum csd_surface surf_idx)
|
||||||
static void
|
static void
|
||||||
csd_commit(struct terminal *term, struct wl_surface *surf, struct buffer *buf)
|
csd_commit(struct terminal *term, struct wl_surface *surf, struct buffer *buf)
|
||||||
{
|
{
|
||||||
xassert(buf->width % term->scale == 0);
|
xassert(buf->width % (int)term->scale == 0);
|
||||||
xassert(buf->height % term->scale == 0);
|
xassert(buf->height % (int)term->scale == 0);
|
||||||
|
|
||||||
wl_surface_attach(surf, buf->wl_buf, 0, 0);
|
wl_surface_attach(surf, buf->wl_buf, 0, 0);
|
||||||
wl_surface_damage_buffer(surf, 0, 0, buf->width, buf->height);
|
wl_surface_damage_buffer(surf, 0, 0, buf->width, buf->height);
|
||||||
|
|
@ -1926,8 +1926,8 @@ render_osd(struct terminal *term,
|
||||||
pixman_image_unref(src);
|
pixman_image_unref(src);
|
||||||
pixman_image_set_clip_region32(buf->pix[0], NULL);
|
pixman_image_set_clip_region32(buf->pix[0], NULL);
|
||||||
|
|
||||||
xassert(buf->width % term->scale == 0);
|
xassert(buf->width % (int)term->scale == 0);
|
||||||
xassert(buf->height % term->scale == 0);
|
xassert(buf->height % (int)term->scale == 0);
|
||||||
|
|
||||||
quirk_weston_subsurface_desync_on(sub_surf);
|
quirk_weston_subsurface_desync_on(sub_surf);
|
||||||
wl_surface_attach(surf, buf->wl_buf, 0, 0);
|
wl_surface_attach(surf, buf->wl_buf, 0, 0);
|
||||||
|
|
@ -1955,8 +1955,8 @@ render_csd_title(struct terminal *term, const struct csd_data *info,
|
||||||
if (info->width == 0 || info->height == 0)
|
if (info->width == 0 || info->height == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
xassert(info->width % term->scale == 0);
|
xassert(info->width % (int)term->scale == 0);
|
||||||
xassert(info->height % term->scale == 0);
|
xassert(info->height % (int)term->scale == 0);
|
||||||
|
|
||||||
uint32_t bg = term->conf->csd.color.title_set
|
uint32_t bg = term->conf->csd.color.title_set
|
||||||
? term->conf->csd.color.title
|
? term->conf->csd.color.title
|
||||||
|
|
@ -2000,8 +2000,8 @@ render_csd_border(struct terminal *term, enum csd_surface surf_idx,
|
||||||
if (info->width == 0 || info->height == 0)
|
if (info->width == 0 || info->height == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
xassert(info->width % term->scale == 0);
|
xassert(info->width % (int)term->scale == 0);
|
||||||
xassert(info->height % term->scale == 0);
|
xassert(info->height % (int)term->scale == 0);
|
||||||
|
|
||||||
{
|
{
|
||||||
pixman_color_t color = color_hex_to_pixman_with_alpha(0, 0);
|
pixman_color_t color = color_hex_to_pixman_with_alpha(0, 0);
|
||||||
|
|
@ -2289,8 +2289,8 @@ render_csd_button(struct terminal *term, enum csd_surface surf_idx,
|
||||||
if (info->width == 0 || info->height == 0)
|
if (info->width == 0 || info->height == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
xassert(info->width % term->scale == 0);
|
xassert(info->width % (int)term->scale == 0);
|
||||||
xassert(info->height % term->scale == 0);
|
xassert(info->height % (int)term->scale == 0);
|
||||||
|
|
||||||
uint32_t _color;
|
uint32_t _color;
|
||||||
uint16_t alpha = 0xffff;
|
uint16_t alpha = 0xffff;
|
||||||
|
|
@ -3067,8 +3067,8 @@ grid_render(struct terminal *term)
|
||||||
term->window->surface, 0, 0, INT32_MAX, INT32_MAX);
|
term->window->surface, 0, 0, INT32_MAX, INT32_MAX);
|
||||||
}
|
}
|
||||||
|
|
||||||
xassert(buf->width % term->scale == 0);
|
xassert(buf->width % (int)term->scale == 0);
|
||||||
xassert(buf->height % term->scale == 0);
|
xassert(buf->height % (int)term->scale == 0);
|
||||||
|
|
||||||
wl_surface_attach(term->window->surface, buf->wl_buf, 0, 0);
|
wl_surface_attach(term->window->surface, buf->wl_buf, 0, 0);
|
||||||
wl_surface_commit(term->window->surface);
|
wl_surface_commit(term->window->surface);
|
||||||
|
|
|
||||||
|
|
@ -454,7 +454,7 @@ struct terminal {
|
||||||
int fd;
|
int fd;
|
||||||
} blink;
|
} blink;
|
||||||
|
|
||||||
int scale;
|
float scale;
|
||||||
int width; /* pixels */
|
int width; /* pixels */
|
||||||
int height; /* pixels */
|
int height; /* pixels */
|
||||||
int stashed_width;
|
int stashed_width;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue