summaryrefslogtreecommitdiff
path: root/src/Kind.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/Kind.zig')
-rw-r--r--src/Kind.zig15
1 files changed, 14 insertions, 1 deletions
diff --git a/src/Kind.zig b/src/Kind.zig
index 2add017a..de5323bb 100644
--- a/src/Kind.zig
+++ b/src/Kind.zig
@@ -600,8 +600,11 @@ pub fn mouse(p: *Pardes, id: usize, m: pardes.Mouse, col: u16, row: u16) bool {
/// The end of a step: each pane of a kind whose focus changed, or whose
/// time has come, ticks (16.2).
pub fn step(p: *Pardes) void {
- if (tape.speculating()) return;
const now = p.clock.stepped_ns;
+ // A tick is the authority's kind's alone: a speculation whose step
+ // would tick one waits for the authority's unit (guessed untouched, the
+ // unit rolled it back, a visible rollback an input).
+ if (tape.speculating()) return if (wouldTick(p, now)) tape.poison("a kind's tick");
for (p.panes, 0..) |pslot, id| if (pslot) |pane| if (pane.addon) |slot| {
// Its tag laid out again by this step's sync, and drawn.
if (slot.retag) p.needs_frame = true;
@@ -629,6 +632,16 @@ pub fn step(p: *Pardes) void {
};
}
+/// Whether `step` would tick some pane of a kind now (its rule, read only).
+fn wouldTick(p: *const Pardes, now: u64) bool {
+ for (p.panes, 0..) |pslot, id| if (pslot) |pane| if (pane.addon) |slot| {
+ if (!caps(p, slot).tick) continue;
+ if (focusedAnywhere(p, id) != slot.focused or std.hash.Wyhash.hash(0, std.mem.asBytes(&viewOf(p, id))) != slot.view) return true;
+ if (slot.next_tick == 1 or (slot.next_tick > 1 and now >= slot.next_tick)) return true;
+ };
+ return false;
+}
+
/// Pane `id` as its next paint sees it: its body below its notices, as
/// draw.zig paints it, a cell's pixels, the theme's colours and the
/// raster this frontend wants a picture at.