aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Eklöf <daniel@ekloef.se>2024-03-14 06:03:51 +0000
committerDaniel Eklöf <daniel@ekloef.se>2024-03-14 06:26:37 +0000
commit712bc95db3bfce96118a3a95dcdaa9779cbeb136 (patch)
tree9e9798d8d12277dbc6afa7e69d273bc1f1d84e89
parentMerge branch 'rectangular-edit' (diff)
csi: the CSI-t family of queries now report unscaled pixel values
Before this patch, we reported scaled pixel values. This was rather useless, since applications have no way of getting the scaling factor, to "scale up" e.g. images. Furthermore, the most common use of these queries are probably to calculate the dimensions to use when emitting sixels. Closes #1643
-rw-r--r--CHANGELOG.md3
-rw-r--r--csi.c15
2 files changed, 9 insertions, 9 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 4712a299..5b898c77 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -102,12 +102,15 @@
* Kitty keyboard protocol: filter out **all** locked modifiers (as
reported by XKB), rather than hardcoding it to CapsLock only, when
determining whether a key combination produces text or not.
+* CSI-t queries now report pixel values **unscaled**, instead of
+ **scaled** ([#1643][1643]).
[1526]: https://codeberg.org/dnkl/foot/issues/1526
[1528]: https://codeberg.org/dnkl/foot/issues/1528
[1561]: https://codeberg.org/dnkl/foot/issues/1561
[kitty-6913]: https://github.com/kovidgoyal/kitty/issues/6913
[1584]: https://codeberg.org/dnkl/foot/issues/1584
+[1643]: https://codeberg.org/dnkl/foot/issues/1643
### Deprecated
diff --git a/csi.c b/csi.c
index d03ae40d..0d1ee1f4 100644
--- a/csi.c
+++ b/csi.c
@@ -1219,9 +1219,7 @@ csi_dispatch(struct terminal *term, uint8_t final)
if (width >= 0 && height >= 0) {
char reply[64];
size_t n = xsnprintf(
- reply, sizeof(reply), "\033[4;%d;%dt",
- (int)roundf(height / term->scale),
- (int)roundf((width / term->scale)));
+ reply, sizeof(reply), "\033[4;%d;%dt", height, width);
term_to_slave(term, reply, n);
}
break;
@@ -1231,8 +1229,8 @@ csi_dispatch(struct terminal *term, uint8_t final)
tll_foreach(term->window->on_outputs, it) {
char reply[64];
size_t n = xsnprintf(reply, sizeof(reply), "\033[5;%d;%dt",
- it->item->dim.px_scaled.height,
- it->item->dim.px_scaled.width);
+ it->item->dim.px_real.height,
+ it->item->dim.px_real.width);
term_to_slave(term, reply, n);
break;
}
@@ -1245,8 +1243,7 @@ csi_dispatch(struct terminal *term, uint8_t final)
char reply[64];
size_t n = xsnprintf(
reply, sizeof(reply), "\033[6;%d;%dt",
- (int)roundf(term->cell_height / term->scale),
- (int)roundf(term->cell_width / term->scale));
+ term->cell_height, term->cell_width);
term_to_slave(term, reply, n);
break;
}
@@ -1264,8 +1261,8 @@ csi_dispatch(struct terminal *term, uint8_t final)
char reply[64];
size_t n = xsnprintf(
reply, sizeof(reply), "\033[9;%d;%dt",
- (int)roundf(it->item->dim.px_real.height / term->cell_height / term->scale),
- (int)roundf(it->item->dim.px_real.width / term->cell_width / term->scale));
+ it->item->dim.px_real.height / term->cell_height,
+ it->item->dim.px_real.width / term->cell_width);
term_to_slave(term, reply, n);
break;
}