tony / oxwm

treewide: change function names to camelCase Browse files
emzywastaken committed 2026-02-23 parent 3663acc commit b3ae92e94a20f6d31973268f5211515a6c0b069a
Showing 29 changed files with 784 additions and 784 deletions. UnifiedSplit
+6 −6 build.zig
@@ -86,16 +86,16 @@ pub fn build(b: *std.Build) void {
86 86 test_step.dependOn(&b.addRunArtifact(lua_config_tests).step);
87 87
88 88 const xephyr_step = b.step("xephyr", "Run in Xephyr (1280x800 on :2)");
89 - xephyr_step.dependOn(&add_xephyr_run(b, exe, false).step);
89 + xephyr_step.dependOn(&addXephyrRun(b, exe, false).step);
90 90
91 91 const xephyr_multi_step = b.step("xephyr-multi", "Run in Xephyr multi-monitor on :2");
92 - xephyr_multi_step.dependOn(&add_xephyr_run(b, exe, true).step);
92 + xephyr_multi_step.dependOn(&addXephyrRun(b, exe, true).step);
93 93
94 94 const multimon_step = b.step("multimon", "Alias for xephyr-multi");
95 - multimon_step.dependOn(&add_xephyr_run(b, exe, true).step);
95 + multimon_step.dependOn(&addXephyrRun(b, exe, true).step);
96 96
97 97 const xwayland_step = b.step("xwayland", "Run in Xwayland on :2");
98 - xwayland_step.dependOn(&add_xwayland_run(b, exe).step);
98 + xwayland_step.dependOn(&addXwaylandRun(b, exe).step);
99 99
100 100 const kill_step = b.step("kill", "Kill Xephyr and oxwm");
101 101 kill_step.dependOn(&b.addSystemCommand(&.{ "sh", "-c", "pkill -9 Xephyr || true; pkill -9 oxwm || true" }).step);
@@ -130,7 +130,7 @@ pub fn build(b: *std.Build) void {
130 130 }).step);
131 131 }
132 132
133 -fn add_xephyr_run(b: *std.Build, exe: *std.Build.Step.Compile, multimon: bool) *std.Build.Step.Run {
133 +fn addXephyrRun(b: *std.Build, exe: *std.Build.Step.Compile, multimon: bool) *std.Build.Step.Run {
134 134 const kill_cmd = if (multimon)
135 135 "pkill -9 Xephyr || true; Xephyr +xinerama -glamor -screen 640x480 -screen 640x480 :2 & sleep 1"
136 136 else
@@ -146,7 +146,7 @@ fn add_xephyr_run(b: *std.Build, exe: *std.Build.Step.Compile, multimon: bool) *
146 146 return run_wm;
147 147 }
148 148
149 -fn add_xwayland_run(b: *std.Build, exe: *std.Build.Step.Compile) *std.Build.Step.Run {
149 +fn addXwaylandRun(b: *std.Build, exe: *std.Build.Step.Compile) *std.Build.Step.Run {
150 150 const cmd = "Xwayland -retro -noreset :2 & sleep 1";
151 151
152 152 const setup = b.addSystemCommand(&.{ "sh", "-c", cmd });
+1 −1 src/animations.zig
@@ -62,7 +62,7 @@ pub const Scroll_Animation = struct {
62 62 return @intFromFloat(current);
63 63 }
64 64
65 - pub fn is_active(self: *const Scroll_Animation) bool {
65 + pub fn isActive(self: *const Scroll_Animation) bool {
66 66 return self.active;
67 67 }
68 68
+26 −26 src/bar/bar.zig
@@ -8,7 +8,7 @@ const ColorScheme = config_mod.ColorScheme;
8 8 const Monitor = monitor_mod.Monitor;
9 9 const Block = blocks_mod.Block;
10 10
11 -fn get_layout_symbol(layout_index: u32, config: config_mod.Config) []const u8 {
11 +fn getLayoutSymbol(layout_index: u32, config: config_mod.Config) []const u8 {
12 12 return switch (layout_index) {
13 13 0 => config.layout_tile_symbol,
14 14 1 => config.layout_monocle_symbol,
@@ -143,11 +143,11 @@ pub const Bar = struct {
143 143 self.allocator.destroy(self);
144 144 }
145 145
146 - pub fn add_block(self: *Bar, block: Block) void {
146 + pub fn addBlock(self: *Bar, block: Block) void {
147 147 self.blocks.append(self.allocator, block) catch {};
148 148 }
149 149
150 - pub fn clear_blocks(self: *Bar) void {
150 + pub fn clearBlocks(self: *Bar) void {
151 151 self.blocks.clearRetainingCapacity();
152 152 }
153 153
@@ -159,7 +159,7 @@ pub const Bar = struct {
159 159 pub fn draw(self: *Bar, display: *xlib.Display, config: config_mod.Config) void {
160 160 if (!self.needs_redraw) return;
161 161
162 - self.fill_rect(display, 0, 0, self.width, self.height, self.scheme_normal.background);
162 + self.fillRect(display, 0, 0, self.width, self.height, self.scheme_normal.background);
163 163
164 164 var x_position: i32 = 0;
165 165 const padding: i32 = 8;
@@ -169,7 +169,7 @@ pub const Bar = struct {
169 169 for (config.tags, 0..) |tag, index| {
170 170 const tag_mask: u32 = @as(u32, 1) << @intCast(index);
171 171 const is_selected = (current_tags & tag_mask) != 0;
172 - const is_occupied = has_clients_on_tag(monitor, tag_mask);
172 + const is_occupied = hasClientsOnTag(monitor, tag_mask);
173 173
174 174 if (self.hide_vacant_tags and !is_occupied and !is_selected) continue;
175 175
@@ -180,35 +180,35 @@ pub const Bar = struct {
180 180 else
181 181 self.scheme_normal;
182 182
183 - const tag_text_width = self.text_width(display, tag);
183 + const tag_text_width = self.textWidth(display, tag);
184 184 const tag_width = tag_text_width + padding * 2;
185 185
186 186 if (is_selected) {
187 - self.fill_rect(display, x_position, self.height - 3, tag_width, 3, scheme.border);
187 + self.fillRect(display, x_position, self.height - 3, tag_width, 3, scheme.border);
188 188 }
189 189
190 190 const text_y = @divTrunc(self.height + self.font_height, 2) - 4;
191 - self.draw_text(display, x_position + padding, text_y, tag, scheme.foreground);
191 + self.drawText(display, x_position + padding, text_y, tag, scheme.foreground);
192 192 x_position += tag_width;
193 193 }
194 194
195 195 x_position += padding;
196 196
197 - const layout_symbol = get_layout_symbol(monitor.sel_lt, config);
198 - self.draw_text(display, x_position, @divTrunc(self.height + self.font_height, 2) - 4, layout_symbol, self.scheme_normal.foreground);
199 - x_position += self.text_width(display, layout_symbol) + padding;
197 + const layout_symbol = getLayoutSymbol(monitor.sel_lt, config);
198 + self.drawText(display, x_position, @divTrunc(self.height + self.font_height, 2) - 4, layout_symbol, self.scheme_normal.foreground);
199 + x_position += self.textWidth(display, layout_symbol) + padding;
200 200
201 201 var block_x: i32 = self.width - padding;
202 202 var block_index: usize = self.blocks.items.len;
203 203 while (block_index > 0) {
204 204 block_index -= 1;
205 205 const block = &self.blocks.items[block_index];
206 - const content = block.get_content();
207 - const content_width = self.text_width(display, content);
206 + const content = block.getContent();
207 + const content_width = self.textWidth(display, content);
208 208 block_x -= content_width;
209 - self.draw_text(display, block_x, @divTrunc(self.height + self.font_height, 2) - 4, content, block.color());
209 + self.drawText(display, block_x, @divTrunc(self.height + self.font_height, 2) - 4, content, block.color());
210 210 if (block.underline) {
211 - self.fill_rect(display, block_x, self.height - 2, content_width, 2, block.color());
211 + self.fillRect(display, block_x, self.height - 2, content_width, 2, block.color());
212 212 }
213 213 block_x -= padding;
214 214 }
@@ -221,7 +221,7 @@ pub const Bar = struct {
221 221
222 222 /// Returns the index of the tag the user clicked on, or null if the
223 223 /// click was outside the tag area.
224 - pub fn handle_click(self: *Bar, display: *xlib.Display, click_x: i32, config: config_mod.Config) ?usize {
224 + pub fn handleClick(self: *Bar, display: *xlib.Display, click_x: i32, config: config_mod.Config) ?usize {
225 225 var x_position: i32 = 0;
226 226 const padding: i32 = 8;
227 227 const monitor = self.monitor;
@@ -230,11 +230,11 @@ pub const Bar = struct {
230 230 for (config.tags, 0..) |tag, index| {
231 231 const tag_mask = @as(u32, 1) << @intCast(index);
232 232 const is_selected = (current_tags & tag_mask) != 0;
233 - const is_occupied = has_clients_on_tag(monitor, tag_mask);
233 + const is_occupied = hasClientsOnTag(monitor, tag_mask);
234 234
235 235 if (self.hide_vacant_tags and !is_occupied and !is_selected) continue;
236 236
237 - const tag_text_width = self.text_width(display, tag);
237 + const tag_text_width = self.textWidth(display, tag);
238 238 const tag_width = tag_text_width + padding * 2;
239 239
240 240 if (click_x >= x_position and click_x < x_position + tag_width) {
@@ -246,7 +246,7 @@ pub const Bar = struct {
246 246 }
247 247
248 248 /// Updates all blocks and marks the bar dirty if any block changed.
249 - pub fn update_blocks(self: *Bar) void {
249 + pub fn updateBlocks(self: *Bar) void {
250 250 var changed = false;
251 251 for (self.blocks.items) |*block| {
252 252 if (block.update()) changed = true;
@@ -254,12 +254,12 @@ pub const Bar = struct {
254 254 if (changed) self.needs_redraw = true;
255 255 }
256 256
257 - fn fill_rect(self: *Bar, display: *xlib.Display, x: i32, y: i32, width: i32, height: i32, color: c_ulong) void {
257 + fn fillRect(self: *Bar, display: *xlib.Display, x: i32, y: i32, width: i32, height: i32, color: c_ulong) void {
258 258 _ = xlib.XSetForeground(display, self.graphics_context, color);
259 259 _ = xlib.XFillRectangle(display, self.pixmap, self.graphics_context, x, y, @intCast(width), @intCast(height));
260 260 }
261 261
262 - fn draw_text(self: *Bar, display: *xlib.Display, x: i32, y: i32, text: []const u8, color: c_ulong) void {
262 + fn drawText(self: *Bar, display: *xlib.Display, x: i32, y: i32, text: []const u8, color: c_ulong) void {
263 263 if (self.xft_draw == null or self.font == null) return;
264 264
265 265 var xft_color: xlib.XftColor = undefined;
@@ -277,7 +277,7 @@ pub const Bar = struct {
277 277 xlib.XftColorFree(display, visual, colormap, &xft_color);
278 278 }
279 279
280 - fn text_width(self: *Bar, display: *xlib.Display, text: []const u8) i32 {
280 + fn textWidth(self: *Bar, display: *xlib.Display, text: []const u8) i32 {
281 281 if (self.font == null) return 0;
282 282
283 283 var extents: xlib.XGlyphInfo = undefined;
@@ -289,7 +289,7 @@ pub const Bar = struct {
289 289 // Bar list helpers >.<
290 290
291 291 /// Marks all bars in the list as needing a redraw.
292 -pub fn invalidate_bars(bars: ?*Bar) void {
292 +pub fn invalidateBars(bars: ?*Bar) void {
293 293 var current = bars;
294 294 while (current) |bar| {
295 295 bar.invalidate();
@@ -298,7 +298,7 @@ pub fn invalidate_bars(bars: ?*Bar) void {
298 298 }
299 299
300 300 /// Destroys all bars in the list and frees their resources.
301 -pub fn destroy_bars(bars: ?*Bar, display: *xlib.Display) void {
301 +pub fn destroyBars(bars: ?*Bar, display: *xlib.Display) void {
302 302 var current = bars;
303 303 while (current) |bar| {
304 304 const next = bar.next;
@@ -308,7 +308,7 @@ pub fn destroy_bars(bars: ?*Bar, display: *xlib.Display) void {
308 308 }
309 309
310 310 /// Returns the bar whose window matches `win`, or null.
311 -pub fn window_to_bar(bars: ?*Bar, win: xlib.Window) ?*Bar {
311 +pub fn windowToBar(bars: ?*Bar, win: xlib.Window) ?*Bar {
312 312 var current = bars;
313 313 while (current) |bar| {
314 314 if (bar.window == win) return bar;
@@ -317,7 +317,7 @@ pub fn window_to_bar(bars: ?*Bar, win: xlib.Window) ?*Bar {
317 317 return null;
318 318 }
319 319
320 -fn has_clients_on_tag(monitor: *Monitor, tag_mask: u32) bool {
320 +fn hasClientsOnTag(monitor: *Monitor, tag_mask: u32) bool {
321 321 var current = monitor.clients;
322 322 while (current) |client| {
323 323 if ((client.tags & tag_mask) != 0) return true;
+5 −5 src/bar/blocks/battery.zig
@@ -30,8 +30,8 @@ pub const Battery = struct {
30 30 pub fn content(self: *Battery, buffer: []u8) []const u8 {
31 31 var path_buf: [128]u8 = undefined;
32 32
33 - const capacity = self.read_battery_file(&path_buf, "capacity") orelse return buffer[0..0];
34 - const status = self.read_battery_status(&path_buf) orelse return buffer[0..0];
33 + const capacity = self.readBatteryFile(&path_buf, "capacity") orelse return buffer[0..0];
34 + const status = self.readBatteryStatus(&path_buf) orelse return buffer[0..0];
35 35
36 36 const format = switch (status) {
37 37 .charging => self.format_charging,
@@ -47,7 +47,7 @@ pub const Battery = struct {
47 47
48 48 const Status = enum { charging, discharging, full };
49 49
50 - fn read_battery_status(self: *Battery, path_buf: *[128]u8) ?Status {
50 + fn readBatteryStatus(self: *Battery, path_buf: *[128]u8) ?Status {
51 51 const path = std.fmt.bufPrint(path_buf, "/sys/class/power_supply/{s}/status", .{self.battery_name}) catch return null;
52 52
53 53 const file = std.fs.openFileAbsolute(path, .{}) catch return null;
@@ -64,7 +64,7 @@ pub const Battery = struct {
64 64 return .discharging;
65 65 }
66 66
67 - fn read_battery_file(self: *Battery, path_buf: *[128]u8, file_name: []const u8) ?u8 {
67 + fn readBatteryFile(self: *Battery, path_buf: *[128]u8, file_name: []const u8) ?u8 {
68 68 const path = std.fmt.bufPrint(path_buf, "/sys/class/power_supply/{s}/{s}", .{ self.battery_name, file_name }) catch return null;
69 69
70 70 const file = std.fs.openFileAbsolute(path, .{}) catch return null;
@@ -81,7 +81,7 @@ pub const Battery = struct {
81 81 return self.interval_secs;
82 82 }
83 83
84 - pub fn get_color(self: *Battery) c_ulong {
84 + pub fn getColor(self: *Battery) c_ulong {
85 85 return self.color;
86 86 }
87 87 };
+7 −7 src/bar/blocks/blocks.zig
@@ -23,7 +23,7 @@ pub const Block = struct {
23 23 cpu_temp: Cpu_Temp,
24 24 };
25 25
26 - pub fn init_static(text: []const u8, col: c_ulong, ul: bool) Block {
26 + pub fn initStatic(text: []const u8, col: c_ulong, ul: bool) Block {
27 27 var block = Block{
28 28 .data = .{ .static = Static.init(text, col) },
29 29 .last_update = 0,
@@ -36,7 +36,7 @@ pub const Block = struct {
36 36 return block;
37 37 }
38 38
39 - pub fn init_datetime(format: []const u8, datetime_format: []const u8, interval_secs: u64, col: c_ulong, ul: bool) Block {
39 + pub fn initDatetime(format: []const u8, datetime_format: []const u8, interval_secs: u64, col: c_ulong, ul: bool) Block {
40 40 return .{
41 41 .data = .{ .datetime = Date_Time.init(format, datetime_format, interval_secs, col) },
42 42 .last_update = 0,
@@ -46,7 +46,7 @@ pub const Block = struct {
46 46 };
47 47 }
48 48
49 - pub fn init_ram(format: []const u8, interval_secs: u64, col: c_ulong, ul: bool) Block {
49 + pub fn initRam(format: []const u8, interval_secs: u64, col: c_ulong, ul: bool) Block {
50 50 return .{
51 51 .data = .{ .ram = Ram.init(format, interval_secs, col) },
52 52 .last_update = 0,
@@ -56,7 +56,7 @@ pub const Block = struct {
56 56 };
57 57 }
58 58
59 - pub fn init_shell(format: []const u8, command: []const u8, interval_secs: u64, col: c_ulong, ul: bool) Block {
59 + pub fn initShell(format: []const u8, command: []const u8, interval_secs: u64, col: c_ulong, ul: bool) Block {
60 60 return .{
61 61 .data = .{ .shell = Shell.init(format, command, interval_secs, col) },
62 62 .last_update = 0,
@@ -66,7 +66,7 @@ pub const Block = struct {
66 66 };
67 67 }
68 68
69 - pub fn init_battery(
69 + pub fn initBattery(
70 70 format_charging: []const u8,
71 71 format_discharging: []const u8,
72 72 format_full: []const u8,
@@ -84,7 +84,7 @@ pub const Block = struct {
84 84 };
85 85 }
86 86
87 - pub fn init_cpu_temp(
87 + pub fn initCpuTemp(
88 88 format: []const u8,
89 89 thermal_zone: []const u8,
90 90 interval_secs: u64,
@@ -146,7 +146,7 @@ pub const Block = struct {
146 146 };
147 147 }
148 148
149 - pub fn get_content(self: *const Block) []const u8 {
149 + pub fn getContent(self: *const Block) []const u8 {
150 150 return self.cached_content[0..self.cached_len];
151 151 }
152 152 };
+9 −9 src/bar/blocks/cpu_temp.zig
@@ -23,11 +23,11 @@ pub const Cpu_Temp = struct {
23 23 .cached_path = undefined,
24 24 .cached_path_len = 0,
25 25 };
26 - self.detect_path();
26 + self.detectPath();
27 27 return self;
28 28 }
29 29
30 - fn detect_path(self: *Cpu_Temp) void {
30 + fn detectPath(self: *Cpu_Temp) void {
31 31 if (self.device.len > 0 and self.device[0] == '/') {
32 32 if (self.device.len <= self.cached_path.len) {
33 33 @memcpy(self.cached_path[0..self.device.len], self.device);
@@ -37,16 +37,16 @@ pub const Cpu_Temp = struct {
37 37 }
38 38
39 39 if (self.device.len > 0) {
40 - if (self.try_path("/sys/class/thermal/{s}/temp", self.device)) return;
41 - if (self.try_path("/sys/class/hwmon/{s}/temp1_input", self.device)) return;
40 + if (self.tryPath("/sys/class/thermal/{s}/temp", self.device)) return;
41 + if (self.tryPath("/sys/class/hwmon/{s}/temp1_input", self.device)) return;
42 42 }
43 43
44 - if (self.find_hwmon_cpu()) return;
44 + if (self.findHwmonCpu()) return;
45 45
46 - if (self.try_path("/sys/class/thermal/{s}/temp", "thermal_zone0")) return;
46 + if (self.tryPath("/sys/class/thermal/{s}/temp", "thermal_zone0")) return;
47 47 }
48 48
49 - fn try_path(self: *Cpu_Temp, comptime fmt: []const u8, device: []const u8) bool {
49 + fn tryPath(self: *Cpu_Temp, comptime fmt: []const u8, device: []const u8) bool {
50 50 const path = std.fmt.bufPrint(&self.cached_path, fmt, .{device}) catch return false;
51 51 const file = std.fs.openFileAbsolute(path, .{}) catch return false;
52 52 file.close();
@@ -54,7 +54,7 @@ pub const Cpu_Temp = struct {
54 54 return true;
55 55 }
56 56
57 - fn find_hwmon_cpu(self: *Cpu_Temp) bool {
57 + fn findHwmonCpu(self: *Cpu_Temp) bool {
58 58 var dir = std.fs.openDirAbsolute("/sys/class/hwmon", .{ .iterate = true }) catch return false;
59 59 defer dir.close();
60 60
@@ -107,7 +107,7 @@ pub const Cpu_Temp = struct {
107 107 return self.interval_secs;
108 108 }
109 109
110 - pub fn get_color(self: *Cpu_Temp) c_ulong {
110 + pub fn getColor(self: *Cpu_Temp) c_ulong {
111 111 return self.color;
112 112 }
113 113 };
+4 −4 src/bar/blocks/datetime.zig
@@ -42,10 +42,10 @@ pub const Date_Time = struct {
42 42 const next = self.datetime_format[fmt_idx + 1];
43 43 if (next == '-' and fmt_idx + 2 < self.datetime_format.len) {
44 44 const spec = self.datetime_format[fmt_idx + 2];
45 - dt_len += format_spec(spec, false, hours, minutes, seconds, day, month, year, dow, datetime_buf[dt_len..]);
45 + dt_len += formatSpec(spec, false, hours, minutes, seconds, day, month, year, dow, datetime_buf[dt_len..]);
46 46 fmt_idx += 3;
47 47 } else {
48 - dt_len += format_spec(next, true, hours, minutes, seconds, day, month, year, dow, datetime_buf[dt_len..]);
48 + dt_len += formatSpec(next, true, hours, minutes, seconds, day, month, year, dow, datetime_buf[dt_len..]);
49 49 fmt_idx += 2;
50 50 }
51 51 } else {
@@ -58,7 +58,7 @@ pub const Date_Time = struct {
58 58 return format_util.substitute(self.format, datetime_buf[0..dt_len], buffer);
59 59 }
60 60
61 - fn format_spec(spec: u8, pad: bool, hours: u32, minutes: u32, seconds: u32, day: u8, month: u8, year: i32, dow: i32, buf: []u8) usize {
61 + fn formatSpec(spec: u8, pad: bool, hours: u32, minutes: u32, seconds: u32, day: u8, month: u8, year: i32, dow: i32, buf: []u8) usize {
62 62 const day_names = [_][]const u8{ "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" };
63 63 const month_names = [_][]const u8{ "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" };
64 64
@@ -101,7 +101,7 @@ pub const Date_Time = struct {
101 101 return self.interval_secs;
102 102 }
103 103
104 - pub fn get_color(self: *Date_Time) c_ulong {
104 + pub fn getColor(self: *Date_Time) c_ulong {
105 105 return self.color;
106 106 }
107 107 };
+1 −1 src/bar/blocks/format.zig
@@ -21,7 +21,7 @@ pub fn substitute(format: []const u8, value: []const u8, buffer: []u8) []const u
21 21 return buffer[0..out_idx];
22 22 }
23 23
24 -pub fn substitute_multi(format: []const u8, values: []const []const u8, buffer: []u8) []const u8 {
24 +pub fn substituteMulti(format: []const u8, values: []const []const u8, buffer: []u8) []const u8 {
25 25 if (format.len == 0 and values.len > 0) {
26 26 const len = @min(values[0].len, buffer.len);
27 27 @memcpy(buffer[0..len], values[0][0..len]);
+4 −4 src/bar/blocks/ram.zig
@@ -27,9 +27,9 @@ pub const Ram = struct {
27 27 var lines = std.mem.splitScalar(u8, file_content, '\n');
28 28 while (lines.next()) |line| {
29 29 if (std.mem.startsWith(u8, line, "MemTotal:")) {
30 - total = parse_mem_value(line);
30 + total = parseMemValue(line);
31 31 } else if (std.mem.startsWith(u8, line, "MemAvailable:")) {
32 - available = parse_mem_value(line);
32 + available = parseMemValue(line);
33 33 }
34 34 }
35 35
@@ -56,12 +56,12 @@ pub const Ram = struct {
56 56 return self.interval_secs;
57 57 }
58 58
59 - pub fn get_color(self: *Ram) c_ulong {
59 + pub fn getColor(self: *Ram) c_ulong {
60 60 return self.color;
61 61 }
62 62 };
63 63
64 -fn parse_mem_value(line: []const u8) u64 {
64 +fn parseMemValue(line: []const u8) u64 {
65 65 var iter = std.mem.tokenizeAny(u8, line, ": \tkB");
66 66 _ = iter.next();
67 67 if (iter.next()) |value_str| {
+1 −1 src/bar/blocks/shell.zig
@@ -39,7 +39,7 @@ pub const Shell = struct {
39 39 return self.interval_secs;
40 40 }
41 41
42 - pub fn get_color(self: *Shell) c_ulong {
42 + pub fn getColor(self: *Shell) c_ulong {
43 43 return self.color;
44 44 }
45 45 };
+1 −1 src/bar/blocks/static.zig
@@ -18,7 +18,7 @@ pub const Static = struct {
18 18 return 0;
19 19 }
20 20
21 - pub fn get_color(self: *Static) c_ulong {
21 + pub fn getColor(self: *Static) c_ulong {
22 22 return self.color;
23 23 }
24 24 };
+17 −17 src/client.zig
@@ -73,7 +73,7 @@ pub fn detach(client: *Client) void {
73 73 }
74 74
75 75 /// Prepends `client` to the front of its monitor's focus stack.
76 -pub fn attach_stack(client: *Client) void {
76 +pub fn attachStack(client: *Client) void {
77 77 if (client.monitor) |monitor| {
78 78 client.stack_next = monitor.stack;
79 79 monitor.stack = client;
@@ -81,7 +81,7 @@ pub fn attach_stack(client: *Client) void {
81 81 }
82 82
83 83 /// Removes `client` from its monitor's focus stack.
84 -pub fn detach_stack(client: *Client) void {
84 +pub fn detachStack(client: *Client) void {
85 85 if (client.monitor) |monitor| {
86 86 var current_ptr: *?*Client = &monitor.stack;
87 87 while (current_ptr.*) |current| {
@@ -97,7 +97,7 @@ pub fn detach_stack(client: *Client) void {
97 97 /// Searches all monitors for a client whose X window matches `window`.
98 98 ///
99 99 /// `monitors` is the head of the monitor linked list.
100 -pub fn window_to_client(monitors: ?*Monitor, window: xlib.Window) ?*Client {
100 +pub fn windowToClient(monitors: ?*Monitor, window: xlib.Window) ?*Client {
101 101 var current_monitor = monitors;
102 102 while (current_monitor) |monitor| {
103 103 var current_client = monitor.clients;
@@ -112,7 +112,7 @@ pub fn window_to_client(monitors: ?*Monitor, window: xlib.Window) ?*Client {
112 112
113 113 /// Returns true if `client` is visible on its monitor's currently selected
114 114 /// tag set.
115 -pub fn is_visible(client: *Client) bool {
115 +pub fn isVisible(client: *Client) bool {
116 116 if (client.monitor) |monitor| {
117 117 return (client.tags & monitor.tagset[monitor.sel_tags]) != 0;
118 118 }
@@ -120,15 +120,15 @@ pub fn is_visible(client: *Client) bool {
120 120 }
121 121
122 122 /// Returns true if `client` is visible on the given tag bitmask.
123 -pub fn is_visible_on_tag(client: *Client, tags: u32) bool {
123 +pub fn isVisibleOnTag(client: *Client, tags: u32) bool {
124 124 return (client.tags & tags) != 0;
125 125 }
126 126
127 127 /// Returns the first non-floating, visible client at or after `client`.
128 -pub fn next_tiled(client: ?*Client) ?*Client {
128 +pub fn nextTiled(client: ?*Client) ?*Client {
129 129 var current = client;
130 130 while (current) |iter| {
131 - if (!iter.is_floating and is_visible(iter)) return iter;
131 + if (!iter.is_floating and isVisible(iter)) return iter;
132 132 current = iter.next;
133 133 }
134 134 return null;
@@ -136,11 +136,11 @@ pub fn next_tiled(client: ?*Client) ?*Client {
136 136
137 137 /// Returns the first non-floating client on `client`'s monitor that shares
138 138 /// any tag with `client`. Used for `attach_aside` ordering.
139 -pub fn next_tagged(client: *Client) ?*Client {
139 +pub fn nextTagged(client: *Client) ?*Client {
140 140 const monitor = client.monitor orelse return null;
141 141 var walked = monitor.clients;
142 142 while (walked) |iter| {
143 - if (!iter.is_floating and is_visible_on_tag(iter, client.tags)) return iter;
143 + if (!iter.is_floating and isVisibleOnTag(iter, client.tags)) return iter;
144 144 walked = iter.next;
145 145 }
146 146 return null;
@@ -148,8 +148,8 @@ pub fn next_tagged(client: *Client) ?*Client {
148 148
149 149 /// Inserts `client` just after the first client that shares its tags,
150 150 /// falling back to prepend if none exists.
151 -pub fn attach_aside(client: *Client) void {
152 - const at = next_tagged(client);
151 +pub fn attachAside(client: *Client) void {
152 + const at = nextTagged(client);
153 153 if (at == null) {
154 154 attach(client);
155 155 return;
@@ -159,19 +159,19 @@ pub fn attach_aside(client: *Client) void {
159 159 }
160 160
161 161 /// Counts non-floating, visible clients on `monitor`.
162 -pub fn count_tiled(monitor: *Monitor) u32 {
162 +pub fn countTiled(monitor: *Monitor) u32 {
163 163 var count: u32 = 0;
164 - var current = next_tiled(monitor.clients);
164 + var current = nextTiled(monitor.clients);
165 165 while (current) |client| {
166 166 count += 1;
167 - current = next_tiled(client.next);
167 + current = nextTiled(client.next);
168 168 }
169 169 return count;
170 170 }
171 171
172 172 /// Returns the tiled client on `monitor` whose bounds contain (`point_x`,
173 173 /// `point_y`), excluding `exclude`. Returns null if none found.
174 -pub fn tiled_window_at(exclude: *Client, monitor: *Monitor, point_x: i32, point_y: i32) ?*Client {
174 +pub fn tiledWindowAt(exclude: *Client, monitor: *Monitor, point_x: i32, point_y: i32) ?*Client {
175 175 const tags = monitor.tagset[monitor.sel_tags];
176 176 var current = monitor.clients;
177 177
@@ -193,7 +193,7 @@ pub fn tiled_window_at(exclude: *Client, monitor: *Monitor, point_x: i32, point_
193 193
194 194 /// Moves `client` to just before `target` in the monitor's client list.
195 195 /// Does nothing if they are on different monitors.
196 -pub fn insert_before(client: *Client, target: *Client) void {
196 +pub fn insertBefore(client: *Client, target: *Client) void {
197 197 const monitor = target.monitor orelse return;
198 198 if (client.monitor != monitor) return;
199 199
@@ -218,7 +218,7 @@ pub fn insert_before(client: *Client, target: *Client) void {
218 218
219 219 /// Swaps the positions of `client_a` and `client_b` in their shared monitor's
220 220 /// client list. Does nothing if they are on different monitors.
221 -pub fn swap_clients(client_a: *Client, client_b: *Client) void {
221 +pub fn swapClients(client_a: *Client, client_b: *Client) void {
222 222 const monitor = client_a.monitor orelse return;
223 223 if (client_b.monitor != monitor) return;
224 224
+39 −39 src/config/config.zig
@@ -164,83 +164,83 @@ pub const Config = struct {
164 164 self.autostart.deinit(self.allocator);
165 165 }
166 166
167 - pub fn add_keybind(self: *Config, keybind: Keybind) !void {
167 + pub fn addKeybind(self: *Config, keybind: Keybind) !void {
168 168 try self.keybinds.append(self.allocator, keybind);
169 169 }
170 170
171 - pub fn add_rule(self: *Config, rule: Rule) !void {
171 + pub fn addRule(self: *Config, rule: Rule) !void {
172 172 try self.rules.append(self.allocator, rule);
173 173 }
174 174
175 - pub fn add_block(self: *Config, block: Block) !void {
175 + pub fn addBlock(self: *Config, block: Block) !void {
176 176 try self.blocks.append(self.allocator, block);
177 177 }
178 178
179 - pub fn add_button(self: *Config, button: Mouse_Button) !void {
179 + pub fn addButton(self: *Config, button: Mouse_Button) !void {
180 180 try self.buttons.append(self.allocator, button);
181 181 }
182 182
183 - pub fn add_autostart(self: *Config, cmd: []const u8) !void {
183 + pub fn addAutostart(self: *Config, cmd: []const u8) !void {
184 184 try self.autostart.append(self.allocator, cmd);
185 185 }
186 186 };
187 187
188 -pub fn initialize_default_config(cfg: *Config) void {
188 +pub fn initializeDefaultConfig(cfg: *Config) void {
189 189 const mod_key: u32 = 1 << 6;
190 190 const shift_key: u32 = 1 << 0;
191 191 const control_key: u32 = 1 << 2;
192 192
193 - cfg.add_keybind(make_keybind(mod_key, 0xff0d, .spawn_terminal)) catch {};
194 - cfg.add_keybind(make_keybind_str(mod_key, 'd', .spawn, "rofi -show drun")) catch {};
195 - cfg.add_keybind(make_keybind_str(mod_key, 's', .spawn, "maim -s | xclip -selection clipboard -t image/png")) catch {};
196 - cfg.add_keybind(make_keybind(mod_key, 'q', .kill_client)) catch {};
197 - cfg.add_keybind(make_keybind(mod_key | shift_key, 'q', .quit)) catch {};
198 - cfg.add_keybind(make_keybind(mod_key | shift_key, 'r', .reload_config)) catch {};
199 - cfg.add_keybind(make_keybind(mod_key, 'j', .focus_next)) catch {};
200 - cfg.add_keybind(make_keybind(mod_key, 'k', .focus_prev)) catch {};
201 - cfg.add_keybind(make_keybind(mod_key | shift_key, 'j', .move_next)) catch {};
202 - cfg.add_keybind(make_keybind(mod_key | shift_key, 'k', .move_prev)) catch {};
203 - cfg.add_keybind(make_keybind_int(mod_key, 'h', .resize_master, -50)) catch {};
204 - cfg.add_keybind(make_keybind_int(mod_key, 'l', .resize_master, 50)) catch {};
205 - cfg.add_keybind(make_keybind(mod_key, 'i', .inc_master)) catch {};
206 - cfg.add_keybind(make_keybind(mod_key, 'p', .dec_master)) catch {};
207 - cfg.add_keybind(make_keybind(mod_key, 'a', .toggle_gaps)) catch {};
208 - cfg.add_keybind(make_keybind(mod_key, 'f', .toggle_fullscreen)) catch {};
209 - cfg.add_keybind(make_keybind(mod_key, 0x0020, .toggle_floating)) catch {};
210 - cfg.add_keybind(make_keybind(mod_key, 'n', .cycle_layout)) catch {};
211 - cfg.add_keybind(make_keybind_int(mod_key, 0x002c, .focus_monitor, -1)) catch {};
212 - cfg.add_keybind(make_keybind_int(mod_key, 0x002e, .focus_monitor, 1)) catch {};
213 - cfg.add_keybind(make_keybind_int(mod_key | shift_key, 0x002c, .send_to_monitor, -1)) catch {};
214 - cfg.add_keybind(make_keybind_int(mod_key | shift_key, 0x002e, .send_to_monitor, 1)) catch {};
193 + cfg.addKeybind(makeKeybind(mod_key, 0xff0d, .spawn_terminal)) catch {};
194 + cfg.addKeybind(makeKeybindStr(mod_key, 'd', .spawn, "rofi -show drun")) catch {};
195 + cfg.addKeybind(makeKeybindStr(mod_key, 's', .spawn, "maim -s | xclip -selection clipboard -t image/png")) catch {};
196 + cfg.addKeybind(makeKeybind(mod_key, 'q', .kill_client)) catch {};
197 + cfg.addKeybind(makeKeybind(mod_key | shift_key, 'q', .quit)) catch {};
198 + cfg.addKeybind(makeKeybind(mod_key | shift_key, 'r', .reload_config)) catch {};
199 + cfg.addKeybind(makeKeybind(mod_key, 'j', .focus_next)) catch {};
200 + cfg.addKeybind(makeKeybind(mod_key, 'k', .focus_prev)) catch {};
201 + cfg.addKeybind(makeKeybind(mod_key | shift_key, 'j', .move_next)) catch {};
202 + cfg.addKeybind(makeKeybind(mod_key | shift_key, 'k', .move_prev)) catch {};
203 + cfg.addKeybind(makeKeybindInt(mod_key, 'h', .resize_master, -50)) catch {};
204 + cfg.addKeybind(makeKeybindInt(mod_key, 'l', .resize_master, 50)) catch {};
205 + cfg.addKeybind(makeKeybind(mod_key, 'i', .inc_master)) catch {};
206 + cfg.addKeybind(makeKeybind(mod_key, 'p', .dec_master)) catch {};
207 + cfg.addKeybind(makeKeybind(mod_key, 'a', .toggle_gaps)) catch {};
208 + cfg.addKeybind(makeKeybind(mod_key, 'f', .toggle_fullscreen)) catch {};
209 + cfg.addKeybind(makeKeybind(mod_key, 0x0020, .toggle_floating)) catch {};
210 + cfg.addKeybind(makeKeybind(mod_key, 'n', .cycle_layout)) catch {};
211 + cfg.addKeybind(makeKeybindInt(mod_key, 0x002c, .focus_monitor, -1)) catch {};
212 + cfg.addKeybind(makeKeybindInt(mod_key, 0x002e, .focus_monitor, 1)) catch {};
213 + cfg.addKeybind(makeKeybindInt(mod_key | shift_key, 0x002c, .send_to_monitor, -1)) catch {};
214 + cfg.addKeybind(makeKeybindInt(mod_key | shift_key, 0x002e, .send_to_monitor, 1)) catch {};
215 215
216 216 var tag_index: i32 = 0;
217 217 while (tag_index < 9) : (tag_index += 1) {
218 218 const keysym: u64 = @as(u64, '1') + @as(u64, @intCast(tag_index));
219 - cfg.add_keybind(make_keybind_int(mod_key, keysym, .view_tag, tag_index)) catch {};
220 - cfg.add_keybind(make_keybind_int(mod_key | shift_key, keysym, .move_to_tag, tag_index)) catch {};
221 - cfg.add_keybind(make_keybind_int(mod_key | control_key, keysym, .toggle_view_tag, tag_index)) catch {};
222 - cfg.add_keybind(make_keybind_int(mod_key | control_key | shift_key, keysym, .toggle_tag, tag_index)) catch {};
219 + cfg.addKeybind(makeKeybindInt(mod_key, keysym, .view_tag, tag_index)) catch {};
220 + cfg.addKeybind(makeKeybindInt(mod_key | shift_key, keysym, .move_to_tag, tag_index)) catch {};
221 + cfg.addKeybind(makeKeybindInt(mod_key | control_key, keysym, .toggle_view_tag, tag_index)) catch {};
222 + cfg.addKeybind(makeKeybindInt(mod_key | control_key | shift_key, keysym, .toggle_tag, tag_index)) catch {};
223 223 }
224 224
225 - cfg.add_button(.{ .click = .client_win, .mod_mask = mod_key, .button = 1, .action = .move_mouse }) catch {};
226 - cfg.add_button(.{ .click = .client_win, .mod_mask = mod_key, .button = 3, .action = .resize_mouse }) catch {};
225 + cfg.addButton(.{ .click = .client_win, .mod_mask = mod_key, .button = 1, .action = .move_mouse }) catch {};
226 + cfg.addButton(.{ .click = .client_win, .mod_mask = mod_key, .button = 3, .action = .resize_mouse }) catch {};
227 227 }
228 228
229 -fn make_keybind(mod: u32, key: u64, action: Action) Keybind {
229 +fn makeKeybind(mod: u32, key: u64, action: Action) Keybind {
230 230 var kb: Keybind = .{ .action = action };
231 231 kb.keys[0] = .{ .mod_mask = mod, .keysym = key };
232 232 kb.key_count = 1;
233 233 return kb;
234 234 }
235 235
236 -fn make_keybind_int(mod: u32, key: u64, action: Action, int_arg: i32) Keybind {
237 - var kb = make_keybind(mod, key, action);
236 +fn makeKeybindInt(mod: u32, key: u64, action: Action, int_arg: i32) Keybind {
237 + var kb = makeKeybind(mod, key, action);
238 238 kb.int_arg = int_arg;
239 239 return kb;
240 240 }
241 241
242 -fn make_keybind_str(mod: u32, key: u64, action: Action, str_arg: []const u8) Keybind {
243 - var kb = make_keybind(mod, key, action);
242 +fn makeKeybindStr(mod: u32, key: u64, action: Action, str_arg: []const u8) Keybind {
243 + var kb = makeKeybind(mod, key, action);
244 244 kb.str_arg = str_arg;
245 245 return kb;
246 246 }
+256 −256 src/config/lua.zig Large diff collapsed, click to expand
@@ -25,7 +25,7 @@ pub fn init(cfg: *Config) bool {
25 25 L = c.luaL_newstate();
26 26 if (L == null) return false;
27 27 c.luaL_openlibs(L);
28 - register_api();
28 + registerApi();
29 29 return true;
30 30 }
31 31
@@ -37,7 +37,7 @@ pub fn deinit() void {
37 37 config = null;
38 38 }
39 39
40 -pub fn load_file(path: []const u8) bool {
40 +pub fn loadFile(path: []const u8) bool {
41 41 const state = L orelse return false;
42 42 var path_buf: [512]u8 = undefined;
43 43 if (path.len >= path_buf.len) return false;
@@ -75,224 +75,224 @@ pub fn load_file(path: []const u8) bool {
75 75 return true;
76 76 }
77 77
78 -pub fn load_config() bool {
78 +pub fn loadConfig() bool {
79 79 const home = std.posix.getenv("HOME") orelse return false;
80 80 var path_buf: [512]u8 = undefined;
81 81 const path = std.fmt.bufPrint(&path_buf, "{s}/.config/oxwm/config.lua", .{home}) catch return false;
82 - return load_file(path);
82 + return loadFile(path);
83 83 }
84 84
85 -fn register_api() void {
85 +fn registerApi() void {
86 86 const state = L orelse return;
87 87
88 88 c.lua_createtable(state, 0, 16);
89 89
90 - register_spawn_functions(state);
91 - register_key_module(state);
92 - register_gaps_module(state);
93 - register_border_module(state);
94 - register_client_module(state);
95 - register_layout_module(state);
96 - register_tag_module(state);
97 - register_monitor_module(state);
98 - register_rule_module(state);
99 - register_bar_module(state);
100 - register_misc_functions(state);
90 + registerSpawnFunctions(state);
91 + registerKeyModule(state);
92 + registerGapsModule(state);
93 + registerBorderModule(state);
94 + registerClientModule(state);
95 + registerLayoutModule(state);
96 + registerTagModule(state);
97 + registerMonitorModule(state);
98 + registerRuleModule(state);
99 + registerBarModule(state);
100 + registerMiscFunctions(state);
101 101
102 102 c.lua_setglobal(state, "oxwm");
103 103 }
104 104
105 -fn register_spawn_functions(state: *c.lua_State) void {
106 - c.lua_pushcfunction(state, lua_spawn);
105 +fn registerSpawnFunctions(state: *c.lua_State) void {
106 + c.lua_pushcfunction(state, luaSpawn);
107 107 c.lua_setfield(state, -2, "spawn");
108 108
109 - c.lua_pushcfunction(state, lua_spawn_terminal);
109 + c.lua_pushcfunction(state, luaSpawnTerminal);
110 110 c.lua_setfield(state, -2, "spawn_terminal");
111 111 }
112 112
113 -fn register_key_module(state: *c.lua_State) void {
113 +fn registerKeyModule(state: *c.lua_State) void {
114 114 c.lua_createtable(state, 0, 2);
115 115
116 - c.lua_pushcfunction(state, lua_key_bind);
116 + c.lua_pushcfunction(state, luaKeyBind);
117 117 c.lua_setfield(state, -2, "bind");
118 118
119 - c.lua_pushcfunction(state, lua_key_chord);
119 + c.lua_pushcfunction(state, luaKeyChord);
120 120 c.lua_setfield(state, -2, "chord");
121 121
122 122 c.lua_setfield(state, -2, "key");
123 123 }
124 124
125 -fn register_gaps_module(state: *c.lua_State) void {
125 +fn registerGapsModule(state: *c.lua_State) void {
126 126 c.lua_createtable(state, 0, 6);
127 127
128 - c.lua_pushcfunction(state, lua_gaps_set_enabled);
128 + c.lua_pushcfunction(state, luaGapsSetEnabled);
129 129 c.lua_setfield(state, -2, "set_enabled");
130 130
131 - c.lua_pushcfunction(state, lua_gaps_enable);
131 + c.lua_pushcfunction(state, luaGapsEnable);
132 132 c.lua_setfield(state, -2, "enable");
133 133
134 - c.lua_pushcfunction(state, lua_gaps_disable);
134 + c.lua_pushcfunction(state, luaGapsDisable);
135 135 c.lua_setfield(state, -2, "disable");
136 136
137 - c.lua_pushcfunction(state, lua_gaps_set_inner);
137 + c.lua_pushcfunction(state, luaGapsSetInner);
138 138 c.lua_setfield(state, -2, "set_inner");
139 139
140 - c.lua_pushcfunction(state, lua_gaps_set_outer);
140 + c.lua_pushcfunction(state, luaGapsSetOuter);
141 141 c.lua_setfield(state, -2, "set_outer");
142 142
143 - c.lua_pushcfunction(state, lua_gaps_set_smart);
143 + c.lua_pushcfunction(state, luaGapsSetSmart);
144 144 c.lua_setfield(state, -2, "set_smart");
145 145
146 146 c.lua_setfield(state, -2, "gaps");
147 147 }
148 148
149 -fn register_border_module(state: *c.lua_State) void {
149 +fn registerBorderModule(state: *c.lua_State) void {
150 150 c.lua_createtable(state, 0, 3);
151 151
152 - c.lua_pushcfunction(state, lua_border_set_width);
152 + c.lua_pushcfunction(state, luaBorderSetWidth);
153 153 c.lua_setfield(state, -2, "set_width");
154 154
155 - c.lua_pushcfunction(state, lua_border_set_focused_color);
155 + c.lua_pushcfunction(state, luaBorderSetFocusedColor);
156 156 c.lua_setfield(state, -2, "set_focused_color");
157 157
158 - c.lua_pushcfunction(state, lua_border_set_unfocused_color);
158 + c.lua_pushcfunction(state, luaBorderSetUnfocusedColor);
159 159 c.lua_setfield(state, -2, "set_unfocused_color");
160 160
161 161 c.lua_setfield(state, -2, "border");
162 162 }
163 163
164 -fn register_client_module(state: *c.lua_State) void {
164 +fn registerClientModule(state: *c.lua_State) void {
165 165 c.lua_createtable(state, 0, 5);
166 166
167 - c.lua_pushcfunction(state, lua_client_kill);
167 + c.lua_pushcfunction(state, luaClientKill);
168 168 c.lua_setfield(state, -2, "kill");
169 169
170 - c.lua_pushcfunction(state, lua_client_toggle_fullscreen);
170 + c.lua_pushcfunction(state, luaClientToggleFullscreen);
171 171 c.lua_setfield(state, -2, "toggle_fullscreen");
172 172
173 - c.lua_pushcfunction(state, lua_client_toggle_floating);
173 + c.lua_pushcfunction(state, luaClientToggleFloating);
174 174 c.lua_setfield(state, -2, "toggle_floating");
175 175
176 - c.lua_pushcfunction(state, lua_client_focus_stack);
176 + c.lua_pushcfunction(state, luaClientFocusStack);
177 177 c.lua_setfield(state, -2, "focus_stack");
178 178
179 - c.lua_pushcfunction(state, lua_client_move_stack);
179 + c.lua_pushcfunction(state, luaClientMoveStack);
180 180 c.lua_setfield(state, -2, "move_stack");
181 181
182 182 c.lua_setfield(state, -2, "client");
183 183 }
184 184
185 -fn register_layout_module(state: *c.lua_State) void {
185 +fn registerLayoutModule(state: *c.lua_State) void {
186 186 c.lua_createtable(state, 0, 4);
187 187
188 - c.lua_pushcfunction(state, lua_layout_cycle);
188 + c.lua_pushcfunction(state, luaLayoutCycle);
189 189 c.lua_setfield(state, -2, "cycle");
190 190
191 - c.lua_pushcfunction(state, lua_layout_set);
191 + c.lua_pushcfunction(state, luaLayoutSet);
192 192 c.lua_setfield(state, -2, "set");
193 193
194 - c.lua_pushcfunction(state, lua_layout_scroll_left);
194 + c.lua_pushcfunction(state, luaLayoutScrollLeft);
195 195 c.lua_setfield(state, -2, "scroll_left");
196 196
197 - c.lua_pushcfunction(state, lua_layout_scroll_right);
197 + c.lua_pushcfunction(state, luaLayoutScrollRight);
198 198 c.lua_setfield(state, -2, "scroll_right");
199 199
200 200 c.lua_setfield(state, -2, "layout");
201 201 }
202 202
203 -fn register_tag_module(state: *c.lua_State) void {
203 +fn registerTagModule(state: *c.lua_State) void {
204 204 c.lua_createtable(state, 0, 10);
205 205
206 - c.lua_pushcfunction(state, lua_tag_view);
206 + c.lua_pushcfunction(state, luaTagView);
207 207 c.lua_setfield(state, -2, "view");
208 208
209 - c.lua_pushcfunction(state, lua_tag_view_next);
209 + c.lua_pushcfunction(state, luaTagViewNext);
210 210 c.lua_setfield(state, -2, "view_next");
211 211
212 - c.lua_pushcfunction(state, lua_tag_view_previous);
212 + c.lua_pushcfunction(state, luaTagViewPrevious);
213 213 c.lua_setfield(state, -2, "view_previous");
214 214
215 - c.lua_pushcfunction(state, lua_tag_view_next_nonempty);
215 + c.lua_pushcfunction(state, luaTagViewNextNonempty);
216 216 c.lua_setfield(state, -2, "view_next_nonempty");
217 217
218 - c.lua_pushcfunction(state, lua_tag_view_previous_nonempty);
218 + c.lua_pushcfunction(state, luaTagViewPreviousNonempty);
219 219 c.lua_setfield(state, -2, "view_previous_nonempty");
220 220
221 - c.lua_pushcfunction(state, lua_tag_toggleview);
221 + c.lua_pushcfunction(state, luaTagToggleview);
222 222 c.lua_setfield(state, -2, "toggleview");
223 223
224 - c.lua_pushcfunction(state, lua_tag_move_to);
224 + c.lua_pushcfunction(state, luaTagMoveTo);
225 225 c.lua_setfield(state, -2, "move_to");
226 226
227 - c.lua_pushcfunction(state, lua_tag_toggletag);
227 + c.lua_pushcfunction(state, luaTagToggletag);
228 228 c.lua_setfield(state, -2, "toggletag");
229 229
230 - c.lua_pushcfunction(state, lua_tag_set_back_and_forth);
230 + c.lua_pushcfunction(state, luaTagSetBackAndForth);
231 231 c.lua_setfield(state, -2, "set_back_and_forth");
232 232
233 233 c.lua_setfield(state, -2, "tag");
234 234 }
235 235
236 -fn register_monitor_module(state: *c.lua_State) void {
236 +fn registerMonitorModule(state: *c.lua_State) void {
237 237 c.lua_createtable(state, 0, 2);
238 238
239 - c.lua_pushcfunction(state, lua_monitor_focus);
239 + c.lua_pushcfunction(state, luaMonitorFocus);
240 240 c.lua_setfield(state, -2, "focus");
241 241
242 - c.lua_pushcfunction(state, lua_monitor_tag);
242 + c.lua_pushcfunction(state, luaMonitorTag);
243 243 c.lua_setfield(state, -2, "tag");
244 244
245 245 c.lua_setfield(state, -2, "monitor");
246 246 }
247 247
248 -fn register_rule_module(state: *c.lua_State) void {
248 +fn registerRuleModule(state: *c.lua_State) void {
249 249 c.lua_createtable(state, 0, 1);
250 250
251 - c.lua_pushcfunction(state, lua_rule_add);
251 + c.lua_pushcfunction(state, luaRuleAdd);
252 252 c.lua_setfield(state, -2, "add");
253 253
254 254 c.lua_setfield(state, -2, "rule");
255 255 }
256 256
257 -fn register_bar_module(state: *c.lua_State) void {
257 +fn registerBarModule(state: *c.lua_State) void {
258 258 c.lua_createtable(state, 0, 10);
259 259
260 - c.lua_pushcfunction(state, lua_bar_set_font);
260 + c.lua_pushcfunction(state, luaBarSetFont);
261 261 c.lua_setfield(state, -2, "set_font");
262 262
263 - c.lua_pushcfunction(state, lua_bar_set_blocks);
263 + c.lua_pushcfunction(state, luaBarSetBlocks);
264 264 c.lua_setfield(state, -2, "set_blocks");
265 265
266 - c.lua_pushcfunction(state, lua_bar_set_scheme_normal);
266 + c.lua_pushcfunction(state, luaBarSetSchemeNormal);
267 267 c.lua_setfield(state, -2, "set_scheme_normal");
268 268
269 - c.lua_pushcfunction(state, lua_bar_set_scheme_selected);
269 + c.lua_pushcfunction(state, luaBarSetSchemeSelected);
270 270 c.lua_setfield(state, -2, "set_scheme_selected");
271 271
272 - c.lua_pushcfunction(state, lua_bar_set_scheme_occupied);
272 + c.lua_pushcfunction(state, luaBarSetSchemeOccupied);
273 273 c.lua_setfield(state, -2, "set_scheme_occupied");
274 274
275 - c.lua_pushcfunction(state, lua_bar_set_scheme_urgent);
275 + c.lua_pushcfunction(state, luaBarSetSchemeUrgent);
276 276 c.lua_setfield(state, -2, "set_scheme_urgent");
277 277
278 - c.lua_pushcfunction(state, lua_bar_set_hide_vacant_tags);
278 + c.lua_pushcfunction(state, luaBarSetHideVacantTags);
279 279 c.lua_setfield(state, -2, "set_hide_vacant_tags");
280 280
281 281 c.lua_createtable(state, 0, 6);
282 282
283 - c.lua_pushcfunction(state, lua_bar_block_ram);
283 + c.lua_pushcfunction(state, luaBarBlockRam);
284 284 c.lua_setfield(state, -2, "ram");
285 285
286 - c.lua_pushcfunction(state, lua_bar_block_datetime);
286 + c.lua_pushcfunction(state, luaBarBlockDatetime);
287 287 c.lua_setfield(state, -2, "datetime");
288 288
289 - c.lua_pushcfunction(state, lua_bar_block_shell);
289 + c.lua_pushcfunction(state, luaBarBlockShell);
290 290 c.lua_setfield(state, -2, "shell");
291 291
292 - c.lua_pushcfunction(state, lua_bar_block_static);
292 + c.lua_pushcfunction(state, luaBarBlockStatic);
293 293 c.lua_setfield(state, -2, "static");
294 294
295 - c.lua_pushcfunction(state, lua_bar_block_battery);
295 + c.lua_pushcfunction(state, luaBarBlockBattery);
296 296 c.lua_setfield(state, -2, "battery");
297 297
298 298 c.lua_setfield(state, -2, "block");
@@ -300,51 +300,51 @@ fn register_bar_module(state: *c.lua_State) void {
300 300 c.lua_setfield(state, -2, "bar");
301 301 }
302 302
303 -fn register_misc_functions(state: *c.lua_State) void {
304 - c.lua_pushcfunction(state, lua_set_terminal);
303 +fn registerMiscFunctions(state: *c.lua_State) void {
304 + c.lua_pushcfunction(state, luaSetTerminal);
305 305 c.lua_setfield(state, -2, "set_terminal");
306 306
307 - c.lua_pushcfunction(state, lua_set_modkey);
307 + c.lua_pushcfunction(state, luaSetModkey);
308 308 c.lua_setfield(state, -2, "set_modkey");
309 309
310 - c.lua_pushcfunction(state, lua_set_tags);
310 + c.lua_pushcfunction(state, luaSetTags);
311 311 c.lua_setfield(state, -2, "set_tags");
312 312
313 - c.lua_pushcfunction(state, lua_set_layout_symbol);
313 + c.lua_pushcfunction(state, luaSetLayoutSymbol);
314 314 c.lua_setfield(state, -2, "set_layout_symbol");
315 315
316 - c.lua_pushcfunction(state, lua_autostart);
316 + c.lua_pushcfunction(state, luaAutostart);
317 317 c.lua_setfield(state, -2, "autostart");
318 318
319 - c.lua_pushcfunction(state, lua_auto_tile);
319 + c.lua_pushcfunction(state, luaAutoTile);
320 320 c.lua_setfield(state, -2, "auto_tile");
321 321
322 - c.lua_pushcfunction(state, lua_quit);
322 + c.lua_pushcfunction(state, luaQuit);
323 323 c.lua_setfield(state, -2, "quit");
324 324
325 - c.lua_pushcfunction(state, lua_restart);
325 + c.lua_pushcfunction(state, luaRestart);
326 326 c.lua_setfield(state, -2, "restart");
327 327
328 - c.lua_pushcfunction(state, lua_toggle_gaps);
328 + c.lua_pushcfunction(state, luaToggleGaps);
329 329 c.lua_setfield(state, -2, "toggle_gaps");
330 330
331 - c.lua_pushcfunction(state, lua_show_keybinds);
331 + c.lua_pushcfunction(state, luaShowKeybinds);
332 332 c.lua_setfield(state, -2, "show_keybinds");
333 333
334 - c.lua_pushcfunction(state, lua_set_master_factor);
334 + c.lua_pushcfunction(state, luaSetMasterFactor);
335 335 c.lua_setfield(state, -2, "set_master_factor");
336 336
337 - c.lua_pushcfunction(state, lua_inc_num_master);
337 + c.lua_pushcfunction(state, luaIncNumMaster);
338 338 c.lua_setfield(state, -2, "inc_num_master");
339 339 }
340 340
341 -fn create_action_table(state: *c.lua_State, action_name: [*:0]const u8) void {
341 +fn createActionTable(state: *c.lua_State, action_name: [*:0]const u8) void {
342 342 c.lua_createtable(state, 0, 2);
343 343 _ = c.lua_pushstring(state, action_name);
344 344 c.lua_setfield(state, -2, "__action");
345 345 }
346 346
347 -fn create_action_table_with_int(state: *c.lua_State, action_name: [*:0]const u8, arg: i32) void {
347 +fn createActionTableWithInt(state: *c.lua_State, action_name: [*:0]const u8, arg: i32) void {
348 348 c.lua_createtable(state, 0, 2);
349 349 _ = c.lua_pushstring(state, action_name);
350 350 c.lua_setfield(state, -2, "__action");
@@ -352,7 +352,7 @@ fn create_action_table_with_int(state: *c.lua_State, action_name: [*:0]const u8,
352 352 c.lua_setfield(state, -2, "__arg");
353 353 }
354 354
355 -fn create_action_table_with_string(state: *c.lua_State, action_name: [*:0]const u8) void {
355 +fn createActionTableWithString(state: *c.lua_State, action_name: [*:0]const u8) void {
356 356 c.lua_createtable(state, 0, 2);
357 357 _ = c.lua_pushstring(state, action_name);
358 358 c.lua_setfield(state, -2, "__action");
@@ -360,36 +360,36 @@ fn create_action_table_with_string(state: *c.lua_State, action_name: [*:0]const
360 360 c.lua_setfield(state, -2, "__arg");
361 361 }
362 362
363 -fn lua_spawn(state: ?*c.lua_State) callconv(.c) c_int {
363 +fn luaSpawn(state: ?*c.lua_State) callconv(.c) c_int {
364 364 const s = state orelse return 0;
365 - create_action_table_with_string(s, "Spawn");
365 + createActionTableWithString(s, "Spawn");
366 366 return 1;
367 367 }
368 368
369 -fn lua_spawn_terminal(state: ?*c.lua_State) callconv(.c) c_int {
369 +fn luaSpawnTerminal(state: ?*c.lua_State) callconv(.c) c_int {
370 370 const s = state orelse return 0;
371 - create_action_table(s, "SpawnTerminal");
371 + createActionTable(s, "SpawnTerminal");
372 372 return 1;
373 373 }
374 374
375 -fn lua_key_bind(state: ?*c.lua_State) callconv(.c) c_int {
375 +fn luaKeyBind(state: ?*c.lua_State) callconv(.c) c_int {
376 376 const s = state orelse return 0;
377 377 const cfg = config orelse return 0;
378 378
379 - const mod_mask = parse_modifiers(s, 1);
380 - const key_str = get_string_arg(s, 2) orelse return 0;
381 - const keysym = key_name_to_keysym(key_str) orelse return 0;
379 + const mod_mask = parseModifiers(s, 1);
380 + const key_str = getStringArg(s, 2) orelse return 0;
381 + const keysym = keyNameToKeysym(key_str) orelse return 0;
382 382
383 383 if (c.lua_type(s, 3) != c.LUA_TTABLE) return 0;
384 384
385 385 _ = c.lua_getfield(s, 3, "__action");
386 - const action_str = get_lua_string(s, -1) orelse {
386 + const action_str = getLuaString(s, -1) orelse {
387 387 c.lua_settop(s, -2);
388 388 return 0;
389 389 };
390 390 c.lua_settop(s, -2);
391 391
392 - const action = parse_action(action_str) orelse return 0;
392 + const action = parseAction(action_str) orelse return 0;
393 393
394 394 var int_arg: i32 = 0;
395 395 var str_arg: ?[]const u8 = null;
@@ -398,9 +398,9 @@ fn lua_key_bind(state: ?*c.lua_State) callconv(.c) c_int {
398 398 if (c.lua_type(s, -1) == c.LUA_TNUMBER) {
399 399 int_arg = @intCast(c.lua_tointegerx(s, -1, null));
400 400 } else if (c.lua_type(s, -1) == c.LUA_TSTRING) {
401 - str_arg = get_lua_string(s, -1);
401 + str_arg = getLuaString(s, -1);
402 402 } else if (c.lua_type(s, -1) == c.LUA_TTABLE) {
403 - str_arg = extract_spawn_command(s, -1);
403 + str_arg = extractSpawnCommand(s, -1);
404 404 }
405 405 c.lua_settop(s, -2);
406 406
@@ -412,12 +412,12 @@ fn lua_key_bind(state: ?*c.lua_State) callconv(.c) c_int {
412 412 keybind.keys[0] = .{ .mod_mask = mod_mask, .keysym = keysym };
413 413 keybind.key_count = 1;
414 414
415 - cfg.add_keybind(keybind) catch return 0;
415 + cfg.addKeybind(keybind) catch return 0;
416 416
417 417 return 0;
418 418 }
419 419
420 -fn lua_key_chord(state: ?*c.lua_State) callconv(.c) c_int {
420 +fn luaKeyChord(state: ?*c.lua_State) callconv(.c) c_int {
421 421 const s = state orelse return 0;
422 422 const cfg = config orelse return 0;
423 423
@@ -443,17 +443,17 @@ fn lua_key_chord(state: ?*c.lua_State) callconv(.c) c_int {
443 443 }
444 444
445 445 _ = c.lua_rawgeti(s, -1, 1);
446 - const mod_mask = parse_modifiers_at_top(s);
446 + const mod_mask = parseModifiersAtTop(s);
447 447 c.lua_settop(s, -2);
448 448
449 449 _ = c.lua_rawgeti(s, -1, 2);
450 - const key_str = get_lua_string(s, -1) orelse {
450 + const key_str = getLuaString(s, -1) orelse {
451 451 c.lua_settop(s, -3);
452 452 return 0;
453 453 };
454 454 c.lua_settop(s, -2);
455 455
456 - const keysym = key_name_to_keysym(key_str) orelse {
456 + const keysym = keyNameToKeysym(key_str) orelse {
457 457 c.lua_settop(s, -2);
458 458 return 0;
459 459 };
@@ -465,51 +465,51 @@ fn lua_key_chord(state: ?*c.lua_State) callconv(.c) c_int {
465 465 }
466 466
467 467 _ = c.lua_getfield(s, 2, "__action");
468 - const action_str = get_lua_string(s, -1) orelse {
468 + const action_str = getLuaString(s, -1) orelse {
469 469 c.lua_settop(s, -2);
470 470 return 0;
471 471 };
472 472 c.lua_settop(s, -2);
473 473
474 - keybind.action = parse_action(action_str) orelse return 0;
474 + keybind.action = parseAction(action_str) orelse return 0;
475 475
476 476 _ = c.lua_getfield(s, 2, "__arg");
477 477 if (c.lua_type(s, -1) == c.LUA_TNUMBER) {
478 478 keybind.int_arg = @intCast(c.lua_tointegerx(s, -1, null));
479 479 } else if (c.lua_type(s, -1) == c.LUA_TSTRING) {
480 - keybind.str_arg = get_lua_string(s, -1);
480 + keybind.str_arg = getLuaString(s, -1);
481 481 } else if (c.lua_type(s, -1) == c.LUA_TTABLE) {
482 - keybind.str_arg = extract_spawn_command(s, -1);
482 + keybind.str_arg = extractSpawnCommand(s, -1);
483 483 }
484 484
485 485 c.lua_settop(s, -2);
486 - cfg.add_keybind(keybind) catch return 0;
486 + cfg.addKeybind(keybind) catch return 0;
487 487
488 488 return 0;
489 489 }
490 490
491 -fn lua_gaps_set_enabled(state: ?*c.lua_State) callconv(.c) c_int {
491 +fn luaGapsSetEnabled(state: ?*c.lua_State) callconv(.c) c_int {
492 492 const cfg = config orelse return 0;
493 493 const s = state orelse return 0;
494 494 cfg.gaps_enabled = c.lua_toboolean(s, 1) != 0;
495 495 return 0;
496 496 }
497 497
498 -fn lua_gaps_enable(state: ?*c.lua_State) callconv(.c) c_int {
498 +fn luaGapsEnable(state: ?*c.lua_State) callconv(.c) c_int {
499 499 _ = state;
500 500 const cfg = config orelse return 0;
501 501 cfg.gaps_enabled = true;
502 502 return 0;
503 503 }
504 504
505 -fn lua_gaps_disable(state: ?*c.lua_State) callconv(.c) c_int {
505 +fn luaGapsDisable(state: ?*c.lua_State) callconv(.c) c_int {
506 506 _ = state;
507 507 const cfg = config orelse return 0;
508 508 cfg.gaps_enabled = false;
509 509 return 0;
510 510 }
511 511
512 -fn lua_gaps_set_inner(state: ?*c.lua_State) callconv(.c) c_int {
512 +fn luaGapsSetInner(state: ?*c.lua_State) callconv(.c) c_int {
513 513 const cfg = config orelse return 0;
514 514 const s = state orelse return 0;
515 515 cfg.gap_inner_h = @intCast(c.lua_tointegerx(s, 1, null));
@@ -517,7 +517,7 @@ fn lua_gaps_set_inner(state: ?*c.lua_State) callconv(.c) c_int {
517 517 return 0;
518 518 }
519 519
520 -fn lua_gaps_set_outer(state: ?*c.lua_State) callconv(.c) c_int {
520 +fn luaGapsSetOuter(state: ?*c.lua_State) callconv(.c) c_int {
521 521 const cfg = config orelse return 0;
522 522 const s = state orelse return 0;
523 523 cfg.gap_outer_h = @intCast(c.lua_tointegerx(s, 1, null));
@@ -525,164 +525,164 @@ fn lua_gaps_set_outer(state: ?*c.lua_State) callconv(.c) c_int {
525 525 return 0;
526 526 }
527 527
528 -fn lua_gaps_set_smart(state: ?*c.lua_State) callconv(.c) c_int {
528 +fn luaGapsSetSmart(state: ?*c.lua_State) callconv(.c) c_int {
529 529 const cfg = config orelse return 0;
530 530 const s = state orelse return 0;
531 531 cfg.smartgaps_enabled = c.lua_toboolean(s, 1) != 0;
532 532 return 0;
533 533 }
534 534
535 -fn lua_border_set_width(state: ?*c.lua_State) callconv(.c) c_int {
535 +fn luaBorderSetWidth(state: ?*c.lua_State) callconv(.c) c_int {
536 536 const cfg = config orelse return 0;
537 537 const s = state orelse return 0;
538 538 cfg.border_width = @intCast(c.lua_tointegerx(s, 1, null));
539 539 return 0;
540 540 }
541 541
542 -fn lua_border_set_focused_color(state: ?*c.lua_State) callconv(.c) c_int {
542 +fn luaBorderSetFocusedColor(state: ?*c.lua_State) callconv(.c) c_int {
543 543 const cfg = config orelse return 0;
544 544 const s = state orelse return 0;
545 - cfg.border_focused = parse_color(s, 1);
545 + cfg.border_focused = parseColor(s, 1);
546 546 return 0;
547 547 }
548 548
549 -fn lua_border_set_unfocused_color(state: ?*c.lua_State) callconv(.c) c_int {
549 +fn luaBorderSetUnfocusedColor(state: ?*c.lua_State) callconv(.c) c_int {
550 550 const cfg = config orelse return 0;
551 551 const s = state orelse return 0;
552 - cfg.border_unfocused = parse_color(s, 1);
552 + cfg.border_unfocused = parseColor(s, 1);
553 553 return 0;
554 554 }
555 555
556 -fn lua_client_kill(state: ?*c.lua_State) callconv(.c) c_int {
556 +fn luaClientKill(state: ?*c.lua_State) callconv(.c) c_int {
557 557 const s = state orelse return 0;
558 - create_action_table(s, "KillClient");
558 + createActionTable(s, "KillClient");
559 559 return 1;
560 560 }
561 561
562 -fn lua_client_toggle_fullscreen(state: ?*c.lua_State) callconv(.c) c_int {
562 +fn luaClientToggleFullscreen(state: ?*c.lua_State) callconv(.c) c_int {
563 563 const s = state orelse return 0;
564 - create_action_table(s, "ToggleFullScreen");
564 + createActionTable(s, "ToggleFullScreen");
565 565 return 1;
566 566 }
567 567
568 -fn lua_client_toggle_floating(state: ?*c.lua_State) callconv(.c) c_int {
568 +fn luaClientToggleFloating(state: ?*c.lua_State) callconv(.c) c_int {
569 569 const s = state orelse return 0;
570 - create_action_table(s, "ToggleFloating");
570 + createActionTable(s, "ToggleFloating");
571 571 return 1;
572 572 }
573 573
574 -fn lua_client_focus_stack(state: ?*c.lua_State) callconv(.c) c_int {
574 +fn luaClientFocusStack(state: ?*c.lua_State) callconv(.c) c_int {
575 575 const s = state orelse return 0;
576 576 const dir: i32 = @intCast(c.lua_tointegerx(s, 1, null));
577 - create_action_table_with_int(s, "FocusStack", dir);
577 + createActionTableWithInt(s, "FocusStack", dir);
578 578 return 1;
579 579 }
580 580
581 -fn lua_client_move_stack(state: ?*c.lua_State) callconv(.c) c_int {
581 +fn luaClientMoveStack(state: ?*c.lua_State) callconv(.c) c_int {
582 582 const s = state orelse return 0;
583 583 const dir: i32 = @intCast(c.lua_tointegerx(s, 1, null));
584 - create_action_table_with_int(s, "MoveStack", dir);
584 + createActionTableWithInt(s, "MoveStack", dir);
585 585 return 1;
586 586 }
587 587
588 -fn lua_layout_cycle(state: ?*c.lua_State) callconv(.c) c_int {
588 +fn luaLayoutCycle(state: ?*c.lua_State) callconv(.c) c_int {
589 589 const s = state orelse return 0;
590 - create_action_table(s, "CycleLayout");
590 + createActionTable(s, "CycleLayout");
591 591 return 1;
592 592 }
593 593
594 -fn lua_layout_set(state: ?*c.lua_State) callconv(.c) c_int {
594 +fn luaLayoutSet(state: ?*c.lua_State) callconv(.c) c_int {
595 595 const s = state orelse return 0;
596 - create_action_table_with_string(s, "ChangeLayout");
596 + createActionTableWithString(s, "ChangeLayout");
597 597 return 1;
598 598 }
599 599
600 -fn lua_layout_scroll_left(state: ?*c.lua_State) callconv(.c) c_int {
600 +fn luaLayoutScrollLeft(state: ?*c.lua_State) callconv(.c) c_int {
601 601 const s = state orelse return 0;
602 - create_action_table(s, "ScrollLeft");
602 + createActionTable(s, "ScrollLeft");
603 603 return 1;
604 604 }
605 605
606 -fn lua_layout_scroll_right(state: ?*c.lua_State) callconv(.c) c_int {
606 +fn luaLayoutScrollRight(state: ?*c.lua_State) callconv(.c) c_int {
607 607 const s = state orelse return 0;
608 - create_action_table(s, "ScrollRight");
608 + createActionTable(s, "ScrollRight");
609 609 return 1;
610 610 }
611 611
612 -fn lua_tag_view(state: ?*c.lua_State) callconv(.c) c_int {
612 +fn luaTagView(state: ?*c.lua_State) callconv(.c) c_int {
613 613 const s = state orelse return 0;
614 614 const idx: i32 = @intCast(c.lua_tointegerx(s, 1, null));
615 - create_action_table_with_int(s, "ViewTag", idx);
615 + createActionTableWithInt(s, "ViewTag", idx);
616 616 return 1;
617 617 }
618 618
619 -fn lua_tag_view_next(state: ?*c.lua_State) callconv(.c) c_int {
619 +fn luaTagViewNext(state: ?*c.lua_State) callconv(.c) c_int {
620 620 const s = state orelse return 0;
621 - create_action_table(s, "ViewNextTag");
621 + createActionTable(s, "ViewNextTag");
622 622 return 1;
623 623 }
624 624
625 -fn lua_tag_view_previous(state: ?*c.lua_State) callconv(.c) c_int {
625 +fn luaTagViewPrevious(state: ?*c.lua_State) callconv(.c) c_int {
626 626 const s = state orelse return 0;
627 - create_action_table(s, "ViewPreviousTag");
627 + createActionTable(s, "ViewPreviousTag");
628 628 return 1;
629 629 }
630 630
631 -fn lua_tag_view_next_nonempty(state: ?*c.lua_State) callconv(.c) c_int {
631 +fn luaTagViewNextNonempty(state: ?*c.lua_State) callconv(.c) c_int {
632 632 const s = state orelse return 0;
633 - create_action_table(s, "ViewNextNonEmptyTag");
633 + createActionTable(s, "ViewNextNonEmptyTag");
634 634 return 1;
635 635 }
636 636
637 -fn lua_tag_view_previous_nonempty(state: ?*c.lua_State) callconv(.c) c_int {
637 +fn luaTagViewPreviousNonempty(state: ?*c.lua_State) callconv(.c) c_int {
638 638 const s = state orelse return 0;
639 - create_action_table(s, "ViewPreviousNonEmptyTag");
639 + createActionTable(s, "ViewPreviousNonEmptyTag");
640 640 return 1;
641 641 }
642 642
643 -fn lua_tag_toggleview(state: ?*c.lua_State) callconv(.c) c_int {
643 +fn luaTagToggleview(state: ?*c.lua_State) callconv(.c) c_int {
644 644 const s = state orelse return 0;
645 645 const idx: i32 = @intCast(c.lua_tointegerx(s, 1, null));
646 - create_action_table_with_int(s, "ToggleView", idx);
646 + createActionTableWithInt(s, "ToggleView", idx);
647 647 return 1;
648 648 }
649 649
650 -fn lua_tag_move_to(state: ?*c.lua_State) callconv(.c) c_int {
650 +fn luaTagMoveTo(state: ?*c.lua_State) callconv(.c) c_int {
651 651 const s = state orelse return 0;
652 652 const idx: i32 = @intCast(c.lua_tointegerx(s, 1, null));
653 - create_action_table_with_int(s, "MoveToTag", idx);
653 + createActionTableWithInt(s, "MoveToTag", idx);
654 654 return 1;
655 655 }
656 656
657 -fn lua_tag_toggletag(state: ?*c.lua_State) callconv(.c) c_int {
657 +fn luaTagToggletag(state: ?*c.lua_State) callconv(.c) c_int {
658 658 const s = state orelse return 0;
659 659 const idx: i32 = @intCast(c.lua_tointegerx(s, 1, null));
660 - create_action_table_with_int(s, "ToggleTag", idx);
660 + createActionTableWithInt(s, "ToggleTag", idx);
661 661 return 1;
662 662 }
663 663
664 -fn lua_tag_set_back_and_forth(state: ?*c.lua_State) callconv(.c) c_int {
664 +fn luaTagSetBackAndForth(state: ?*c.lua_State) callconv(.c) c_int {
665 665 const cfg = config orelse return 0;
666 666 const s = state orelse return 0;
667 667 cfg.tag_back_and_forth = c.lua_toboolean(s, 1) != 0;
668 668 return 0;
669 669 }
670 670
671 -fn lua_monitor_focus(state: ?*c.lua_State) callconv(.c) c_int {
671 +fn luaMonitorFocus(state: ?*c.lua_State) callconv(.c) c_int {
672 672 const s = state orelse return 0;
673 673 const dir: i32 = @intCast(c.lua_tointegerx(s, 1, null));
674 - create_action_table_with_int(s, "FocusMonitor", dir);
674 + createActionTableWithInt(s, "FocusMonitor", dir);
675 675 return 1;
676 676 }
677 677
678 -fn lua_monitor_tag(state: ?*c.lua_State) callconv(.c) c_int {
678 +fn luaMonitorTag(state: ?*c.lua_State) callconv(.c) c_int {
679 679 const s = state orelse return 0;
680 680 const dir: i32 = @intCast(c.lua_tointegerx(s, 1, null));
681 - create_action_table_with_int(s, "TagMonitor", dir);
681 + createActionTableWithInt(s, "TagMonitor", dir);
682 682 return 1;
683 683 }
684 684
685 -fn lua_rule_add(state: ?*c.lua_State) callconv(.c) c_int {
685 +fn luaRuleAdd(state: ?*c.lua_State) callconv(.c) c_int {
686 686 const cfg = config orelse return 0;
687 687 const s = state orelse return 0;
688 688
@@ -700,19 +700,19 @@ fn lua_rule_add(state: ?*c.lua_State) callconv(.c) c_int {
700 700
701 701 _ = c.lua_getfield(s, 1, "class");
702 702 if (c.lua_type(s, -1) == c.LUA_TSTRING) {
703 - rule.class = get_lua_string(s, -1);
703 + rule.class = getLuaString(s, -1);
704 704 }
705 705 c.lua_settop(s, -2);
706 706
707 707 _ = c.lua_getfield(s, 1, "instance");
708 708 if (c.lua_type(s, -1) == c.LUA_TSTRING) {
709 - rule.instance = get_lua_string(s, -1);
709 + rule.instance = getLuaString(s, -1);
710 710 }
711 711 c.lua_settop(s, -2);
712 712
713 713 _ = c.lua_getfield(s, 1, "title");
714 714 if (c.lua_type(s, -1) == c.LUA_TSTRING) {
715 - rule.title = get_lua_string(s, -1);
715 + rule.title = getLuaString(s, -1);
716 716 }
717 717 c.lua_settop(s, -2);
718 718
@@ -743,20 +743,20 @@ fn lua_rule_add(state: ?*c.lua_State) callconv(.c) c_int {
743 743 }
744 744 c.lua_settop(s, -2);
745 745
746 - cfg.add_rule(rule) catch return 0;
746 + cfg.addRule(rule) catch return 0;
747 747 return 0;
748 748 }
749 749
750 -fn lua_bar_set_font(state: ?*c.lua_State) callconv(.c) c_int {
750 +fn luaBarSetFont(state: ?*c.lua_State) callconv(.c) c_int {
751 751 const cfg = config orelse return 0;
752 752 const s = state orelse return 0;
753 - if (dupe_lua_string(s, 1)) |font| {
753 + if (dupeLuaString(s, 1)) |font| {
754 754 cfg.font = font;
755 755 }
756 756 return 0;
757 757 }
758 758
759 -fn lua_bar_set_blocks(state: ?*c.lua_State) callconv(.c) c_int {
759 +fn luaBarSetBlocks(state: ?*c.lua_State) callconv(.c) c_int {
760 760 const cfg = config orelse return 0;
761 761 const s = state orelse return 0;
762 762
@@ -772,8 +772,8 @@ fn lua_bar_set_blocks(state: ?*c.lua_State) callconv(.c) c_int {
772 772 continue;
773 773 }
774 774
775 - if (parse_block_config(s, -1)) |block| {
776 - cfg.add_block(block) catch {};
775 + if (parseBlockConfig(s, -1)) |block| {
776 + cfg.addBlock(block) catch {};
777 777 }
778 778
779 779 c.lua_settop(s, -2);
@@ -782,16 +782,16 @@ fn lua_bar_set_blocks(state: ?*c.lua_State) callconv(.c) c_int {
782 782 return 0;
783 783 }
784 784
785 -fn parse_block_config(state: *c.lua_State, idx: c_int) ?Block {
785 +fn parseBlockConfig(state: *c.lua_State, idx: c_int) ?Block {
786 786 _ = c.lua_getfield(state, idx, "__block_type");
787 - const block_type_str = get_lua_string(state, -1) orelse {
787 + const block_type_str = getLuaString(state, -1) orelse {
788 788 c.lua_settop(state, -2);
789 789 return null;
790 790 };
791 791 c.lua_settop(state, -2);
792 792
793 793 _ = c.lua_getfield(state, idx, "format");
794 - const format = dupe_lua_string(state, -1) orelse "";
794 + const format = dupeLuaString(state, -1) orelse "";
795 795 c.lua_settop(state, -2);
796 796
797 797 _ = c.lua_getfield(state, idx, "interval");
@@ -799,7 +799,7 @@ fn parse_block_config(state: *c.lua_State, idx: c_int) ?Block {
799 799 c.lua_settop(state, -2);
800 800
801 801 _ = c.lua_getfield(state, idx, "color");
802 - const color = parse_color(state, -1);
802 + const color = parseColor(state, -1);
803 803 c.lua_settop(state, -2);
804 804
805 805 _ = c.lua_getfield(state, idx, "underline");
@@ -819,17 +819,17 @@ fn parse_block_config(state: *c.lua_State, idx: c_int) ?Block {
819 819 } else if (std.mem.eql(u8, block_type_str, "DateTime")) {
820 820 block.block_type = .datetime;
821 821 _ = c.lua_getfield(state, idx, "__arg");
822 - block.datetime_format = dupe_lua_string(state, -1);
822 + block.datetime_format = dupeLuaString(state, -1);
823 823 c.lua_settop(state, -2);
824 824 } else if (std.mem.eql(u8, block_type_str, "Shell")) {
825 825 block.block_type = .shell;
826 826 _ = c.lua_getfield(state, idx, "__arg");
827 - block.command = dupe_lua_string(state, -1);
827 + block.command = dupeLuaString(state, -1);
828 828 c.lua_settop(state, -2);
829 829 } else if (std.mem.eql(u8, block_type_str, "Static")) {
830 830 block.block_type = .static;
831 831 _ = c.lua_getfield(state, idx, "__arg");
832 - if (dupe_lua_string(state, -1)) |text| {
832 + if (dupeLuaString(state, -1)) |text| {
833 833 block.format = text;
834 834 }
835 835 c.lua_settop(state, -2);
@@ -838,19 +838,19 @@ fn parse_block_config(state: *c.lua_State, idx: c_int) ?Block {
838 838 _ = c.lua_getfield(state, idx, "__arg");
839 839 if (c.lua_type(state, -1) == c.LUA_TTABLE) {
840 840 _ = c.lua_getfield(state, -1, "charging");
841 - block.format_charging = dupe_lua_string(state, -1);
841 + block.format_charging = dupeLuaString(state, -1);
842 842 c.lua_settop(state, -2);
843 843
844 844 _ = c.lua_getfield(state, -1, "discharging");
845 - block.format_discharging = dupe_lua_string(state, -1);
845 + block.format_discharging = dupeLuaString(state, -1);
846 846 c.lua_settop(state, -2);
847 847
848 848 _ = c.lua_getfield(state, -1, "full");
849 - block.format_full = dupe_lua_string(state, -1);
849 + block.format_full = dupeLuaString(state, -1);
850 850 c.lua_settop(state, -2);
851 851
852 852 _ = c.lua_getfield(state, -1, "battery_name");
853 - block.battery_name = dupe_lua_string(state, -1);
853 + block.battery_name = dupeLuaString(state, -1);
854 854 c.lua_settop(state, -2);
855 855 }
856 856 c.lua_settop(state, -2);
@@ -861,75 +861,75 @@ fn parse_block_config(state: *c.lua_State, idx: c_int) ?Block {
861 861 return block;
862 862 }
863 863
864 -fn lua_bar_set_scheme_normal(state: ?*c.lua_State) callconv(.c) c_int {
864 +fn luaBarSetSchemeNormal(state: ?*c.lua_State) callconv(.c) c_int {
865 865 const cfg = config orelse return 0;
866 866 const s = state orelse return 0;
867 - cfg.scheme_normal = parse_scheme(s);
867 + cfg.scheme_normal = parseScheme(s);
868 868 return 0;
869 869 }
870 870
871 -fn lua_bar_set_scheme_selected(state: ?*c.lua_State) callconv(.c) c_int {
871 +fn luaBarSetSchemeSelected(state: ?*c.lua_State) callconv(.c) c_int {
872 872 const cfg = config orelse return 0;
873 873 const s = state orelse return 0;
874 - cfg.scheme_selected = parse_scheme(s);
874 + cfg.scheme_selected = parseScheme(s);
875 875 return 0;
876 876 }
877 877
878 -fn lua_bar_set_scheme_occupied(state: ?*c.lua_State) callconv(.c) c_int {
878 +fn luaBarSetSchemeOccupied(state: ?*c.lua_State) callconv(.c) c_int {
879 879 const cfg = config orelse return 0;
880 880 const s = state orelse return 0;
881 - cfg.scheme_occupied = parse_scheme(s);
881 + cfg.scheme_occupied = parseScheme(s);
882 882 return 0;
883 883 }
884 884
885 -fn lua_bar_set_scheme_urgent(state: ?*c.lua_State) callconv(.c) c_int {
885 +fn luaBarSetSchemeUrgent(state: ?*c.lua_State) callconv(.c) c_int {
886 886 const cfg = config orelse return 0;
887 887 const s = state orelse return 0;
888 - cfg.scheme_urgent = parse_scheme(s);
888 + cfg.scheme_urgent = parseScheme(s);
889 889 return 0;
890 890 }
891 891
892 -fn lua_bar_set_hide_vacant_tags(state: ?*c.lua_State) callconv(.c) c_int {
892 +fn luaBarSetHideVacantTags(state: ?*c.lua_State) callconv(.c) c_int {
893 893 const cfg = config orelse return 0;
894 894 const s = state orelse return 0;
895 895 cfg.hide_vacant_tags = c.lua_toboolean(s, 1) != 0;
896 896 return 0;
897 897 }
898 898
899 -fn lua_bar_block_ram(state: ?*c.lua_State) callconv(.c) c_int {
899 +fn luaBarBlockRam(state: ?*c.lua_State) callconv(.c) c_int {
900 900 const s = state orelse return 0;
901 - create_block_table(s, "Ram", null);
901 + createBlockTable(s, "Ram", null);
902 902 return 1;
903 903 }
904 904
905 -fn lua_bar_block_datetime(state: ?*c.lua_State) callconv(.c) c_int {
905 +fn luaBarBlockDatetime(state: ?*c.lua_State) callconv(.c) c_int {
906 906 const s = state orelse return 0;
907 907 _ = c.lua_getfield(s, 1, "date_format");
908 - const date_format = get_lua_string(s, -1);
908 + const date_format = getLuaString(s, -1);
909 909 c.lua_settop(s, -2);
910 - create_block_table(s, "DateTime", date_format);
910 + createBlockTable(s, "DateTime", date_format);
911 911 return 1;
912 912 }
913 913
914 -fn lua_bar_block_shell(state: ?*c.lua_State) callconv(.c) c_int {
914 +fn luaBarBlockShell(state: ?*c.lua_State) callconv(.c) c_int {
915 915 const s = state orelse return 0;
916 916 _ = c.lua_getfield(s, 1, "command");
917 - const command = get_lua_string(s, -1);
917 + const command = getLuaString(s, -1);
918 918 c.lua_settop(s, -2);
919 - create_block_table(s, "Shell", command);
919 + createBlockTable(s, "Shell", command);
920 920 return 1;
921 921 }
922 922
923 -fn lua_bar_block_static(state: ?*c.lua_State) callconv(.c) c_int {
923 +fn luaBarBlockStatic(state: ?*c.lua_State) callconv(.c) c_int {
924 924 const s = state orelse return 0;
925 925 _ = c.lua_getfield(s, 1, "text");
926 - const text = get_lua_string(s, -1);
926 + const text = getLuaString(s, -1);
927 927 c.lua_settop(s, -2);
928 - create_block_table(s, "Static", text);
928 + createBlockTable(s, "Static", text);
929 929 return 1;
930 930 }
931 931
932 -fn lua_bar_block_battery(state: ?*c.lua_State) callconv(.c) c_int {
932 +fn luaBarBlockBattery(state: ?*c.lua_State) callconv(.c) c_int {
933 933 const s = state orelse return 0;
934 934
935 935 c.lua_createtable(s, 0, 6);
@@ -963,7 +963,7 @@ fn lua_bar_block_battery(state: ?*c.lua_State) callconv(.c) c_int {
963 963 return 1;
964 964 }
965 965
966 -fn create_block_table(state: *c.lua_State, block_type: [*:0]const u8, arg: ?[]const u8) void {
966 +fn createBlockTable(state: *c.lua_State, block_type: [*:0]const u8, arg: ?[]const u8) void {
967 967 c.lua_createtable(state, 0, 6);
968 968
969 969 _ = c.lua_pushstring(state, block_type);
@@ -992,27 +992,27 @@ fn create_block_table(state: *c.lua_State, block_type: [*:0]const u8, arg: ?[]co
992 992 }
993 993 }
994 994
995 -fn lua_set_terminal(state: ?*c.lua_State) callconv(.c) c_int {
995 +fn luaSetTerminal(state: ?*c.lua_State) callconv(.c) c_int {
996 996 const cfg = config orelse return 0;
997 997 const s = state orelse return 0;
998 - if (dupe_lua_string(s, 1)) |term| {
998 + if (dupeLuaString(s, 1)) |term| {
999 999 cfg.terminal = term;
1000 1000 }
1001 1001 return 0;
1002 1002 }
1003 1003
1004 -fn lua_set_modkey(state: ?*c.lua_State) callconv(.c) c_int {
1004 +fn luaSetModkey(state: ?*c.lua_State) callconv(.c) c_int {
1005 1005 const cfg = config orelse return 0;
1006 1006 const s = state orelse return 0;
1007 - if (get_string_arg(s, 1)) |modkey_str| {
1008 - cfg.modkey = parse_single_modifier(modkey_str);
1009 - cfg.add_button(.{
1007 + if (getStringArg(s, 1)) |modkey_str| {
1008 + cfg.modkey = parseSingleModifier(modkey_str);
1009 + cfg.addButton(.{
1010 1010 .click = .client_win,
1011 1011 .mod_mask = cfg.modkey,
1012 1012 .button = 1,
1013 1013 .action = .move_mouse,
1014 1014 }) catch {};
1015 - cfg.add_button(.{
1015 + cfg.addButton(.{
1016 1016 .click = .client_win,
1017 1017 .mod_mask = cfg.modkey,
1018 1018 .button = 3,
@@ -1022,7 +1022,7 @@ fn lua_set_modkey(state: ?*c.lua_State) callconv(.c) c_int {
1022 1022 return 0;
1023 1023 }
1024 1024
1025 -fn lua_set_tags(state: ?*c.lua_State) callconv(.c) c_int {
1025 +fn luaSetTags(state: ?*c.lua_State) callconv(.c) c_int {
1026 1026 const cfg = config orelse return 0;
1027 1027 const s = state orelse return 0;
1028 1028
@@ -1032,7 +1032,7 @@ fn lua_set_tags(state: ?*c.lua_State) callconv(.c) c_int {
1032 1032 var i: usize = 0;
1033 1033 while (i < len and i < 9) : (i += 1) {
1034 1034 _ = c.lua_rawgeti(s, 1, @intCast(i + 1));
1035 - if (dupe_lua_string(s, -1)) |tag_str| {
1035 + if (dupeLuaString(s, -1)) |tag_str| {
1036 1036 cfg.tags[i] = tag_str;
1037 1037 }
1038 1038 c.lua_settop(s, -2);
@@ -1041,27 +1041,27 @@ fn lua_set_tags(state: ?*c.lua_State) callconv(.c) c_int {
1041 1041 return 0;
1042 1042 }
1043 1043
1044 -fn lua_autostart(state: ?*c.lua_State) callconv(.c) c_int {
1044 +fn luaAutostart(state: ?*c.lua_State) callconv(.c) c_int {
1045 1045 const cfg = config orelse return 0;
1046 1046 const s = state orelse return 0;
1047 - if (dupe_lua_string(s, 1)) |cmd| {
1048 - cfg.add_autostart(cmd) catch return 0;
1047 + if (dupeLuaString(s, 1)) |cmd| {
1048 + cfg.addAutostart(cmd) catch return 0;
1049 1049 }
1050 1050 return 0;
1051 1051 }
1052 1052
1053 -fn lua_auto_tile(state: ?*c.lua_State) callconv(.c) c_int {
1053 +fn luaAutoTile(state: ?*c.lua_State) callconv(.c) c_int {
1054 1054 const cfg = config orelse return 0;
1055 1055 const s = state orelse return 0;
1056 1056 cfg.auto_tile = c.lua_toboolean(s, 1) != 0;
1057 1057 return 0;
1058 1058 }
1059 1059
1060 -fn lua_set_layout_symbol(state: ?*c.lua_State) callconv(.c) c_int {
1060 +fn luaSetLayoutSymbol(state: ?*c.lua_State) callconv(.c) c_int {
1061 1061 const cfg = config orelse return 0;
1062 1062 const s = state orelse return 0;
1063 - const name = get_string_arg(s, 1) orelse return 0;
1064 - const symbol = dupe_lua_string(s, 2) orelse return 0;
1063 + const name = getStringArg(s, 1) orelse return 0;
1064 + const symbol = dupeLuaString(s, 2) orelse return 0;
1065 1065
1066 1066 const layout_map = .{
1067 1067 .{ "tiling", &cfg.layout_tile_symbol },
@@ -1083,103 +1083,103 @@ fn lua_set_layout_symbol(state: ?*c.lua_State) callconv(.c) c_int {
1083 1083 return 0;
1084 1084 }
1085 1085
1086 -fn lua_quit(state: ?*c.lua_State) callconv(.c) c_int {
1086 +fn luaQuit(state: ?*c.lua_State) callconv(.c) c_int {
1087 1087 const s = state orelse return 0;
1088 - create_action_table(s, "Quit");
1088 + createActionTable(s, "Quit");
1089 1089 return 1;
1090 1090 }
1091 1091
1092 -fn lua_restart(state: ?*c.lua_State) callconv(.c) c_int {
1092 +fn luaRestart(state: ?*c.lua_State) callconv(.c) c_int {
1093 1093 const s = state orelse return 0;
1094 - create_action_table(s, "Restart");
1094 + createActionTable(s, "Restart");
1095 1095 return 1;
1096 1096 }
1097 1097
1098 -fn lua_toggle_gaps(state: ?*c.lua_State) callconv(.c) c_int {
1098 +fn luaToggleGaps(state: ?*c.lua_State) callconv(.c) c_int {
1099 1099 const s = state orelse return 0;
1100 - create_action_table(s, "ToggleGaps");
1100 + createActionTable(s, "ToggleGaps");
1101 1101 return 1;
1102 1102 }
1103 1103
1104 -fn lua_show_keybinds(state: ?*c.lua_State) callconv(.c) c_int {
1104 +fn luaShowKeybinds(state: ?*c.lua_State) callconv(.c) c_int {
1105 1105 const s = state orelse return 0;
1106 - create_action_table(s, "ShowKeybinds");
1106 + createActionTable(s, "ShowKeybinds");
1107 1107 return 1;
1108 1108 }
1109 1109
1110 -fn lua_set_master_factor(state: ?*c.lua_State) callconv(.c) c_int {
1110 +fn luaSetMasterFactor(state: ?*c.lua_State) callconv(.c) c_int {
1111 1111 const s = state orelse return 0;
1112 1112 const delta: i32 = @intCast(c.lua_tointegerx(s, 1, null));
1113 - create_action_table_with_int(s, "ResizeMaster", delta);
1113 + createActionTableWithInt(s, "ResizeMaster", delta);
1114 1114 return 1;
1115 1115 }
1116 1116
1117 -fn lua_inc_num_master(state: ?*c.lua_State) callconv(.c) c_int {
1117 +fn luaIncNumMaster(state: ?*c.lua_State) callconv(.c) c_int {
1118 1118 const s = state orelse return 0;
1119 1119 const delta: i32 = @intCast(c.lua_tointegerx(s, 1, null));
1120 1120 if (delta > 0) {
1121 - create_action_table(s, "IncMaster");
1121 + createActionTable(s, "IncMaster");
1122 1122 } else {
1123 - create_action_table(s, "DecMaster");
1123 + createActionTable(s, "DecMaster");
1124 1124 }
1125 1125 return 1;
1126 1126 }
1127 1127
1128 -fn get_string_arg(state: *c.lua_State, idx: c_int) ?[]const u8 {
1128 +fn getStringArg(state: *c.lua_State, idx: c_int) ?[]const u8 {
1129 1129 if (c.lua_type(state, idx) != c.LUA_TSTRING) return null;
1130 - return get_lua_string(state, idx);
1130 + return getLuaString(state, idx);
1131 1131 }
1132 1132
1133 -fn extract_spawn_command(state: *c.lua_State, idx: c_int) ?[]const u8 {
1133 +fn extractSpawnCommand(state: *c.lua_State, idx: c_int) ?[]const u8 {
1134 1134 const len = c.lua_rawlen(state, idx);
1135 1135 if (len == 0) return null;
1136 1136
1137 1137 if (len >= 3) {
1138 1138 _ = c.lua_rawgeti(state, idx, 1);
1139 - const first = get_lua_string(state, -1);
1139 + const first = getLuaString(state, -1);
1140 1140 c.lua_settop(state, -2);
1141 1141
1142 1142 _ = c.lua_rawgeti(state, idx, 2);
1143 - const second = get_lua_string(state, -1);
1143 + const second = getLuaString(state, -1);
1144 1144 c.lua_settop(state, -2);
1145 1145
1146 1146 if (first != null and second != null and
1147 1147 std.mem.eql(u8, first.?, "sh") and std.mem.eql(u8, second.?, "-c"))
1148 1148 {
1149 1149 _ = c.lua_rawgeti(state, idx, 3);
1150 - const cmd = get_lua_string(state, -1);
1150 + const cmd = getLuaString(state, -1);
1151 1151 c.lua_settop(state, -2);
1152 1152 return cmd;
1153 1153 }
1154 1154 }
1155 1155
1156 1156 _ = c.lua_rawgeti(state, idx, 1);
1157 - const first_elem = get_lua_string(state, -1);
1157 + const first_elem = getLuaString(state, -1);
1158 1158 c.lua_settop(state, -2);
1159 1159 return first_elem;
1160 1160 }
1161 1161
1162 -fn get_lua_string(state: *c.lua_State, idx: c_int) ?[]const u8 {
1162 +fn getLuaString(state: *c.lua_State, idx: c_int) ?[]const u8 {
1163 1163 const cstr = c.lua_tolstring(state, idx, null);
1164 1164 if (cstr == null) return null;
1165 1165 return std.mem.span(cstr);
1166 1166 }
1167 1167
1168 -fn dupe_lua_string(state: *c.lua_State, idx: c_int) ?[]const u8 {
1168 +fn dupeLuaString(state: *c.lua_State, idx: c_int) ?[]const u8 {
1169 1169 const cfg = config orelse return null;
1170 - const lua_str = get_lua_string(state, idx) orelse return null;
1170 + const lua_str = getLuaString(state, idx) orelse return null;
1171 1171 const arena_allocator = cfg.string_arena.allocator();
1172 1172 const duped = arena_allocator.dupe(u8, lua_str) catch return null;
1173 1173 return duped;
1174 1174 }
1175 1175
1176 -fn parse_color(state: *c.lua_State, idx: c_int) u32 {
1176 +fn parseColor(state: *c.lua_State, idx: c_int) u32 {
1177 1177 const lua_type = c.lua_type(state, idx);
1178 1178 if (lua_type == c.LUA_TNUMBER) {
1179 1179 return @intCast(c.lua_tointegerx(state, idx, null));
1180 1180 }
1181 1181 if (lua_type == c.LUA_TSTRING) {
1182 - const str = get_lua_string(state, idx) orelse return 0;
1182 + const str = getLuaString(state, idx) orelse return 0;
1183 1183 if (str.len > 0 and str[0] == '#') {
1184 1184 return std.fmt.parseInt(u32, str[1..], 16) catch return 0;
1185 1185 }
@@ -1191,15 +1191,15 @@ fn parse_color(state: *c.lua_State, idx: c_int) u32 {
1191 1191 return 0;
1192 1192 }
1193 1193
1194 -fn parse_scheme(state: *c.lua_State) ColorScheme {
1194 +fn parseScheme(state: *c.lua_State) ColorScheme {
1195 1195 return ColorScheme{
1196 - .foreground = parse_color(state, 1),
1197 - .background = parse_color(state, 2),
1198 - .border = parse_color(state, 3),
1196 + .foreground = parseColor(state, 1),
1197 + .background = parseColor(state, 2),
1198 + .border = parseColor(state, 3),
1199 1199 };
1200 1200 }
1201 1201
1202 -fn parse_modifiers(state: *c.lua_State, idx: c_int) u32 {
1202 +fn parseModifiers(state: *c.lua_State, idx: c_int) u32 {
1203 1203 var mod_mask: u32 = 0;
1204 1204
1205 1205 if (c.lua_type(state, idx) != c.LUA_TTABLE) return mod_mask;
@@ -1208,8 +1208,8 @@ fn parse_modifiers(state: *c.lua_State, idx: c_int) u32 {
1208 1208 var i: usize = 1;
1209 1209 while (i <= len) : (i += 1) {
1210 1210 _ = c.lua_rawgeti(state, idx, @intCast(i));
1211 - if (get_lua_string(state, -1)) |mod_str| {
1212 - const parsed = parse_single_modifier(mod_str);
1211 + if (getLuaString(state, -1)) |mod_str| {
1212 + const parsed = parseSingleModifier(mod_str);
1213 1213 mod_mask |= parsed;
1214 1214 }
1215 1215 c.lua_settop(state, -2);
@@ -1218,11 +1218,11 @@ fn parse_modifiers(state: *c.lua_State, idx: c_int) u32 {
1218 1218 return mod_mask;
1219 1219 }
1220 1220
1221 -fn parse_modifiers_at_top(state: *c.lua_State) u32 {
1222 - return parse_modifiers(state, -1);
1221 +fn parseModifiersAtTop(state: *c.lua_State) u32 {
1222 + return parseModifiers(state, -1);
1223 1223 }
1224 1224
1225 -fn parse_single_modifier(name: []const u8) u32 {
1225 +fn parseSingleModifier(name: []const u8) u32 {
1226 1226 if (std.mem.eql(u8, name, "Mod4") or std.mem.eql(u8, name, "mod4") or std.mem.eql(u8, name, "super")) {
1227 1227 return (1 << 6);
1228 1228 } else if (std.mem.eql(u8, name, "Mod1") or std.mem.eql(u8, name, "mod1") or std.mem.eql(u8, name, "alt")) {
@@ -1235,7 +1235,7 @@ fn parse_single_modifier(name: []const u8) u32 {
1235 1235 return 0;
1236 1236 }
1237 1237
1238 -fn parse_action(name: []const u8) ?Action {
1238 +fn parseAction(name: []const u8) ?Action {
1239 1239 const action_map = .{
1240 1240 .{ "Spawn", Action.spawn },
1241 1241 .{ "SpawnTerminal", Action.spawn_terminal },
@@ -1275,7 +1275,7 @@ fn parse_action(name: []const u8) ?Action {
1275 1275 return null;
1276 1276 }
1277 1277
1278 -fn key_name_to_keysym(name: []const u8) ?u64 {
1278 +fn keyNameToKeysym(name: []const u8) ?u64 {
1279 1279 const key_map = .{
1280 1280 .{ "Return", 0xff0d },
1281 1281 .{ "Enter", 0xff0d },
+2 −2 src/keyboard/chord.zig
@@ -32,7 +32,7 @@ pub const ChordState = struct {
32 32 }
33 33
34 34 /// Returns true if the sequence has timed out and should be reset.
35 - pub fn is_timed_out(self: *const ChordState) bool {
35 + pub fn isTimedOut(self: *const ChordState) bool {
36 36 if (self.index == 0) return false;
37 37 return (std.time.milliTimestamp() - self.last_timestamp) >= timeout_ms;
38 38 }
@@ -58,7 +58,7 @@ pub const ChordState = struct {
58 58 ///
59 59 /// Sets `keyboard_grabbed` on success. Safe to call repeatedly,
60 60 /// does nothing if already grabbed.
61 - pub fn grab_keyboard(self: *ChordState, display: *xlib.Display, root: xlib.Window) void {
61 + pub fn grabKeyboard(self: *ChordState, display: *xlib.Display, root: xlib.Window) void {
62 62 if (self.keyboard_grabbed) return;
63 63
64 64 const result = xlib.XGrabKeyboard(display, root, xlib.True, xlib.GrabModeAsync, xlib.GrabModeAsync, xlib.CurrentTime);
+5 −5 src/layouts/grid.zig
@@ -13,8 +13,8 @@ pub const layout = monitor_mod.Layout{
13 13
14 14 pub fn grid(monitor: *Monitor) void {
15 15 var client_count: u32 = 0;
16 - var current = client_mod.next_tiled(monitor.clients);
17 - while (current) |_| : (current = client_mod.next_tiled(current.?.next)) {
16 + var current = client_mod.nextTiled(monitor.clients);
17 + while (current) |_| : (current = client_mod.nextTiled(current.?.next)) {
18 18 client_count += 1;
19 19 }
20 20
@@ -26,7 +26,7 @@ pub fn grid(monitor: *Monitor) void {
26 26 const gap_inner_v = monitor.gap_inner_v;
27 27
28 28 if (client_count == 1) {
29 - const client = client_mod.next_tiled(monitor.clients).?;
29 + const client = client_mod.nextTiled(monitor.clients).?;
30 30 tiling.resize(
31 31 client,
32 32 monitor.win_x + gap_outer_v,
@@ -50,8 +50,8 @@ pub fn grid(monitor: *Monitor) void {
50 50 const cell_height: i32 = @divTrunc(available_height, @as(i32, @intCast(rows)));
51 51
52 52 var index: u32 = 0;
53 - current = client_mod.next_tiled(monitor.clients);
54 - while (current) |client| : (current = client_mod.next_tiled(client.next)) {
53 + current = client_mod.nextTiled(monitor.clients);
54 + while (current) |client| : (current = client_mod.nextTiled(client.next)) {
55 55 const row = index / cols;
56 56 const col = index % cols;
57 57
+2 −2 src/layouts/monocle.zig
@@ -16,7 +16,7 @@ pub fn monocle(monitor: *Monitor) void {
16 16 const gap_h = monitor.gap_outer_h;
17 17 const gap_v = monitor.gap_outer_v;
18 18
19 - var current = client_mod.next_tiled(monitor.clients);
19 + var current = client_mod.nextTiled(monitor.clients);
20 20 while (current) |client| {
21 21 tiling.resize(
22 22 client,
@@ -26,6 +26,6 @@ pub fn monocle(monitor: *Monitor) void {
26 26 monitor.win_h - 2 * gap_h - 2 * client.border_width,
27 27 false,
28 28 );
29 - current = client_mod.next_tiled(client.next);
29 + current = client_mod.nextTiled(client.next);
30 30 }
31 31 }
+17 −17 src/layouts/scrolling.zig
@@ -14,8 +14,8 @@ pub const layout = monitor_mod.Layout{
14 14
15 15 pub fn scroll(monitor: *Monitor) void {
16 16 var client_count: u32 = 0;
17 - var current = client_mod.next_tiled(monitor.clients);
18 - while (current) |_| : (current = client_mod.next_tiled(current.?.next)) {
17 + var current = client_mod.nextTiled(monitor.clients);
18 + while (current) |_| : (current = client_mod.nextTiled(current.?.next)) {
19 19 client_count += 1;
20 20 }
21 21
@@ -37,8 +37,8 @@ pub fn scroll(monitor: *Monitor) void {
37 37 const height = available_height;
38 38
39 39 var index: u32 = 0;
40 - current = client_mod.next_tiled(monitor.clients);
41 - while (current) |client| : (current = client_mod.next_tiled(client.next)) {
40 + current = client_mod.nextTiled(monitor.clients);
41 + while (current) |client| : (current = client_mod.nextTiled(client.next)) {
42 42 const window_right = x_pos + window_width;
43 43 const screen_left = monitor.win_x;
44 44 const screen_right = monitor.win_x + monitor.win_w;
@@ -54,7 +54,7 @@ pub fn scroll(monitor: *Monitor) void {
54 54 false,
55 55 );
56 56 } else {
57 - tiling.resize_client(
57 + tiling.resizeClient(
58 58 client,
59 59 -2 * window_width,
60 60 y_pos,
@@ -67,7 +67,7 @@ pub fn scroll(monitor: *Monitor) void {
67 67 }
68 68 }
69 69
70 -pub fn get_scroll_step(monitor: *Monitor) i32 {
70 +pub fn getScrollStep(monitor: *Monitor) i32 {
71 71 const gap_outer_v = monitor.gap_outer_v;
72 72 const gap_inner_v = monitor.gap_inner_v;
73 73 const visible_count: u32 = @intCast(@max(1, monitor.nmaster));
@@ -77,37 +77,37 @@ pub fn get_scroll_step(monitor: *Monitor) i32 {
77 77 return window_width + gap_inner_v;
78 78 }
79 79
80 -pub fn get_max_scroll(monitor: *Monitor) i32 {
80 +pub fn getMaxScroll(monitor: *Monitor) i32 {
81 81 var client_count: u32 = 0;
82 - var current = client_mod.next_tiled(monitor.clients);
83 - while (current) |_| : (current = client_mod.next_tiled(current.?.next)) {
82 + var current = client_mod.nextTiled(monitor.clients);
83 + while (current) |_| : (current = client_mod.nextTiled(current.?.next)) {
84 84 client_count += 1;
85 85 }
86 86
87 87 const visible_count: u32 = @intCast(@max(1, monitor.nmaster));
88 88 if (client_count <= visible_count) return 0;
89 89
90 - const scroll_step = get_scroll_step(monitor);
90 + const scroll_step = getScrollStep(monitor);
91 91 const scrollable = client_count - visible_count;
92 92 return scroll_step * @as(i32, @intCast(scrollable));
93 93 }
94 94
95 -pub fn get_window_index(monitor: *Monitor, target: *Client) ?u32 {
95 +pub fn getWindowIndex(monitor: *Monitor, target: *Client) ?u32 {
96 96 var index: u32 = 0;
97 - var current = client_mod.next_tiled(monitor.clients);
98 - while (current) |client| : (current = client_mod.next_tiled(client.next)) {
97 + var current = client_mod.nextTiled(monitor.clients);
98 + while (current) |client| : (current = client_mod.nextTiled(client.next)) {
99 99 if (client == target) return index;
100 100 index += 1;
101 101 }
102 102 return null;
103 103 }
104 104
105 -pub fn get_target_scroll_for_window(monitor: *Monitor, target: *Client) i32 {
106 - const index = get_window_index(monitor, target) orelse return 0;
105 +pub fn getTargetScrollForWindow(monitor: *Monitor, target: *Client) i32 {
106 + const index = getWindowIndex(monitor, target) orelse return 0;
107 107 if (index == 0) return 0;
108 108
109 - const scroll_step = get_scroll_step(monitor);
110 - const max_scroll = get_max_scroll(monitor);
109 + const scroll_step = getScrollStep(monitor);
110 + const max_scroll = getMaxScroll(monitor);
111 111
112 112 const target_scroll = scroll_step * @as(i32, @intCast(index));
113 113 return @min(target_scroll, max_scroll);
+27 −27 src/layouts/tiling.zig
@@ -16,16 +16,16 @@ pub var screen_width: i32 = 0;
16 16 pub var screen_height: i32 = 0;
17 17 pub var bar_height: i32 = 0;
18 18
19 -pub fn set_display(display: *xlib.Display) void {
19 +pub fn setDisplay(display: *xlib.Display) void {
20 20 display_handle = display;
21 21 }
22 22
23 -pub fn set_screen_size(width: i32, height: i32) void {
23 +pub fn setScreenSize(width: i32, height: i32) void {
24 24 screen_width = width;
25 25 screen_height = height;
26 26 }
27 27
28 -pub fn set_bar_height(height: i32) void {
28 +pub fn setBarHeight(height: i32) void {
29 29 bar_height = height;
30 30 }
31 31
@@ -36,7 +36,7 @@ pub fn tile(monitor: *Monitor) void {
36 36 var gap_inner_v: i32 = 0;
37 37 var client_count: u32 = 0;
38 38
39 - get_gaps(monitor, &gap_outer_h, &gap_outer_v, &gap_inner_h, &gap_inner_v, &client_count);
39 + getGaps(monitor, &gap_outer_h, &gap_outer_v, &gap_inner_h, &gap_inner_v, &client_count);
40 40 if (client_count == 0) return;
41 41
42 42 const nmaster: i32 = monitor.nmaster;
@@ -62,29 +62,29 @@ pub fn tile(monitor: *Monitor) void {
62 62 var stack_facts: f32 = 0;
63 63 var master_rest: i32 = 0;
64 64 var stack_rest: i32 = 0;
65 - get_facts(monitor, master_height, stack_height, &master_facts, &stack_facts, &master_rest, &stack_rest);
65 + getFacts(monitor, master_height, stack_height, &master_facts, &stack_facts, &master_rest, &stack_rest);
66 66
67 67 var index: u32 = 0;
68 - var current = client_mod.next_tiled(monitor.clients);
69 - while (current) |client| : (current = client_mod.next_tiled(client.next)) {
68 + var current = client_mod.nextTiled(monitor.clients);
69 + while (current) |client| : (current = client_mod.nextTiled(client.next)) {
70 70 if (index < nmaster_count) {
71 71 const height = @as(i32, @intFromFloat(@as(f32, @floatFromInt(master_height)) / master_facts)) + (if (index < @as(u32, @intCast(master_rest))) @as(i32, 1) else @as(i32, 0)) - 2 * client.border_width;
72 72 resize(client, master_x, master_y, master_width - 2 * client.border_width, height, false);
73 - master_y += get_client_height(client) + gap_inner_h;
73 + master_y += getClientHeight(client) + gap_inner_h;
74 74 } else {
75 75 const stack_index = index - nmaster_count;
76 76 const height = @as(i32, @intFromFloat(@as(f32, @floatFromInt(stack_height)) / stack_facts)) + (if (stack_index < @as(u32, @intCast(stack_rest))) @as(i32, 1) else @as(i32, 0)) - 2 * client.border_width;
77 77 resize(client, stack_x, stack_y, stack_width - 2 * client.border_width, height, false);
78 - stack_y += get_client_height(client) + gap_inner_h;
78 + stack_y += getClientHeight(client) + gap_inner_h;
79 79 }
80 80 index += 1;
81 81 }
82 82 }
83 83
84 -fn get_gaps(monitor: *Monitor, gap_outer_h: *i32, gap_outer_v: *i32, gap_inner_h: *i32, gap_inner_v: *i32, client_count: *u32) void {
84 +fn getGaps(monitor: *Monitor, gap_outer_h: *i32, gap_outer_v: *i32, gap_inner_h: *i32, gap_inner_v: *i32, client_count: *u32) void {
85 85 var count: u32 = 0;
86 - var current = client_mod.next_tiled(monitor.clients);
87 - while (current) |client| : (current = client_mod.next_tiled(client.next)) {
86 + var current = client_mod.nextTiled(monitor.clients);
87 + while (current) |client| : (current = client_mod.nextTiled(client.next)) {
88 88 count += 1;
89 89 }
90 90
@@ -95,10 +95,10 @@ fn get_gaps(monitor: *Monitor, gap_outer_h: *i32, gap_outer_v: *i32, gap_inner_h
95 95 client_count.* = count;
96 96 }
97 97
98 -fn get_facts(monitor: *Monitor, master_size: i32, stack_size: i32, master_factor: *f32, stack_factor: *f32, master_rest: *i32, stack_rest: *i32) void {
98 +fn getFacts(monitor: *Monitor, master_size: i32, stack_size: i32, master_factor: *f32, stack_factor: *f32, master_rest: *i32, stack_rest: *i32) void {
99 99 var count: u32 = 0;
100 - var current = client_mod.next_tiled(monitor.clients);
101 - while (current) |client| : (current = client_mod.next_tiled(client.next)) {
100 + var current = client_mod.nextTiled(monitor.clients);
101 + while (current) |client| : (current = client_mod.nextTiled(client.next)) {
102 102 count += 1;
103 103 }
104 104
@@ -122,15 +122,15 @@ fn get_facts(monitor: *Monitor, master_size: i32, stack_size: i32, master_factor
122 122 stack_rest.* = stack_size - stack_total;
123 123 }
124 124
125 -fn get_client_width(client: *Client) i32 {
125 +fn getClientWidth(client: *Client) i32 {
126 126 return client.width + 2 * client.border_width;
127 127 }
128 128
129 -fn get_client_height(client: *Client) i32 {
129 +fn getClientHeight(client: *Client) i32 {
130 130 return client.height + 2 * client.border_width;
131 131 }
132 132
133 -pub fn apply_size_hints(client: *Client, target_x: *i32, target_y: *i32, target_width: *i32, target_height: *i32, interact: bool) bool {
133 +pub fn applySizeHints(client: *Client, target_x: *i32, target_y: *i32, target_width: *i32, target_height: *i32, interact: bool) bool {
134 134 const monitor = client.monitor orelse return false;
135 135
136 136 target_width.* = @max(1, target_width.*);
@@ -138,10 +138,10 @@ pub fn apply_size_hints(client: *Client, target_x: *i32, target_y: *i32, target_
138 138
139 139 if (interact) {
140 140 if (target_x.* > screen_width) {
141 - target_x.* = screen_width - get_client_width(client);
141 + target_x.* = screen_width - getClientWidth(client);
142 142 }
143 143 if (target_y.* > screen_height) {
144 - target_y.* = screen_height - get_client_height(client);
144 + target_y.* = screen_height - getClientHeight(client);
145 145 }
146 146 if (target_x.* + target_width.* + 2 * client.border_width < 0) {
147 147 target_x.* = 0;
@@ -151,10 +151,10 @@ pub fn apply_size_hints(client: *Client, target_x: *i32, target_y: *i32, target_
151 151 }
152 152 } else {
153 153 if (target_x.* >= monitor.win_x + monitor.win_w) {
154 - target_x.* = monitor.win_x + monitor.win_w - get_client_width(client);
154 + target_x.* = monitor.win_x + monitor.win_w - getClientWidth(client);
155 155 }
156 156 if (target_y.* >= monitor.win_y + monitor.win_h) {
157 - target_y.* = monitor.win_y + monitor.win_h - get_client_height(client);
157 + target_y.* = monitor.win_y + monitor.win_h - getClientHeight(client);
158 158 }
159 159 if (target_x.* + target_width.* + 2 * client.border_width <= monitor.win_x) {
160 160 target_x.* = monitor.win_x;
@@ -224,12 +224,12 @@ pub fn resize(client: *Client, target_x: i32, target_y: i32, target_width: i32,
224 224 var final_width = target_width;
225 225 var final_height = target_height;
226 226
227 - if (apply_size_hints(client, &final_x, &final_y, &final_width, &final_height, interact)) {
228 - resize_client(client, final_x, final_y, final_width, final_height);
227 + if (applySizeHints(client, &final_x, &final_y, &final_width, &final_height, interact)) {
228 + resizeClient(client, final_x, final_y, final_width, final_height);
229 229 }
230 230 }
231 231
232 -pub fn resize_client(client: *Client, target_x: i32, target_y: i32, target_width: i32, target_height: i32) void {
232 +pub fn resizeClient(client: *Client, target_x: i32, target_y: i32, target_width: i32, target_height: i32) void {
233 233 client.old_x = client.x;
234 234 client.old_y = client.y;
235 235 client.old_width = client.width;
@@ -255,11 +255,11 @@ pub fn resize_client(client: *Client, target_x: i32, target_y: i32, target_width
255 255 &window_changes,
256 256 );
257 257
258 - send_configure(client);
258 + sendConfigure(client);
259 259 _ = xlib.XSync(display, xlib.False);
260 260 }
261 261
262 -pub fn send_configure(client: *Client) void {
262 +pub fn sendConfigure(client: *Client) void {
263 263 const display = display_handle orelse return;
264 264
265 265 var configure_event: xlib.c.XConfigureEvent = undefined;
+21 −21 src/main.zig
@@ -9,7 +9,7 @@ const lua = @import("config/lua.zig");
9 9
10 10 const WindowManager = window_manager.WindowManager;
11 11
12 -fn print_help() void {
12 +fn printHelp() void {
13 13 std.debug.print(
14 14 \\oxwm - A window manager
15 15 \\
@@ -35,7 +35,7 @@ fn print_help() void {
35 35 , .{});
36 36 }
37 37
38 -fn get_config_path(allocator: std.mem.Allocator) ![]u8 {
38 +fn getConfigPath(allocator: std.mem.Allocator) ![]u8 {
39 39 const config_home = std.posix.getenv("XDG_CONFIG_HOME") orelse blk: {
40 40 const home = std.posix.getenv("HOME") orelse return error.CouldNotGetHomeDir;
41 41 break :blk try std.fs.path.join(allocator, &.{ home, ".config" });
@@ -47,8 +47,8 @@ fn get_config_path(allocator: std.mem.Allocator) ![]u8 {
47 47 return config_path;
48 48 }
49 49
50 -fn init_config(allocator: std.mem.Allocator) void {
51 - const config_path = get_config_path(allocator) catch return;
50 +fn initConfig(allocator: std.mem.Allocator) void {
51 + const config_path = getConfigPath(allocator) catch return;
52 52 defer allocator.free(config_path);
53 53
54 54 const template = @embedFile("templates/config.lua");
@@ -83,7 +83,7 @@ fn init_config(allocator: std.mem.Allocator) void {
83 83 std.debug.print("No compilation needed - changes take effect immediately!\n", .{});
84 84 }
85 85
86 -fn validate_config(allocator: std.mem.Allocator, config_path: []const u8) !void {
86 +fn validateConfig(allocator: std.mem.Allocator, config_path: []const u8) !void {
87 87 var config = config_mod.Config.init(allocator);
88 88 defer config.deinit();
89 89
@@ -99,7 +99,7 @@ fn validate_config(allocator: std.mem.Allocator, config_path: []const u8) !void
99 99 std.process.exit(1);
100 100 };
101 101
102 - if (lua.load_file(config_path)) {
102 + if (lua.loadFile(config_path)) {
103 103 std.debug.print("✓ config valid: {s}\n", .{config_path});
104 104 std.process.exit(0);
105 105 } else {
@@ -113,7 +113,7 @@ pub fn main() !void {
113 113 const allocator = gpa.allocator();
114 114 defer _ = gpa.deinit();
115 115
116 - const default_config_path = try get_config_path(allocator);
116 + const default_config_path = try getConfigPath(allocator);
117 117 defer allocator.free(default_config_path);
118 118
119 119 var config_path: []const u8 = default_config_path;
@@ -124,13 +124,13 @@ pub fn main() !void {
124 124 if (std.mem.eql(u8, arg, "-c") or std.mem.eql(u8, arg, "--config")) {
125 125 if (args.next()) |path| config_path = path;
126 126 } else if (std.mem.eql(u8, arg, "-h") or std.mem.eql(u8, arg, "--help")) {
127 - print_help();
127 + printHelp();
128 128 return;
129 129 } else if (std.mem.eql(u8, arg, "-v") or std.mem.eql(u8, arg, "--version")) {
130 130 std.debug.print("{s}\n", .{build_options.version});
131 131 return;
132 132 } else if (std.mem.eql(u8, arg, "--init")) {
133 - init_config(allocator);
133 + initConfig(allocator);
134 134 return;
135 135 } else if (std.mem.eql(u8, arg, "--validate")) {
136 136 validate_mode = true;
@@ -138,7 +138,7 @@ pub fn main() !void {
138 138 }
139 139
140 140 if (validate_mode) {
141 - try validate_config(allocator, config_path);
141 + try validateConfig(allocator, config_path);
142 142 return;
143 143 }
144 144
@@ -149,10 +149,10 @@ pub fn main() !void {
149 149
150 150 if (lua.init(&config)) {
151 151 const loaded = if (std.fs.cwd().statFile(config_path)) |_|
152 - lua.load_file(config_path)
152 + lua.loadFile(config_path)
153 153 else |_| blk: {
154 - init_config(allocator);
155 - break :blk lua.load_config();
154 + initConfig(allocator);
155 + break :blk lua.loadConfig();
156 156 };
157 157
158 158 if (loaded) {
@@ -160,11 +160,11 @@ pub fn main() !void {
160 160 std.debug.print("loaded config from {s}\n", .{config_path});
161 161 } else {
162 162 std.debug.print("no config found, using defaults\n", .{});
163 - config_mod.initialize_default_config(&config);
163 + config_mod.initializeDefaultConfig(&config);
164 164 }
165 165 } else {
166 166 std.debug.print("failed to init lua, using defaults\n", .{});
167 - config_mod.initialize_default_config(&config);
167 + config_mod.initializeDefaultConfig(&config);
168 168 }
169 169
170 170 var wm = WindowManager.init(allocator, config, config_path_global) catch |err| {
@@ -177,20 +177,20 @@ pub fn main() !void {
177 177 std.debug.print("successfully became window manager\n", .{});
178 178 std.debug.print("atoms initialized with EWMH support\n", .{});
179 179
180 - wm.grab_keybinds();
181 - wm.scan_existing_windows(window_manager.core.manage);
180 + wm.grabKeybinds();
181 + wm.scanExistingWindows(window_manager.core.manage);
182 182
183 - try run_autostart_commands(&wm);
183 + try runAutostartCommands(&wm);
184 184 std.debug.print("entering event loop\n", .{});
185 - wm.run(handlers.handle_event, window_manager.core.tick_animations);
185 + wm.run(handlers.handleEvent, window_manager.core.tickAnimations);
186 186
187 187 lua.deinit();
188 188 std.debug.print("oxwm exiting\n", .{});
189 189 }
190 190
191 -fn run_autostart_commands(wm: *WindowManager) !void {
191 +fn runAutostartCommands(wm: *WindowManager) !void {
192 192 const commands = wm.config.autostart.items;
193 - for (commands) |cmd| actions.spawn_command(wm, cmd);
193 + for (commands) |cmd| actions.spawnCommand(wm, cmd);
194 194 }
195 195
196 196 test {
+5 −5 src/monitor.zig
@@ -66,7 +66,7 @@ pub fn destroy(allocator: std.mem.Allocator, mon: *Monitor) void {
66 66
67 67 /// Returns the monitor whose bar window or client matches `win`, falling
68 68 /// back to a pointer-position query when `win` is the root window.
69 -pub fn window_to_monitor(wm: *WindowManager, win: xlib.Window) ?*Monitor {
69 +pub fn windowToMonitor(wm: *WindowManager, win: xlib.Window) ?*Monitor {
70 70 const monitors = wm.monitors;
71 71 const selected_monitor = wm.selected_monitor;
72 72
@@ -77,7 +77,7 @@ pub fn window_to_monitor(wm: *WindowManager, win: xlib.Window) ?*Monitor {
77 77 var dummy_int: c_int = undefined;
78 78 var dummy_uint: c_uint = undefined;
79 79 if (xlib.XQueryPointer(wm.display.handle, wm.display.root, &dummy_win, &dummy_win, &root_x, &root_y, &dummy_int, &dummy_int, &dummy_uint) != 0) {
80 - return rect_to_monitor(wm, root_x, root_y, 1, 1);
80 + return rectToMonitor(wm, root_x, root_y, 1, 1);
81 81 }
82 82 }
83 83
@@ -87,7 +87,7 @@ pub fn window_to_monitor(wm: *WindowManager, win: xlib.Window) ?*Monitor {
87 87 current = monitor.next;
88 88 }
89 89
90 - const client = @import("client.zig").window_to_client(monitors, win);
90 + const client = @import("client.zig").windowToClient(monitors, win);
91 91 if (client) |found_client| {
92 92 return found_client.monitor;
93 93 }
@@ -97,7 +97,7 @@ pub fn window_to_monitor(wm: *WindowManager, win: xlib.Window) ?*Monitor {
97 97
98 98 /// Returns the monitor with the greatest intersection area with the given
99 99 /// rectangle, or `selected_monitor` if no intersection is found.
100 -pub fn rect_to_monitor(wm: *WindowManager, x: i32, y: i32, width: i32, height: i32) ?*Monitor {
100 +pub fn rectToMonitor(wm: *WindowManager, x: i32, y: i32, width: i32, height: i32) ?*Monitor {
101 101 const monitors = wm.monitors;
102 102 const selected_monitor = wm.selected_monitor;
103 103 var result = selected_monitor;
@@ -125,7 +125,7 @@ pub fn rect_to_monitor(wm: *WindowManager, x: i32, y: i32, width: i32, height: i
125 125 // TODO:
126 126 // - Change direction to an enum/enum_literal
127 127 // - Rename function
128 -pub fn dir_to_monitor(wm: *WindowManager, direction: i32) ?*Monitor {
128 +pub fn dirToMonitor(wm: *WindowManager, direction: i32) ?*Monitor {
129 129 const monitors = wm.monitors;
130 130 const selected_monitor = wm.selected_monitor;
131 131 var target: ?*Monitor = null;
+26 −26 src/overlay.zig
@@ -62,7 +62,7 @@ pub const Keybind_Overlay = struct {
62 62
63 63 pub fn deinit(self: *Keybind_Overlay, allocator: std.mem.Allocator) void {
64 64 if (self.display) |display| {
65 - self.destroy_window(display);
65 + self.destroyWindow(display);
66 66 if (self.font) |font| {
67 67 xlib.XftFontClose(display, font);
68 68 }
@@ -70,7 +70,7 @@ pub const Keybind_Overlay = struct {
70 70 allocator.destroy(self);
71 71 }
72 72
73 - fn destroy_window(self: *Keybind_Overlay, display: *xlib.Display) void {
73 + fn destroyWindow(self: *Keybind_Overlay, display: *xlib.Display) void {
74 74 if (self.xft_draw) |xft_draw| {
75 75 xlib.XftDrawDestroy(xft_draw);
76 76 self.xft_draw = null;
@@ -100,7 +100,7 @@ pub const Keybind_Overlay = struct {
100 100 pub fn show(self: *Keybind_Overlay, mon_x: i32, mon_y: i32, mon_w: i32, mon_h: i32, config: *config_mod.Config) void {
101 101 const display = self.display orelse return;
102 102
103 - self.collect_keybinds(config);
103 + self.collectKeybinds(config);
104 104 if (self.line_count == 0) return;
105 105
106 106 var max_key_width: i32 = 0;
@@ -108,14 +108,14 @@ pub const Keybind_Overlay = struct {
108 108
109 109 for (0..self.line_count) |i| {
110 110 const key_slice = self.key_bufs[i][0..self.key_lens[i]];
111 - const key_w = self.text_width(display, key_slice);
112 - const desc_w = self.text_width(display, self.descs[i]);
111 + const key_w = self.textWidth(display, key_slice);
112 + const desc_w = self.textWidth(display, self.descs[i]);
113 113 if (key_w > max_key_width) max_key_width = key_w;
114 114 if (desc_w > max_desc_width) max_desc_width = desc_w;
115 115 }
116 116
117 117 const title = "Keybindings";
118 - const title_width = self.text_width(display, title);
118 + const title_width = self.textWidth(display, title);
119 119
120 120 const content_width = max_key_width + key_action_spacing + max_desc_width;
121 121 const min_width = @max(title_width, content_width);
@@ -125,7 +125,7 @@ pub const Keybind_Overlay = struct {
125 125 const title_height = self.font_height + 20;
126 126 self.height = title_height + @as(i32, @intCast(self.line_count)) * line_height + padding * 2;
127 127
128 - self.destroy_window(display);
128 + self.destroyWindow(display);
129 129
130 130 const x: i32 = mon_x + @divTrunc(mon_w - self.width, 2);
131 131 const y: i32 = mon_y + @divTrunc(mon_h - self.height, 2);
@@ -178,7 +178,7 @@ pub const Keybind_Overlay = struct {
178 178 self.visible = false;
179 179 }
180 180
181 - pub fn handle_key(self: *Keybind_Overlay, keysym: u64) bool {
181 + pub fn handleKey(self: *Keybind_Overlay, keysym: u64) bool {
182 182 if (!self.visible) return false;
183 183 if (keysym == 0xff1b or keysym == 'q' or keysym == 'Q') {
184 184 self.hide();
@@ -187,28 +187,28 @@ pub const Keybind_Overlay = struct {
187 187 return false;
188 188 }
189 189
190 - pub fn is_overlay_window(self: *Keybind_Overlay, win: xlib.Window) bool {
190 + pub fn isOverlayWindow(self: *Keybind_Overlay, win: xlib.Window) bool {
191 191 return self.visible and self.window != 0 and self.window == win;
192 192 }
193 193
194 194 fn draw(self: *Keybind_Overlay, display: *xlib.Display, max_key_width: i32, title: []const u8) void {
195 - self.fill_rect(display, 0, 0, self.width, self.height, bg_color);
195 + self.fillRect(display, 0, 0, self.width, self.height, bg_color);
196 196
197 - const title_x = @divTrunc(self.width - self.text_width(display, title), 2);
197 + const title_x = @divTrunc(self.width - self.textWidth(display, title), 2);
198 198 const title_y = padding + self.font.?.*.ascent;
199 - self.draw_text(display, title_x, title_y, title, fg_color);
199 + self.drawText(display, title_x, title_y, title, fg_color);
200 200
201 201 const line_height = self.font_height + line_spacing;
202 202 var y = padding + self.font_height + 20 + self.font.?.*.ascent;
203 203
204 204 for (0..self.line_count) |i| {
205 205 const key_slice = self.key_bufs[i][0..self.key_lens[i]];
206 - const key_w = self.text_width(display, key_slice);
207 - self.fill_rect(display, padding - 4, y - self.font.?.*.ascent - 2, key_w + 8, self.font_height + 4, key_bg_color);
208 - self.draw_text(display, padding, y, key_slice, fg_color);
206 + const key_w = self.textWidth(display, key_slice);
207 + self.fillRect(display, padding - 4, y - self.font.?.*.ascent - 2, key_w + 8, self.font_height + 4, key_bg_color);
208 + self.drawText(display, padding, y, key_slice, fg_color);
209 209
210 210 const desc_x = padding + max_key_width + key_action_spacing;
211 - self.draw_text(display, desc_x, y, self.descs[i], fg_color);
211 + self.drawText(display, desc_x, y, self.descs[i], fg_color);
212 212
213 213 y += line_height;
214 214 }
@@ -217,12 +217,12 @@ pub const Keybind_Overlay = struct {
217 217 _ = xlib.c.XFlush(display);
218 218 }
219 219
220 - fn fill_rect(self: *Keybind_Overlay, display: *xlib.Display, x: i32, y: i32, w: i32, h: i32, color: c_ulong) void {
220 + fn fillRect(self: *Keybind_Overlay, display: *xlib.Display, x: i32, y: i32, w: i32, h: i32, color: c_ulong) void {
221 221 _ = xlib.XSetForeground(display, self.gc, color);
222 222 _ = xlib.XFillRectangle(display, self.pixmap, self.gc, x, y, @intCast(w), @intCast(h));
223 223 }
224 224
225 - fn draw_text(self: *Keybind_Overlay, display: *xlib.Display, x: i32, y: i32, text: []const u8, color: c_ulong) void {
225 + fn drawText(self: *Keybind_Overlay, display: *xlib.Display, x: i32, y: i32, text: []const u8, color: c_ulong) void {
226 226 if (self.xft_draw == null or self.font == null) return;
227 227 if (text.len == 0) return;
228 228
@@ -241,14 +241,14 @@ pub const Keybind_Overlay = struct {
241 241 xlib.XftColorFree(display, visual, colormap, &xft_color);
242 242 }
243 243
244 - fn text_width(self: *Keybind_Overlay, display: *xlib.Display, text: []const u8) i32 {
244 + fn textWidth(self: *Keybind_Overlay, display: *xlib.Display, text: []const u8) i32 {
245 245 if (self.font == null or text.len == 0) return 0;
246 246 var extents: xlib.XGlyphInfo = undefined;
247 247 xlib.XftTextExtentsUtf8(display, self.font, text.ptr, @intCast(text.len), &extents);
248 248 return extents.xOff;
249 249 }
250 250
251 - fn collect_keybinds(self: *Keybind_Overlay, cfg: *config_mod.Config) void {
251 + fn collectKeybinds(self: *Keybind_Overlay, cfg: *config_mod.Config) void {
252 252 const priority_actions = [_]config_mod.Action{
253 253 .show_keybinds,
254 254 .quit,
@@ -271,8 +271,8 @@ pub const Keybind_Overlay = struct {
271 271
272 272 for (cfg.keybinds.items) |kb| {
273 273 if (kb.action == action and kb.key_count > 0) {
274 - self.format_key_to_buf(self.line_count, &kb.keys[0]);
275 - self.descs[self.line_count] = action_desc(action);
274 + self.formatKeyToBuf(self.line_count, &kb.keys[0]);
275 + self.descs[self.line_count] = actionDesc(action);
276 276 self.line_count += 1;
277 277 break;
278 278 }
@@ -280,7 +280,7 @@ pub const Keybind_Overlay = struct {
280 280 }
281 281 }
282 282
283 - fn format_key_to_buf(self: *Keybind_Overlay, idx: usize, key: *const config_mod.Key_Press) void {
283 + fn formatKeyToBuf(self: *Keybind_Overlay, idx: usize, key: *const config_mod.Key_Press) void {
284 284 var len: usize = 0;
285 285 var buf = &self.key_bufs[idx];
286 286
@@ -300,7 +300,7 @@ pub const Keybind_Overlay = struct {
300 300 len += s.len;
301 301 }
302 302
303 - const key_name = keysym_to_name(key.keysym);
303 + const key_name = keysymToName(key.keysym);
304 304 if (len + key_name.len < buf.len) {
305 305 @memcpy(buf[len .. len + key_name.len], key_name);
306 306 len += key_name.len;
@@ -309,7 +309,7 @@ pub const Keybind_Overlay = struct {
309 309 self.key_lens[idx] = len;
310 310 }
311 311
312 - fn keysym_to_name(keysym: u64) []const u8 {
312 + fn keysymToName(keysym: u64) []const u8 {
313 313 const upper_letters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
314 314 const digits = "0123456789";
315 315
@@ -345,7 +345,7 @@ pub const Keybind_Overlay = struct {
345 345 };
346 346 }
347 347
348 - fn action_desc(action: config_mod.Action) []const u8 {
348 + fn actionDesc(action: config_mod.Action) []const u8 {
349 349 return switch (action) {
350 350 .show_keybinds => "Show Keybinds",
351 351 .quit => "Quit WM",
+82 −82 src/wm/actions.zig
@@ -15,7 +15,7 @@ const WindowManager = wm_mod.WindowManager;
15 15
16 16 const snap_distance: i32 = 32;
17 17
18 -pub fn spawn_child_setup(wm: *WindowManager) void {
18 +pub fn spawnChildSetup(wm: *WindowManager) void {
19 19 _ = std.c.setsid();
20 20 if (wm.x11_fd >= 0) std.posix.close(@intCast(wm.x11_fd));
21 21 const sigchld_handler = std.posix.Sigaction{
@@ -26,11 +26,11 @@ pub fn spawn_child_setup(wm: *WindowManager) void {
26 26 std.posix.sigaction(std.posix.SIG.CHLD, &sigchld_handler, null);
27 27 }
28 28
29 -pub fn spawn_command(wm: *WindowManager, cmd: []const u8) void {
29 +pub fn spawnCommand(wm: *WindowManager, cmd: []const u8) void {
30 30 std.debug.print("running cmd: {s}\n", .{cmd});
31 31 const pid = std.posix.fork() catch return;
32 32 if (pid == 0) {
33 - spawn_child_setup(wm);
33 + spawnChildSetup(wm);
34 34 var cmd_buf: [1024]u8 = undefined;
35 35 if (cmd.len >= cmd_buf.len) {
36 36 std.posix.exit(1);
@@ -43,10 +43,10 @@ pub fn spawn_command(wm: *WindowManager, cmd: []const u8) void {
43 43 }
44 44 }
45 45
46 -pub fn spawn_terminal(wm: *WindowManager) void {
46 +pub fn spawnTerminal(wm: *WindowManager) void {
47 47 const pid = std.posix.fork() catch return;
48 48 if (pid == 0) {
49 - spawn_child_setup(wm);
49 + spawnChildSetup(wm);
50 50 var term_buf: [256]u8 = undefined;
51 51 const terminal = wm.config.terminal;
52 52 if (terminal.len >= term_buf.len) {
@@ -74,7 +74,7 @@ pub fn movestack(direction: i32, wm: *WindowManager) void {
74 74 if (direction > 0) {
75 75 target = current.next;
76 76 while (target) |client| {
77 - if (client_mod.is_visible(client) and !client.is_floating) {
77 + if (client_mod.isVisible(client) and !client.is_floating) {
78 78 break;
79 79 }
80 80 target = client.next;
@@ -85,7 +85,7 @@ pub fn movestack(direction: i32, wm: *WindowManager) void {
85 85 if (client == current) {
86 86 break;
87 87 }
88 - if (client_mod.is_visible(client) and !client.is_floating) {
88 + if (client_mod.isVisible(client) and !client.is_floating) {
89 89 break;
90 90 }
91 91 target = client.next;
@@ -98,7 +98,7 @@ pub fn movestack(direction: i32, wm: *WindowManager) void {
98 98 if (client == current) {
99 99 break;
100 100 }
101 - if (client_mod.is_visible(client) and !client.is_floating) {
101 + if (client_mod.isVisible(client) and !client.is_floating) {
102 102 prev = client;
103 103 }
104 104 iter = client.next;
@@ -106,7 +106,7 @@ pub fn movestack(direction: i32, wm: *WindowManager) void {
106 106 if (prev == null) {
107 107 iter = current.next;
108 108 while (iter) |client| {
109 - if (client_mod.is_visible(client) and !client.is_floating) {
109 + if (client_mod.isVisible(client) and !client.is_floating) {
110 110 prev = client;
111 111 }
112 112 iter = client.next;
@@ -117,14 +117,14 @@ pub fn movestack(direction: i32, wm: *WindowManager) void {
117 117
118 118 if (target) |swap_client| {
119 119 if (swap_client != current) {
120 - client_mod.swap_clients(current, swap_client);
120 + client_mod.swapClients(current, swap_client);
121 121 core.arrange(monitor, wm);
122 122 core.focus(current, wm);
123 123 }
124 124 }
125 125 }
126 126
127 -pub fn toggle_view(tag_mask: u32, wm: *WindowManager) void {
127 +pub fn toggleView(tag_mask: u32, wm: *WindowManager) void {
128 128 const monitor = wm.selected_monitor orelse return;
129 129 const new_tags = monitor.tagset[monitor.sel_tags] ^ tag_mask;
130 130 if (new_tags != 0) {
@@ -148,25 +148,25 @@ pub fn toggle_view(tag_mask: u32, wm: *WindowManager) void {
148 148 monitor.mfact = monitor.pertag.mfacts[monitor.pertag.curtag];
149 149 monitor.sel_lt = monitor.pertag.sellts[monitor.pertag.curtag];
150 150
151 - core.focus_top_client(monitor, wm);
151 + core.focusTopClient(monitor, wm);
152 152 core.arrange(monitor, wm);
153 - wm.invalidate_bars();
153 + wm.invalidateBars();
154 154 }
155 155 }
156 156
157 -pub fn toggle_client_tag(tag_mask: u32, wm: *WindowManager) void {
157 +pub fn toggleClientTag(tag_mask: u32, wm: *WindowManager) void {
158 158 const monitor = wm.selected_monitor orelse return;
159 159 const client = monitor.sel orelse return;
160 160 const new_tags = client.tags ^ tag_mask;
161 161 if (new_tags != 0) {
162 162 client.tags = new_tags;
163 - core.focus_top_client(monitor, wm);
163 + core.focusTopClient(monitor, wm);
164 164 core.arrange(monitor, wm);
165 - wm.invalidate_bars();
165 + wm.invalidateBars();
166 166 }
167 167 }
168 168
169 -pub fn toggle_gaps(wm: *WindowManager) void {
169 +pub fn toggleGaps(wm: *WindowManager) void {
170 170 const monitor = wm.selected_monitor orelse return;
171 171 if (monitor.gap_inner_h == 0) {
172 172 monitor.gap_inner_h = wm.config.gap_inner_h;
@@ -182,12 +182,12 @@ pub fn toggle_gaps(wm: *WindowManager) void {
182 182 core.arrange(monitor, wm);
183 183 }
184 184
185 -pub fn kill_focused(wm: *WindowManager) void {
185 +pub fn killFocused(wm: *WindowManager) void {
186 186 const selected = wm.selected_monitor orelse return;
187 187 const client = selected.sel orelse return;
188 188 std.debug.print("killing window: 0x{x}\n", .{client.window});
189 189
190 - if (!core.send_event(client, wm.atoms.wm_delete, wm)) {
190 + if (!core.sendEvent(client, wm.atoms.wm_delete, wm)) {
191 191 _ = xlib.XGrabServer(wm.display.handle);
192 192 _ = xlib.XKillClient(wm.display.handle, client.window);
193 193 _ = xlib.XSync(wm.display.handle, xlib.False);
@@ -195,13 +195,13 @@ pub fn kill_focused(wm: *WindowManager) void {
195 195 }
196 196 }
197 197
198 -pub fn toggle_fullscreen(wm: *WindowManager) void {
198 +pub fn toggleFullscreen(wm: *WindowManager) void {
199 199 const selected = wm.selected_monitor orelse return;
200 200 const client = selected.sel orelse return;
201 - core.set_fullscreen(client, !client.is_fullscreen, wm);
201 + core.setFullscreen(client, !client.is_fullscreen, wm);
202 202 }
203 203
204 -pub fn view_adjacent_tag(direction: i32, wm: *WindowManager) void {
204 +pub fn viewAdjacentTag(direction: i32, wm: *WindowManager) void {
205 205 const monitor = wm.selected_monitor orelse return;
206 206 const current_tag = monitor.pertag.curtag;
207 207 var new_tag: i32 = @intCast(current_tag);
@@ -214,7 +214,7 @@ pub fn view_adjacent_tag(direction: i32, wm: *WindowManager) void {
214 214 core.view(tag_mask, wm);
215 215 }
216 216
217 -pub fn view_adjacent_nonempty_tag(direction: i32, wm: *WindowManager) void {
217 +pub fn viewAdjacentNonemptyTag(direction: i32, wm: *WindowManager) void {
218 218 const monitor = wm.selected_monitor orelse return;
219 219 const current_tag = monitor.pertag.curtag;
220 220 var new_tag: i32 = @intCast(current_tag);
@@ -226,23 +226,23 @@ pub fn view_adjacent_nonempty_tag(direction: i32, wm: *WindowManager) void {
226 226 if (new_tag > 9) new_tag = 1;
227 227
228 228 const tag_mask: u32 = @as(u32, 1) << @intCast(new_tag - 1);
229 - if (core.has_clients_on_tag(monitor, tag_mask)) {
229 + if (core.hasClientsOnTag(monitor, tag_mask)) {
230 230 core.view(tag_mask, wm);
231 231 return;
232 232 }
233 233 }
234 234 }
235 235
236 -pub fn tag_client(tag_mask: u32, wm: *WindowManager) void {
236 +pub fn tagClient(tag_mask: u32, wm: *WindowManager) void {
237 237 const monitor = wm.selected_monitor orelse return;
238 238 const client = monitor.sel orelse return;
239 239 if (tag_mask == 0) {
240 240 return;
241 241 }
242 242 client.tags = tag_mask;
243 - core.focus_top_client(monitor, wm);
243 + core.focusTopClient(monitor, wm);
244 244 core.arrange(monitor, wm);
245 - wm.invalidate_bars();
245 + wm.invalidateBars();
246 246 std.debug.print("tag_client: window=0x{x} tag_mask={d}\n", .{ client.window, tag_mask });
247 247 }
248 248
@@ -255,7 +255,7 @@ pub fn focusstack(direction: i32, wm: *WindowManager) void {
255 255 if (direction > 0) {
256 256 next_client = current.next;
257 257 while (next_client) |client| {
258 - if (client_mod.is_visible(client)) {
258 + if (client_mod.isVisible(client)) {
259 259 break;
260 260 }
261 261 next_client = client.next;
@@ -263,7 +263,7 @@ pub fn focusstack(direction: i32, wm: *WindowManager) void {
263 263 if (next_client == null) {
264 264 next_client = monitor.clients;
265 265 while (next_client) |client| {
266 - if (client_mod.is_visible(client)) {
266 + if (client_mod.isVisible(client)) {
267 267 break;
268 268 }
269 269 next_client = client.next;
@@ -276,7 +276,7 @@ pub fn focusstack(direction: i32, wm: *WindowManager) void {
276 276 if (client == current) {
277 277 break;
278 278 }
279 - if (client_mod.is_visible(client)) {
279 + if (client_mod.isVisible(client)) {
280 280 prev = client;
281 281 }
282 282 iter = client.next;
@@ -284,7 +284,7 @@ pub fn focusstack(direction: i32, wm: *WindowManager) void {
284 284 if (prev == null) {
285 285 iter = current.next;
286 286 while (iter) |client| {
287 - if (client_mod.is_visible(client)) {
287 + if (client_mod.isVisible(client)) {
288 288 prev = client;
289 289 }
290 290 iter = client.next;
@@ -301,7 +301,7 @@ pub fn focusstack(direction: i32, wm: *WindowManager) void {
301 301 }
302 302 }
303 303
304 -pub fn toggle_floating(wm: *WindowManager) void {
304 +pub fn toggleFloating(wm: *WindowManager) void {
305 305 const monitor = wm.selected_monitor orelse return;
306 306 const client = monitor.sel orelse return;
307 307
@@ -340,7 +340,7 @@ pub fn setmfact(delta: f32, wm: *WindowManager) void {
340 340 std.debug.print("setmfact: mfact={d:.2}\n", .{monitor.mfact});
341 341 }
342 342
343 -pub fn cycle_layout(wm: *WindowManager) void {
343 +pub fn cycleLayout(wm: *WindowManager) void {
344 344 const monitor = wm.selected_monitor orelse return;
345 345 const new_lt = (monitor.sel_lt + 1) % 5;
346 346 monitor.sel_lt = new_lt;
@@ -349,13 +349,13 @@ pub fn cycle_layout(wm: *WindowManager) void {
349 349 monitor.scroll_offset = 0;
350 350 }
351 351 core.arrange(monitor, wm);
352 - wm.invalidate_bars();
352 + wm.invalidateBars();
353 353 if (monitor.lt[monitor.sel_lt]) |layout| {
354 354 std.debug.print("cycle_layout: {s}\n", .{layout.symbol});
355 355 }
356 356 }
357 357
358 -pub fn set_layout(layout_name: ?[]const u8, wm: *WindowManager) void {
358 +pub fn setLayout(layout_name: ?[]const u8, wm: *WindowManager) void {
359 359 const monitor = wm.selected_monitor orelse return;
360 360 const name = layout_name orelse return;
361 361
@@ -380,13 +380,13 @@ pub fn set_layout(layout_name: ?[]const u8, wm: *WindowManager) void {
380 380 monitor.scroll_offset = 0;
381 381 }
382 382 core.arrange(monitor, wm);
383 - wm.invalidate_bars();
383 + wm.invalidateBars();
384 384 if (monitor.lt[monitor.sel_lt]) |layout| {
385 385 std.debug.print("set_layout: {s}\n", .{layout.symbol});
386 386 }
387 387 }
388 388
389 -pub fn set_layout_index(index: u32, wm: *WindowManager) void {
389 +pub fn setLayoutIndex(index: u32, wm: *WindowManager) void {
390 390 const monitor = wm.selected_monitor orelse return;
391 391 monitor.sel_lt = index;
392 392 monitor.pertag.sellts[monitor.pertag.curtag] = index;
@@ -394,7 +394,7 @@ pub fn set_layout_index(index: u32, wm: *WindowManager) void {
394 394 monitor.scroll_offset = 0;
395 395 }
396 396 core.arrange(monitor, wm);
397 - wm.invalidate_bars();
397 + wm.invalidateBars();
398 398 if (monitor.lt[monitor.sel_lt]) |layout| {
399 399 std.debug.print("set_layout_index: {s}\n", .{layout.symbol});
400 400 }
@@ -402,11 +402,11 @@ pub fn set_layout_index(index: u32, wm: *WindowManager) void {
402 402
403 403 pub fn focusmon(direction: i32, wm: *WindowManager) void {
404 404 const selmon = wm.selected_monitor orelse return;
405 - const target = monitor_mod.dir_to_monitor(wm, direction) orelse return;
405 + const target = monitor_mod.dirToMonitor(wm, direction) orelse return;
406 406 if (target == selmon) {
407 407 return;
408 408 }
409 - core.unfocus_client(selmon.sel, false, wm);
409 + core.unfocusClient(selmon.sel, false, wm);
410 410 wm.selected_monitor = target;
411 411 core.focus(null, wm);
412 412 std.debug.print("focusmon: monitor {d}\n", .{target.num});
@@ -415,27 +415,27 @@ pub fn focusmon(direction: i32, wm: *WindowManager) void {
415 415 pub fn sendmon(direction: i32, wm: *WindowManager) void {
416 416 const source_monitor = wm.selected_monitor orelse return;
417 417 const client = source_monitor.sel orelse return;
418 - const target = monitor_mod.dir_to_monitor(wm, direction) orelse return;
418 + const target = monitor_mod.dirToMonitor(wm, direction) orelse return;
419 419
420 420 if (target == source_monitor) {
421 421 return;
422 422 }
423 423
424 424 client_mod.detach(client);
425 - client_mod.detach_stack(client);
425 + client_mod.detachStack(client);
426 426 client.monitor = target;
427 427 client.tags = target.tagset[target.sel_tags];
428 - client_mod.attach_aside(client);
429 - client_mod.attach_stack(client);
428 + client_mod.attachAside(client);
429 + client_mod.attachStack(client);
430 430
431 - core.focus_top_client(source_monitor, wm);
431 + core.focusTopClient(source_monitor, wm);
432 432 core.arrange(source_monitor, wm);
433 433 core.arrange(target, wm);
434 434
435 435 std.debug.print("sendmon: window=0x{x} to monitor {d}\n", .{ client.window, target.num });
436 436 }
437 437
438 -pub fn snap_x(client: *Client, new_x: i32, monitor: *Monitor) i32 {
438 +pub fn snapX(client: *Client, new_x: i32, monitor: *Monitor) i32 {
439 439 const client_width = client.width + 2 * client.border_width;
440 440 if (@abs(monitor.win_x - new_x) < snap_distance) {
441 441 return monitor.win_x;
@@ -445,7 +445,7 @@ pub fn snap_x(client: *Client, new_x: i32, monitor: *Monitor) i32 {
445 445 return new_x;
446 446 }
447 447
448 -pub fn snap_y(client: *Client, new_y: i32, monitor: *Monitor) i32 {
448 +pub fn snapY(client: *Client, new_y: i32, monitor: *Monitor) i32 {
449 449 const client_height = client.height + 2 * client.border_width;
450 450 if (@abs(monitor.win_y - new_y) < snap_distance) {
451 451 return monitor.win_y;
@@ -518,8 +518,8 @@ pub fn movemouse(wm: *WindowManager) void {
518 518 var new_x = start_x + delta_x;
519 519 var new_y = start_y + delta_y;
520 520 if (client.monitor) |client_monitor| {
521 - new_x = snap_x(client, new_x, client_monitor);
522 - new_y = snap_y(client, new_y, client_monitor);
521 + new_x = snapX(client, new_x, client_monitor);
522 + new_y = snapY(client, new_y, client_monitor);
523 523 }
524 524 tiling.resize(client, new_x, new_y, client.width, client.height, true);
525 525 },
@@ -532,14 +532,14 @@ pub fn movemouse(wm: *WindowManager) void {
532 532
533 533 _ = xlib.XUngrabPointer(wm.display.handle, xlib.CurrentTime);
534 534
535 - const new_mon = monitor_mod.rect_to_monitor(wm, client.x, client.y, client.width, client.height);
535 + const new_mon = monitor_mod.rectToMonitor(wm, client.x, client.y, client.width, client.height);
536 536 if (new_mon != null and new_mon != monitor) {
537 537 client_mod.detach(client);
538 - client_mod.detach_stack(client);
538 + client_mod.detachStack(client);
539 539 client.monitor = new_mon;
540 540 client.tags = new_mon.?.tagset[new_mon.?.sel_tags];
541 - client_mod.attach_aside(client);
542 - client_mod.attach_stack(client);
541 + client_mod.attachAside(client);
542 + client_mod.attachStack(client);
543 543 wm.selected_monitor = new_mon;
544 544 core.focus(client, wm);
545 545 core.arrange(monitor, wm);
@@ -553,8 +553,8 @@ pub fn movemouse(wm: *WindowManager) void {
553 553 const center_x = client.x + @divTrunc(client.width, 2);
554 554 const center_y = client.y + @divTrunc(client.height, 2);
555 555
556 - if (client_mod.tiled_window_at(client, drop_monitor, center_x, center_y)) |target| {
557 - client_mod.insert_before(client, target);
556 + if (client_mod.tiledWindowAt(client, drop_monitor, center_x, center_y)) |target| {
557 + client_mod.insertBefore(client, target);
558 558 }
559 559
560 560 client.is_floating = false;
@@ -635,16 +635,16 @@ pub fn resizemouse(wm: *WindowManager) void {
635 635 core.arrange(monitor, wm);
636 636 }
637 637
638 -/// Config-loading callback for wm.reload_config().
638 +/// Config-loading callback for wm.reloadConfig().
639 639 /// Re-initialises Lua and loads the config file (or falls back to defaults).
640 -pub fn reload_load_config(wm: *WindowManager) void {
640 +pub fn reloadLoadConfig(wm: *WindowManager) void {
641 641 lua.deinit();
642 642 _ = lua.init(&wm.config);
643 643
644 644 const loaded = if (wm.config_path) |path|
645 - lua.load_file(path)
645 + lua.loadFile(path)
646 646 else
647 - lua.load_config();
647 + lua.loadConfig();
648 648
649 649 if (loaded) {
650 650 if (wm.config_path) |path| {
@@ -654,23 +654,23 @@ pub fn reload_load_config(wm: *WindowManager) void {
654 654 }
655 655 } else {
656 656 std.debug.print("reload failed, restoring defaults\n", .{});
657 - config_mod.initialize_default_config(&wm.config);
657 + config_mod.initializeDefaultConfig(&wm.config);
658 658 }
659 659 }
660 660
661 -pub fn execute_action(action: config_mod.Action, int_arg: i32, str_arg: ?[]const u8, wm: *WindowManager) void {
661 +pub fn executeAction(action: config_mod.Action, int_arg: i32, str_arg: ?[]const u8, wm: *WindowManager) void {
662 662 switch (action) {
663 - .spawn_terminal => spawn_terminal(wm),
663 + .spawn_terminal => spawnTerminal(wm),
664 664 .spawn => {
665 - if (str_arg) |cmd| spawn_command(wm, cmd);
665 + if (str_arg) |cmd| spawnCommand(wm, cmd);
666 666 },
667 - .kill_client => kill_focused(wm),
667 + .kill_client => killFocused(wm),
668 668 .quit => {
669 669 std.debug.print("quit keybind pressed\n", .{});
670 670 wm.running = false;
671 671 },
672 - .reload_config => wm.reload_config(reload_load_config),
673 - .restart => wm.reload_config(reload_load_config),
672 + .reload_config => wm.reloadConfig(reloadLoadConfig),
673 + .restart => wm.reloadConfig(reloadLoadConfig),
674 674 .show_keybinds => {
675 675 if (wm.overlay) |overlay| {
676 676 const mon = wm.selected_monitor orelse wm.monitors;
@@ -686,36 +686,36 @@ pub fn execute_action(action: config_mod.Action, int_arg: i32, str_arg: ?[]const
686 686 .resize_master => setmfact(@as(f32, @floatFromInt(int_arg)) / 1000.0, wm),
687 687 .inc_master => incnmaster(1, wm),
688 688 .dec_master => incnmaster(-1, wm),
689 - .toggle_floating => toggle_floating(wm),
690 - .toggle_fullscreen => toggle_fullscreen(wm),
691 - .toggle_gaps => toggle_gaps(wm),
692 - .cycle_layout => cycle_layout(wm),
693 - .set_layout => set_layout(str_arg, wm),
694 - .set_layout_tiling => set_layout_index(0, wm),
695 - .set_layout_floating => set_layout_index(2, wm),
689 + .toggle_floating => toggleFloating(wm),
690 + .toggle_fullscreen => toggleFullscreen(wm),
691 + .toggle_gaps => toggleGaps(wm),
692 + .cycle_layout => cycleLayout(wm),
693 + .set_layout => setLayout(str_arg, wm),
694 + .set_layout_tiling => setLayoutIndex(0, wm),
695 + .set_layout_floating => setLayoutIndex(2, wm),
696 696 .view_tag => {
697 697 const tag_mask: u32 = @as(u32, 1) << @intCast(int_arg);
698 698 core.view(tag_mask, wm);
699 699 },
700 - .view_next_tag => view_adjacent_tag(1, wm),
701 - .view_prev_tag => view_adjacent_tag(-1, wm),
702 - .view_next_nonempty_tag => view_adjacent_nonempty_tag(1, wm),
703 - .view_prev_nonempty_tag => view_adjacent_nonempty_tag(-1, wm),
700 + .view_next_tag => viewAdjacentTag(1, wm),
701 + .view_prev_tag => viewAdjacentTag(-1, wm),
702 + .view_next_nonempty_tag => viewAdjacentNonemptyTag(1, wm),
703 + .view_prev_nonempty_tag => viewAdjacentNonemptyTag(-1, wm),
704 704 .move_to_tag => {
705 705 const tag_mask: u32 = @as(u32, 1) << @intCast(int_arg);
706 - tag_client(tag_mask, wm);
706 + tagClient(tag_mask, wm);
707 707 },
708 708 .toggle_view_tag => {
709 709 const tag_mask: u32 = @as(u32, 1) << @intCast(int_arg);
710 - toggle_view(tag_mask, wm);
710 + toggleView(tag_mask, wm);
711 711 },
712 712 .toggle_tag => {
713 713 const tag_mask: u32 = @as(u32, 1) << @intCast(int_arg);
714 - toggle_client_tag(tag_mask, wm);
714 + toggleClientTag(tag_mask, wm);
715 715 },
716 716 .focus_monitor => focusmon(int_arg, wm),
717 717 .send_to_monitor => sendmon(int_arg, wm),
718 - .scroll_left => core.scroll_layout(-1, wm),
719 - .scroll_right => core.scroll_layout(1, wm),
718 + .scroll_left => core.scrollLayout(-1, wm),
719 + .scroll_right => core.scrollLayout(1, wm),
720 720 }
721 721 }
+76 −76 src/wm/core.zig
@@ -27,10 +27,10 @@ pub fn manage(win: xlib.Window, window_attrs: *xlib.XWindowAttributes, wm: *Wind
27 27 client.old_border_width = window_attrs.border_width;
28 28 client.border_width = wm.config.border_width;
29 29
30 - update_title(client, wm);
30 + updateTitle(client, wm);
31 31
32 32 if (xlib.XGetTransientForHint(wm.display.handle, win, &trans) != 0) {
33 - if (client_mod.window_to_client(wm.monitors, trans)) |transient_client| {
33 + if (client_mod.windowToClient(wm.monitors, trans)) |transient_client| {
34 34 client.monitor = transient_client.monitor;
35 35 client.tags = transient_client.tags;
36 36 }
@@ -38,7 +38,7 @@ pub fn manage(win: xlib.Window, window_attrs: *xlib.XWindowAttributes, wm: *Wind
38 38
39 39 if (client.monitor == null) {
40 40 client.monitor = wm.selected_monitor;
41 - apply_rules(client, wm);
41 + applyRules(client, wm);
42 42 }
43 43
44 44 const monitor = client.monitor orelse return;
@@ -54,11 +54,11 @@ pub fn manage(win: xlib.Window, window_attrs: *xlib.XWindowAttributes, wm: *Wind
54 54
55 55 _ = xlib.XSetWindowBorderWidth(wm.display.handle, win, @intCast(client.border_width));
56 56 _ = xlib.XSetWindowBorder(wm.display.handle, win, wm.config.border_unfocused);
57 - tiling.send_configure(client);
57 + tiling.sendConfigure(client);
58 58
59 - update_window_type(client, wm);
60 - update_size_hints(client, wm);
61 - update_wm_hints(client, wm);
59 + updateWindowType(client, wm);
60 + updateSizeHints(client, wm);
61 + updateWmHints(client, wm);
62 62
63 63 _ = xlib.XSelectInput(
64 64 wm.display.handle,
@@ -75,20 +75,20 @@ pub fn manage(win: xlib.Window, window_attrs: *xlib.XWindowAttributes, wm: *Wind
75 75 _ = xlib.XRaiseWindow(wm.display.handle, client.window);
76 76 }
77 77
78 - client_mod.attach_aside(client);
79 - client_mod.attach_stack(client);
78 + client_mod.attachAside(client);
79 + client_mod.attachStack(client);
80 80
81 81 _ = xlib.XChangeProperty(wm.display.handle, wm.display.root, wm.atoms.net_client_list, xlib.XA_WINDOW, 32, xlib.PropModeAppend, @ptrCast(&client.window), 1);
82 - _ = xlib.XMoveResizeWindow(wm.display.handle, client.window, client.x + 2 * wm.display.screen_width(), client.y, @intCast(client.width), @intCast(client.height));
83 - set_client_state(client, NormalState, wm);
82 + _ = xlib.XMoveResizeWindow(wm.display.handle, client.window, client.x + 2 * wm.display.screenWidth(), client.y, @intCast(client.width), @intCast(client.height));
83 + setClientState(client, NormalState, wm);
84 84
85 85 if (client.monitor == wm.selected_monitor) {
86 86 const selmon = wm.selected_monitor orelse return;
87 - unfocus_client(selmon.sel, false, wm);
87 + unfocusClient(selmon.sel, false, wm);
88 88 }
89 89 monitor.sel = client;
90 90
91 - if (is_scrolling_layout(monitor)) {
91 + if (isScrollingLayout(monitor)) {
92 92 monitor.scroll_offset = 0;
93 93 }
94 94
@@ -102,7 +102,7 @@ pub fn unmanage(client: *Client, wm: *WindowManager) void {
102 102
103 103 var next_focus: ?*Client = null;
104 104 if (client_monitor) |monitor| {
105 - if (monitor.sel == client and is_scrolling_layout(monitor)) {
105 + if (monitor.sel == client and isScrollingLayout(monitor)) {
106 106 next_focus = client.next;
107 107 if (next_focus == null) {
108 108 var prev: ?*Client = null;
@@ -118,16 +118,16 @@ pub fn unmanage(client: *Client, wm: *WindowManager) void {
118 118 }
119 119
120 120 client_mod.detach(client);
121 - client_mod.detach_stack(client);
121 + client_mod.detachStack(client);
122 122
123 123 if (client_monitor) |monitor| {
124 124 if (monitor.sel == client) {
125 125 monitor.sel = if (next_focus) |nf| nf else monitor.stack;
126 126 }
127 - if (is_scrolling_layout(monitor)) {
128 - const target = if (monitor.sel) |sel| scrolling.get_target_scroll_for_window(monitor, sel) else 0;
127 + if (isScrollingLayout(monitor)) {
128 + const target = if (monitor.sel) |sel| scrolling.getTargetScrollForWindow(monitor, sel) else 0;
129 129 if (target == 0) {
130 - monitor.scroll_offset = scrolling.get_scroll_step(monitor);
130 + monitor.scroll_offset = scrolling.getScrollStep(monitor);
131 131 } else {
132 132 monitor.scroll_offset = 0;
133 133 }
@@ -142,24 +142,24 @@ pub fn unmanage(client: *Client, wm: *WindowManager) void {
142 142 }
143 143
144 144 client_mod.destroy(wm.allocator, client);
145 - update_client_list(wm);
146 - wm.invalidate_bars();
145 + updateClientList(wm);
146 + wm.invalidateBars();
147 147 }
148 148
149 149 pub fn focus(target_client: ?*Client, wm: *WindowManager) void {
150 150 const selmon = wm.selected_monitor orelse return;
151 151
152 152 var focus_client = target_client;
153 - if (focus_client == null or !client_mod.is_visible(focus_client.?)) {
153 + if (focus_client == null or !client_mod.isVisible(focus_client.?)) {
154 154 focus_client = selmon.stack;
155 155 while (focus_client) |iter| {
156 - if (client_mod.is_visible(iter)) break;
156 + if (client_mod.isVisible(iter)) break;
157 157 focus_client = iter.stack_next;
158 158 }
159 159 }
160 160
161 161 if (selmon.sel != null and selmon.sel != focus_client) {
162 - unfocus_client(selmon.sel, false, wm);
162 + unfocusClient(selmon.sel, false, wm);
163 163 }
164 164
165 165 if (focus_client) |client| {
@@ -167,17 +167,17 @@ pub fn focus(target_client: ?*Client, wm: *WindowManager) void {
167 167 wm.selected_monitor = client.monitor;
168 168 }
169 169 if (client.is_urgent) {
170 - set_urgent(client, false, wm);
170 + setUrgent(client, false, wm);
171 171 }
172 - client_mod.detach_stack(client);
173 - client_mod.attach_stack(client);
172 + client_mod.detachStack(client);
173 + client_mod.attachStack(client);
174 174 grabbuttons(client, true, wm);
175 175 _ = xlib.XSetWindowBorder(wm.display.handle, client.window, wm.config.border_focused);
176 176 if (!client.never_focus) {
177 177 _ = xlib.XSetInputFocus(wm.display.handle, client.window, xlib.RevertToPointerRoot, xlib.CurrentTime);
178 178 _ = xlib.XChangeProperty(wm.display.handle, wm.display.root, wm.atoms.net_active_window, xlib.XA_WINDOW, 32, xlib.PropModeReplace, @ptrCast(&client.window), 1);
179 179 }
180 - _ = send_event(client, wm.atoms.wm_take_focus, wm);
180 + _ = sendEvent(client, wm.atoms.wm_take_focus, wm);
181 181 } else {
182 182 _ = xlib.XSetInputFocus(wm.display.handle, wm.display.root, xlib.RevertToPointerRoot, xlib.CurrentTime);
183 183 _ = xlib.XDeleteProperty(wm.display.handle, wm.display.root, wm.atoms.net_active_window);
@@ -187,15 +187,15 @@ pub fn focus(target_client: ?*Client, wm: *WindowManager) void {
187 187 current_selmon.sel = focus_client;
188 188
189 189 if (focus_client) |client| {
190 - if (is_scrolling_layout(current_selmon)) {
191 - scroll_to_window(client, true, wm);
190 + if (isScrollingLayout(current_selmon)) {
191 + scrollToWindow(client, true, wm);
192 192 }
193 193 }
194 194
195 - wm.invalidate_bars();
195 + wm.invalidateBars();
196 196 }
197 197
198 -pub fn unfocus_client(client: ?*Client, reset_input_focus: bool, wm: *WindowManager) void {
198 +pub fn unfocusClient(client: ?*Client, reset_input_focus: bool, wm: *WindowManager) void {
199 199 const unfocus_target = client orelse return;
200 200 grabbuttons(unfocus_target, false, wm);
201 201 _ = xlib.XSetWindowBorder(wm.display.handle, unfocus_target.window, wm.config.border_unfocused);
@@ -205,16 +205,16 @@ pub fn unfocus_client(client: ?*Client, reset_input_focus: bool, wm: *WindowMana
205 205 }
206 206 }
207 207
208 -pub fn set_focus(client: *Client, wm: *WindowManager) void {
208 +pub fn setFocus(client: *Client, wm: *WindowManager) void {
209 209 if (!client.never_focus) {
210 210 _ = xlib.XSetInputFocus(wm.display.handle, client.window, xlib.RevertToPointerRoot, xlib.CurrentTime);
211 211 _ = xlib.XChangeProperty(wm.display.handle, wm.display.root, wm.atoms.net_active_window, xlib.XA_WINDOW, 32, xlib.PropModeReplace, @ptrCast(&client.window), 1);
212 212 }
213 - _ = send_event(client, wm.atoms.wm_take_focus, wm);
213 + _ = sendEvent(client, wm.atoms.wm_take_focus, wm);
214 214 }
215 215
216 216 pub fn restack(monitor: *Monitor, wm: *WindowManager) void {
217 - wm.invalidate_bars();
217 + wm.invalidateBars();
218 218 const selected_client = monitor.sel orelse return;
219 219
220 220 if (selected_client.is_floating or monitor.lt[monitor.sel_lt] == null) {
@@ -228,7 +228,7 @@ pub fn restack(monitor: *Monitor, wm: *WindowManager) void {
228 228
229 229 var current = monitor.stack;
230 230 while (current) |client| {
231 - if (!client.is_floating and client_mod.is_visible(client)) {
231 + if (!client.is_floating and client_mod.isVisible(client)) {
232 232 _ = xlib.c.XConfigureWindow(wm.display.handle, client.window, xlib.c.CWSibling | xlib.c.CWStackMode, &window_changes);
233 233 window_changes.sibling = client.window;
234 234 }
@@ -253,27 +253,27 @@ pub fn arrange(monitor: *Monitor, wm: *WindowManager) void {
253 253 }
254 254
255 255 pub fn showhide(monitor: *Monitor, wm: *WindowManager) void {
256 - showhide_client(monitor.stack, wm);
256 + showhideClient(monitor.stack, wm);
257 257 }
258 258
259 -pub fn showhide_client(client: ?*Client, wm: *WindowManager) void {
259 +pub fn showhideClient(client: ?*Client, wm: *WindowManager) void {
260 260 const target = client orelse return;
261 - if (client_mod.is_visible(target)) {
261 + if (client_mod.isVisible(target)) {
262 262 _ = xlib.XMoveWindow(wm.display.handle, target.window, target.x, target.y);
263 263 const monitor = target.monitor orelse return;
264 264 if ((monitor.lt[monitor.sel_lt] == null or target.is_floating) and !target.is_fullscreen) {
265 265 tiling.resize(target, target.x, target.y, target.width, target.height, false);
266 266 }
267 - showhide_client(target.stack_next, wm);
267 + showhideClient(target.stack_next, wm);
268 268 } else {
269 - showhide_client(target.stack_next, wm);
269 + showhideClient(target.stack_next, wm);
270 270 const client_width = target.width + 2 * target.border_width;
271 271 _ = xlib.XMoveWindow(wm.display.handle, target.window, -2 * client_width, target.y);
272 272 }
273 273 }
274 274
275 275 pub fn grabbuttons(client: *Client, focused: bool, wm: *WindowManager) void {
276 - wm.update_numlock_mask();
276 + wm.updateNumlockMask();
277 277 const modifiers = [_]c_uint{ 0, xlib.LockMask, wm.numlock_mask, wm.numlock_mask | xlib.LockMask };
278 278
279 279 _ = xlib.XUngrabButton(wm.display.handle, xlib.AnyButton, xlib.AnyModifier, client.window);
@@ -311,12 +311,12 @@ pub fn grabbuttons(client: *Client, focused: bool, wm: *WindowManager) void {
311 311 }
312 312 }
313 313
314 -pub fn set_client_state(client: *Client, state: c_long, wm: *WindowManager) void {
314 +pub fn setClientState(client: *Client, state: c_long, wm: *WindowManager) void {
315 315 var data: [2]c_long = .{ state, xlib.None };
316 316 _ = xlib.c.XChangeProperty(wm.display.handle, client.window, wm.atoms.wm_state, xlib.XA_ATOM, 32, xlib.PropModeReplace, @ptrCast(&data), 2);
317 317 }
318 318
319 -pub fn set_fullscreen(client: *Client, fullscreen: bool, wm: *WindowManager) void {
319 +pub fn setFullscreen(client: *Client, fullscreen: bool, wm: *WindowManager) void {
320 320 const monitor = client.monitor orelse return;
321 321
322 322 if (fullscreen and !client.is_fullscreen) {
@@ -338,7 +338,7 @@ pub fn set_fullscreen(client: *Client, fullscreen: bool, wm: *WindowManager) voi
338 338 client.is_floating = true;
339 339
340 340 _ = xlib.XSetWindowBorderWidth(wm.display.handle, client.window, 0);
341 - tiling.resize_client(client, monitor.mon_x, monitor.mon_y, monitor.mon_w, monitor.mon_h);
341 + tiling.resizeClient(client, monitor.mon_x, monitor.mon_y, monitor.mon_w, monitor.mon_h);
342 342 _ = xlib.XRaiseWindow(wm.display.handle, client.window);
343 343
344 344 std.debug.print("fullscreen enabled: window=0x{x}\n", .{client.window});
@@ -363,17 +363,17 @@ pub fn set_fullscreen(client: *Client, fullscreen: bool, wm: *WindowManager) voi
363 363 client.width = client.old_width;
364 364 client.height = client.old_height;
365 365
366 - tiling.resize_client(client, client.x, client.y, client.width, client.height);
366 + tiling.resizeClient(client, client.x, client.y, client.width, client.height);
367 367 arrange(monitor, wm);
368 368
369 369 std.debug.print("fullscreen disabled: window=0x{x}\n", .{client.window});
370 370 }
371 371 }
372 372
373 -pub fn focus_top_client(monitor: *Monitor, wm: *WindowManager) void {
373 +pub fn focusTopClient(monitor: *Monitor, wm: *WindowManager) void {
374 374 var visible_client = monitor.stack;
375 375 while (visible_client) |client| {
376 - if (client_mod.is_visible(client)) {
376 + if (client_mod.isVisible(client)) {
377 377 focus(client, wm);
378 378 return;
379 379 }
@@ -383,8 +383,8 @@ pub fn focus_top_client(monitor: *Monitor, wm: *WindowManager) void {
383 383 _ = xlib.XSetInputFocus(wm.display.handle, wm.display.root, xlib.RevertToPointerRoot, xlib.CurrentTime);
384 384 }
385 385
386 -pub fn tick_animations(wm: *WindowManager) void {
387 - if (!wm.scroll_animation.is_active()) return;
386 +pub fn tickAnimations(wm: *WindowManager) void {
387 + if (!wm.scroll_animation.isActive()) return;
388 388
389 389 const monitor = wm.selected_monitor orelse return;
390 390 if (wm.scroll_animation.update()) |new_offset| {
@@ -393,21 +393,21 @@ pub fn tick_animations(wm: *WindowManager) void {
393 393 }
394 394 }
395 395
396 -pub fn is_scrolling_layout(monitor: *Monitor) bool {
396 +pub fn isScrollingLayout(monitor: *Monitor) bool {
397 397 if (monitor.lt[monitor.sel_lt]) |layout| {
398 398 return layout.arrange_fn == scrolling.layout.arrange_fn;
399 399 }
400 400 return false;
401 401 }
402 402
403 -pub fn scroll_layout(direction: i32, wm: *WindowManager) void {
403 +pub fn scrollLayout(direction: i32, wm: *WindowManager) void {
404 404 const monitor = wm.selected_monitor orelse return;
405 - if (!is_scrolling_layout(monitor)) return;
405 + if (!isScrollingLayout(monitor)) return;
406 406
407 - const scroll_step = scrolling.get_scroll_step(monitor);
408 - const max_scroll = scrolling.get_max_scroll(monitor);
407 + const scroll_step = scrolling.getScrollStep(monitor);
408 + const max_scroll = scrolling.getMaxScroll(monitor);
409 409
410 - const current = if (wm.scroll_animation.is_active())
410 + const current = if (wm.scroll_animation.isActive())
411 411 wm.scroll_animation.target()
412 412 else
413 413 monitor.scroll_offset;
@@ -418,11 +418,11 @@ pub fn scroll_layout(direction: i32, wm: *WindowManager) void {
418 418 wm.scroll_animation.start(monitor.scroll_offset, target, wm.animation_config);
419 419 }
420 420
421 -pub fn scroll_to_window(client: *Client, animate: bool, wm: *WindowManager) void {
421 +pub fn scrollToWindow(client: *Client, animate: bool, wm: *WindowManager) void {
422 422 const monitor = client.monitor orelse return;
423 - if (!is_scrolling_layout(monitor)) return;
423 + if (!isScrollingLayout(monitor)) return;
424 424
425 - const target = scrolling.get_target_scroll_for_window(monitor, client);
425 + const target = scrolling.getTargetScrollForWindow(monitor, client);
426 426
427 427 if (animate) {
428 428 wm.scroll_animation.start(monitor.scroll_offset, target, wm.animation_config);
@@ -432,7 +432,7 @@ pub fn scroll_to_window(client: *Client, animate: bool, wm: *WindowManager) void
432 432 }
433 433 }
434 434
435 -pub fn apply_rules(client: *Client, wm: *WindowManager) void {
435 +pub fn applyRules(client: *Client, wm: *WindowManager) void {
436 436 var class_hint: xlib.XClassHint = .{ .res_name = null, .res_class = null };
437 437 _ = xlib.XGetClassHint(wm.display.handle, client.window, &class_hint);
438 438
@@ -490,7 +490,7 @@ pub fn apply_rules(client: *Client, wm: *WindowManager) void {
490 490 }
491 491 }
492 492
493 -pub fn update_size_hints(client: *Client, wm: *WindowManager) void {
493 +pub fn updateSizeHints(client: *Client, wm: *WindowManager) void {
494 494 var size_hints: xlib.XSizeHints = undefined;
495 495 var msize: c_long = 0;
496 496
@@ -548,7 +548,7 @@ pub fn update_size_hints(client: *Client, wm: *WindowManager) void {
548 548 client.hints_valid = true;
549 549 }
550 550
551 -pub fn update_wm_hints(client: *Client, wm: *WindowManager) void {
551 +pub fn updateWmHints(client: *Client, wm: *WindowManager) void {
552 552 const wmh = xlib.XGetWMHints(wm.display.handle, client.window);
553 553 if (wmh) |hints| {
554 554 defer _ = xlib.XFree(@ptrCast(hints));
@@ -568,28 +568,28 @@ pub fn update_wm_hints(client: *Client, wm: *WindowManager) void {
568 568 }
569 569 }
570 570
571 -pub fn update_window_type(client: *Client, wm: *WindowManager) void {
572 - const state = get_atom_prop(client, wm.atoms.net_wm_state, wm);
573 - const window_type = get_atom_prop(client, wm.atoms.net_wm_window_type, wm);
571 +pub fn updateWindowType(client: *Client, wm: *WindowManager) void {
572 + const state = getAtomProp(client, wm.atoms.net_wm_state, wm);
573 + const window_type = getAtomProp(client, wm.atoms.net_wm_window_type, wm);
574 574
575 575 if (state == wm.atoms.net_wm_state_fullscreen) {
576 - set_fullscreen(client, true, wm);
576 + setFullscreen(client, true, wm);
577 577 }
578 578 if (window_type == wm.atoms.net_wm_window_type_dialog) {
579 579 client.is_floating = true;
580 580 }
581 581 }
582 582
583 -pub fn update_title(client: *Client, wm: *WindowManager) void {
584 - if (!get_text_prop(client.window, wm.atoms.net_wm_name, &client.name, wm)) {
585 - _ = get_text_prop(client.window, xlib.XA_WM_NAME, &client.name, wm);
583 +pub fn updateTitle(client: *Client, wm: *WindowManager) void {
584 + if (!getTextProp(client.window, wm.atoms.net_wm_name, &client.name, wm)) {
585 + _ = getTextProp(client.window, xlib.XA_WM_NAME, &client.name, wm);
586 586 }
587 587 if (client.name[0] == 0) {
588 588 @memcpy(client.name[0..6], "broken");
589 589 }
590 590 }
591 591
592 -pub fn get_atom_prop(client: *Client, prop: xlib.Atom, wm: *WindowManager) xlib.Atom {
592 +pub fn getAtomProp(client: *Client, prop: xlib.Atom, wm: *WindowManager) xlib.Atom {
593 593 var actual_type: xlib.Atom = undefined;
594 594 var actual_format: c_int = undefined;
595 595 var num_items: c_ulong = undefined;
@@ -604,7 +604,7 @@ pub fn get_atom_prop(client: *Client, prop: xlib.Atom, wm: *WindowManager) xlib.
604 604 return 0;
605 605 }
606 606
607 -pub fn get_text_prop(window: xlib.Window, atom: xlib.Atom, text: *[256]u8, wm: *WindowManager) bool {
607 +pub fn getTextProp(window: xlib.Window, atom: xlib.Atom, text: *[256]u8, wm: *WindowManager) bool {
608 608 var name: xlib.XTextProperty = undefined;
609 609 text[0] = 0;
610 610
@@ -632,7 +632,7 @@ pub fn get_text_prop(window: xlib.Window, atom: xlib.Atom, text: *[256]u8, wm: *
632 632 return true;
633 633 }
634 634
635 -pub fn update_client_list(wm: *WindowManager) void {
635 +pub fn updateClientList(wm: *WindowManager) void {
636 636 _ = xlib.XDeleteProperty(wm.display.handle, wm.display.root, wm.atoms.net_client_list);
637 637
638 638 var current_monitor = wm.monitors;
@@ -646,7 +646,7 @@ pub fn update_client_list(wm: *WindowManager) void {
646 646 }
647 647 }
648 648
649 -pub fn send_event(client: *Client, protocol: xlib.Atom, wm: *WindowManager) bool {
649 +pub fn sendEvent(client: *Client, protocol: xlib.Atom, wm: *WindowManager) bool {
650 650 var protocols: [*c]xlib.Atom = undefined;
651 651 var num_protocols: c_int = 0;
652 652 var exists = false;
@@ -675,7 +675,7 @@ pub fn send_event(client: *Client, protocol: xlib.Atom, wm: *WindowManager) bool
675 675 return exists;
676 676 }
677 677
678 -pub fn set_urgent(client: *Client, urgent: bool, wm: *WindowManager) void {
678 +pub fn setUrgent(client: *Client, urgent: bool, wm: *WindowManager) void {
679 679 client.is_urgent = urgent;
680 680 const wmh = xlib.XGetWMHints(wm.display.handle, client.window);
681 681 if (wmh) |hints| {
@@ -689,7 +689,7 @@ pub fn set_urgent(client: *Client, urgent: bool, wm: *WindowManager) void {
689 689 }
690 690 }
691 691
692 -pub fn has_clients_on_tag(monitor: *monitor_mod.Monitor, tag_mask: u32) bool {
692 +pub fn hasClientsOnTag(monitor: *monitor_mod.Monitor, tag_mask: u32) bool {
693 693 var client = monitor.clients;
694 694 while (client) |c| {
695 695 if ((c.tags & tag_mask) != 0) {
@@ -729,8 +729,8 @@ pub fn view(tag_mask: u32, wm: *WindowManager) void {
729 729 monitor.mfact = monitor.pertag.mfacts[monitor.pertag.curtag];
730 730 monitor.sel_lt = monitor.pertag.sellts[monitor.pertag.curtag];
731 731
732 - focus_top_client(monitor, wm);
732 + focusTopClient(monitor, wm);
733 733 arrange(monitor, wm);
734 - wm.invalidate_bars();
734 + wm.invalidateBars();
735 735 std.debug.print("view: tag_mask={d}\n", .{monitor.tagset[monitor.sel_tags]});
736 736 }
+63 −63 src/wm/handlers.zig
@@ -12,31 +12,31 @@ const xlib = @import("../x11/xlib.zig");
12 12
13 13 const WindowManager = wm_mod.WindowManager;
14 14
15 -pub fn handle_event(event: *xlib.XEvent, wm: *WindowManager) void {
16 - const event_type = events.get_event_type(event);
15 +pub fn handleEvent(event: *xlib.XEvent, wm: *WindowManager) void {
16 + const event_type = events.getEventType(event);
17 17
18 18 if (event_type == .button_press) {
19 19 std.debug.print("EVENT: button_press received type={d}\n", .{event.type});
20 20 }
21 21
22 22 switch (event_type) {
23 - .map_request => handle_map_request(&event.xmaprequest, wm),
24 - .configure_request => handle_configure_request(&event.xconfigurerequest, wm),
25 - .key_press => handle_key_press(&event.xkey, wm),
26 - .destroy_notify => handle_destroy_notify(&event.xdestroywindow, wm),
27 - .unmap_notify => handle_unmap_notify(&event.xunmap, wm),
28 - .enter_notify => handle_enter_notify(&event.xcrossing, wm),
29 - .focus_in => handle_focus_in(&event.xfocus, wm),
30 - .motion_notify => handle_motion_notify(&event.xmotion, wm),
31 - .client_message => handle_client_message(&event.xclient, wm),
32 - .button_press => handle_button_press(&event.xbutton, wm),
33 - .expose => handle_expose(&event.xexpose, wm),
34 - .property_notify => handle_property_notify(&event.xproperty, wm),
23 + .map_request => handleMapRequest(&event.xmaprequest, wm),
24 + .configure_request => handleConfigureRequest(&event.xconfigurerequest, wm),
25 + .key_press => handleKeyPress(&event.xkey, wm),
26 + .destroy_notify => handleDestroyNotify(&event.xdestroywindow, wm),
27 + .unmap_notify => handleUnmapNotify(&event.xunmap, wm),
28 + .enter_notify => handleEnterNotify(&event.xcrossing, wm),
29 + .focus_in => handleFocusIn(&event.xfocus, wm),
30 + .motion_notify => handleMotionNotify(&event.xmotion, wm),
31 + .client_message => handleClientMessage(&event.xclient, wm),
32 + .button_press => handleButtonPress(&event.xbutton, wm),
33 + .expose => handleExpose(&event.xexpose, wm),
34 + .property_notify => handlePropertyNotify(&event.xproperty, wm),
35 35 else => {},
36 36 }
37 37 }
38 38
39 -fn handle_map_request(event: *xlib.XMapRequestEvent, wm: *WindowManager) void {
39 +fn handleMapRequest(event: *xlib.XMapRequestEvent, wm: *WindowManager) void {
40 40 std.debug.print("map_request: window=0x{x}\n", .{event.window});
41 41
42 42 var window_attributes: xlib.XWindowAttributes = undefined;
@@ -46,15 +46,15 @@ fn handle_map_request(event: *xlib.XMapRequestEvent, wm: *WindowManager) void {
46 46 if (window_attributes.override_redirect != 0) {
47 47 return;
48 48 }
49 - if (client_mod.window_to_client(wm.monitors, event.window) != null) {
49 + if (client_mod.windowToClient(wm.monitors, event.window) != null) {
50 50 return;
51 51 }
52 52
53 53 core.manage(event.window, &window_attributes, wm);
54 54 }
55 55
56 -fn handle_configure_request(event: *xlib.XConfigureRequestEvent, wm: *WindowManager) void {
57 - const client = client_mod.window_to_client(wm.monitors, event.window);
56 +fn handleConfigureRequest(event: *xlib.XConfigureRequestEvent, wm: *WindowManager) void {
57 + const client = client_mod.windowToClient(wm.monitors, event.window);
58 58
59 59 if (client) |managed_client| {
60 60 if ((event.value_mask & xlib.c.CWBorderWidth) != 0) {
@@ -86,13 +86,13 @@ fn handle_configure_request(event: *xlib.XConfigureRequestEvent, wm: *WindowMana
86 86 managed_client.y = monitor.mon_y + @divTrunc(monitor.mon_h, 2) - @divTrunc(client_full_height, 2);
87 87 }
88 88 if (((event.value_mask & (xlib.c.CWX | xlib.c.CWY)) != 0) and ((event.value_mask & (xlib.c.CWWidth | xlib.c.CWHeight)) == 0)) {
89 - tiling.send_configure(managed_client);
89 + tiling.sendConfigure(managed_client);
90 90 }
91 - if (client_mod.is_visible(managed_client)) {
91 + if (client_mod.isVisible(managed_client)) {
92 92 _ = xlib.XMoveResizeWindow(wm.display.handle, managed_client.window, managed_client.x, managed_client.y, @intCast(managed_client.width), @intCast(managed_client.height));
93 93 }
94 94 } else {
95 - tiling.send_configure(managed_client);
95 + tiling.sendConfigure(managed_client);
96 96 }
97 97 } else {
98 98 var changes: xlib.XWindowChanges = undefined;
@@ -108,16 +108,16 @@ fn handle_configure_request(event: *xlib.XConfigureRequestEvent, wm: *WindowMana
108 108 _ = xlib.XSync(wm.display.handle, xlib.False);
109 109 }
110 110
111 -fn handle_key_press(event: *xlib.XKeyEvent, wm: *WindowManager) void {
111 +fn handleKeyPress(event: *xlib.XKeyEvent, wm: *WindowManager) void {
112 112 const keysym = xlib.XKeycodeToKeysym(wm.display.handle, @intCast(event.keycode), 0);
113 113
114 114 if (wm.overlay) |overlay| {
115 - if (overlay.handle_key(keysym)) return;
115 + if (overlay.handleKey(keysym)) return;
116 116 }
117 117
118 118 const clean_state = event.state & ~@as(c_uint, xlib.LockMask | xlib.Mod2Mask);
119 119
120 - if (wm.chord.is_timed_out()) {
120 + if (wm.chord.isTimedOut()) {
121 121 wm.chord.reset(wm.display.handle);
122 122 }
123 123
@@ -137,7 +137,7 @@ fn handle_key_press(event: *xlib.XKeyEvent, wm: *WindowManager) void {
137 137 }
138 138 }
139 139 if (matches) {
140 - actions.execute_action(keybind.action, keybind.int_arg, keybind.str_arg, wm);
140 + actions.executeAction(keybind.action, keybind.int_arg, keybind.str_arg, wm);
141 141 wm.chord.reset(wm.display.handle);
142 142 return;
143 143 }
@@ -164,13 +164,13 @@ fn handle_key_press(event: *xlib.XKeyEvent, wm: *WindowManager) void {
164 164 }
165 165
166 166 if (has_partial_match) {
167 - wm.chord.grab_keyboard(wm.display.handle, wm.display.root);
167 + wm.chord.grabKeyboard(wm.display.handle, wm.display.root);
168 168 } else {
169 169 wm.chord.reset(wm.display.handle);
170 170 }
171 171 }
172 172
173 -fn clean_mask(mask: c_uint, wm: *WindowManager) c_uint {
173 +fn cleanMask(mask: c_uint, wm: *WindowManager) c_uint {
174 174 const lock: c_uint = @intCast(xlib.LockMask);
175 175 const shift: c_uint = @intCast(xlib.ShiftMask);
176 176 const ctrl: c_uint = @intCast(xlib.ControlMask);
@@ -182,30 +182,30 @@ fn clean_mask(mask: c_uint, wm: *WindowManager) c_uint {
182 182 return mask & ~(lock | wm.numlock_mask) & (shift | ctrl | mod1 | mod2 | mod3 | mod4 | mod5);
183 183 }
184 184
185 -fn handle_expose(event: *xlib.XExposeEvent, wm: *WindowManager) void {
185 +fn handleExpose(event: *xlib.XExposeEvent, wm: *WindowManager) void {
186 186 if (event.count != 0) return;
187 - if (bar_mod.window_to_bar(wm.bars, event.window)) |bar| {
187 + if (bar_mod.windowToBar(wm.bars, event.window)) |bar| {
188 188 bar.invalidate();
189 189 bar.draw(wm.display.handle, wm.config);
190 190 }
191 191 }
192 192
193 -fn handle_button_press(event: *xlib.XButtonEvent, wm: *WindowManager) void {
193 +fn handleButtonPress(event: *xlib.XButtonEvent, wm: *WindowManager) void {
194 194 std.debug.print("button_press: window=0x{x} subwindow=0x{x}\n", .{ event.window, event.subwindow });
195 195
196 - const clicked_monitor = monitor_mod.window_to_monitor(wm, event.window);
196 + const clicked_monitor = monitor_mod.windowToMonitor(wm, event.window);
197 197 if (clicked_monitor) |monitor| {
198 198 if (monitor != wm.selected_monitor) {
199 199 if (wm.selected_monitor) |selmon| {
200 - core.unfocus_client(selmon.sel, true, wm);
200 + core.unfocusClient(selmon.sel, true, wm);
201 201 }
202 202 wm.selected_monitor = monitor;
203 203 core.focus(null, wm);
204 204 }
205 205 }
206 206
207 - if (bar_mod.window_to_bar(wm.bars, event.window)) |bar| {
208 - const clicked_tag = bar.handle_click(wm.display.handle, event.x, wm.config);
207 + if (bar_mod.windowToBar(wm.bars, event.window)) |bar| {
208 + const clicked_tag = bar.handleClick(wm.display.handle, event.x, wm.config);
209 209 if (clicked_tag) |tag_index| {
210 210 const tag_mask: u32 = @as(u32, 1) << @intCast(tag_index);
211 211 core.view(tag_mask, wm);
@@ -213,7 +213,7 @@ fn handle_button_press(event: *xlib.XButtonEvent, wm: *WindowManager) void {
213 213 return;
214 214 }
215 215
216 - const click_client = client_mod.window_to_client(wm.monitors, event.window);
216 + const click_client = client_mod.windowToClient(wm.monitors, event.window);
217 217 if (click_client) |found_client| {
218 218 core.focus(found_client, wm);
219 219 if (wm.selected_monitor) |selmon| {
@@ -222,10 +222,10 @@ fn handle_button_press(event: *xlib.XButtonEvent, wm: *WindowManager) void {
222 222 _ = xlib.XAllowEvents(wm.display.handle, xlib.ReplayPointer, xlib.CurrentTime);
223 223 }
224 224
225 - const clean_state = clean_mask(event.state, wm);
225 + const clean_state = cleanMask(event.state, wm);
226 226 for (wm.config.buttons.items) |button| {
227 227 if (button.click != .client_win) continue;
228 - const button_clean_mask = clean_mask(button.mod_mask, wm);
228 + const button_clean_mask = cleanMask(button.mod_mask, wm);
229 229 if (clean_state == button_clean_mask and event.button == button.button) {
230 230 switch (button.action) {
231 231 .move_mouse => actions.movemouse(wm),
@@ -244,8 +244,8 @@ fn handle_button_press(event: *xlib.XButtonEvent, wm: *WindowManager) void {
244 244 }
245 245 }
246 246
247 -fn handle_client_message(event: *xlib.XClientMessageEvent, wm: *WindowManager) void {
248 - const client = client_mod.window_to_client(wm.monitors, event.window) orelse return;
247 +fn handleClientMessage(event: *xlib.XClientMessageEvent, wm: *WindowManager) void {
248 + const client = client_mod.windowToClient(wm.monitors, event.window) orelse return;
249 249
250 250 if (event.message_type == wm.atoms.net_wm_state) {
251 251 const action = event.data.l[0];
@@ -258,45 +258,45 @@ fn handle_client_message(event: *xlib.XClientMessageEvent, wm: *WindowManager) v
258 258 const net_wm_state_toggle = 2;
259 259
260 260 if (action == net_wm_state_add) {
261 - core.set_fullscreen(client, true, wm);
261 + core.setFullscreen(client, true, wm);
262 262 } else if (action == net_wm_state_remove) {
263 - core.set_fullscreen(client, false, wm);
263 + core.setFullscreen(client, false, wm);
264 264 } else if (action == net_wm_state_toggle) {
265 - core.set_fullscreen(client, !client.is_fullscreen, wm);
265 + core.setFullscreen(client, !client.is_fullscreen, wm);
266 266 }
267 267 }
268 268 } else if (event.message_type == wm.atoms.net_active_window) {
269 269 const selected = wm.selected_monitor orelse return;
270 270 if (client != selected.sel and !client.is_urgent) {
271 - core.set_urgent(client, true, wm);
271 + core.setUrgent(client, true, wm);
272 272 }
273 273 }
274 274 }
275 275
276 -fn handle_destroy_notify(event: *xlib.XDestroyWindowEvent, wm: *WindowManager) void {
277 - const client = client_mod.window_to_client(wm.monitors, event.window) orelse return;
276 +fn handleDestroyNotify(event: *xlib.XDestroyWindowEvent, wm: *WindowManager) void {
277 + const client = client_mod.windowToClient(wm.monitors, event.window) orelse return;
278 278 std.debug.print("destroy_notify: window=0x{x}\n", .{event.window});
279 279 core.unmanage(client, wm);
280 280 }
281 281
282 -fn handle_unmap_notify(event: *xlib.XUnmapEvent, wm: *WindowManager) void {
283 - const client = client_mod.window_to_client(wm.monitors, event.window) orelse return;
282 +fn handleUnmapNotify(event: *xlib.XUnmapEvent, wm: *WindowManager) void {
283 + const client = client_mod.windowToClient(wm.monitors, event.window) orelse return;
284 284 std.debug.print("unmap_notify: window=0x{x}\n", .{event.window});
285 285 core.unmanage(client, wm);
286 286 }
287 287
288 -fn handle_enter_notify(event: *xlib.XCrossingEvent, wm: *WindowManager) void {
288 +fn handleEnterNotify(event: *xlib.XCrossingEvent, wm: *WindowManager) void {
289 289 if ((event.mode != xlib.NotifyNormal or event.detail == xlib.NotifyInferior) and event.window != wm.display.root) {
290 290 return;
291 291 }
292 292
293 - const client = client_mod.window_to_client(wm.monitors, event.window);
294 - const target_mon = if (client) |c| c.monitor else monitor_mod.window_to_monitor(wm, event.window);
293 + const client = client_mod.windowToClient(wm.monitors, event.window);
294 + const target_mon = if (client) |c| c.monitor else monitor_mod.windowToMonitor(wm, event.window);
295 295 const selmon = wm.selected_monitor;
296 296
297 297 if (target_mon != selmon) {
298 298 if (selmon) |sel| {
299 - core.unfocus_client(sel.sel, true, wm);
299 + core.unfocusClient(sel.sel, true, wm);
300 300 }
301 301 wm.selected_monitor = target_mon;
302 302 } else if (client == null) {
@@ -310,21 +310,21 @@ fn handle_enter_notify(event: *xlib.XCrossingEvent, wm: *WindowManager) void {
310 310 core.focus(client, wm);
311 311 }
312 312
313 -fn handle_focus_in(event: *xlib.XFocusChangeEvent, wm: *WindowManager) void {
313 +fn handleFocusIn(event: *xlib.XFocusChangeEvent, wm: *WindowManager) void {
314 314 const selmon = wm.selected_monitor orelse return;
315 315 const selected = selmon.sel orelse return;
316 316 if (event.window != selected.window) {
317 - core.set_focus(selected, wm);
317 + core.setFocus(selected, wm);
318 318 }
319 319 }
320 320
321 -fn handle_motion_notify(event: *xlib.XMotionEvent, wm: *WindowManager) void {
321 +fn handleMotionNotify(event: *xlib.XMotionEvent, wm: *WindowManager) void {
322 322 if (event.window != wm.display.root) return;
323 323
324 - const target_mon = monitor_mod.rect_to_monitor(wm, event.x_root, event.y_root, 1, 1);
324 + const target_mon = monitor_mod.rectToMonitor(wm, event.x_root, event.y_root, 1, 1);
325 325 if (target_mon != wm.last_motion_monitor and wm.last_motion_monitor != null) {
326 326 if (wm.selected_monitor) |selmon| {
327 - core.unfocus_client(selmon.sel, true, wm);
327 + core.unfocusClient(selmon.sel, true, wm);
328 328 }
329 329 wm.selected_monitor = target_mon;
330 330 core.focus(null, wm);
@@ -332,17 +332,17 @@ fn handle_motion_notify(event: *xlib.XMotionEvent, wm: *WindowManager) void {
332 332 wm.last_motion_monitor = target_mon;
333 333 }
334 334
335 -fn handle_property_notify(event: *xlib.XPropertyEvent, wm: *WindowManager) void {
335 +fn handlePropertyNotify(event: *xlib.XPropertyEvent, wm: *WindowManager) void {
336 336 if (event.state == xlib.PropertyDelete) {
337 337 return;
338 338 }
339 339
340 - const client = client_mod.window_to_client(wm.monitors, event.window) orelse return;
340 + const client = client_mod.windowToClient(wm.monitors, event.window) orelse return;
341 341
342 342 if (event.atom == xlib.XA_WM_TRANSIENT_FOR) {
343 343 var trans: xlib.Window = 0;
344 344 if (!client.is_floating and xlib.XGetTransientForHint(wm.display.handle, client.window, &trans) != 0) {
345 - client.is_floating = client_mod.window_to_client(wm.monitors, trans) != null;
345 + client.is_floating = client_mod.windowToClient(wm.monitors, trans) != null;
346 346 if (client.is_floating) {
347 347 if (client.monitor) |monitor| {
348 348 core.arrange(monitor, wm);
@@ -352,11 +352,11 @@ fn handle_property_notify(event: *xlib.XPropertyEvent, wm: *WindowManager) void
352 352 } else if (event.atom == xlib.XA_WM_NORMAL_HINTS) {
353 353 client.hints_valid = false;
354 354 } else if (event.atom == xlib.XA_WM_HINTS) {
355 - core.update_wm_hints(client, wm);
356 - wm.invalidate_bars();
355 + core.updateWmHints(client, wm);
356 + wm.invalidateBars();
357 357 } else if (event.atom == xlib.XA_WM_NAME or event.atom == wm.atoms.net_wm_name) {
358 - core.update_title(client, wm);
358 + core.updateTitle(client, wm);
359 359 } else if (event.atom == wm.atoms.net_wm_window_type) {
360 - core.update_window_type(client, wm);
360 + core.updateWindowType(client, wm);
361 361 }
362 362 }
+65 −65 src/wm/wm.zig
@@ -94,7 +94,7 @@ pub const WindowManager = struct {
94 94 var display = try Display.open();
95 95 errdefer display.close();
96 96
97 - try display.become_window_manager();
97 + try display.becomeWindowManager();
98 98
99 99 const x11_fd = xlib.XConnectionNumber(display.handle);
100 100
@@ -102,8 +102,8 @@ pub const WindowManager = struct {
102 102 const cursors = Cursors.init(&display);
103 103 _ = xlib.XDefineCursor(display.handle, display.root, cursors.normal);
104 104
105 - tiling.set_display(display.handle);
106 - tiling.set_screen_size(display.screen_width(), display.screen_height());
105 + tiling.setDisplay(display.handle);
106 + tiling.setScreenSize(display.screenWidth(), display.screenHeight());
107 107
108 108 var wm = WindowManager{
109 109 .allocator = allocator,
@@ -126,16 +126,16 @@ pub const WindowManager = struct {
126 126 .last_motion_monitor = null,
127 127 };
128 128
129 - wm.setup_monitors();
130 - wm.setup_bars();
131 - wm.setup_overlay();
129 + wm.setupMonitors();
130 + wm.setupBars();
131 + wm.setupOverlay();
132 132
133 133 return wm;
134 134 }
135 135
136 136 /// Release all allocated memory owned by the WM.
137 137 pub fn deinit(self: *WindowManager) void {
138 - bar_mod.destroy_bars(self.bars, self.display.handle);
138 + bar_mod.destroyBars(self.bars, self.display.handle);
139 139 self.bars = null;
140 140
141 141 if (self.overlay) |o| {
@@ -158,7 +158,7 @@ pub const WindowManager = struct {
158 158 self.config.deinit();
159 159 }
160 160
161 - fn setup_monitors(self: *WindowManager) void {
161 + fn setupMonitors(self: *WindowManager) void {
162 162 if (xlib.XineramaIsActive(self.display.handle) != 0) {
163 163 var screen_count: c_int = 0;
164 164 const screens = xlib.XineramaQueryScreens(self.display.handle, &screen_count);
@@ -194,7 +194,7 @@ pub const WindowManager = struct {
194 194 mon.pertag.ltidxs[i][4] = mon.lt[4];
195 195 }
196 196
197 - self.init_monitor_gaps(mon);
197 + self.initMonitorGaps(mon);
198 198
199 199 if (prev_monitor) |prev| {
200 200 prev.next = mon;
@@ -215,8 +215,8 @@ pub const WindowManager = struct {
215 215 mon.num = 0;
216 216 mon.mon_x = 0;
217 217 mon.mon_y = 0;
218 - mon.mon_w = self.display.screen_width();
219 - mon.mon_h = self.display.screen_height();
218 + mon.mon_w = self.display.screenWidth();
219 + mon.mon_h = self.display.screenHeight();
220 220 mon.win_x = 0;
221 221 mon.win_y = 0;
222 222 mon.win_w = mon.mon_w;
@@ -235,13 +235,13 @@ pub const WindowManager = struct {
235 235 mon.pertag.ltidxs[i][4] = mon.lt[4];
236 236 }
237 237
238 - self.init_monitor_gaps(mon);
238 + self.initMonitorGaps(mon);
239 239 self.monitors = mon;
240 240 self.selected_monitor = mon;
241 241 }
242 242 }
243 243
244 - fn init_monitor_gaps(self: *WindowManager, mon: *Monitor) void {
244 + fn initMonitorGaps(self: *WindowManager, mon: *Monitor) void {
245 245 const cfg = &self.config;
246 246 const any_gap_nonzero = cfg.gap_inner_h != 0 or cfg.gap_inner_v != 0 or
247 247 cfg.gap_outer_h != 0 or cfg.gap_outer_v != 0;
@@ -259,7 +259,7 @@ pub const WindowManager = struct {
259 259 }
260 260 }
261 261
262 - pub fn setup_bars(self: *WindowManager) void {
262 + pub fn setupBars(self: *WindowManager) void {
263 263 var current_monitor = self.monitors;
264 264 var last_bar: ?*Bar = null;
265 265
@@ -276,10 +276,10 @@ pub const WindowManager = struct {
276 276 };
277 277
278 278 if (tiling.bar_height == 0) {
279 - tiling.set_bar_height(bar.height);
279 + tiling.setBarHeight(bar.height);
280 280 }
281 281
282 - self.populate_bar_blocks(bar);
282 + self.populateBarBlocks(bar);
283 283
284 284 if (last_bar) |prev| {
285 285 prev.next = bar;
@@ -293,19 +293,19 @@ pub const WindowManager = struct {
293 293 }
294 294 }
295 295
296 - pub fn populate_bar_blocks(self: *WindowManager, bar: *Bar) void {
296 + pub fn populateBarBlocks(self: *WindowManager, bar: *Bar) void {
297 297 if (self.config.blocks.items.len > 0) {
298 298 for (self.config.blocks.items) |cfg_block| {
299 - bar.add_block(config_block_to_bar_block(cfg_block));
299 + bar.addBlock(configBlockToBarBlock(cfg_block));
300 300 }
301 301 } else {
302 - bar.add_block(blocks_mod.Block.init_ram("", 5, 0x7aa2f7, true));
303 - bar.add_block(blocks_mod.Block.init_static(" | ", 0x666666, false));
304 - bar.add_block(blocks_mod.Block.init_datetime("", "%H:%M", 1, 0x0db9d7, true));
302 + bar.addBlock(blocks_mod.Block.initRam("", 5, 0x7aa2f7, true));
303 + bar.addBlock(blocks_mod.Block.initStatic(" | ", 0x666666, false));
304 + bar.addBlock(blocks_mod.Block.initDatetime("", "%H:%M", 1, 0x0db9d7, true));
305 305 }
306 306 }
307 307
308 - fn setup_overlay(self: *WindowManager) void {
308 + fn setupOverlay(self: *WindowManager) void {
309 309 self.overlay = overlay_mod.Keybind_Overlay.init(
310 310 self.display.handle,
311 311 self.display.screen,
@@ -317,18 +317,18 @@ pub const WindowManager = struct {
317 317
318 318 // Wrap free functions in `bar_mod` with `self.bars` passed in.
319 319
320 - pub fn invalidate_bars(self: *WindowManager) void {
321 - bar_mod.invalidate_bars(self.bars);
320 + pub fn invalidateBars(self: *WindowManager) void {
321 + bar_mod.invalidateBars(self.bars);
322 322 }
323 323
324 - pub fn window_to_bar(self: *WindowManager, win: xlib.Window) ?*Bar {
325 - return bar_mod.window_to_bar(self.bars, win);
324 + pub fn windowToBar(self: *WindowManager, win: xlib.Window) ?*Bar {
325 + return bar_mod.windowToBar(self.bars, win);
326 326 }
327 327
328 328 /// Refreshes the cached numlock modifier bitmask from the X server's
329 329 /// current modifier map. Called before any key or button grab so that
330 330 /// grabs cover all numlock combinations.
331 - pub fn update_numlock_mask(self: *WindowManager) void {
331 + pub fn updateNumlockMask(self: *WindowManager) void {
332 332 self.numlock_mask = 0;
333 333 const modmap = xlib.XGetModifierMapping(self.display.handle);
334 334 if (modmap == null) return;
@@ -350,8 +350,8 @@ pub const WindowManager = struct {
350 350
351 351 /// Grabs all configured keybinds and mouse buttons from the X server.
352 352 /// Replaces any existing grabs. Call after config load or reload.
353 - pub fn grab_keybinds(self: *WindowManager) void {
354 - self.update_numlock_mask();
353 + pub fn grabKeybinds(self: *WindowManager) void {
354 + self.updateNumlockMask();
355 355 const modifiers = [_]c_uint{ 0, xlib.LockMask, self.numlock_mask, self.numlock_mask | xlib.LockMask };
356 356
357 357 _ = xlib.XUngrabKey(self.display.handle, xlib.AnyKey, xlib.AnyModifier, self.display.root);
@@ -397,14 +397,14 @@ pub const WindowManager = struct {
397 397 std.debug.print("grabbed {d} keybinds from config\n", .{self.config.keybinds.items.len});
398 398 }
399 399
400 - pub fn ungrab_keybinds(self: *WindowManager) void {
400 + pub fn ungrabKeybinds(self: *WindowManager) void {
401 401 _ = xlib.XUngrabKey(self.display.handle, xlib.AnyKey, xlib.AnyModifier, self.display.root);
402 402 }
403 403
404 - /// Walk the existing window tree and call `manage_fn` for each window
404 + /// Walk the existing window tree and call `manageFn` for each window
405 405 /// that should be managed. Non-transient windows are processed first
406 406 /// so transient (dialog) windows can be stacked on top.
407 - pub fn scan_existing_windows(self: *WindowManager, manage_fn: fn (xlib.Window, *xlib.XWindowAttributes, *WindowManager) void) void {
407 + pub fn scanExistingWindows(self: *WindowManager, manageFn: fn (xlib.Window, *xlib.XWindowAttributes, *WindowManager) void) void {
408 408 var root_return: xlib.Window = undefined;
409 409 var parent_return: xlib.Window = undefined;
410 410 var children: [*c]xlib.Window = undefined;
@@ -425,8 +425,8 @@ pub const WindowManager = struct {
425 425 var trans: xlib.Window = 0;
426 426 if (xlib.XGetTransientForHint(self.display.handle, children[index], &trans) != 0) continue;
427 427
428 - if (window_attrs.map_state == IsViewable or self.get_state(children[index]) == IconicState) {
429 - manage_fn(children[index], &window_attrs, self);
428 + if (window_attrs.map_state == IsViewable or self.getState(children[index]) == IconicState) {
429 + manageFn(children[index], &window_attrs, self);
430 430 }
431 431 }
432 432
@@ -438,8 +438,8 @@ pub const WindowManager = struct {
438 438 }
439 439 var trans: xlib.Window = 0;
440 440 if (xlib.XGetTransientForHint(self.display.handle, children[index], &trans) != 0) {
441 - if (window_attrs.map_state == IsViewable or self.get_state(children[index]) == IconicState) {
442 - manage_fn(children[index], &window_attrs, self);
441 + if (window_attrs.map_state == IsViewable or self.getState(children[index]) == IconicState) {
442 + manageFn(children[index], &window_attrs, self);
443 443 }
444 444 }
445 445 }
@@ -449,7 +449,7 @@ pub const WindowManager = struct {
449 449
450 450 /// Reads the ICCCM WM_STATE property for a window.
451 451 /// Returns WithdrawnState if the property is absent or malformed.
452 - pub fn get_state(self: *WindowManager, window: xlib.Window) c_long {
452 + pub fn getState(self: *WindowManager, window: xlib.Window) c_long {
453 453 var actual_type: xlib.Atom = 0;
454 454 var actual_format: c_int = 0;
455 455 var num_items: c_ulong = 0;
@@ -483,12 +483,12 @@ pub const WindowManager = struct {
483 483
484 484 /// Run the event loop until `self.running` is set to false.
485 485 ///
486 - /// `event_fn` dispatches a single XEvent
487 - /// `tick_fn` is called once per loop iteration to advance animations
486 + /// `eventFn` dispatches a single XEvent
487 + /// `tickFn` is called once per loop iteration to advance animations
488 488 pub fn run(
489 489 self: *WindowManager,
490 - event_fn: fn (*xlib.XEvent, *WindowManager) void,
491 - tick_fn: fn (*WindowManager) void,
490 + eventFn: fn (*xlib.XEvent, *WindowManager) void,
491 + tickFn: fn (*WindowManager) void,
492 492 ) void {
493 493 var fds = [_]std.posix.pollfd{
494 494 .{ .fd = self.x11_fd, .events = std.posix.POLL.IN, .revents = 0 },
@@ -498,81 +498,81 @@ pub const WindowManager = struct {
498 498
499 499 while (self.running) {
500 500 while (xlib.XPending(self.display.handle) > 0) {
501 - var event = self.display.next_event();
502 - event_fn(&event, self);
501 + var event = self.display.nextEvent();
502 + eventFn(&event, self);
503 503 }
504 504
505 - tick_fn(self);
505 + tickFn(self);
506 506
507 507 var current_bar = self.bars;
508 508 while (current_bar) |bar| {
509 - bar.update_blocks();
509 + bar.updateBlocks();
510 510 bar.draw(self.display.handle, self.config);
511 511 current_bar = bar.next;
512 512 }
513 513
514 - const poll_timeout: i32 = if (self.scroll_animation.is_active()) 16 else 1000;
514 + const poll_timeout: i32 = if (self.scroll_animation.isActive()) 16 else 1000;
515 515 _ = std.posix.poll(&fds, poll_timeout) catch 0;
516 516 }
517 517 }
518 518
519 519 /// Reloads the configuration
520 520 ///
521 - /// `load_fn` repopulates `self.config`
521 + /// `loadFn` repopulates `self.config`
522 522 /// keys/buttons are unbound before reload and rebound after
523 - pub fn reload_config(
523 + pub fn reloadConfig(
524 524 self: *WindowManager,
525 - load_fn: fn (*WindowManager) void,
525 + loadFn: fn (*WindowManager) void,
526 526 ) void {
527 527 std.debug.print("reloading config...\n", .{});
528 528
529 - self.ungrab_keybinds();
529 + self.ungrabKeybinds();
530 530
531 531 self.config.keybinds.clearRetainingCapacity();
532 532 self.config.buttons.clearRetainingCapacity();
533 533 self.config.rules.clearRetainingCapacity();
534 534 self.config.blocks.clearRetainingCapacity();
535 535
536 - load_fn(self);
536 + loadFn(self);
537 537
538 - bar_mod.destroy_bars(self.bars, self.display.handle);
538 + bar_mod.destroyBars(self.bars, self.display.handle);
539 539 self.bars = null;
540 - self.setup_bars();
541 - self.rebuild_bar_blocks();
540 + self.setupBars();
541 + self.rebuildBarBlocks();
542 542
543 - self.grab_keybinds();
543 + self.grabKeybinds();
544 544 }
545 545
546 - fn rebuild_bar_blocks(self: *WindowManager) void {
546 + fn rebuildBarBlocks(self: *WindowManager) void {
547 547 var current_bar = self.bars;
548 548 while (current_bar) |bar| {
549 - bar.clear_blocks();
550 - self.populate_bar_blocks(bar);
549 + bar.clearBlocks();
550 + self.populateBarBlocks(bar);
551 551 current_bar = bar.next;
552 552 }
553 553 }
554 554 };
555 555
556 556 /// Converts a config block description into a live status bar block.
557 -pub fn config_block_to_bar_block(cfg: config_mod.Block) blocks_mod.Block {
557 +pub fn configBlockToBarBlock(cfg: config_mod.Block) blocks_mod.Block {
558 558 return switch (cfg.block_type) {
559 - .static => blocks_mod.Block.init_static(cfg.format, cfg.color, cfg.underline),
560 - .datetime => blocks_mod.Block.init_datetime(
559 + .static => blocks_mod.Block.initStatic(cfg.format, cfg.color, cfg.underline),
560 + .datetime => blocks_mod.Block.initDatetime(
561 561 cfg.format,
562 562 cfg.datetime_format orelse "%H:%M",
563 563 cfg.interval,
564 564 cfg.color,
565 565 cfg.underline,
566 566 ),
567 - .ram => blocks_mod.Block.init_ram(cfg.format, cfg.interval, cfg.color, cfg.underline),
568 - .shell => blocks_mod.Block.init_shell(
567 + .ram => blocks_mod.Block.initRam(cfg.format, cfg.interval, cfg.color, cfg.underline),
568 + .shell => blocks_mod.Block.initShell(
569 569 cfg.format,
570 570 cfg.command orelse "",
571 571 cfg.interval,
572 572 cfg.color,
573 573 cfg.underline,
574 574 ),
575 - .battery => blocks_mod.Block.init_battery(
575 + .battery => blocks_mod.Block.initBattery(
576 576 cfg.format_charging orelse "",
577 577 cfg.format_discharging orelse "",
578 578 cfg.format_full orelse "",
@@ -581,7 +581,7 @@ pub fn config_block_to_bar_block(cfg: config_mod.Block) blocks_mod.Block {
581 581 cfg.color,
582 582 cfg.underline,
583 583 ),
584 - .cpu_temp => blocks_mod.Block.init_cpu_temp(
584 + .cpu_temp => blocks_mod.Block.initCpuTemp(
585 585 cfg.format,
586 586 cfg.thermal_zone orelse "thermal_zone0",
587 587 cfg.interval,
+10 −10 src/x11/display.zig
@@ -29,9 +29,9 @@ pub const Display = struct {
29 29 _ = xlib.XCloseDisplay(self.handle);
30 30 }
31 31
32 - pub fn become_window_manager(self: *Display) DisplayError!void {
32 + pub fn becomeWindowManager(self: *Display) DisplayError!void {
33 33 wm_detected = false;
34 - _ = xlib.XSetErrorHandler(on_wm_detected);
34 + _ = xlib.XSetErrorHandler(onWmDetected);
35 35 _ = xlib.XSelectInput(
36 36 self.handle,
37 37 self.root,
@@ -43,18 +43,18 @@ pub const Display = struct {
43 43 return DisplayError.another_wm_running;
44 44 }
45 45
46 - _ = xlib.XSetErrorHandler(on_x_error);
46 + _ = xlib.XSetErrorHandler(onXError);
47 47 }
48 48
49 - pub fn screen_width(self: *Display) c_int {
49 + pub fn screenWidth(self: *Display) c_int {
50 50 return xlib.XDisplayWidth(self.handle, self.screen);
51 51 }
52 52
53 - pub fn screen_height(self: *Display) c_int {
53 + pub fn screenHeight(self: *Display) c_int {
54 54 return xlib.XDisplayHeight(self.handle, self.screen);
55 55 }
56 56
57 - pub fn next_event(self: *Display) xlib.XEvent {
57 + pub fn nextEvent(self: *Display) xlib.XEvent {
58 58 var event: xlib.XEvent = undefined;
59 59 _ = xlib.XNextEvent(self.handle, &event);
60 60 return event;
@@ -68,7 +68,7 @@ pub const Display = struct {
68 68 _ = xlib.XSync(self.handle, if (discard) xlib.True else xlib.False);
69 69 }
70 70
71 - pub fn grab_key(
71 + pub fn grabKey(
72 72 self: *Display,
73 73 keycode: c_int,
74 74 modifiers: c_uint,
@@ -84,17 +84,17 @@ pub const Display = struct {
84 84 );
85 85 }
86 86
87 - pub fn keysym_to_keycode(self: *Display, keysym: xlib.KeySym) c_int {
87 + pub fn keysymToKeycode(self: *Display, keysym: xlib.KeySym) c_int {
88 88 return @intCast(xlib.XKeysymToKeycode(self.handle, keysym));
89 89 }
90 90 };
91 91
92 -fn on_wm_detected(_: ?*xlib.Display, _: [*c]xlib.XErrorEvent) callconv(.c) c_int {
92 +fn onWmDetected(_: ?*xlib.Display, _: [*c]xlib.XErrorEvent) callconv(.c) c_int {
93 93 wm_detected = true;
94 94 return 0;
95 95 }
96 96
97 -fn on_x_error(_: ?*xlib.Display, event: [*c]xlib.XErrorEvent) callconv(.c) c_int {
97 +fn onXError(_: ?*xlib.Display, event: [*c]xlib.XErrorEvent) callconv(.c) c_int {
98 98 std.debug.print("x11 error: request={d} error={d}\n", .{ event.*.request_code, event.*.error_code });
99 99 return 0;
100 100 }
+5 −5 src/x11/events.zig
@@ -39,21 +39,21 @@ pub const EventType = enum(c_int) {
39 39 _,
40 40 };
41 41
42 -pub fn get_event_type(event: *const xlib.XEvent) EventType {
42 +pub fn getEventType(event: *const xlib.XEvent) EventType {
43 43 return @enumFromInt(event.type);
44 44 }
45 45
46 -pub fn event_name(event_type: EventType) []const u8 {
46 +pub fn eventName(event_type: EventType) []const u8 {
47 47 if (@intFromEnum(event_type) > @intFromEnum(EventType.generic_event)) return "unknown";
48 48
49 49 return @tagName(event_type);
50 50 }
51 51
52 -test event_name {
52 +test eventName {
53 53 const testing = std.testing;
54 54
55 - const name = event_name(.key_press);
55 + const name = eventName(.key_press);
56 56 try testing.expectEqualStrings("key_press", name);
57 57
58 - try testing.expectEqualStrings("unknown", event_name(@enumFromInt(100)));
58 + try testing.expectEqualStrings("unknown", eventName(@enumFromInt(100)));
59 59 }
+1 −1 tests/lua_config_tests.zig
@@ -13,6 +13,6 @@ test "test-config.lua loads without errors" {
13 13 }
14 14 defer lua.deinit();
15 15
16 - const loaded = lua.load_file("resources/test-config.lua");
16 + const loaded = lua.loadFile("resources/test-config.lua");
17 17 try testing.expect(loaded);
18 18 }