aboutsummaryrefslogtreecommitdiff
path: root/src/Output.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/Output.zig')
-rw-r--r--src/Output.zig30
1 files changed, 28 insertions, 2 deletions
diff --git a/src/Output.zig b/src/Output.zig
index 11c467e..6dc999d 100644
--- a/src/Output.zig
+++ b/src/Output.zig
@@ -53,7 +53,7 @@ master_count: u32,
master_factor: f64,
/// Current layout of the output.
-layout: Layouts,
+layout: Layout,
// All listeners for this output, in alphabetical order
listen_destroy: c.wl_listener,
@@ -61,7 +61,7 @@ listen_frame: c.wl_listener,
listen_mode: c.wl_listener,
// All possible layouts.
-pub const Layouts = enum {
+pub const Layout = enum {
TopMaster,
RightMaster,
BottomMaster,
@@ -69,6 +69,32 @@ pub const Layouts = enum {
Full,
};
+const LayoutName = struct {
+ name: []const u8,
+ layout: Layout,
+};
+
+// zig fmt: off
+const layout_names = [_]LayoutName {
+ .{ .name = "TopMaster", .layout = Layout.TopMaster, },
+ .{ .name = "RightMaster", .layout = Layout.RightMaster, },
+ .{ .name = "BottomMaster", .layout = Layout.BottomMaster, },
+ .{ .name = "LeftMaster", .layout = Layout.LeftMaster, },
+ .{ .name = "Full", .layout = Layout.Full, },
+};
+// zig fmt: on
+
+pub fn getLayoutByName(self: Self, name: []const u8) Layout {
+ for (layout_names) |current| {
+ if (std.mem.eql(u8, name, current.name)) {
+ return current.layout;
+ }
+ }
+ Log.Error.log("Layout '{}' does not exist", .{name});
+ // In case of error default to LeftMaster
+ return Layout.LeftMaster;
+}
+
pub fn init(self: *Self, root: *Root, wlr_output: *c.wlr_output) !void {
// Some backends don't have modes. DRM+KMS does, and we need to set a mode
// before we can use the output. The mode is a tuple of (width, height,