tony / oxwm

Added grid layout Browse files
tonybanters committed 2026-02-16 parent 3f07d04 commit ee77e24171b8a369df7af801cf9eede040cf929d
Showing 3 changed files with 12 additions and 3 deletions. UnifiedSplit
+2 −0 src/bar/bar.zig
@@ -16,6 +16,7 @@ fn get_layout_symbol(layout_index: u32) []const u8 {
16 16 1 => conf.layout_monocle_symbol,
17 17 2 => conf.layout_floating_symbol,
18 18 3 => "[S]",
19 + 4 => "[#]",
19 20 else => "[?]",
20 21 };
21 22 }
@@ -24,6 +25,7 @@ fn get_layout_symbol(layout_index: u32) []const u8 {
24 25 1 => "[M]",
25 26 2 => "><>",
26 27 3 => "[S]",
28 + 4 => "[#]",
27 29 else => "[?]",
28 30 };
29 31 }
+8 −1 src/main.zig
@@ -9,6 +9,7 @@ const tiling = @import("layouts/tiling.zig");
9 9 const monocle = @import("layouts/monocle.zig");
10 10 const floating = @import("layouts/floating.zig");
11 11 const scrolling = @import("layouts/scrolling.zig");
12 +const grid = @import("layouts/grid.zig");
12 13 const animations = @import("animations.zig");
13 14 const bar_mod = @import("bar/bar.zig");
14 15 const blocks_mod = @import("bar/blocks/blocks.zig");
@@ -349,11 +350,13 @@ fn setup_monitors(display: *Display) void {
349 350 mon.lt[1] = &monocle.layout;
350 351 mon.lt[2] = &floating.layout;
351 352 mon.lt[3] = &scrolling.layout;
353 + mon.lt[4] = &grid.layout;
352 354 for (0..10) |i| {
353 355 mon.pertag.ltidxs[i][0] = mon.lt[0];
354 356 mon.pertag.ltidxs[i][1] = mon.lt[1];
355 357 mon.pertag.ltidxs[i][2] = mon.lt[2];
356 358 mon.pertag.ltidxs[i][3] = mon.lt[3];
359 + mon.pertag.ltidxs[i][4] = mon.lt[4];
357 360 }
358 361
359 362 if (prev_monitor) |prev| {
@@ -387,11 +390,13 @@ fn setup_monitors(display: *Display) void {
387 390 mon.lt[1] = &monocle.layout;
388 391 mon.lt[2] = &floating.layout;
389 392 mon.lt[3] = &scrolling.layout;
393 + mon.lt[4] = &grid.layout;
390 394 for (0..10) |i| {
391 395 mon.pertag.ltidxs[i][0] = mon.lt[0];
392 396 mon.pertag.ltidxs[i][1] = mon.lt[1];
393 397 mon.pertag.ltidxs[i][2] = mon.lt[2];
394 398 mon.pertag.ltidxs[i][3] = mon.lt[3];
399 + mon.pertag.ltidxs[i][4] = mon.lt[4];
395 400 }
396 401 monitor_mod.monitors = mon;
397 402 monitor_mod.selected_monitor = mon;
@@ -1466,7 +1471,7 @@ fn setmfact(delta: f32) void {
1466 1471
1467 1472 fn cycle_layout() void {
1468 1473 const monitor = monitor_mod.selected_monitor orelse return;
1469 - const new_lt = (monitor.sel_lt + 1) % 4;
1474 + const new_lt = (monitor.sel_lt + 1) % 5;
1470 1475 monitor.sel_lt = new_lt;
1471 1476 monitor.pertag.sellts[monitor.pertag.curtag] = new_lt;
1472 1477 if (new_lt != 3) {
@@ -1491,6 +1496,8 @@ fn set_layout(layout_name: ?[]const u8) void {
1491 1496 2
1492 1497 else if (std.mem.eql(u8, name, "scrolling") or std.mem.eql(u8, name, "[S]"))
1493 1498 3
1499 + else if (std.mem.eql(u8, name, "grid") or std.mem.eql(u8, name, "[#]"))
1500 + 4
1494 1501 else {
1495 1502 std.debug.print("set_layout: unknown layout '{s}'\n", .{name});
1496 1503 return;
+2 −2 src/monitor.zig
@@ -13,7 +13,7 @@ pub const Pertag = struct {
13 13 nmasters: [10]i32 = [_]i32{1} ** 10,
14 14 mfacts: [10]f32 = [_]f32{0.55} ** 10,
15 15 sellts: [10]u32 = [_]u32{0} ** 10,
16 - ltidxs: [10][4]?*const Layout = [_][4]?*const Layout{.{ null, null, null, null }} ** 10,
16 + ltidxs: [10][5]?*const Layout = [_][5]?*const Layout{.{ null, null, null, null, null }} ** 10,
17 17 showbars: [10]bool = [_]bool{true} ** 10,
18 18 };
19 19
@@ -46,7 +46,7 @@ pub const Monitor = struct {
46 46 stack: ?*Client = null,
47 47 next: ?*Monitor = null,
48 48 bar_win: xlib.Window = 0,
49 - lt: [4]?*const Layout = .{ null, null, null, null },
49 + lt: [5]?*const Layout = .{ null, null, null, null, null },
50 50 pertag: Pertag = Pertag{},
51 51 };
52 52