diff options
Diffstat (limited to 'dev/gui/gui.zig')
| -rw-r--r-- | dev/gui/gui.zig | 37 |
1 files changed, 6 insertions, 31 deletions
diff --git a/dev/gui/gui.zig b/dev/gui/gui.zig index c3272957..81d58137 100644 --- a/dev/gui/gui.zig +++ b/dev/gui/gui.zig @@ -990,8 +990,9 @@ fn closeWindow(g: *Gui) void { }; } -/// `pardes-gui --attach`: a window again, as the first was made, at the -/// size the last one had. False when the display will not give one. +/// A window again, as the first was made, at the size the last one had +/// (a transparent one: syncWindowOpacity). False when the display will not +/// give one. fn reopenWindow(g: *Gui) bool { const window = c.SDL_CreateWindow("pardes", g.window_w, g.window_h, g.win_flags) orelse return false; if (comptime builtin.os.tag == .macos) c.ui_macos_trackpad_attach(window); @@ -2395,10 +2396,8 @@ fn pollGamepad(g: *Gui, in: *Input) void { const Shell = struct { core: *pardes.Pardes, - /// The window's, while one is open; null while detached (`detached` has - /// it). + /// The window's, while one is open; null once detached. gui: ?*Gui = null, - detached: ?*Gui = null, io: std.Io, gpa: std.mem.Allocator, fs: ?*ninep_io.Listener = null, @@ -2452,7 +2451,7 @@ const Shell = struct { } /// Detach: the window closed, the session left running with no - /// window, for `pardes-gui --attach` to open one again. + /// window, detached for good: an attach shows it as a client. fn detachWindow(ctx: ?*anyopaque) void { const s = shellOf(ctx); // A replica client's: its link ends. @@ -2499,29 +2498,13 @@ const Shell = struct { fn closeTheWindow(s: *Shell) void { const g = s.gui orelse return; closeWindow(g); - s.detached = g; s.gui = null; s.presented = false; s.surface = null; // Its clients look at it still (Peers keeps it attended). s.peers.detached = true; s.core.unattended = s.peers.count() == 0; - daemon.setState(true); - } - - fn openTheWindow(s: *Shell) void { - const g = s.detached orelse return; - if (!reopenWindow(g)) { - log.err("--attach: no window: {s}", .{c.SDL_GetError()}); - return daemon.setState(true); - } - s.gui = g; - s.detached = null; - s.peers.detached = false; - s.core.unattended = false; - s.core.needs_frame = true; - resetScroll(g); - daemon.setState(false); + daemon.setDetached(); } fn watched(ctx: ?*anyopaque) bool { @@ -2686,7 +2669,6 @@ const Shell = struct { }, .files_changed => check_files = true, .fs_ready => {}, - .window => if (s.gui == null) s.openTheWindow(), .adopted => |a| s.ptys.adoptions.adoptShell(s.core, a.pid, a.fd), }; if (check_files and file_watch.reloadChanged(s.core, s.io, s.gpa, s.watches)) @@ -3200,13 +3182,6 @@ fn deliverNote(ctx: *anyopaque, note: daemon.Note) void { const s: *Shell = @ptrCast(@alignCast(ctx)); const q = s.queue; switch (note) { - .attach => |a| { - // A terminal for a window session: the daemon refuses that kind - // before it is sent, so only an old one's would be here. - if (a.tty >= 0) _ = libc.close(a.tty); - if (a.stub >= 0) daemon.tellStub(a.stub, "r{s}", .{"a window session takes no terminal"}); - if (a.tty < 0) q.push(.window); - }, .adopted => |a| { for (a.pids[0..a.n], a.fds[0..a.n]) |pid, fd| q.push(.{ .adopted = .{ .pid = pid, .fd = fd } }); q.push(.{ .adopted = .{ .pid = 0, .fd = -1 } }); |
