tony / oxwm

added inner gaps to dwindle, and fixed last update = 0 for .real vs .awake update on zig 16 Browse files
tonybanters committed 2026-05-27 parent dd25e8c commit 81a1296774ce23d7f9c1dd855f3d5364f1daae71
Showing 2 changed files with 18 additions and 15 deletions. UnifiedSplit
+2 −1 src/bar/blocks/blocks.zig
@@ -110,7 +110,8 @@ pub const Block = struct {
110 110
111 // .awake (monotonic) for interval bookkeeping, not .real (wall-clock) — std.Io rework gives us a clock enum now, and a wall-clock backstep would stretch intervals. 111 // .awake (monotonic) for interval bookkeeping, not .real (wall-clock) — std.Io rework gives us a clock enum now, and a wall-clock backstep would stretch intervals.
112 const now = std.Io.Timestamp.now(io, .awake).toSeconds(); 112 const now = std.Io.Timestamp.now(io, .awake).toSeconds();
113 - if (now - self.last_update < @as(i64, @intCast(interval_secs))) { 113 + // last_update == 0 is the never-ran sentinel; force the first refresh since `now - 0` is just uptime under .awake and can be smaller than the interval.
114 + if (self.last_update != 0 and now - self.last_update < @as(i64, @intCast(interval_secs))) {
114 return false; 115 return false;
115 } 116 }
116 117
+16 −14 src/layouts/dwindle.zig
@@ -19,13 +19,15 @@ pub fn dwindle(monitor: *Monitor) void {
19 } 19 }
20 if (n == 0) return; 20 if (n == 0) return;
21 21
22 - const gap_h = if (monitor.smartgaps_enabled and n == 1) 0 else monitor.gap_outer_h; 22 + const gap_outer_h = if (monitor.smartgaps_enabled and n == 1) 0 else monitor.gap_outer_h;
23 - const gap_v = if (monitor.smartgaps_enabled and n == 1) 0 else monitor.gap_outer_v; 23 + const gap_outer_v = if (monitor.smartgaps_enabled and n == 1) 0 else monitor.gap_outer_v;
24 + const gap_inner_h = monitor.gap_inner_h;
25 + const gap_inner_v = monitor.gap_inner_v;
24 26
25 - const work_x: i32 = monitor.win_x + gap_v; 27 + const work_x: i32 = monitor.win_x + gap_outer_v;
26 - const work_y: i32 = monitor.win_y + gap_h; 28 + const work_y: i32 = monitor.win_y + gap_outer_h;
27 - const work_w: i32 = monitor.win_w - 2 * gap_v; 29 + const work_w: i32 = monitor.win_w - 2 * gap_outer_v;
28 - const work_h: i32 = monitor.win_h - 2 * gap_h; 30 + const work_h: i32 = monitor.win_h - 2 * gap_outer_h;
29 31
30 var nx: i32 = work_x; 32 var nx: i32 = work_x;
31 var ny: i32 = 0; 33 var ny: i32 = 0;
@@ -42,25 +44,25 @@ pub fn dwindle(monitor: *Monitor) void {
42 if (can_split) { 44 if (can_split) {
43 if (i + 1 < n) { 45 if (i + 1 < n) {
44 if (i % 2 == 1) { 46 if (i % 2 == 1) {
45 - nh = @divTrunc(nh, 2); 47 + nh = @divTrunc(nh - gap_inner_h, 2);
46 } else { 48 } else {
47 - nw = @divTrunc(nw, 2); 49 + nw = @divTrunc(nw - gap_inner_v, 2);
48 } 50 }
49 } 51 }
50 switch (i % 4) { 52 switch (i % 4) {
51 - 0 => ny += nh, 53 + 0 => ny += nh + gap_inner_h,
52 - 1 => nx += nw, 54 + 1 => nx += nw + gap_inner_v,
53 - 2 => ny += nh, 55 + 2 => ny += nh + gap_inner_h,
54 - 3 => nx += nw, 56 + 3 => nx += nw + gap_inner_v,
55 else => unreachable, 57 else => unreachable,
56 } 58 }
57 if (i == 0) { 59 if (i == 0) {
58 if (n != 1) { 60 if (n != 1) {
59 - nw = @intFromFloat(@as(f32, @floatFromInt(work_w)) * monitor.mfact); 61 + nw = @intFromFloat(@as(f32, @floatFromInt(work_w - gap_inner_v)) * monitor.mfact);
60 } 62 }
61 ny = work_y; 63 ny = work_y;
62 } else if (i == 1) { 64 } else if (i == 1) {
63 - nw = work_w - nw; 65 + nw = work_w - nw - gap_inner_v;
64 } 66 }
65 i += 1; 67 i += 1;
66 } 68 }