summaryrefslogtreecommitdiff
path: root/src/detached/wire.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/detached/wire.zig')
-rw-r--r--src/detached/wire.zig19
1 files changed, 14 insertions, 5 deletions
diff --git a/src/detached/wire.zig b/src/detached/wire.zig
index 051e9317..c9d9b578 100644
--- a/src/detached/wire.zig
+++ b/src/detached/wire.zig
@@ -12,7 +12,7 @@ const ShaderAnimation = pardes.config.Runtime.ShaderAnimation;
/// to be refused, which is what this number is for.
/// 8: one layer type: a tag band carries all its rows (not a layer per
/// line), and a frame carries the core's placed regions after its layers.
-pub const version: u16 = 8;
+pub const version: u16 = 10;
/// The Chrome palette is carried field by field as its declaration lists
/// them, so any change to it changes the wire: bump `version`, then this.
@@ -58,6 +58,7 @@ pub const ClientTag = enum(u8) {
pinch = 0x1b,
touch_scroll = 0x1c,
pointer_leave = 0x1d,
+ focus = 0x1e,
};
// Session control precedes display-local effects.
@@ -1052,6 +1053,8 @@ pub fn encodeClient(out: []u8, msg: ClientMsg) Error![]const u8 {
try w.putU16(m.col);
try w.putU16(m.row);
try w.putBool(m.ctrl);
+ try w.putBool(m.shift);
+ try w.putBool(m.alt);
try putBodyHit(&w, m.body_hit);
try putTagHit(&w, m.tag_hit);
},
@@ -1074,6 +1077,7 @@ pub fn encodeClient(out: []u8, msg: ClientMsg) Error![]const u8 {
.pinch => |v| try w.putF32(v),
.touch_scroll => |v| try w.putF32(v),
.pointer_leave => {},
+ .focus => |focused| try w.putBool(focused),
// See `clientTag`: no tag, so nothing to encode.
.output, .eof, .exited, .lsp_resp, .pipe_resp, .file_changed, .tick => unreachable,
},
@@ -1115,6 +1119,8 @@ pub fn decodeClient(tag: u8, payload: []const u8) Error!ClientMsg {
.col = try r.getU16(),
.row = try r.getU16(),
.ctrl = try r.getBool(),
+ .shift = try r.getBool(),
+ .alt = try r.getBool(),
.body_hit = try getBodyHit(&r),
.tag_hit = try getTagHit(&r),
} } },
@@ -1134,6 +1140,7 @@ pub fn decodeClient(tag: u8, payload: []const u8) Error!ClientMsg {
.pinch => .{ .event = .{ .pinch = try r.getF32() } },
.touch_scroll => .{ .event = .{ .touch_scroll = try r.getF32() } },
.pointer_leave => .{ .event = .pointer_leave },
+ .focus => .{ .event = .{ .focus = try r.getBool() } },
};
try r.end();
return msg;
@@ -1218,7 +1225,7 @@ pub fn clientBound(msg: ClientMsg) usize {
return msg_slack + switch (msg) {
.hello, .bye => 0,
.event => |ev| switch (ev) {
- .mouse, .resize, .pdf_scroll, .pinch, .touch_scroll, .pointer_leave => 0,
+ .mouse, .resize, .pdf_scroll, .pinch, .touch_scroll, .pointer_leave, .focus => 0,
.key => |k| k.text.len,
.paste => |b| b.len,
.command => |line| line.len,
@@ -1357,13 +1364,15 @@ test "detached wire: every Event variant round-trips" {
// the only place a value can be mistranslated and still decode.
for (std.enums.values(pardes.Mouse.Button)) |button| {
for (std.enums.values(pardes.Mouse.Kind)) |kind| {
- const m: pardes.Mouse = .{ .button = button, .kind = kind, .col = 4200, .row = 7, .ctrl = true };
+ const m: pardes.Mouse = .{ .button = button, .kind = kind, .col = 4200, .row = 7, .ctrl = true, .shift = true, .alt = true };
const got = (try roundClient(&buf, .{ .event = .{ .mouse = m } })).event.mouse;
try testing.expectEqual(m.button, got.button);
try testing.expectEqual(m.kind, got.kind);
try testing.expectEqual(m.col, got.col);
try testing.expectEqual(m.row, got.row);
try testing.expectEqual(m.ctrl, got.ctrl);
+ try testing.expectEqual(m.shift, got.shift);
+ try testing.expectEqual(m.alt, got.alt);
}
}
}
@@ -1449,7 +1458,7 @@ test "detached wire: a session is never told to do a frontend's remembering" {
// Adding a name here is meant to be an ARGUMENT, not a formality, and the
// bar is one sentence: A HUMAN DID IT. A keystroke, a click, a pinch, a
// window resized, a paste, a command line executed, a pointer leaving the
- // window — plus the two session words that say who is speaking. A pty's
+ // window, the window's focus — plus the two session words that say who is speaking. A pty's
// output, a worker's answer, a watched file's new bytes and an animation
// tick all fail that bar the same way: nobody did them, a machine reported
// them, and the machine that reports them is the one already holding the
@@ -1462,7 +1471,7 @@ test "detached wire: a session is never told to do a frontend's remembering" {
"resize", "paste",
"command", "pdf_scroll",
"pinch", "touch_scroll",
- "pointer_leave",
+ "pointer_leave", "focus",
};
// One: the tag set is exactly that, named rather than counted, so