summaryrefslogtreecommitdiff
path: root/dev/gui
diff options
context:
space:
mode:
Diffstat (limited to 'dev/gui')
-rw-r--r--dev/gui/gui.zig21
1 files changed, 20 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;