diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-26 11:29:28 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-26 11:29:40 -0300 |
| commit | 3d60aa05ec1a6f9ed535186be6c6c2850c71b24d (patch) | |
| tree | e55587fb9d1ec5f55c55fa81b7d81f3a91bf5375 /core/Kind.zig | |
| parent | add0837dc1927389096cbaaf65b7e1a42028eafc (diff) | |
| parent | 8723462d8e02bc9d78b5004de38b910e83540575 (diff) | |
| download | pardes-3d60aa05ec1a6f9ed535186be6c6c2850c71b24d.tar.gz pardes-3d60aa05ec1a6f9ed535186be6c6c2850c71b24d.zip | |
merge: L2a (tags, grips, band, notice onto chrome) + M2's fix + FP (PDF leaks, spawn stop, PDF hits)
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016Y9MNBFhdevVu48bvL9kCE
Diffstat (limited to 'core/Kind.zig')
| -rw-r--r-- | core/Kind.zig | 50 |
1 files changed, 40 insertions, 10 deletions
diff --git a/core/Kind.zig b/core/Kind.zig index ffea8aa3..cf684a55 100644 --- a/core/Kind.zig +++ b/core/Kind.zig @@ -39,7 +39,7 @@ pub const abi: u32 = c.PA_ABI; // records the core reads are the ones addons are built to. comptime { if (@sizeOf(usize) == 8) for (.{ - .{ c.pa_cell, 20 }, .{ c.pa_window, 24 }, .{ c.pa_rect, 16 }, .{ c.pa_cells, 8 }, + .{ c.pa_cell, 20 }, .{ c.pa_window, 32 }, .{ c.pa_rect, 16 }, .{ c.pa_cells, 8 }, .{ c.pa_placement, 80 }, .{ c.pa_paint, 48 }, .{ c.pa_key, 8 }, .{ c.pa_mouse, 16 }, .{ c.pa_api, 128 }, .{ c.pa_out, 16 }, .{ c.pa_word, 32 }, .{ c.pa_head, 56 }, .{ c.pa_ops, 208 }, .{ c.pa_view, 32 }, .{ c.pa_tick, 128 }, @@ -320,10 +320,16 @@ pub fn reopen(p: *Pardes, id: usize, s: *Slot, bytes: ?[]const u8) bool { if (p.kinds.byName(s.nameOf())) |k| { // Its code: its library loaded at the first pane of its kind. if (s.ops == null) s.ops = Addon.need(&p.kinds, p.tape, k, &cl.refused, p.opts.distrusted); - // Its block made afresh by this open. + // Its block made afresh by this open. And what a plain kind keeps + // beside it (a PDF's document), made in every core that runs it, is + // no rollback copy's: a write outside the copy (Pardes.outside), + // counted by the registry's word on every side alike, the kind's + // code here or not. A client that kept this step to replay over its + // copy would make that state again and never close the first. if (p.kinds.kinds[k].caps.plain) { if (s.plain) |b| if (b.len > 0) s.gpa.free(b); s.plain = &.{}; + p.outside.n +%= 1; } // Its tag's computed words (UX K'3): its words, then Del. var w: std.Io.Writer = .fixed(&s.tail.bytes); @@ -416,6 +422,11 @@ pub fn close(p: *Pardes, pane: *Pane) void { // own memory (its pictures) is left be, as the rollback brings the pane // back; the session's order closes it. const kept = s.plain != null and s.ops != null and s.ops.?.close != null and p.tape.authorityOnly("a kind's close"); + // What a plain kind keeps beside its block let go: outside the copy, as + // its open was (reopen). + if (p.kinds.byName(s.nameOf())) |k| if (p.kinds.kinds[k].caps.plain) { + p.outside.n +%= 1; + }; if (!kept) { var i: usize = 0; while (i < ready.items.len) if (ready.items[i].draw == p and ready.items[i].serial == pane.serial) ready.orderedRemove(i).drop() else { @@ -518,7 +529,8 @@ pub fn paint(p: *const Pardes, slot: *Slot, id: usize, arena: std.mem.Allocator, var gpu: GpuPaint = .{ .arena = arena, .frame = frame }; var out: c.pa_paint = std.mem.zeroInit(c.pa_paint, .{ .placements = &frame.buf, .cap = frame.buf.len, .gpu = GpuPaint.emit, .gpu_ctx = &gpu }); const px = p.view().cell_pixels; - const win = std.mem.zeroInit(c.pa_window, .{ .cells = cells.ptr, .stride = cols, .rows = rows, .cols = cols, .cell_w = px.w, .cell_h = px.h, .focused = @intFromBool(focusedAnywhere(p, id)), .view = p.live + 1, .glyphs = @intFromBool(!p.view().frontend.native_images) }); + const chrome = p.chrome(); + const win = std.mem.zeroInit(c.pa_window, .{ .cells = cells.ptr, .stride = cols, .rows = rows, .cols = cols, .cell_w = px.w, .cell_h = px.h, .focused = @intFromBool(focusedAnywhere(p, id)), .view = p.live + 1, .glyphs = @intFromBool(!p.view().frontend.native_images), .hit = rgb(chrome.hit), .hit_current = rgb(chrome.hit_current) }); var cl: Call = .{ .p = null, .id = id, .slot = slot, .quiet = true, .core = p }; const prev = cl.begin("paint"); const before = if (checked) usedHash(slot) else {}; @@ -792,11 +804,6 @@ pub fn viewOf(p: *const Pardes, k: u8, id: usize) c.pa_view { // derived, so a client joined from a dump has none. const notices = pardes.Messages.bands(p, pane, tag_rows, r).span(); const chrome = p.chrome(); - const rgb = struct { - fn f(x: [3]u8) u32 { - return @as(u32, x[0]) << 16 | @as(u32, x[1]) << 8 | x[2]; - } - }.f; const policy = rasterPolicy(v.frontend.windowed); return .{ .cols = r.w -| pardes.config.GUTTER, @@ -816,6 +823,11 @@ pub fn viewOf(p: *const Pardes, k: u8, id: usize) c.pa_view { }; } +/// A theme's colour as the header's PA_RGB. +fn rgb(x: [3]u8) u32 { + return @as(u32, x[0]) << 16 | @as(u32, x[1]) << 8 | x[2]; +} + /// Whether pane `id` has the keyboard in some view (its window focused). fn focusedAnywhere(p: *const Pardes, id: usize) bool { for (&p.views) |*v| if (v.*) |*vw| if (vw.active == id and vw.window_focused) return true; @@ -1298,8 +1310,11 @@ var drawn: u32 = 0; /// its own. pub fn landDraw(p: *Pardes, j: *host_io.KindJob) void { if (j.draw != p) return j.drop(); - // Its pane closed meanwhile: no paint of it would ever take it. - if (if (p.panes[j.pane]) |pane| pane.serial != j.serial else true) return j.drop(); + // Its pane closed meanwhile, or showing no kind now (a picker's preview + // closed, the pane its own text again): no paint of it would ever take + // it, nor would the pane's close (Kind.close: a slot's draws). + const pane = p.panes[j.pane] orelse return j.drop(); + if (pane.serial != j.serial or pane.addon == null) return j.drop(); ready.append(heap, j) catch return j.drop(); p.needs_frame = true; } @@ -1415,3 +1430,18 @@ const GpuPaint = struct { return 0; } }; + +test "a picture drawn for a pane that shows no kind's slot when it lands (a picker's preview closed meanwhile) is dropped, never kept for a paint that never comes" { + const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 80, .rows = 24 }); + defer p.deinit(); + _ = try p.setTestFile("the notes\n"); + const id = p.view().active; + try std.testing.expect(p.panes[id].?.addon == null); + // A draw of the preview's, back from its worker after Esc gave the pane + // its own text again. + const j = try heap.create(host_io.KindJob); + j.* = .{ .gpa = heap, .pane = @intCast(id), .serial = p.panes[id].?.serial, .token = c.PA_DRAWN | 1, .gen = 0, .ops = &test_kind.ops, .in = try heap.dupe(u8, "draw"), .arena = .init(heap), .draw = p }; + Addon.holdJob(j.ops, true); + landDraw(p, j); + try std.testing.expectEqual(@as(usize, 0), ready.items.len); +} |
