tony / oxwm

Branch: 7c02e65
Switch branches/tags
master
tonybanters Added smartgaps impl c09f004 2026-02-27
37 lines · 1.2 KB Raw Blame History
1 const std = @import("std");
2 const client_mod = @import("../client.zig");
3 const monitor_mod = @import("../monitor.zig");
4 const xlib = @import("../x11/xlib.zig");
5 const tiling = @import("tiling.zig");
6
7 const Client = client_mod.Client;
8 const Monitor = monitor_mod.Monitor;
9
10 pub const layout = monitor_mod.Layout{
11 .symbol = "[M]",
12 .arrange_fn = monocle,
13 };
14
15 pub fn monocle(monitor: *Monitor) void {
16 var client_count: u32 = 0;
17 var count_current = client_mod.nextTiled(monitor.clients);
18 while (count_current) |_| : (count_current = client_mod.nextTiled(count_current.?.next)) {
19 client_count += 1;
20 }
21
22 const gap_h = if (monitor.smartgaps_enabled and client_count == 1) 0 else monitor.gap_outer_h;
23 const gap_v = if (monitor.smartgaps_enabled and client_count == 1) 0 else monitor.gap_outer_v;
24
25 var current = client_mod.nextTiled(monitor.clients);
26 while (current) |client| {
27 tiling.resize(
28 client,
29 monitor.win_x + gap_v,
30 monitor.win_y + gap_h,
31 monitor.win_w - 2 * gap_v - 2 * client.border_width,
32 monitor.win_h - 2 * gap_h - 2 * client.border_width,
33 false,
34 );
35 current = client_mod.nextTiled(client.next);
36 }
37 }