diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-04 23:21:07 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-05 01:40:08 -0300 |
| commit | b10679649936d986f7cf798352cf999324666952 (patch) | |
| tree | bf11709dae39f911534216e3065237c76a10a027 /src/detached | |
| parent | 27d8941a177a4ec2c3b0990d4b81f529b93c6f0a (diff) | |
| download | pardes-b10679649936d986f7cf798352cf999324666952.tar.gz pardes-b10679649936d986f7cf798352cf999324666952.zip | |
the pinch and touch_scroll events go: the window and the web page sent them and the core only kept them for two numbers on the Debug line; their wire tags (0x1b, 0x1c) now answer BadTag, and the NaN check they had moves onto pdf_scroll's distance
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016Y9MNAtZenFv4weoMD3cge
Diffstat (limited to 'src/detached')
| -rw-r--r-- | src/detached/wire.zig | 37 |
1 files changed, 14 insertions, 23 deletions
diff --git a/src/detached/wire.zig b/src/detached/wire.zig index f73dee13..9d1abee5 100644 --- a/src/detached/wire.zig +++ b/src/detached/wire.zig @@ -100,8 +100,7 @@ pub const ClientTag = enum(u8) { paste = 0x18, command = 0x19, pdf_scroll = 0x1a, - pinch = 0x1b, - touch_scroll = 0x1c, + // 0x1b and 0x1c were a pinch and a touch scroll, gone since. pointer_leave = 0x1d, focus = 0x1e, /// Which frontend the client is: a window, or a terminal. @@ -318,9 +317,7 @@ fn getBool(r: *std.Io.Reader) Error!bool { /// and an x86_64 do agree about. fn getF32(r: *std.Io.Reader) Error!f32 { const v: f32 = @bitCast(try r.takeInt(u32, .little)); - // A NaN or an infinity here is not a scroll distance. `pinch` in - // particular multiplies into a zoom factor the pane keeps, so one bad - // value poisons that pane for the rest of the session. + // A NaN or an infinity here is not a scroll distance. if (!std.math.isFinite(v)) return error.BadValue; return v; } @@ -552,8 +549,6 @@ pub fn encodeClient(out: []u8, msg: ClientMsg) Error![]const u8 { try w.writeInt(u32, @bitCast(s.delta_pixels), .little); try w.writeByte(@intFromBool(s.glide)); }, - .pinch => |v| try w.writeInt(u32, @bitCast(v), .little), - .touch_scroll => |v| try w.writeInt(u32, @bitCast(v), .little), .pointer_leave => {}, .focus => |focused| try w.writeByte(@intFromBool(focused)), .frontend => |f| { @@ -634,8 +629,6 @@ pub fn decodeClient(tag: u8, payload: []const u8) Error!ClientMsg { .paste => .{ .event = .{ .paste = try getSlice32(&r) } }, .command => .{ .event = .{ .command = try r.take(try r.takeInt(u16, .little)) } }, .pdf_scroll => .{ .event = .{ .pdf_scroll = .{ .pane = try getPane(&r), .delta_pixels = try getF32(&r), .glide = try getBool(&r) } } }, - .pinch => .{ .event = .{ .pinch = try getF32(&r) } }, - .touch_scroll => .{ .event = .{ .touch_scroll = try getF32(&r) } }, .pointer_leave => .{ .event = .pointer_leave }, .focus => .{ .event = .{ .focus = try getBool(&r) } }, .frontend => .{ .event = .{ .frontend = .{ .windowed = try getBool(&r), .native_images = try getBool(&r), .native_image_patches = try getBool(&r) } } }, @@ -658,7 +651,7 @@ pub fn clientBound(msg: ClientMsg) usize { .event => |ev| switch (ev) { // Its hits' places (14 bytes each) past the slack. .mouse => 28, - .resize, .pdf_scroll, .pinch, .touch_scroll, .pointer_leave, .focus, .frontend => 0, + .resize, .pdf_scroll, .pointer_leave, .focus, .frontend => 0, .key => |k| k.text.len, .paste => |b| b.len, .command => |line| line.len, @@ -764,8 +757,6 @@ test "detached wire: every Event variant round-trips" { try testing.expectEqual(@as(f32, -12.5), got.delta_pixels); try testing.expect(!got.glide); } - try testing.expectEqual(@as(f32, 1.25), (try roundClient(&buf, .{ .event = .{ .pinch = 1.25 } })).event.pinch); - try testing.expectEqual(@as(f32, -0.75), (try roundClient(&buf, .{ .event = .{ .touch_scroll = -0.75 } })).event.touch_scroll); try testing.expectEqual( std.meta.Tag(pardes.Event).pointer_leave, (try roundClient(&buf, .{ .event = .pointer_leave })).event, @@ -782,7 +773,7 @@ test "detached wire: a session is never told to do a frontend's remembering" { // straight to `core.update`. // // 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 + // bar is one sentence: A HUMAN DID IT. A keystroke, a click, a // window resized, a paste, a command line executed, a pointer leaving the // window, the window's focus — plus the session words that say who is speaking, time the link and end it. A pty's // output, a worker's answer, a watched file's new bytes and an animation @@ -800,8 +791,7 @@ test "detached wire: a session is never told to do a frontend's remembering" { "stamp", // ...and everything a person can do to a window. "key", "mouse", "resize", - "paste", "command", "pdf_scroll", "pinch", "touch_scroll", - "pointer_leave", "focus", + "paste", "command", "pdf_scroll", "pointer_leave", "focus", // ...and which of its frontends the person sits at: a window, or a // terminal (what the view draws, and the words it takes). "frontend", @@ -821,9 +811,10 @@ test "detached wire: a session is never told to do a frontend's remembering" { // Two: and no tag BYTE outside them decodes either — the check above is // about this build's enum, this one is about the bytes on the socket. The - // six deleted numbers (0x13..0x17, 0x1e) are in the 250 that must answer + // six deleted numbers (0x13..0x17, 0x1e) are in the ones that must answer // `BadTag`, so a frontend built before this change cannot forge a pane's - // output into a session built after it. + // output into a session built after it (as are 0x1b and 0x1c, once a + // pinch and a touch scroll). var accepted: usize = 0; for (0..256) |i| { const tag: u8 = @intCast(i); @@ -936,13 +927,13 @@ test "detached wire: values a field cannot mean are refused" { try testing.expectEqual(@as(usize, max_name), (try decodeClient(@backingInt(ClientTag.hello), &hello)).hello.session.len); try testing.expect(header_len + hello.len == hello_max); } - // A NaN scroll distance. `pinch` multiplies into a zoom the pane keeps. + // A NaN or an infinite scroll distance. { - var pinch: [4]u8 = undefined; - std.mem.writeInt(u32, &pinch, @bitCast(std.math.nan(f32)), .little); - try testing.expectError(error.BadValue, decodeClient(@backingInt(ClientTag.pinch), &pinch)); - std.mem.writeInt(u32, &pinch, @bitCast(std.math.inf(f32)), .little); - try testing.expectError(error.BadValue, decodeClient(@backingInt(ClientTag.touch_scroll), &pinch)); + var scroll: [6]u8 = .{ 0, 0, 0, 0, 0, 1 }; + std.mem.writeInt(u32, scroll[1..5], @bitCast(std.math.nan(f32)), .little); + try testing.expectError(error.BadValue, decodeClient(@backingInt(ClientTag.pdf_scroll), &scroll)); + std.mem.writeInt(u32, scroll[1..5], @bitCast(std.math.inf(f32)), .little); + try testing.expectError(error.BadValue, decodeClient(@backingInt(ClientTag.pdf_scroll), &scroll)); } } |
