From 444cf77ad377f0556d46e433f0cd13e0a82e74ab Mon Sep 17 00:00:00 2001 From: Leon Henrik Plickat Date: Mon, 18 May 2020 20:02:37 +0200 Subject: [PATCH] Add "full" layout Similar to dwm's "monocle" layout --- src/Output.zig | 37 ++++++++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/src/Output.zig b/src/Output.zig index 9937fb6..e1ceb52 100644 --- a/src/Output.zig +++ b/src/Output.zig @@ -323,6 +323,40 @@ pub fn layoutLeftMaster(self: *Self, visible_count: u32, output_tags: u32) void layoutMasterStack(self, visible_count, output_tags, MasterPosition.Left); } +/// A layout in which every window uses the maximum available space. +pub fn layoutFull(self: *Self, visible_count: u32, output_tags: u32) void { + const border_width = self.root.server.config.border_width; + const outer_padding = self.root.server.config.outer_padding; + + const layout_width = @intCast(u32, self.usable_box.width) + - (outer_padding * 2) - (border_width * 2); + const layout_height = @intCast(u32, self.usable_box.height) + - (outer_padding * 2) - (border_width * 2); + const xy_offset = @intCast(i32, outer_padding + border_width); + + var i: u32 = 0; + var it = ViewStack(View).pendingIterator(self.views.first, output_tags); + while (it.next()) |node| { + const view = &node.view; + + if (view.floating) { + continue; + } + + var new_box: Box = undefined; + new_box = .{ + .x = xy_offset, + .y = xy_offset, + .width = layout_width, + .height = layout_height, + }; + + view.pending_box = new_box; + + i += 1; + } +} + /// Arrange all views on the output for the current layout. Modifies only /// pending state, the changes are not appplied until a transaction is started /// and completed. @@ -354,7 +388,8 @@ pub fn arrangeViews(self: *Self) void { //layoutTopMaster(self, visible_count, output_tags); //layoutRightMaster(self, visible_count, output_tags); //layoutBottomMaster(self, visible_count, output_tags); - layoutLeftMaster(self, visible_count, output_tags); + //layoutLeftMaster(self, visible_count, output_tags); + layoutFull(self, visible_count, output_tags); } /// Arrange all layer surfaces of this output and addjust the usable aread