summaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/gui.zig26
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);