summaryrefslogtreecommitdiff
path: root/core/Core.zig
diff options
context:
space:
mode:
Diffstat (limited to 'core/Core.zig')
-rw-r--r--core/Core.zig19
1 files changed, 13 insertions, 6 deletions
diff --git a/core/Core.zig b/core/Core.zig
index 6de4f21e..de911469 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.
@@ -1162,13 +1165,17 @@ 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