Added dwindle layout, accept fib, fibonacci as keywords from config, added helper to lsp file, and comment to default config.
Browse files
+1 −0 src/bar/bar.zig
| @@ -18,6 +18,7 @@ fn getLayoutSymbol(layout_index: u32, config: config_mod.Config) []const u8 { | |||
| 18 | .floating => config.layout_floating_symbol, | 18 | .floating => config.layout_floating_symbol, |
| 19 | .scrolling => config.layout_scrolling_symbol, | 19 | .scrolling => config.layout_scrolling_symbol, |
| 20 | .grid => config.layout_grid_symbol, | 20 | .grid => config.layout_grid_symbol, |
| 21 | + .dwindle => config.layout_dwindle_symbol, | ||
| 21 | }; | 22 | }; |
| 22 | } | 23 | } |
| 23 | 24 | ||
+4 −0 src/config/config.zig
| @@ -88,6 +88,7 @@ pub const Layouts = enum(u32) { | |||
| 88 | floating, | 88 | floating, |
| 89 | scrolling, | 89 | scrolling, |
| 90 | grid, | 90 | grid, |
| 91 | + dwindle, | ||
| 91 | 92 | ||
| 92 | pub fn fromString(name: []const u8) ?Layouts { | 93 | pub fn fromString(name: []const u8) ?Layouts { |
| 93 | if (std.meta.stringToEnum(Layouts, name)) |v| return v; | 94 | if (std.meta.stringToEnum(Layouts, name)) |v| return v; |
| @@ -95,6 +96,8 @@ pub const Layouts = enum(u32) { | |||
| 95 | if (std.mem.eql(u8, name, "normie")) return .floating; | 96 | if (std.mem.eql(u8, name, "normie")) return .floating; |
| 96 | if (std.mem.eql(u8, name, "float")) return .floating; | 97 | if (std.mem.eql(u8, name, "float")) return .floating; |
| 97 | if (std.mem.eql(u8, name, "scroll")) return .scrolling; | 98 | if (std.mem.eql(u8, name, "scroll")) return .scrolling; |
| 99 | + if (std.mem.eql(u8, name, "fib")) return .dwindle; | ||
| 100 | + if (std.mem.eql(u8, name, "fibonacci")) return .dwindle; | ||
| 98 | return null; | 101 | return null; |
| 99 | } | 102 | } |
| 100 | }; | 103 | }; |
| @@ -208,6 +211,7 @@ pub const Config = struct { | |||
| 208 | layout_floating_symbol: []const u8 = "><>", | 211 | layout_floating_symbol: []const u8 = "><>", |
| 209 | layout_scrolling_symbol: []const u8 = "[S]", | 212 | layout_scrolling_symbol: []const u8 = "[S]", |
| 210 | layout_grid_symbol: []const u8 = "[#]", | 213 | layout_grid_symbol: []const u8 = "[#]", |
| 214 | + layout_dwindle_symbol: []const u8 = "[\\]", | ||
| 211 | 215 | ||
| 212 | scheme_normal: ColorScheme = .{ .foreground = 0xbbbbbb, .background = 0x1a1b26, .border = 0x444444 }, | 216 | scheme_normal: ColorScheme = .{ .foreground = 0xbbbbbb, .background = 0x1a1b26, .border = 0x444444 }, |
| 213 | scheme_selected: ColorScheme = .{ .foreground = 0x0db9d7, .background = 0x1a1b26, .border = 0xad8ee6 }, | 217 | scheme_selected: ColorScheme = .{ .foreground = 0x0db9d7, .background = 0x1a1b26, .border = 0xad8ee6 }, |
+1 −0 src/config/lua.zig
| @@ -1147,6 +1147,7 @@ fn luaSetLayoutSymbol(state: ?*c.lua_State) callconv(.c) c_int { | |||
| 1147 | .floating => cfg.layout_floating_symbol = symbol, | 1147 | .floating => cfg.layout_floating_symbol = symbol, |
| 1148 | .scrolling => cfg.layout_scrolling_symbol = symbol, | 1148 | .scrolling => cfg.layout_scrolling_symbol = symbol, |
| 1149 | .grid => cfg.layout_grid_symbol = symbol, | 1149 | .grid => cfg.layout_grid_symbol = symbol, |
| 1150 | + .dwindle => cfg.layout_dwindle_symbol = symbol, | ||
| 1150 | } | 1151 | } |
| 1151 | return 0; | 1152 | return 0; |
| 1152 | } | 1153 | } |
+2 −2 src/monitor.zig
| @@ -15,7 +15,7 @@ pub const Pertag = struct { | |||
| 15 | nmasters: [10]i32 = [_]i32{1} ** 10, | 15 | nmasters: [10]i32 = [_]i32{1} ** 10, |
| 16 | mfacts: [10]f32 = [_]f32{0.55} ** 10, | 16 | mfacts: [10]f32 = [_]f32{0.55} ** 10, |
| 17 | sellts: [10]u32 = [_]u32{0} ** 10, | 17 | sellts: [10]u32 = [_]u32{0} ** 10, |
| 18 | - ltidxs: [10][5]?*const Layout = [_][5]?*const Layout{.{ null, null, null, null, null }} ** 10, | 18 | + ltidxs: [10][6]?*const Layout = [_][6]?*const Layout{.{ null, null, null, null, null, null }} ** 10, |
| 19 | showbars: [10]bool = [_]bool{true} ** 10, | 19 | showbars: [10]bool = [_]bool{true} ** 10, |
| 20 | }; | 20 | }; |
| 21 | 21 | ||
| @@ -49,7 +49,7 @@ pub const Monitor = struct { | |||
| 49 | stack: ?*Client = null, | 49 | stack: ?*Client = null, |
| 50 | next: ?*Monitor = null, | 50 | next: ?*Monitor = null, |
| 51 | bar_win: xlib.Window = 0, | 51 | bar_win: xlib.Window = 0, |
| 52 | - lt: [5]?*const Layout = .{null} ** 5, | 52 | + lt: [6]?*const Layout = .{null} ** 6, |
| 53 | pertag: Pertag = .{}, | 53 | pertag: Pertag = .{}, |
| 54 | }; | 54 | }; |
| 55 | 55 | ||
+5 −0 src/wm/wm.zig
| @@ -17,6 +17,7 @@ const monocle = @import("../layouts/monocle.zig"); | |||
| 17 | const floating = @import("../layouts/floating.zig"); | 17 | const floating = @import("../layouts/floating.zig"); |
| 18 | const scrolling = @import("../layouts/scrolling.zig"); | 18 | const scrolling = @import("../layouts/scrolling.zig"); |
| 19 | const grid = @import("../layouts/grid.zig"); | 19 | const grid = @import("../layouts/grid.zig"); |
| 20 | +const dwindle = @import("../layouts/dwindle.zig"); | ||
| 20 | 21 | ||
| 21 | pub const core = @import("core.zig"); | 22 | pub const core = @import("core.zig"); |
| 22 | pub const actions = @import("actions.zig"); | 23 | pub const actions = @import("actions.zig"); |
| @@ -167,6 +168,7 @@ pub const WindowManager = struct { | |||
| 167 | &floating.layout, | 168 | &floating.layout, |
| 168 | &scrolling.layout, | 169 | &scrolling.layout, |
| 169 | &grid.layout, | 170 | &grid.layout, |
| 171 | + &dwindle.layout, | ||
| 170 | }; | 172 | }; |
| 171 | 173 | ||
| 172 | fn initMonitor(self: *WindowManager, mon: *Monitor, num: usize, x: i16, y: i16, w: c_int, h: c_int) void { | 174 | fn initMonitor(self: *WindowManager, mon: *Monitor, num: usize, x: i16, y: i16, w: c_int, h: c_int) void { |
| @@ -267,12 +269,14 @@ pub const WindowManager = struct { | |||
| 267 | new_mon.lt[2] = &floating.layout; | 269 | new_mon.lt[2] = &floating.layout; |
| 268 | new_mon.lt[3] = &scrolling.layout; | 270 | new_mon.lt[3] = &scrolling.layout; |
| 269 | new_mon.lt[4] = &grid.layout; | 271 | new_mon.lt[4] = &grid.layout; |
| 272 | + new_mon.lt[5] = &dwindle.layout; | ||
| 270 | for (0..10) |i| { | 273 | for (0..10) |i| { |
| 271 | new_mon.pertag.ltidxs[i][0] = new_mon.lt[0]; | 274 | new_mon.pertag.ltidxs[i][0] = new_mon.lt[0]; |
| 272 | new_mon.pertag.ltidxs[i][1] = new_mon.lt[1]; | 275 | new_mon.pertag.ltidxs[i][1] = new_mon.lt[1]; |
| 273 | new_mon.pertag.ltidxs[i][2] = new_mon.lt[2]; | 276 | new_mon.pertag.ltidxs[i][2] = new_mon.lt[2]; |
| 274 | new_mon.pertag.ltidxs[i][3] = new_mon.lt[3]; | 277 | new_mon.pertag.ltidxs[i][3] = new_mon.lt[3]; |
| 275 | new_mon.pertag.ltidxs[i][4] = new_mon.lt[4]; | 278 | new_mon.pertag.ltidxs[i][4] = new_mon.lt[4]; |
| 279 | + new_mon.pertag.ltidxs[i][5] = new_mon.lt[5]; | ||
| 276 | } | 280 | } |
| 277 | if (last) |l| { | 281 | if (last) |l| { |
| 278 | l.next = new_mon; | 282 | l.next = new_mon; |
| @@ -356,6 +360,7 @@ pub const WindowManager = struct { | |||
| 356 | mon.lt[2] = &floating.layout; | 360 | mon.lt[2] = &floating.layout; |
| 357 | mon.lt[3] = &scrolling.layout; | 361 | mon.lt[3] = &scrolling.layout; |
| 358 | mon.lt[4] = &grid.layout; | 362 | mon.lt[4] = &grid.layout; |
| 363 | + mon.lt[5] = &dwindle.layout; | ||
| 359 | self.monitors = mon; | 364 | self.monitors = mon; |
| 360 | self.selected_monitor = mon; | 365 | self.selected_monitor = mon; |
| 361 | } | 366 | } |
+5 −1 templates/config.lua
| @@ -112,10 +112,14 @@ oxwm.set_tags(tags) | |||
| 112 | -- Layouts | 112 | -- Layouts |
| 113 | ------------------------------------------------------------------------------- | 113 | ------------------------------------------------------------------------------- |
| 114 | -- Set custom symbols for layouts (displayed in the status bar) | 114 | -- Set custom symbols for layouts (displayed in the status bar) |
| 115 | --- Available layouts: "tiling", "normie" (floating), "grid", "monocle", "tabbed" | 115 | +-- Available layouts: "tiling", "normie" (floating), "grid", "monocle", "tabbed", "dwindle" |
| 116 | oxwm.set_layout_symbol("tiling", "[T]") | 116 | oxwm.set_layout_symbol("tiling", "[T]") |
| 117 | oxwm.set_layout_symbol("normie", "[F]") | 117 | oxwm.set_layout_symbol("normie", "[F]") |
| 118 | oxwm.set_layout_symbol("tabbed", "[=]") | 118 | oxwm.set_layout_symbol("tabbed", "[=]") |
| 119 | +-- oxwm.set_layout_symbol("dwindle", "[\\]") | ||
| 120 | + | ||
| 121 | +-- Example: bind dwindle (fibonacci) layout | ||
| 122 | +-- oxwm.key.bind({ modkey }, "R", oxwm.layout.set("dwindle")) | ||
| 119 | 123 | ||
| 120 | -- Set default layout of specific tag (tag_index, layout_name) | 124 | -- Set default layout of specific tag (tag_index, layout_name) |
| 121 | -- Unset value uses oxwm.set_layout value | 125 | -- Unset value uses oxwm.set_layout value |
+5 −5 templates/oxwm.lua
| @@ -46,17 +46,17 @@ function oxwm.auto_tile(enabled) end | |||
| 46 | function oxwm.tiled_resize_mode(enabled) end | 46 | function oxwm.tiled_resize_mode(enabled) end |
| 47 | 47 | ||
| 48 | ---Set layout symbol override | 48 | ---Set layout symbol override |
| 49 | ----@param name string Layout name (e.g., "tiling", "normie", "tabbed", "grid", "monocle") | 49 | +---@param name string Layout name (e.g., "tiling", "normie", "tabbed", "grid", "monocle", "dwindle") |
| 50 | ----@param symbol string Symbol to display (e.g., "[T]", "[F]", "[=]") | 50 | +---@param symbol string Symbol to display (e.g., "[T]", "[F]", "[=]", "[\\]") |
| 51 | function oxwm.set_layout_symbol(name, symbol) end | 51 | function oxwm.set_layout_symbol(name, symbol) end |
| 52 | 52 | ||
| 53 | ---Set default layout for all tags | 53 | ---Set default layout for all tags |
| 54 | ----@param name string Layout name ("tiling", "floating", "scrolling", "grid", "monocle", or aliases: "tile", "float", "scroll", "normie") | 54 | +---@param name string Layout name ("tiling", "floating", "scrolling", "grid", "monocle", "dwindle", or aliases: "tile", "float", "scroll", "normie", "fib", "fibonacci") |
| 55 | function oxwm.set_layout(name) end | 55 | function oxwm.set_layout(name) end |
| 56 | 56 | ||
| 57 | ---Set default layout for a specific tag | 57 | ---Set default layout for a specific tag |
| 58 | ---@param tag integer Tag index (1-9) | 58 | ---@param tag integer Tag index (1-9) |
| 59 | ----@param name string Layout name ("tiling", "floating", "scrolling", "grid", "monocle", or aliases) | 59 | +---@param name string Layout name ("tiling", "floating", "scrolling", "grid", "monocle", "dwindle", or aliases) |
| 60 | function oxwm.set_tag_layout(tag, name) end | 60 | function oxwm.set_tag_layout(tag, name) end |
| 61 | 61 | ||
| 62 | ---Set floating window spawn position | 62 | ---Set floating window spawn position |
| @@ -213,7 +213,7 @@ oxwm.layout = {} | |||
| 213 | function oxwm.layout.cycle() end | 213 | function oxwm.layout.cycle() end |
| 214 | 214 | ||
| 215 | ---Set specific layout | 215 | ---Set specific layout |
| 216 | ----@param name string Layout name (e.g., "tiling", "normie", "tabbed", "grid", "monocle", "scrolling") | 216 | +---@param name string Layout name (e.g., "tiling", "normie", "tabbed", "grid", "monocle", "scrolling", "dwindle") |
| 217 | ---@return table Action table for keybinding | 217 | ---@return table Action table for keybinding |
| 218 | function oxwm.layout.set(name) end | 218 | function oxwm.layout.set(name) end |
| 219 | 219 | ||