tony / oxwm

Added fallbacks if 0 is passed to config to no-op correctly. Browse files
tonybanters committed 2026-05-11 parent 61c6a94 commit f2cf6ff86127dce33ed2b20f473661788c902a16
Showing 2 changed files with 8 additions and 2 deletions. UnifiedSplit
+6 −2 src/config/lua.zig
@@ -590,14 +590,18 @@ fn luaClientToggleFloating(state: ?*c.lua_State) callconv(.c) c_int {
590 590
591 fn luaClientFocusStack(state: ?*c.lua_State) callconv(.c) c_int { 591 fn luaClientFocusStack(state: ?*c.lua_State) callconv(.c) c_int {
592 const s = state orelse return 0; 592 const s = state orelse return 0;
593 - const dir: i32 = @intCast(c.lua_tointegerx(s, 1, null)); 593 + var isnum: c_int = 0;
594 + const raw = c.lua_tointegerx(s, 1, &isnum);
595 + const dir: i32 = if (isnum != 0) @intCast(raw) else 1;
594 createActionTableWithInt(s, "FocusStack", dir); 596 createActionTableWithInt(s, "FocusStack", dir);
595 return 1; 597 return 1;
596 } 598 }
597 599
598 fn luaClientMoveStack(state: ?*c.lua_State) callconv(.c) c_int { 600 fn luaClientMoveStack(state: ?*c.lua_State) callconv(.c) c_int {
599 const s = state orelse return 0; 601 const s = state orelse return 0;
600 - const dir: i32 = @intCast(c.lua_tointegerx(s, 1, null)); 602 + var isnum: c_int = 0;
603 + const raw = c.lua_tointegerx(s, 1, &isnum);
604 + const dir: i32 = if (isnum != 0) @intCast(raw) else 1;
601 createActionTableWithInt(s, "MoveStack", dir); 605 createActionTableWithInt(s, "MoveStack", dir);
602 return 1; 606 return 1;
603 } 607 }
+2 −0 src/wm/actions.zig
@@ -69,6 +69,7 @@ pub fn spawnTerminal(wm: *WindowManager) void {
69 } 69 }
70 70
71 pub fn movestack(direction: i32, wm: *WindowManager) void { 71 pub fn movestack(direction: i32, wm: *WindowManager) void {
72 + if (direction == 0) return;
72 const monitor = wm.selected_monitor orelse return; 73 const monitor = wm.selected_monitor orelse return;
73 const current = monitor.sel orelse return; 74 const current = monitor.sel orelse return;
74 75
@@ -289,6 +290,7 @@ pub fn tagClient(tag_mask: u32, wm: *WindowManager) void {
289 } 290 }
290 291
291 pub fn focusstack(direction: i32, wm: *WindowManager) void { 292 pub fn focusstack(direction: i32, wm: *WindowManager) void {
293 + if (direction == 0) return;
292 const monitor = wm.selected_monitor orelse return; 294 const monitor = wm.selected_monitor orelse return;
293 const current = monitor.sel orelse return; 295 const current = monitor.sel orelse return;
294 296