summaryrefslogtreecommitdiff
path: root/src/pardes.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/pardes.zig')
-rw-r--r--src/pardes.zig46
1 files changed, 28 insertions, 18 deletions
diff --git a/src/pardes.zig b/src/pardes.zig
index 5b37342e..189a5b02 100644
--- a/src/pardes.zig
+++ b/src/pardes.zig
@@ -172,8 +172,10 @@ pub const Turn = struct {
/// a step. Nests: a directory listing that resolves each entry yields
/// inside a yield, and only the outermost one lets go.
pub fn yield(t: *Turn) void {
- // A replica makes no syscall: each is a site of the tape's.
- if (tape.replaying()) @panic("tape: a syscall that is no tape site, made replaying");
+ // A replica makes no syscall: each is a site of the tape's. One that
+ // is none stops a speculation and diverges a replay (it joins
+ // again), never the process (a window client's `Tty fish`, H17).
+ if (tape.replaying()) tape.stray();
const io = t.io orelse return;
yield_depth += 1;
if (yield_depth != 1) return;
@@ -478,6 +480,7 @@ pub const Loc = struct {
test {
_ = @import("rollback.zig");
+ _ = @import("tape.zig");
_ = @import("replica.zig");
_ = @import("echo.zig");
_ = @import("modal.zig");
@@ -3595,6 +3598,7 @@ pub const Mouse = struct {
pixel_x: f32,
pixel_y: f32,
metrics: RowMetrics,
+ place: Layer.Place = .{},
};
// sel indexing relies on left/middle/right being 0/1/2
pub const Button = enum { left, middle, right, wheel_up, wheel_down, wheel_left, wheel_right, none, back, forward };
@@ -5692,6 +5696,17 @@ pub const Pardes = struct {
p.settle();
}
+ /// The last client of a session no one else watches gone: its view
+ /// goes, and the session's own is laid out as it was (views.closeKeeping),
+ /// which the client's rejoin copies. Settled as `closeView` is.
+ pub fn leaveView(p: *Pardes, k: u8) void {
+ const taped = tape.enter(p, .{ .leave_view = k });
+ defer tape.leave(p, taped);
+ views.closeKeeping(p, k);
+ p.sync();
+ p.settle();
+ }
+
/// Into view `k`, before the input its client sent.
pub fn toView(p: *Pardes, k: u8) void {
if (k == p.view) return;
@@ -8176,18 +8191,16 @@ pub const Pardes = struct {
return p.haptic;
}
+ /// A frontend's tag hit, if what it names is still there: resolved on
+ /// the place it carries (Layer.Place), not on this process's frame.
pub fn reprojectTagHit(p: *const Pardes, tag_hit: TagHit) ?TagHit {
- for (p.surface.tagLayers()) |*layer| {
- if (layer.rows == 0 or layer.kind != tag_hit.kind or layer.id != tag_hit.id or layer.serial != tag_hit.serial) continue;
- if (layer.kind == .pane) {
- if (layer.id >= p.panes.len) return null;
- const pane = p.panes[layer.id] orelse return null;
- if (pane.serial != layer.serial) return null;
- }
- if (layer.kind == .column and (layer.id >= p.ncol or p.col_serial[layer.id] != layer.serial)) return null;
- return layer.tagHit(tag_hit.pixel_x, tag_hit.pixel_y, @floatFromInt(tag_hit.metrics.body_w), @floatFromInt(tag_hit.metrics.body_h), @floatFromInt(tag_hit.metrics.tagline_w), @floatFromInt(tag_hit.metrics.tagline_h)) orelse continue;
+ if (tag_hit.kind == .pane) {
+ if (tag_hit.id >= p.panes.len) return null;
+ const pane = p.panes[tag_hit.id] orelse return null;
+ if (pane.serial != tag_hit.serial) return null;
}
- return null;
+ if (tag_hit.kind == .column and (tag_hit.id >= p.ncol or p.col_serial[tag_hit.id] != tag_hit.serial)) return null;
+ return Layer.tagAgain(tag_hit);
}
/// The pane's first body row: under the tag when it is on top, over it
@@ -8207,12 +8220,9 @@ pub const Pardes = struct {
return layer.capacity(p.row_metrics);
}
- pub fn reprojectBodyHit(p: *const Pardes, body_hit: Mouse.BodyHit) ?Mouse.BodyHit {
- for (&p.surface.body_layers) |*layer| {
- if (layer.rows == 0 or layer.serial != body_hit.serial) continue;
- return layer.bodyHit(body_hit.pixel_x, body_hit.pixel_y, @floatFromInt(body_hit.metrics.body_w), @floatFromInt(body_hit.metrics.body_h), @floatFromInt(body_hit.metrics.tagline_w), @floatFromInt(body_hit.metrics.tagline_h));
- }
- return null;
+ /// A frontend's body hit, resolved on the place it carries.
+ pub fn reprojectBodyHit(_: *const Pardes, body_hit: Mouse.BodyHit) ?Mouse.BodyHit {
+ return Layer.bodyAgain(body_hit);
}
// ---- render: build the canonical surface (draw.zig) ----