summaryrefslogtreecommitdiff
path: root/src/Kind.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-06 11:38:06 -0300
committerGabriel Schneider <[email protected]>2026-11-06 12:03:00 -0300
commitf05c69380c8f23ab7dadb1c9d6240af687c88bed (patch)
tree8bb77af9ba2fadf64ac789bbe94c39df346a9db8 /src/Kind.zig
parent239e8186111c215bf3bca842216205056e4b00e1 (diff)
downloadpardes-f05c69380c8f23ab7dadb1c9d6240af687c88bed.tar.gz
pardes-f05c69380c8f23ab7dadb1c9d6240af687c88bed.zip
kinds #18, ABI 2.2: pa_api says the core's ABI, pa_mouse grows a wheel's amount (a window passes a touchpad's fraction of a turn over a kind's pane, a terminal whole notches), pa_view says glyphs (no graphics), pa_paint's tail padding holds the pointer the kind asks for (the window shows a hand for PA_POINTER_LINK over its pane, a Shadow's frame carries it), and tick is told PA_FRAMED when a frame was drawn since its last; addon-test gains graphics on|off
Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNAtZenFv4weoMD3cge
Diffstat (limited to 'src/Kind.zig')
-rw-r--r--src/Kind.zig24
1 files changed, 20 insertions, 4 deletions
diff --git a/src/Kind.zig b/src/Kind.zig
index c1640b57..2add017a 100644
--- a/src/Kind.zig
+++ b/src/Kind.zig
@@ -38,8 +38,8 @@ pub const abi: u32 = c.PA_ABI;
comptime {
if (@sizeOf(usize) == 8) for (.{
.{ c.pa_cell, 20 }, .{ c.pa_window, 24 }, .{ c.pa_rect, 16 }, .{ c.pa_cells, 8 },
- .{ c.pa_placement, 80 }, .{ c.pa_paint, 128 }, .{ c.pa_key, 8 }, .{ c.pa_mouse, 10 },
- .{ c.pa_api, 96 }, .{ c.pa_out, 16 }, .{ c.pa_word, 32 }, .{ c.pa_head, 56 },
+ .{ c.pa_placement, 80 }, .{ c.pa_paint, 128 }, .{ c.pa_key, 8 }, .{ c.pa_mouse, 16 },
+ .{ c.pa_api, 104 }, .{ c.pa_out, 16 }, .{ c.pa_word, 32 }, .{ c.pa_head, 56 },
.{ c.pa_ops, 200 }, .{ c.pa_view, 32 },
}) |r| if (@sizeOf(r[0]) != r[1]) @compileError(std.fmt.comptimePrint("{s} is {d} bytes, the header says {d}", .{ @typeName(r[0]), @sizeOf(r[0]), r[1] }));
}
@@ -60,7 +60,9 @@ pub const Caps = packed struct(u16) {
/// Esc comes to its `key` first (2.1).
esc: bool = false,
address: bool = false,
- pad: u7 = 0,
+ /// 2.2's: a wheel's amount, the pointer in paint, PA_FRAMED.
+ v22: bool = false,
+ pad: u6 = 0,
};
pub const Entry = struct {
@@ -171,6 +173,10 @@ pub const Slot = struct {
told: Buf(400) = .{},
thumb_at: f32 = 0,
thumb_span: f32 = 0,
+ /// The pointer its last frame asked for over it (PA_POINTER_*, 2.2),
+ /// and whether a frame was painted since its last tick.
+ pointer: u8 = 0,
+ painted: bool = false,
/// What its view was (`api.view`) when `tick` was last told: a change
/// ticks it again (2.1).
view: u64 = 0,
@@ -433,6 +439,8 @@ pub fn paint(p: *const Pardes, slot: *Slot, id: usize, arena: std.mem.Allocator,
slot.placed = placed;
slot.thumb_at = std.math.clamp(out.at, 0, 1);
slot.thumb_span = std.math.clamp(out.span, 0, 1);
+ slot.pointer = if (caps(p, slot).v22) @intCast(@min(out.pointer, 255)) else 0;
+ slot.painted = true;
return cells;
}
@@ -581,6 +589,7 @@ pub fn mouse(p: *Pardes, id: usize, m: pardes.Mouse, col: u16, row: u16) bool {
.pad = 0,
.col = col,
.row = row,
+ .amount = m.amount,
};
var cl: Call = .{ .p = p, .id = id, .slot = slot };
const prev = cl.begin("mouse");
@@ -610,7 +619,11 @@ pub fn step(p: *Pardes) void {
if (slot.next_tick == 0 or (slot.next_tick > 1 and now < slot.next_tick)) continue;
var cl: Call = .{ .p = p, .id = id, .slot = slot };
const prev = cl.begin("tick");
- if (slot.ops) |o| cl.ret = @bitCast(o.tick.?(slot.st, now, if (focused) c.PA_FOCUSED else 0));
+ // A frame drawn since its last tick (2.2): a fling's frames are
+ // counted by them.
+ const flags = (if (focused) c.PA_FOCUSED else 0) | (if (slot.painted and caps(p, slot).v22) c.PA_FRAMED else 0);
+ slot.painted = false;
+ if (slot.ops) |o| cl.ret = @bitCast(o.tick.?(slot.st, now, flags));
slot.next_tick = @bitCast(cl.end(prev).ret);
p.needs_frame = true;
};
@@ -642,6 +655,7 @@ pub fn viewOf(p: *const Pardes, id: usize) c.pa_view {
.dpi = policy.dpi,
.max_px = policy.max_dimension,
.fill = @intFromBool(policy.match_viewport),
+ .glyphs = @intFromBool(!v.frontend.native_images),
.pad = @splat(0),
};
}
@@ -850,6 +864,8 @@ pub fn calling(buf: []u8) ?[]const u8 {
pub const api: c.pa_api = .{
.size = @sizeOf(c.pa_api),
+ .abi = c.PA_ABI,
+ .pad = 0,
.alloc = struct {
fn f(n: usize) callconv(.c) ?*anyopaque {
const cl = current orelse return null;