diff options
Diffstat (limited to 'src/web.zig')
| -rw-r--r-- | src/web.zig | 56 |
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; -} |
