tony / oxwm

refactor(bar): remove redundant allocator param from `Bar.destroy` Browse files
emzywastaken committed 2026-02-23 parent d70d713 commit 3663acc5ed97bdccf46ac76ae07a9938e2565ed9
Showing 3 changed files with 6 additions and 8 deletions. UnifiedSplit
+4 −5 src/bar/bar.zig
@@ -132,8 +132,7 @@ pub const Bar = struct {
132 132 }
133 133
134 134 /// Destroys the bar's X resources and frees the allocation.
135 - // TODO: Remove `allocator` param as its already stored in `Bar`.
136 - pub fn destroy(self: *Bar, allocator: std.mem.Allocator, display: *xlib.Display) void {
135 + pub fn destroy(self: *Bar, display: *xlib.Display) void {
137 136 if (self.xft_draw) |xft_draw| xlib.XftDrawDestroy(xft_draw);
138 137 if (self.font) |font| xlib.XftFontClose(display, font);
139 138
@@ -141,7 +140,7 @@ pub const Bar = struct {
141 140 _ = xlib.XFreePixmap(display, self.pixmap);
142 141 _ = xlib.c.XDestroyWindow(display, self.window);
143 142 self.blocks.deinit(self.allocator);
144 - allocator.destroy(self);
143 + self.allocator.destroy(self);
145 144 }
146 145
147 146 pub fn add_block(self: *Bar, block: Block) void {
@@ -299,11 +298,11 @@ pub fn invalidate_bars(bars: ?*Bar) void {
299 298 }
300 299
301 300 /// Destroys all bars in the list and frees their resources.
302 -pub fn destroy_bars(bars: ?*Bar, allocator: std.mem.Allocator, display: *xlib.Display) void {
301 +pub fn destroy_bars(bars: ?*Bar, display: *xlib.Display) void {
303 302 var current = bars;
304 303 while (current) |bar| {
305 304 const next = bar.next;
306 - bar.destroy(allocator, display);
305 + bar.destroy(display);
307 306 current = next;
308 307 }
309 308 }
+0 −1 src/wm/actions.zig
@@ -43,7 +43,6 @@ pub fn spawn_command(wm: *WindowManager, cmd: []const u8) void {
43 43 }
44 44 }
45 45
46 -// TODO: take in the terminal cmd directly.
47 46 pub fn spawn_terminal(wm: *WindowManager) void {
48 47 const pid = std.posix.fork() catch return;
49 48 if (pid == 0) {
+2 −2 src/wm/wm.zig
@@ -135,7 +135,7 @@ pub const WindowManager = struct {
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.allocator, self.display.handle);
138 + bar_mod.destroy_bars(self.bars, self.display.handle);
139 139 self.bars = null;
140 140
141 141 if (self.overlay) |o| {
@@ -535,7 +535,7 @@ pub const WindowManager = struct {
535 535
536 536 load_fn(self);
537 537
538 - bar_mod.destroy_bars(self.bars, self.allocator, self.display.handle);
538 + bar_mod.destroy_bars(self.bars, self.display.handle);
539 539 self.bars = null;
540 540 self.setup_bars();
541 541 self.rebuild_bar_blocks();