summaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/gui.zig29
1 files changed, 28 insertions, 1 deletions
diff --git a/src/gui/gui.zig b/src/gui/gui.zig
index 65e3088c..3af66b12 100644
--- a/src/gui/gui.zig
+++ b/src/gui/gui.zig
@@ -1117,6 +1117,8 @@ fn localSession(
frame_capture_dir = if (std.c.getenv("PARDES_FRAMES_CAPTURE")) |dir| std.mem.span(dir) else null;
const host = shell.host();
core.host = host;
+ pardes.Kind.drawer = .{ .ctx = &shell, .go = kindDraw };
+ defer pardes.Kind.drawer = null;
shell.peers = .{ .gpa = gpa, .io = io, .name = daemon.name(), .wake = sdlWake, .detached = detached };
defer shell.peers.deinit();
// Before the core goes: each client sees its link end.
@@ -1383,7 +1385,7 @@ fn clientSession(init: std.process.Init, g: *Gui, opts_in: pardes.Options, test_
// empty ones, there for what draws.
var ptys: [pardes.MAX_PANES]?Pty = @splat(null);
var gens: [pardes.MAX_PANES]u32 = @splat(0);
- var queue: Queue = .{ .io = io, .gpa = gpa, .lsp_allocator = allocs.lsp };
+ var queue: Queue = .{ .io = io, .gpa = gpa, .lsp_allocator = allocs.lsp, .wake_fn = sdlWake };
defer queue.deinit();
var pipe_tasks: PipeTasks = .{};
var watches: file_watch.Table = @splat(null);
@@ -1404,6 +1406,9 @@ fn clientSession(init: std.process.Init, g: *Gui, opts_in: pardes.Options, test_
.test_mode = test_mode,
.client = &client,
};
+ pardes.Kind.drawer = .{ .ctx = &shell, .go = kindDraw };
+ defer pardes.Kind.drawer = null;
+ defer shell.job_tasks.cancelAll(io);
g.no_blink = test_mode;
defer g.hit_core = null;
_ = c.SDL_StartTextInput(g.window);
@@ -1481,6 +1486,8 @@ fn clientSession(init: std.process.Init, g: *Gui, opts_in: pardes.Options, test_
if (link.quit) break;
}
client.takeSaid();
+ // Its draws done (api.draw: this window's own pictures).
+ if (shell.takeDraws()) link.dirty = true;
r.settle();
if (titled and link.notice_len == 0) {
titled = false;
@@ -2688,6 +2695,20 @@ const Shell = struct {
s.closePty(@intCast(id));
}
+ /// A client's queue holds its draws alone: each landed for its pane's
+ /// next paint. Whether any came.
+ fn takeDraws(s: *Shell) bool {
+ s.queue.takeInto(&s.batch);
+ for (s.batch.slice()) |m| switch (m) {
+ .kind_job => |j| {
+ s.job_tasks.finish(s.io, j.id);
+ j.land(s.core);
+ },
+ else => m.deinit(s.gpa, s.lsp_allocator),
+ };
+ return s.batch.slice().len > 0;
+ }
+
fn drainQueue(s: *Shell) void {
s.reconcilePtys();
// After this batch's output, which an exit is told behind.
@@ -3451,6 +3472,12 @@ fn pipe(ctx: ?*anyopaque, id: u32) void {
s.core.reportError(s.core.view().active, "pipe", error.WorkersUnavailable);
}
+/// A draw (api.draw) on a worker, as a job is.
+fn kindDraw(ctx: ?*anyopaque, j: *host_io.KindJob) bool {
+ const s = shellOf(ctx);
+ return (s.threads_ok or s.client != null) and host_io.KindJob.go(s.io, &s.job_tasks, j, s.queue, Queue.pushJob);
+}
+
fn kindJob(ctx: ?*anyopaque, pane: u8, serial: u32, token: u32) void {
const s = shellOf(ctx);
if (s.threads_ok) return host_io.KindJob.start(s.io, s.core, &s.job_tasks, pane, serial, token, s.queue, Queue.pushJob);