summaryrefslogtreecommitdiff
path: root/src/macos.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/macos.zig')
-rw-r--r--src/macos.zig78
1 files changed, 38 insertions, 40 deletions
diff --git a/src/macos.zig b/src/macos.zig
index d46f6cd4..0d79f96b 100644
--- a/src/macos.zig
+++ b/src/macos.zig
@@ -1755,52 +1755,50 @@ fn encodeChanged(diff: pardes.PanelCellDiff) u8 {
}
fn collectImages(st: *State, surface: *const pardes.Surface) void {
- if (comptime !pardes.pdf_enabled) return;
- if (surface.images.items.len == 0) return;
- if (st.images.len < surface.images.items.len) {
+ const placements = surface.placements.items;
+ if (placements.len == 0) return;
+ if (st.images.len < placements.len) {
const resized = if (st.images.len == 0)
- st.gpa.alloc(Image, surface.images.items.len)
+ st.gpa.alloc(Image, placements.len)
else
- st.gpa.realloc(st.images, surface.images.items.len);
+ st.gpa.realloc(st.images, placements.len);
st.images = resized catch return;
}
- for (surface.images.items) |place| {
- if (place.iw == 0 or place.ih == 0 or place.rgba.len == 0) continue;
- const geometry = place.native.geometry orelse image.NativeGeometry{
- .src = .{ .x = 0, .y = 0, .w = @intCast(place.iw), .h = @intCast(place.ih) },
- .dst = .{
- .x = 0,
- .y = 0,
- .w = @as(u32, place.w) * st.core.cell_pixels.w,
- .h = @as(u32, place.h) * st.core.cell_pixels.h,
- },
+ for (placements) |place| {
+ if (place.raster.w == 0 or place.raster.h == 0) continue;
+ const dst = place.at orelse pardes.RectPx{
+ .w = @as(u32, place.dst.w) * st.core.cell_pixels.w,
+ .h = @as(u32, place.dst.h) * st.core.cell_pixels.h,
+ };
+ if (dst.w == 0 or dst.h == 0 or place.src.w == 0 or place.src.h == 0) continue;
+ var scroll: f64 = 0;
+ for (surface.regionList()) |r| if (r.kind == .body and r.owner == place.pane) {
+ scroll = r.scroll_px;
+ break;
};
- if (geometry.dst.w == 0 or geometry.dst.h == 0) continue;
- if (geometry.src.w == 0 or geometry.src.h == 0) continue;
st.images[st.images_len] = .{
- .serial = place.serial,
- .page = place.native.page,
- .revision = place.native.revision,
- .cell_x = place.x,
- .cell_y = place.y,
- .cell_w = place.w,
- .cell_h = place.h,
- .dst_x = geometry.dst.x,
- .dst_y = geometry.dst.y,
- .dst_w = geometry.dst.w,
- .dst_h = geometry.dst.h,
- .src_x = geometry.src.x,
- .src_y = geometry.src.y,
- .src_w = geometry.src.w,
- .src_h = geometry.src.h,
- .offset_y = place.native.pixel_offset_y,
- .iw = @intCast(place.iw),
- .ih = @intCast(place.ih),
- .rgba = place.rgba.ptr,
- .paper_bg = if (place.native.paper_bg) |bg|
- @as(u32, bg[0]) << 16 | @as(u32, bg[1]) << 8 | bg[2]
- else
- color_default,
+ // The shell keys its textures by these three: the placement's
+ // key in two halves keeps them one picture each.
+ .serial = if (st.core.panes[place.pane]) |pane| pane.serial else 0,
+ .page = @truncate(place.key),
+ .revision = @truncate(place.key >> 32),
+ .cell_x = place.dst.x,
+ .cell_y = place.dst.y,
+ .cell_w = place.dst.w,
+ .cell_h = place.dst.h,
+ .dst_x = dst.x,
+ .dst_y = dst.y,
+ .dst_w = dst.w,
+ .dst_h = dst.h,
+ .src_x = place.src.x,
+ .src_y = place.src.y,
+ .src_w = place.src.w,
+ .src_h = place.src.h,
+ .offset_y = -@as(f32, @floatCast(scroll - @floor(scroll))),
+ .iw = place.raster.w,
+ .ih = place.raster.h,
+ .rgba = place.raster.ptr,
+ .paper_bg = color_default,
};
st.images_len += 1;
}