diff options
Diffstat (limited to 'dev')
| -rw-r--r-- | dev/gui/gui.zig | 21 | ||||
| -rw-r--r-- | dev/tui/tui.zig | 10 |
2 files changed, 30 insertions, 1 deletions
diff --git a/dev/gui/gui.zig b/dev/gui/gui.zig index 201c23df..521f685f 100644 --- a/dev/gui/gui.zig +++ b/dev/gui/gui.zig @@ -1428,12 +1428,22 @@ fn clientSession(init: std.process.Init, g: *Gui, opts_in: pardes.Options, test_ .done => {}, .gone => Said.no(io, "'{s}' let this client go (a Detach in it, or the session's end)", .{to.session}), .failed => Said.no(io, "{s}", .{start.said()}), + // A new process's window: the build at its start path, exec'd. + .upgrade => |view| Said.no(io, "{s}", .{client_loop.execAgain(&start, view)}), .left => { var said: [600]u8 = undefined; std.Io.File.stderr().writeStreamingAll(io, std.fmt.bufPrint(&said, "pardes-gui: detached from '{s}', which is still running; come back with `pardes-gui attach {s}`\n", .{ to.session, to.session }) catch "pardes-gui: detached\n") catch {}; std.process.exit(0); }, - .ended => |code| std.process.exit(code), + .ended => |code| { + // A pair's window is its session's parent: its status once it + // is gone, as the terminal's (tui.zig `runClient`). + if (opts_in.pair != null) { + var status: c_int = 0; + while (libc.waitpid(@intCast(start.joined.pid), &status, 0) < 0 and libc.errno(-1) == .INTR) {} + } + std.process.exit(code); + }, } } @@ -1485,6 +1495,7 @@ const StdinFeed = struct { // so a driver exercises the real pointer path (pixel to cell, // tag and body hits). SGR mouse carries only cells. // finger;<kind>;<id>;<x>;<y>;<pressure> + // close: the window's close button // One the read cut short, or what may yet begin one, waits for // the next read. const rest = f.buf[seq_start..len]; @@ -1548,6 +1559,12 @@ const StdinFeed = struct { dispatch(gp, in, &sev); c.SDL_SetModState(before); } + } else if (std.mem.eql(u8, event[0..semi], "close")) { + if (g) |gp| { + var sev = std.mem.zeroes(c.SDL_Event); + sev.type = c.SDL_EVENT_WINDOW_CLOSE_REQUESTED; + dispatch(gp, in, &sev); + } } else if (std.mem.eql(u8, event[0..semi], "finger")) { if (parseFinger(fields)) |finger| if (g) |gp| { var wpw: c_int = 0; @@ -1728,6 +1745,8 @@ const Input = struct { fn close(in: *Input) void { if (in.client) |r| { + // Its bye says so: a pair's session ends at its last client's. + r.loop.link.close = true; r.loop.link.quit = true; in.quit = true; return; diff --git a/dev/tui/tui.zig b/dev/tui/tui.zig index e5e28f6e..72028b04 100644 --- a/dev/tui/tui.zig +++ b/dev/tui/tui.zig @@ -809,6 +809,12 @@ pub fn runClient(init: std.process.Init, opts: pardes.Options, path: []const u8, screen.leave(); Said.no(io, "{s}", .{start.said()}); }, + .upgrade => |view| { + // The blink: its screen left, the build at its start path + // exec'd, which enters it again. + screen.leave(); + Said.no(io, "{s}", .{client_loop.execAgain(&start, view)}); + }, } } @@ -1271,6 +1277,10 @@ const Shell = struct { const core = s.core; var why: [800]u8 = undefined; const path = upgrade.exe() orelse return core.reportFailure(pane, "Upgrade: this process does not know the path it was started from"); + // A client of a session no daemon keeps is a pair's first (no other + // can attach): let go, it has no socket to find the session again + // by, and the session would end with its last link. + if (s.peers.count() > 0 and daemon.link < 0) return core.reportFailure(pane, "Upgrade: no daemon keeps this session, so its client could not join it again; this session stays as it is"); // 9P is served while the new binary is asked (its clients' clunks // and reads after the word are answered), and not after. pardes.turn.rest(); |
