summaryrefslogtreecommitdiff
path: root/src/detached
diff options
context:
space:
mode:
Diffstat (limited to 'src/detached')
-rw-r--r--src/detached/wire.zig26
1 files changed, 23 insertions, 3 deletions
diff --git a/src/detached/wire.zig b/src/detached/wire.zig
index 1c9e554e..a809bebd 100644
--- a/src/detached/wire.zig
+++ b/src/detached/wire.zig
@@ -9,6 +9,8 @@ const builtin = @import("builtin");
const pardes = @import("../pardes.zig");
const config = @import("pardes_config");
+/// 17: a pointer's hit carries the place it was made on (Layer.Place) and
+/// a tag hit its line, which the step resolves it by, not by its frame;
/// 16: a far client says so, the session sends it its blobs' hashes before
/// the rest and only the blobs it asks for, all of it in zstd (phase 6's
/// content cache and zstd notes), and a client says its frontend (a window
@@ -18,7 +20,7 @@ const config = @import("pardes_config");
/// part B); 14: the hello names a session and
/// carries the semantics hash, and a ping is answered (phase 5's
/// groundwork); 13: the frames went (phase 3).
-pub const version: u16 = 16;
+pub const version: u16 = 17;
/// The terminal's build and the window's step alike (`semantics`).
const family = switch (config.platform) {
@@ -417,6 +419,17 @@ fn getMetrics(r: *std.Io.Reader) Error!?pardes.RowMetrics {
return m;
}
+fn putPlace(w: *std.Io.Writer, at: pardes.Layer.Place) Error!void {
+ for ([_]u16{ at.viewport.x, at.viewport.y, at.viewport.w, at.viewport.h, at.cols, at.rows, at.context_rows }) |n| try w.writeInt(u16, n, .little);
+}
+
+fn getPlace(r: *std.Io.Reader) Error!pardes.Layer.Place {
+ var n: [7]u16 = undefined;
+ for (&n) |*x| x.* = try r.takeInt(u16, .little);
+ if (n[6] > n[5]) return error.BadValue;
+ return .{ .viewport = .{ .x = n[0], .y = n[1], .w = n[2], .h = n[3] }, .cols = n[4], .rows = n[5], .context_rows = n[6] };
+}
+
fn putBodyHit(w: *std.Io.Writer, hit: ?pardes.Mouse.BodyHit) Error!void {
try w.writeByte(@intFromBool(hit != null));
if (hit) |h| {
@@ -426,12 +439,13 @@ fn putBodyHit(w: *std.Io.Writer, hit: ?pardes.Mouse.BodyHit) Error!void {
try w.writeInt(u32, @bitCast(h.pixel_x), .little);
try w.writeInt(u32, @bitCast(h.pixel_y), .little);
try putMetrics(w, h.metrics);
+ try putPlace(w, h.place);
}
}
fn getBodyHit(r: *std.Io.Reader) Error!?pardes.Mouse.BodyHit {
if (!try getBool(r)) return null;
- const hit: pardes.Mouse.BodyHit = .{ .serial = try r.takeInt(u32, .little), .row = try r.takeInt(u16, .little), .col = try r.takeInt(u16, .little), .pixel_x = try getF32(r), .pixel_y = try getF32(r), .metrics = (try getMetrics(r)) orelse return error.BadValue };
+ const hit: pardes.Mouse.BodyHit = .{ .serial = try r.takeInt(u32, .little), .row = try r.takeInt(u16, .little), .col = try r.takeInt(u16, .little), .pixel_x = try getF32(r), .pixel_y = try getF32(r), .metrics = (try getMetrics(r)) orelse return error.BadValue, .place = try getPlace(r) };
if (!std.math.isFinite(hit.pixel_x) or !std.math.isFinite(hit.pixel_y)) return error.BadValue;
return hit;
}
@@ -443,9 +457,11 @@ fn putTagHit(w: *std.Io.Writer, hit: ?pardes.TagHit) Error!void {
try w.writeInt(u16, h.id, .little);
try w.writeInt(u32, h.serial, .little);
try w.writeInt(u16, h.col, .little);
+ try w.writeInt(u16, h.line, .little);
try w.writeInt(u32, @bitCast(h.pixel_x), .little);
try w.writeInt(u32, @bitCast(h.pixel_y), .little);
try putMetrics(w, h.metrics);
+ try putPlace(w, h.place);
}
}
@@ -456,9 +472,11 @@ fn getTagHit(r: *std.Io.Reader) Error!?pardes.TagHit {
.id = try r.takeInt(u16, .little),
.serial = try r.takeInt(u32, .little),
.col = try r.takeInt(u16, .little),
+ .line = try r.takeInt(u16, .little),
.pixel_x = try getF32(r),
.pixel_y = try getF32(r),
.metrics = (try getMetrics(r)) orelse return error.BadValue,
+ .place = try getPlace(r),
};
if (!std.math.isFinite(hit.pixel_x) or !std.math.isFinite(hit.pixel_y)) return error.BadValue;
return hit;
@@ -618,7 +636,9 @@ pub fn clientBound(msg: ClientMsg) usize {
.bye, .ping, .check, .far => 0,
.screen_ack, .want => |bytes| bytes.len,
.event => |ev| switch (ev) {
- .mouse, .resize, .pdf_scroll, .pinch, .touch_scroll, .pointer_leave, .focus, .frontend => 0,
+ // Its hits' places (14 bytes each) past the slack.
+ .mouse => 28,
+ .resize, .pdf_scroll, .pinch, .touch_scroll, .pointer_leave, .focus, .frontend => 0,
.key => |k| k.text.len,
.paste => |b| b.len,
.command => |line| line.len,