mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-16 08:46:08 +03:00
kitty graphics: assign automatic placement ID if p==0
Fixes #1356 As stated in the code, the specification itself doesn't explicitly specify this behavior (as far as I can tell), but testing in Kitty results in this working and I believe this is how they do it.
This commit is contained in:
@ -170,6 +170,16 @@ fn display(
|
|||||||
.placement_id = d.placement_id,
|
.placement_id = d.placement_id,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// If the placement has no ID, we assign one. This is not in the spec
|
||||||
|
// but Kitty appears to support the behavior where specifying multiple
|
||||||
|
// placements with ID 0 creates new placements rather than replacing
|
||||||
|
// the existing placement.
|
||||||
|
if (result.placement_id == 0) {
|
||||||
|
const storage = &terminal.screen.kitty_images;
|
||||||
|
result.placement_id = storage.next_id;
|
||||||
|
storage.next_id +%= 1;
|
||||||
|
}
|
||||||
|
|
||||||
// Verify the requested image exists if we have an ID
|
// Verify the requested image exists if we have an ID
|
||||||
const storage = &terminal.screen.kitty_images;
|
const storage = &terminal.screen.kitty_images;
|
||||||
const img_: ?Image = if (d.image_id != 0)
|
const img_: ?Image = if (d.image_id != 0)
|
||||||
@ -203,7 +213,12 @@ fn display(
|
|||||||
.rows = d.rows,
|
.rows = d.rows,
|
||||||
.z = d.z,
|
.z = d.z,
|
||||||
};
|
};
|
||||||
storage.addPlacement(alloc, img.id, d.placement_id, p) catch |err| {
|
storage.addPlacement(
|
||||||
|
alloc,
|
||||||
|
img.id,
|
||||||
|
result.placement_id,
|
||||||
|
p,
|
||||||
|
) catch |err| {
|
||||||
encodeError(&result, err);
|
encodeError(&result, err);
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user