diff options
Diffstat (limited to 'core/Core.zig')
| -rw-r--r-- | core/Core.zig | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/core/Core.zig b/core/Core.zig index 55b3682f..d2cfadfc 100644 --- a/core/Core.zig +++ b/core/Core.zig @@ -127,6 +127,9 @@ pub const View = struct { /// pane (util.c:467). Where the acme placement puts new panes /// (layout.placeNew). A Look click moves the keyboard but not this. active_column: u32 = 0, + /// When its client went away to join again for it (Views.away), on + /// the session's clock. + away_ns: u64 = 0, /// The live view's frontend (Event.frontend): a window, what it draws and /// the words it takes (builtins.zig `here`); it starts as /// `Options.windowed` says. @@ -1161,21 +1164,27 @@ pub inline fn view(p: anytype) if (@typeInfo(@TypeOf(p)).pointer.attrs.@"const") pub const openView = pardes.tape.taped(openViewInner); fn openViewInner(p: *Pardes) ?View.Id { // Every view taken: one kept for a client that has not come back - // for it (Views.away) goes first. ponytail: no timer lets one go; - // until its place is wanted it costs a parked slot, and a terminal - // it sized last keeps that size until another view types into it. - if (@popCount(p.views_open) == Views.max and p.views_away != 0) { - Views.close(p, @ctz(p.views_away)); + // for it in Views.away_kept_ns (Views.away) goes first; one kept + // since is its client's, and the join is refused. ponytail: no timer + // lets one go; until its place is wanted it costs a parked slot, and + // a terminal it sized last keeps that size until another view types + // into it. + if (@popCount(p.views_open) == Views.max) for (0..Views.max) |k| { + if (!Views.isAway(p, @intCast(k)) or p.clock.now_ns -| p.views[k].?.away_ns < Views.away_kept_ns) continue; + Views.close(p, @intCast(k)); p.sync(); - } + break; + }; // What was queued since the last pump (a leaving client's view // closed, a 9P request's step) done first, as every client of the // tape does it here: a join dumps the session next, and a core // loaded from a dump has no queue (Replica.initDump). p.settle(); + // A join refused (every view taken) reloads nothing. + const k = Views.open(p) orelse return null; pardes.panes.reloadTerminals(p); p.needs_frame = true; - return .at(Views.open(p) orelse return null); + return .at(k); } /// The client of view `k` gone: its view goes, the others stay. The |
