diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-18 06:25:46 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-18 08:01:10 -0300 |
| commit | 96bee017263f60b91f4b4fb2d99771abd07b9465 (patch) | |
| tree | 8b25c561ba464ca840be57bdad273e4e130d872c | |
| parent | 96e8398a38bba02e0ea5a9e59c14016dba270531 (diff) | |
| download | pardes-96bee017263f60b91f4b4fb2d99771abd07b9465.tar.gz pardes-96bee017263f60b91f4b4fb2d99771abd07b9465.zip | |
gui: the window client waits as the session's own window does and draws its own motion as it does: under a latency trace (PARDES_TEST_LATENCY) the stdin feed's poll is the loop's wait and SDL's is not waited too (the offscreen driver's SDL_WaitEventTimeout polled a clock and an rwlock a millisecond at a time, and the two waits made every glide frame two), and a blink edge or the window's glide re-presents the last frame (renderFrame, as pollFrame does) instead of a whole draw of the replica's view; a rollback since the last draw draws it whole again (Replica.moved). Offscreen test mode, ReleaseFast, client instructions against the own window's, before -> after: key-down 29.8M -> 13.2M (own 29.3M), type 48.3M -> 23.9M, edit 29.0M -> 19.7M, page-down 126.7M -> 54.3M, wheel 89.6M -> 38.9M, open 138.5M -> 75.2M, cat 222.3M -> 113.4M; page-down settled median 370 -> 273 ms (own 283), wheel 227 -> 198 ms (own 204); load 6-20, the first-frame minima are the test mode's frame phase and want a quiet retake; corpus 77/77 (Debug, against mbase)
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T
| -rw-r--r-- | src/gui/gui.zig | 26 |
1 files changed, 22 insertions, 4 deletions
diff --git a/src/gui/gui.zig b/src/gui/gui.zig index 65e3088c..c7895b0a 100644 --- a/src/gui/gui.zig +++ b/src/gui/gui.zig @@ -1434,6 +1434,7 @@ fn clientSession(init: std.process.Init, g: *Gui, opts_in: pardes.Options, test_ // What it is, then its size, are its view's first inputs. link.input(.{ .frontend = .{ .windowed = true, .native_images = true, .native_image_patches = true } }); var drew = false; + var again = false; while (!link.quit) { core.frames.period_ns = refreshNs(g); var own: OwnView = .{ .g = g, .in = &in, .s = &shell, .pointer = drew }; @@ -1446,14 +1447,25 @@ fn clientSession(init: std.process.Init, g: *Gui, opts_in: pardes.Options, test_ if (link.dirty) { client.draw(&shell); drew = shell.presented; - } + } else if (again and shell.presented) if (shell.surface) |frame| { + // A blink, the window's own motion: the last frame again, + // moved on, as the session's own window draws it (pollFrame). + g.now_ns = shell.ownNow(); + shell.presented = renderFrame(g, gpa, core, frame) catch false; + drew = shell.presented; + }; + again = false; // The window's own motions (its glide, its caret, a jump's // trail) and its blink are on its clock: no unit need come. const minimized = !test_mode and c.SDL_GetWindowFlags(g.window) & (c.SDL_WINDOW_MINIMIZED | c.SDL_WINDOW_OCCLUDED) != 0; const moving = !minimized and frontendMoving(g); const blink = if (minimized or shell.surface == null) null else blinkNow(g, core.settings.cursor_blink); const predicting = r.echo.n > 0 or r.echo.cursor != null or r.echo.nd > 0; - var ms: c_int = if (test_mode) 16 else -1; + // A latency trace's feed paces the loop, as the session's own + // window's (waitInput): its poll on stdin is the wait, and SDL's, + // which polls a clock and a lock a millisecond at a time with + // the offscreen driver, is not waited too (a frame a loop more). + var ms: c_int = if (latency_fd >= 0) 0 else if (test_mode) 16 else -1; if (demoDue(g)) |due| ms = if (ms < 0) due else @min(ms, due); if (predicting or link.owed) ms = if (ms < 0) frame_ms else @min(ms, frame_ms); // A touchpad's fraction settling onto a row (scrollRows). @@ -1467,7 +1479,7 @@ fn clientSession(init: std.process.Init, g: *Gui, opts_in: pardes.Options, test_ }; if (link.quietCheck()) |wait| ms = if (ms < 0) @intCast(wait) else @min(ms, @as(c_int, @intCast(wait))); // Idle, its frame drawn: the next input needs no copy taken. - if (ms != 0) r.ready(); + if (ms != 0 or latency_fd >= 0) r.ready(); if (shell.surface != null) startGamepads(g); var sev = std.mem.zeroes(c.SDL_Event); g.input_seen = false; @@ -1482,12 +1494,18 @@ fn clientSession(init: std.process.Init, g: *Gui, opts_in: pardes.Options, test_ } client.takeSaid(); r.settle(); + // A rollback since it drew: drawn again, never moved on from + // cells the copy put back. + if (r.moved) { + r.moved = false; + link.dirty = true; + } if (titled and link.notice_len == 0) { titled = false; _ = c.SDL_SetWindowTitle(g.window, "pardes"); } if (link.owed or r.echo.changed) link.dirty = true; - if (moving or (blink != null and (blink.?.edge or timed_out))) link.dirty = true; + if (moving or (blink != null and (blink.?.edge or timed_out))) again = true; if (r.diverged != null) link.quit = true; } if (init.environ_map.get("PARDES_REPLICA_STATS")) |file| link.writeStats(file); |
