summaryrefslogtreecommitdiff
path: root/src/gui/gui.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/gui/gui.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/gui/gui.zig')
-rw-r--r--src/gui/gui.zig80
1 files changed, 3 insertions, 77 deletions
diff --git a/src/gui/gui.zig b/src/gui/gui.zig
index 0cc5f520..39d8c575 100644
--- a/src/gui/gui.zig
+++ b/src/gui/gui.zig
@@ -461,7 +461,7 @@ fn handleSingleFinger(t: *Touch, core: *pardes.Pardes, f: Finger, win_w: f32, wi
const point = TouchNormPoint{ .x = f.x, .y = f.y };
const col = normCell(point.x, win_w, cell_w);
const row = normCell(point.y, win_h, cell_h);
- const chrome = webChromeTarget(core, col, row);
+ const chrome = core.chromeTarget(col, row);
t.beginSingle(f, chrome != null);
if (chrome) |target|
core.update(.{ .mouse = .{ .button = .left, .kind = .press, .col = target.col, .row = target.row } });
@@ -496,73 +496,6 @@ fn handleSingleFinger(t: *Touch, core: *pardes.Pardes, f: Finger, win_w: f32, wi
}
}
-const WebChromeTarget = struct { col: u16, row: u16 };
-
-/// Fat-finger hit test for web layout chrome. A gesture is classified once at
-/// finger-down, then never changes into scrolling. Handle coordinates are
-/// snapped onto the core's one-cell resize edge; body rows remain untouched.
-///
-/// The tag row and the stacked-pair seam come from the core's own rule:
-/// 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 web.zig's chromeTarget — the
-/// two must classify a finger identically.
-fn webChromeTarget(core: *const pardes.Pardes, col: u16, row: u16) ?WebChromeTarget {
- if (row < pardes.TOPBAR_H) return .{ .col = col, .row = row };
-
- // The move box wins over a horizontal handle when a pane is tag-only,
- // matching the core's own mouse hit-test priority.
- 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 + 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 };
- }
- }
-
- // The remainder of each tag row is tag editing, not a scrollable body.
- 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 };
- }
-
- // One-cell tolerance around thin separators, after exact tag rows have had
- // first refusal so a fat-finger tag edit never turns into a resize.
- for (0..core.ncol -| 1) |column| {
- const handle = core.col_x[column] + core.col_w[column] -| 1;
- if (cellDistance(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 (cellDistance(row, handle) == 1) return .{ .col = col, .row = handle };
- }
- }
- return null;
-}
-
-fn cellDistance(a: u16, b: u16) u16 {
- return if (a > b) a - b else b - a;
-}
-
fn handlePairFinger(t: *Touch, core: *pardes.Pardes, f: Finger, win_w: f32, win_h: f32, cell_w: f32, cell_h: f32) void {
switch (f.kind) {
.down => {
@@ -1336,15 +1269,8 @@ fn runNative(init: std.process.Init, opts_in: pardes.Options) !void {
// --nested opted out of the whole mechanism, including being an outer
// instance; so does any failure to bind, and then children simply open
// their own session.
- var sock_buf: [108]u8 = undefined;
- const sock_path: ?[:0]const u8 = if (opts.nested) null else nested.socketPath(&sock_buf, libc.getpid());
- const sock_fd: c_int = if (sock_path) |sp| nested.listenAt(sp) else -1;
- // only on the fd, so a bind that FAILED cannot unlink a path this process
- // never created
- defer if (sock_fd >= 0) {
- _ = libc.close(sock_fd);
- _ = libc.unlink(sock_path.?);
- };
+ const sock_fd: c_int = if (opts.nested) -1 else nested.listen();
+ defer nested.unlisten(sock_fd);
// initial spawns BEFORE any worker thread exists: forkpty from a
// multithreaded process can wedge the child before exec (see tty.zig).