summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-04 23:21:07 -0300
committerGabriel Schneider <[email protected]>2026-11-05 01:40:08 -0300
commitb10679649936d986f7cf798352cf999324666952 (patch)
treebf11709dae39f911534216e3065237c76a10a027 /src
parent27d8941a177a4ec2c3b0990d4b81f529b93c6f0a (diff)
downloadpardes-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')
-rw-r--r--src/detached/wire.zig37
-rw-r--r--src/gui/gui.zig12
-rw-r--r--src/pardes.zig4
-rw-r--r--src/web.zig5
-rw-r--r--src/web/app.mjs1
5 files changed, 19 insertions, 40 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));
}
}
diff --git a/src/gui/gui.zig b/src/gui/gui.zig
index 880e41ee..3fdcd21c 100644
--- a/src/gui/gui.zig
+++ b/src/gui/gui.zig
@@ -789,7 +789,7 @@ const Touch = struct {
return center;
}
- fn noteMotion(t: *Touch, f: Finger) ?struct { center: TouchNormPoint, ticks: i32, delta_y: f32 } {
+ fn noteMotion(t: *Touch, f: Finger) ?struct { center: TouchNormPoint, ticks: i32 } {
if (!t.scroll.active or (t.scroll.ids[0] != f.id and t.scroll.ids[1] != f.id)) return null;
const center = t.pairCenter(t.scroll.ids) orelse t.scroll.last_center;
const delta_y = center.y - t.scroll.last_center.y;
@@ -798,7 +798,7 @@ const Touch = struct {
const ticks = takeScrollTicks(&t.scroll.accum_y);
if (ticks == 0) return null;
t.scroll.scrolled = true;
- return .{ .center = center, .ticks = ticks, .delta_y = @as(f32, @floatFromInt(ticks)) * touch_scroll_tick };
+ return .{ .center = center, .ticks = ticks };
}
};
@@ -826,7 +826,7 @@ fn handlePairFinger(t: *Touch, in: *Input, f: Finger, win_w: f32, win_h: f32, ce
t.syncPair();
if (!had_pair) return;
const res = t.noteMotion(f) orelse return;
- emitTouchScroll(in, res.center, res.ticks, res.delta_y, win_w, win_h, cell_w, cell_h, tagline_w);
+ emitTouchScroll(in, res.center, res.ticks, win_w, win_h, cell_w, cell_h, tagline_w);
},
.up, .cancel => {
const tap_center = t.finishPair(f);
@@ -837,13 +837,12 @@ fn handlePairFinger(t: *Touch, in: *Input, f: Finger, win_w: f32, win_h: f32, ce
}
}
-fn emitTouchScroll(in: *Input, center: TouchNormPoint, ticks: i32, delta_y: f32, win_w: f32, win_h: f32, cell_w: f32, cell_h: f32, tagline_w: f32) void {
+fn emitTouchScroll(in: *Input, center: TouchNormPoint, ticks: i32, win_w: f32, win_h: f32, cell_w: f32, cell_h: f32, tagline_w: f32) void {
const cell = gridCellAtDimensions(in.core, center.x * win_w, center.y * win_h, cell_w, cell_h, tagline_w);
const button: pardes.Mouse.Button = if (ticks > 0) .wheel_up else .wheel_down;
var remaining: u32 = @abs(ticks);
while (remaining > 0) : (remaining -= 1)
in.post(.{ .mouse = .{ .button = button, .kind = .press, .col = cell.col, .row = cell.row, .tag_hit = cell.tag_hit, .body_hit = cell.body_hit } });
- in.post(.{ .touch_scroll = delta_y });
}
fn emitTouchClick(in: *Input, point: TouchNormPoint, button: pardes.Mouse.Button, win_w: f32, win_h: f32, cell_w: f32, cell_h: f32, tagline_w: f32) void {
@@ -3416,7 +3415,6 @@ fn dispatch(g: *Gui, in: *Input, sev: *const c.SDL_Event) void {
const fch: f32 = @floatFromInt(g.cell_h);
handleFinger(&g.touch, in, finger, win_w, win_h, fcw, fch, @floatFromInt(g.tagline_width));
},
- c.SDL_EVENT_PINCH_BEGIN, c.SDL_EVENT_PINCH_UPDATE => in.post(.{ .pinch = sev.pinch.scale }),
c.SDL_EVENT_GAMEPAD_ADDED => {
if (g.gamepad == null) g.gamepad = c.SDL_OpenGamepad(sev.gdevice.which);
},
@@ -4154,7 +4152,7 @@ const Shell = struct {
if (sev.type != c.SDL_EVENT_USER) s.mail_only = false;
if (!s.peers.recording) return false;
switch (sev.type) {
- c.SDL_EVENT_KEY_DOWN, c.SDL_EVENT_TEXT_INPUT, c.SDL_EVENT_MOUSE_BUTTON_DOWN, c.SDL_EVENT_MOUSE_BUTTON_UP, c.SDL_EVENT_MOUSE_MOTION, c.SDL_EVENT_MOUSE_WHEEL, c.SDL_EVENT_WINDOW_FOCUS_GAINED, c.SDL_EVENT_WINDOW_FOCUS_LOST, c.SDL_EVENT_WINDOW_MOUSE_LEAVE, c.SDL_EVENT_FINGER_DOWN, c.SDL_EVENT_FINGER_MOTION, c.SDL_EVENT_FINGER_UP, c.SDL_EVENT_PINCH_BEGIN, c.SDL_EVENT_PINCH_UPDATE => {},
+ c.SDL_EVENT_KEY_DOWN, c.SDL_EVENT_TEXT_INPUT, c.SDL_EVENT_MOUSE_BUTTON_DOWN, c.SDL_EVENT_MOUSE_BUTTON_UP, c.SDL_EVENT_MOUSE_MOTION, c.SDL_EVENT_MOUSE_WHEEL, c.SDL_EVENT_WINDOW_FOCUS_GAINED, c.SDL_EVENT_WINDOW_FOCUS_LOST, c.SDL_EVENT_WINDOW_MOUSE_LEAVE, c.SDL_EVENT_FINGER_DOWN, c.SDL_EVENT_FINGER_MOTION, c.SDL_EVENT_FINGER_UP => {},
else => return false,
}
if (s.took_input) {
diff --git a/src/pardes.zig b/src/pardes.zig
index e8d2d598..9af74212 100644
--- a/src/pardes.zig
+++ b/src/pardes.zig
@@ -3052,8 +3052,6 @@ pub const Event = union(enum) {
/// `glide`: a wheel's notch, which the strip glides; a touchpad's
/// fraction is followed as it comes.
pdf_scroll: struct { pane: u8, delta_pixels: f32, glide: bool = true },
- pinch: f32,
- touch_scroll: f32,
/// The host pointer left the drawable area. Unlike an out-of-range motion,
/// this must not clamp onto and preview the final grid cell.
pointer_leave,
@@ -5809,8 +5807,6 @@ pub const Pardes = struct {
edit.applyPaste(p, bytes);
},
.command => |line| _ = p.executeBuiltinLine(p.active, line),
- .pinch => |scale| p.ov_pinch_scale = scale,
- .touch_scroll => |delta| p.ov_touch_scroll_delta = delta,
.focus => |focused| {
p.window_focused = focused;
if (focused) if (p.host.vtable.newer_build) |f| if (f(p.host.ctx)) p.setMessage(p.active, newer_build_words);
diff --git a/src/web.zig b/src/web.zig
index 5e5a0d74..27a74289 100644
--- a/src/web.zig
+++ b/src/web.zig
@@ -235,11 +235,6 @@ fn mouseWithHit(button_arg: u32, kind_arg: u32, col_arg: u32, row_arg: u32, mods
});
}
-export fn pardes_touch_scroll(delta: f32) void {
- const s = &(state orelse return);
- s.core.update(.{ .touch_scroll = delta });
-}
-
export fn pardes_pointer_leave() void {
const s = &(state orelse return);
s.core.update(.pointer_leave);
diff --git a/src/web/app.mjs b/src/web/app.mjs
index d2405cf4..1a8036c0 100644
--- a/src/web/app.mjs
+++ b/src/web/app.mjs
@@ -505,7 +505,6 @@ export class PardesRuntime {
this.mouse(BUTTON.wheelUp, MOUSE.press, point.col, point.row, 0);
active.accum -= 1;
}
- this.wasm.pardes_touch_scroll(dy / this.cellHeight);
}
active.lastX = event.clientX;
active.lastY = event.clientY;