mirror of
https://github.com/kovidgoyal/kitty
synced 2026-07-27 10:41:58 +02:00
Forgot to use aspect ratio calculation when only one of r/c is specified for determining cursor position and image cell overlaps. Fixes #7479
This commit is contained in:
@@ -59,6 +59,8 @@ Detailed list of changes
|
|||||||
|
|
||||||
- Fix a regression in the previous release causing an error when setting background_opacity to zero (:iss:`7483`)
|
- Fix a regression in the previous release causing an error when setting background_opacity to zero (:iss:`7483`)
|
||||||
|
|
||||||
|
- Image display: Fix cursor movement and image hit region incorrect for image placements that specify only a number of rows or columns to display in (:iss:`7479`)
|
||||||
|
|
||||||
|
|
||||||
0.35.0 [2024-05-25]
|
0.35.0 [2024-05-25]
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|||||||
@@ -798,14 +798,26 @@ static void
|
|||||||
update_dest_rect(ImageRef *ref, uint32_t num_cols, uint32_t num_rows, CellPixelSize cell) {
|
update_dest_rect(ImageRef *ref, uint32_t num_cols, uint32_t num_rows, CellPixelSize cell) {
|
||||||
uint32_t t;
|
uint32_t t;
|
||||||
if (num_cols == 0) {
|
if (num_cols == 0) {
|
||||||
t = (uint32_t)(ref->src_width + ref->cell_x_offset);
|
if (num_rows == 0) {
|
||||||
num_cols = t / cell.width;
|
t = (uint32_t)(ref->src_width + ref->cell_x_offset);
|
||||||
if (t > num_cols * cell.width) num_cols += 1;
|
num_cols = t / cell.width;
|
||||||
|
if (t > num_cols * cell.width) num_cols += 1;
|
||||||
|
} else {
|
||||||
|
double height_px = cell.height * num_rows + ref->cell_y_offset;
|
||||||
|
double width_px = height_px * ref->src_width / (double) ref->src_height;
|
||||||
|
num_cols = (uint32_t)ceil(width_px / cell.width);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (num_rows == 0) {
|
if (num_rows == 0) {
|
||||||
t = (uint32_t)(ref->src_height + ref->cell_y_offset);
|
if (num_cols == 0) {
|
||||||
num_rows = t / cell.height;
|
t = (uint32_t)(ref->src_height + ref->cell_y_offset);
|
||||||
if (t > num_rows * cell.height) num_rows += 1;
|
num_rows = t / cell.height;
|
||||||
|
if (t > num_rows * cell.height) num_rows += 1;
|
||||||
|
} else {
|
||||||
|
double width_px = cell.width * num_cols + ref->cell_x_offset;
|
||||||
|
double height_px = width_px * ref->src_height / (double)ref->src_width;
|
||||||
|
num_rows = (uint32_t)ceil(height_px / cell.height);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
ref->effective_num_rows = num_rows;
|
ref->effective_num_rows = num_rows;
|
||||||
ref->effective_num_cols = num_cols;
|
ref->effective_num_cols = num_cols;
|
||||||
|
|||||||
@@ -548,7 +548,7 @@ class TestGraphics(BaseTest):
|
|||||||
def test_image_put(self):
|
def test_image_put(self):
|
||||||
cw, ch = 10, 20
|
cw, ch = 10, 20
|
||||||
s, dx, dy, put_image, put_ref, layers, rect_eq = put_helpers(self, cw, ch)
|
s, dx, dy, put_image, put_ref, layers, rect_eq = put_helpers(self, cw, ch)
|
||||||
self.ae(put_image(s, 10, 20)[1], 'OK')
|
self.ae(put_image(s, cw, ch)[1], 'OK')
|
||||||
l0 = layers(s)
|
l0 = layers(s)
|
||||||
self.ae(len(l0), 1)
|
self.ae(len(l0), 1)
|
||||||
rect_eq(l0[0]['src_rect'], 0, 0, 1, 1)
|
rect_eq(l0[0]['src_rect'], 0, 0, 1, 1)
|
||||||
@@ -556,7 +556,7 @@ class TestGraphics(BaseTest):
|
|||||||
self.ae(l0[0]['group_count'], 1)
|
self.ae(l0[0]['group_count'], 1)
|
||||||
self.ae(s.cursor.x, 1), self.ae(s.cursor.y, 0)
|
self.ae(s.cursor.x, 1), self.ae(s.cursor.y, 0)
|
||||||
src_width, src_height = 3, 5
|
src_width, src_height = 3, 5
|
||||||
iid, (code, idstr) = put_ref(s, num_cols=s.columns, x_off=2, y_off=1, width=src_width, height=src_height,
|
iid, (code, idstr) = put_ref(s, num_cols=s.columns, num_lines=1, x_off=2, y_off=1, width=src_width, height=src_height,
|
||||||
cell_x_off=3, cell_y_off=1, z=-1, placement_id=17)
|
cell_x_off=3, cell_y_off=1, z=-1, placement_id=17)
|
||||||
self.ae(idstr, f'i={iid},p=17')
|
self.ae(idstr, f'i={iid},p=17')
|
||||||
l2 = layers(s)
|
l2 = layers(s)
|
||||||
@@ -566,15 +566,16 @@ class TestGraphics(BaseTest):
|
|||||||
self.ae(l2[0]['group_count'], 2)
|
self.ae(l2[0]['group_count'], 2)
|
||||||
left, top = -1 + dx + 3 * dx / cw, 1 - 1 * dy / ch
|
left, top = -1 + dx + 3 * dx / cw, 1 - 1 * dy / ch
|
||||||
right = -1 + (1 + s.columns) * dx
|
right = -1 + (1 + s.columns) * dx
|
||||||
width_px = ((right - left) / 2) * (cw * s.columns)
|
bottom = 1 - dy
|
||||||
height_px = width_px * (src_height / src_width)
|
|
||||||
bottom = top - (height_px / (ch * s.lines)) * 2
|
|
||||||
rect_eq(l2[0]['dest_rect'], left, top, right, bottom)
|
rect_eq(l2[0]['dest_rect'], left, top, right, bottom)
|
||||||
self.ae(s.cursor.x, 0), self.ae(s.cursor.y, 1)
|
self.ae(s.cursor.x, 0), self.ae(s.cursor.y, 1)
|
||||||
self.ae(put_image(s, 10, 20, cursor_movement=1)[1], 'OK')
|
self.ae(put_image(s, 10, 20, cursor_movement=1)[1], 'OK')
|
||||||
self.ae(s.cursor.x, 0), self.ae(s.cursor.y, 1)
|
self.ae(s.cursor.x, 0), self.ae(s.cursor.y, 1)
|
||||||
s.reset()
|
s.reset()
|
||||||
self.assertEqual(s.grman.disk_cache.total_size, 0)
|
self.assertEqual(s.grman.disk_cache.total_size, 0)
|
||||||
|
self.ae(put_image(s, 2*cw, 2*ch, num_cols=3)[1], 'OK')
|
||||||
|
self.ae((s.cursor.x, s.cursor.y), (3, 2))
|
||||||
|
rect_eq(layers(s)[0]['dest_rect'], -1, 1, -1 + 3 * dx, 1 - 3*dy)
|
||||||
|
|
||||||
def test_image_layer_grouping(self):
|
def test_image_layer_grouping(self):
|
||||||
cw, ch = 10, 20
|
cw, ch = 10, 20
|
||||||
|
|||||||
Reference in New Issue
Block a user