diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-19 20:54:11 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-20 00:01:22 -0300 |
| commit | 19f9e43dfa8bab618b2566a9060aef0ccb71fb0f (patch) | |
| tree | 502b3a9836d962dcfb2347d2ac15431c465b415a /core/replica.zig | |
| parent | 1d6160072e474f8c07987ffe0b58de5d7576002b (diff) | |
| download | pardes-19f9e43dfa8bab618b2566a9060aef0ccb71fb0f.tar.gz pardes-19f9e43dfa8bab618b2566a9060aef0ccb71fb0f.zip | |
mouse: a drag or release in a kind's pane it grabbed, the pane since too short (or narrow) for a cell of body, is told its body's edge instead of tripping std.math.clamp's assertion: a press on a kind's body grabs it (`kind_grab`), and the drag and release after it are the kind's wherever they land, so `kindMouse` (core/mouse.zig) clamped the pointer into the body's range, which a step between the press and the drag (a resize, a pane put above it) can leave empty: `clamp(m.row, top, r.y + r.h -| 1)` with `top > r.y + r.h - 1` (the soak's one `lo <= hi` assertion, in a client's speculation at rtt 207: its typists press at random, resize the window to 16 rows and open panes; the same in the session, which a user could hit with a mouse kind's pane (a PDF) and a resize while a button is held, in Debug a panic, in ReleaseFast a wrong row); now `@min(m.row -| top, (r.y + r.h) -| top -| 1)` and the same for the column: equal to the clamp where the range has a cell, 0 where it has none; the test `a far client's drag in a kind's pane it grabbed, the pane since too short for a row of body: ...` (end of core/replica.zig, with a plain kind that takes the mouse and `runsHere`, its code in the client as a client with its library runs it) aborted on the base at core/mouse.zig's clamp (the press, a resize to 4 rows leaving the pane its tag alone, the drag) and passes: applied at once, confirmed, the client's digest the session's; gates on the seven together (the stack's top, load 18 to 50 beside them): tui core-test 855/999 (144 skipped), shell-test 1035/1038, pane-test 183/184, term-test 15/15, kitty-test 45/45, behaviour-test 275/275 and --replay 20 seeds 0 failures, process-test 3 of 144 (lspcomplete and lspcompletemoved, the base's, and headersweep-restored, which passes alone), gui unit-test 1633/1637 with the base's BaselineHarnessMismatch; replicas --clients 5 and --seeds 8: diverged 0, unequal 0, deltas wrong 0, quiet checks differed 0, unlisted stops 0, corpus 22 of 22, no leak report; the walk over every word and key passes; frame and perf gate against tree1 (farfaults): frames 77/77 byte-identical in Debug, unit-test 1633/1637, perfab corpus2x -0.087% (noise 0.092%, bar 0.4%, pictures identical), perfops 97 counts within 0.1% (largest +0.0329%)
Co-Authored-By: Claude Opus <[email protected]>
Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T
Diffstat (limited to 'core/replica.zig')
| -rw-r--r-- | core/replica.zig | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/core/replica.zig b/core/replica.zig index a13acada..5b4afbb6 100644 --- a/core/replica.zig +++ b/core/replica.zig @@ -5906,3 +5906,72 @@ test "a far client's window found again is instant: its refocus asks the session try std.testing.expectEqual(@as(u32, 0), r.stats.stopped); try std.testing.expectEqual(@as(u32, 2), r.stats.fast); } + +/// Kind `ops`'s code in the client for its pane `id`, as a client that +/// has its library runs it (initDump: Addon.plainOps, dump.plainHere). +fn runsHere(r: *Replica, id: usize, ops: *const pardes.Kind.Ops) !void { + const was = Stepping.begin(&r.t, &r.epoch); + defer was.end(); + const c = r.core(); + const slot = c.panes[id].?.addon.?; + c.kinds.ops[c.kinds.byName(slot.nameOf()).?] = ops; + c.panes[id].?.addon = try pardes.dump.plainHere(c, id, slot, ops); +} + +/// A plain kind that takes the mouse (normal mode has its keys). +const Pointed = struct { + const pa = pardes.Kind.c; + fn mouse(_: ?*anyopaque, _: [*c]const pa.pa_mouse) callconv(.c) c_int { + return 1; + } + const words = [_]pa.pa_word{std.mem.zeroInit(pa.pa_word, .{ .name = "Pointed", .opens = 1, .doc = "a pane that takes the mouse" })}; + const ops = std.mem.zeroInit(pardes.Kind.Ops, .{ + .head = std.mem.zeroInit(pa.pa_head, .{ .size = @sizeOf(pa.pa_head), .abi = pardes.Kind.abi, .name = "pointed".* ++ @as([9]u8, @splat(0)), .version = 1, .exts = "", .flags = pa.PA_PLAIN, .words = &words, .nwords = 1 }), + .open = Still.open, + .paint = Still.paint, + .mouse = mouse, + }); +}; + +// A press grabs a kind's pane (the drag and release after it are the +// kind's wherever they land); a step between can leave that pane too +// short for a row of body, and the drag's row clamped into an empty range +// tripped std.math.clamp's assertion (the soak, once, at rtt 207, in a +// client's speculation). +test "a far client's drag in a kind's pane it grabbed, the pane since too short for a row of body: the kind is told its edge, at once and as on the session" { + const gpa = std.testing.allocator; + const a = try Authority.init(gpa, .{ .cols = 80, .rows = 24, .file = "mise.toml" }, TestHost.host(), false); + defer a.deinit(); + var words: [64]pardes.Kind.LoadedWord = undefined; + const pointed = pardes.Kind.loadedOf(&Pointed.ops, "/x/pointed.so", @splat(8), &words); + _ = try a.local(.{ .addon = .{ .op = .load, .pane = .at(0), .kind = &pointed } }); + _ = try a.local(.{ .command = "Pointed" }); + const kid = a.core.view().active; + const r = try joinedFresh(a); + defer r.deinit(); + try runsHere(r, kid, &Pointed.ops); + const rect = r.core().view().rects[kid]; + const col = rect.x + 4; + const row = rect.y + r.core().panes[kid].?.tag_rows + 1; + var sent: std.ArrayListUnmanaged([]u8) = .empty; + defer { + for (sent.items) |m| gpa.free(m); + sent.deinit(gpa); + } + for ([_]pardes.Event{ + .{ .mouse = .{ .button = .left, .kind = .press, .col = col, .row = row } }, + .{ .resize = .{ .cols = 80, .rows = 4 } }, + .{ .mouse = .{ .button = .left, .kind = .drag, .col = col, .row = 30 } }, + .{ .mouse = .{ .button = .left, .kind = .release, .col = col, .row = 30 } }, + }) |ev| { + try sent.append(gpa, try gpa.dupe(u8, try r.input(ev))); + } + try std.testing.expectEqual(@as(u16, 1), r.core().view().rects[kid].h); + try std.testing.expectEqual(@as(u32, 0), r.stats.stopped); + for (sent.items) |m| { + r.confirm(try a.take(m)); + r.settle(); + } + try std.testing.expectEqual(@as(u32, 0), r.stats.mispredicted); + try agrees(a, r); +} |
