summaryrefslogtreecommitdiff
path: root/src/web.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-08-09 06:54:27 -0300
committerGabriel Schneider <[email protected]>2026-08-10 09:17:07 -0300
commit599dd82f96b9d091aae78300aa6c3fbc81f9eb69 (patch)
tree532d29eb0d79896cd730fb324df4866056306506 /src/web.zig
parent628aa40f13e9bbd313b51ab625f193110aad8dd0 (diff)
downloadpardes-599dd82f96b9d091aae78300aa6c3fbc81f9eb69.tar.gz
pardes-599dd82f96b9d091aae78300aa6c3fbc81f9eb69.zip
review pass: fix the eaten Tab, drop the duplicated code, cover the gaps
Diffstat (limited to 'src/web.zig')
-rw-r--r--src/web.zig56
1 files changed, 1 insertions, 55 deletions
diff --git a/src/web.zig b/src/web.zig
index b8abf27e..43b6c96d 100644
--- a/src/web.zig
+++ b/src/web.zig
@@ -344,7 +344,7 @@ export fn pardes_chrome_target(col_arg: u32, row_arg: u32) u32 {
const s = &(state orelse return std.math.maxInt(u32));
const col: u16 = @intCast(@min(col_arg, std.math.maxInt(u16)));
const row: u16 = @intCast(@min(row_arg, std.math.maxInt(u16)));
- const target = chromeTarget(s.core, col, row) orelse return std.math.maxInt(u32);
+ const target = s.core.chromeTarget(col, row) orelse return std.math.maxInt(u32);
return (@as(u32, target.row) << 16) | target.col;
}
@@ -486,57 +486,3 @@ fn putU32(s: *State, value: u32) void {
std.mem.writeInt(u32, &bytes, value, .little);
appendEffect(s, &bytes);
}
-
-const Target = struct { col: u16, row: u16 };
-
-/// The tag row and the stacked-pair seam, the way the core's own hit test
-/// derives them: Tagbottom puts a pane's tag on its LAST row, which makes its
-/// FIRST row an ordinary scrollable body row and moves the h-handle down to
-/// the lower pane's first. Kept a line-for-line clone of gui.zig's
-/// webChromeTarget — the two must classify a finger identically.
-fn chromeTarget(core: *const pardes.Pardes, col: u16, row: u16) ?Target {
- if (row < pardes.TOPBAR_H) return .{ .col = col, .row = row };
- for (core.panes, 0..) |slot, id| {
- if (slot == null) continue;
- const rect = core.rects[id];
- const tag = if (core.tag_bottom) rect.y + rect.h -| pardes.BOX_H else rect.y;
- if (row == tag and col >= rect.x and col < rect.x + rect.w and col < rect.x + pardes.config.GUTTER)
- return .{ .col = col, .row = tag };
- }
- for (0..core.ncol -| 1) |column| {
- const handle = core.col_x[column] + core.col_w[column] -| 1;
- if (col == handle) return .{ .col = handle, .row = row };
- }
- for (0..core.ncol) |column| {
- if (col < core.col_x[column] or col >= core.col_x[column] + core.col_w[column]) continue;
- for (0..core.col_n[column] -| 1) |index| {
- const rect = core.rects[core.col_terms[column][index]];
- const handle = if (core.tag_bottom) rect.y +| rect.h else rect.y + rect.h -| 1;
- if (row == handle) return .{ .col = col, .row = handle };
- }
- }
- for (core.panes, 0..) |slot, id| {
- if (slot == null) continue;
- const rect = core.rects[id];
- const tag = if (core.tag_bottom) rect.y + rect.h -| pardes.BOX_H else rect.y;
- if (row == tag and col >= rect.x and col < rect.x + rect.w)
- return .{ .col = col, .row = tag };
- }
- for (0..core.ncol -| 1) |column| {
- const handle = core.col_x[column] + core.col_w[column] -| 1;
- if (distance(col, handle) == 1) return .{ .col = handle, .row = row };
- }
- for (0..core.ncol) |column| {
- if (col < core.col_x[column] or col >= core.col_x[column] + core.col_w[column]) continue;
- for (0..core.col_n[column] -| 1) |index| {
- const rect = core.rects[core.col_terms[column][index]];
- const handle = if (core.tag_bottom) rect.y +| rect.h else rect.y + rect.h -| 1;
- if (distance(row, handle) == 1) return .{ .col = col, .row = handle };
- }
- }
- return null;
-}
-
-fn distance(a: u16, b: u16) u16 {
- return if (a > b) a - b else b - a;
-}