summaryrefslogtreecommitdiff
path: root/src/gui/gui.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-09-28 17:56:10 -0300
committerGabriel Schneider <[email protected]>2026-10-01 00:12:15 -0300
commitb4781b334a06d16aedb0b6a3d604cb249eb619de (patch)
tree6c95db55cbd6bf7dde4bc89d1e76e6c1556223b1 /src/gui/gui.zig
parentdeeb8ac54f71d4322a778336db9a7aec411c23ce (diff)
downloadpardes-b4781b334a06d16aedb0b6a3d604cb249eb619de.tar.gz
pardes-b4781b334a06d16aedb0b6a3d604cb249eb619de.zip
Lift moves at the display's rate: render-time animation
Review (and the coordinator): Lift stepped with the core's 16 ms ticks, so a 144 Hz display held each shadow for 2-3 refreshes. The lift springs are now sampled at each frame's own time (p.now_ns), and Pardes.continuous() reports a render-time animation in motion: while it is, the pump draws every loop (a 1 ms wait takes only the input there is) and the present's vsync paces it at the display's rate. They left nextWake; the stepped, frame-indexed animations (transitions, message fades, the theme fade) and every golden are unchanged. With PARDES_TEST_CLOCK, each loop of a moving render-time animation moves the virtual clock by a display frame at PARDES_TEST_HZ (default 60), so a 144 Hz series is deterministic: a focus switch is 51 distinct frames at 144 Hz. Test: renders 6.9 ms apart give rising lifts; settled, no frames. The tty never lifts (GUI capability). Shared files touched: pardes.zig (continuous, pump), gui.zig.
Diffstat (limited to 'src/gui/gui.zig')
-rw-r--r--src/gui/gui.zig18
1 files changed, 14 insertions, 4 deletions
diff --git a/src/gui/gui.zig b/src/gui/gui.zig
index 92bec92c..905caa48 100644
--- a/src/gui/gui.zig
+++ b/src/gui/gui.zig
@@ -2613,6 +2613,7 @@ fn localSession(
.fs = fs,
.test_mode = test_mode,
.test_clock = if (test_mode) host_io.testClock() else null,
+ .test_hz = if (std.c.getenv("PARDES_TEST_HZ")) |hz| @max(1, std.fmt.parseInt(u64, std.mem.span(hz), 10) catch 60) else 60,
};
defer shell.shutdownPtys();
const host = shell.host();
@@ -3898,6 +3899,8 @@ const Shell = struct {
retired_shells: [pardes.MAX_PANES]RetiredShell = @splat(.{}),
/// PARDES_TEST_CLOCK's virtual time (host_io.testClock), in test mode.
test_clock: ?u64 = null,
+ /// The display rate a virtual clock stands in for (PARDES_TEST_HZ).
+ test_hz: u64 = 60,
fn reap(s: *Shell) void {
const now = shellClock();
@@ -4150,10 +4153,17 @@ fn waitInput(ctx: ?*anyopaque, timeout_ms: u32) void {
pardes.turn.rest();
const got = c.SDL_WaitEventTimeout(&sev, ms);
pardes.turn.wake();
- // The core's wake ran out: a virtual clock moves exactly there.
- if (!got and timeout_ms != 0) if (s.test_clock) |*virtual| {
- virtual.* = @max(virtual.*, core.nextWake() orelse virtual.*);
- };
+ // A virtual clock: while a render-time animation moves, each loop
+ // is a presented frame and moves it by one display frame
+ // (PARDES_TEST_HZ), events or not, as a real display's present
+ // would; otherwise a wait that ran out moves it exactly to the
+ // core's wake.
+ if (s.test_clock) |*virtual| {
+ if (core.continuous()) {
+ const display = virtual.* + std.time.ns_per_s / s.test_hz;
+ virtual.* = if (core.nextWake()) |due| @max(virtual.*, @min(due, display)) else display;
+ } else if (!got and timeout_ms != 0) virtual.* = @max(virtual.*, core.nextWake() orelse virtual.*);
+ }
if (got) {
// A run of queued motions is one move to its last position (the
// handler reads only absolute x/y and held buttons): acting on