Implement outer padding
This commit is contained in:
parent
5ce2bef513
commit
0038a56a62
@ -13,6 +13,9 @@ pub const Config = struct {
|
|||||||
/// Amount of view padding in pixels
|
/// Amount of view padding in pixels
|
||||||
view_padding: u32,
|
view_padding: u32,
|
||||||
|
|
||||||
|
/// Amount of padding arount the outer edge of the layout in pixels
|
||||||
|
outer_padding: u32,
|
||||||
|
|
||||||
const Keybind = struct {
|
const Keybind = struct {
|
||||||
keysym: c.xkb_keysym_t,
|
keysym: c.xkb_keysym_t,
|
||||||
modifiers: u32,
|
modifiers: u32,
|
||||||
@ -25,7 +28,8 @@ pub const Config = struct {
|
|||||||
|
|
||||||
pub fn init(self: *Self, allocator: *std.mem.Allocator) !void {
|
pub fn init(self: *Self, allocator: *std.mem.Allocator) !void {
|
||||||
self.border_width = 2;
|
self.border_width = 2;
|
||||||
self.view_padding = 10;
|
self.view_padding = 8;
|
||||||
|
self.outer_padding = 8;
|
||||||
|
|
||||||
self.keybinds = std.ArrayList(Keybind).init(allocator);
|
self.keybinds = std.ArrayList(Keybind).init(allocator);
|
||||||
|
|
||||||
|
30
src/root.zig
30
src/root.zig
@ -177,17 +177,23 @@ pub const Root = struct {
|
|||||||
|
|
||||||
// This can't return null if we pass null as the reference
|
// This can't return null if we pass null as the reference
|
||||||
const output_box: *c.wlr_box = c.wlr_output_layout_get_box(self.wlr_output_layout, null);
|
const output_box: *c.wlr_box = c.wlr_output_layout_get_box(self.wlr_output_layout, null);
|
||||||
|
|
||||||
|
const outer_padding = self.server.config.outer_padding;
|
||||||
|
|
||||||
|
const layout_width = @intCast(u32, output_box.width) - outer_padding * 2;
|
||||||
|
const layout_height = @intCast(u32, output_box.height) - outer_padding * 2;
|
||||||
|
|
||||||
var master_column_width: u32 = undefined;
|
var master_column_width: u32 = undefined;
|
||||||
var slave_column_width: u32 = undefined;
|
var slave_column_width: u32 = undefined;
|
||||||
if (master_count > 0 and slave_count > 0) {
|
if (master_count > 0 and slave_count > 0) {
|
||||||
// If both master and slave views are present
|
// If both master and slave views are present
|
||||||
master_column_width = @floatToInt(u32, @round(@intToFloat(f64, output_box.width) * self.master_factor));
|
master_column_width = @floatToInt(u32, @round(@intToFloat(f64, layout_width) * self.master_factor));
|
||||||
slave_column_width = @intCast(u32, output_box.width) - master_column_width;
|
slave_column_width = layout_width - master_column_width;
|
||||||
} else if (master_count > 0) {
|
} else if (master_count > 0) {
|
||||||
master_column_width = @intCast(u32, output_box.width);
|
master_column_width = layout_width;
|
||||||
slave_column_width = 0;
|
slave_column_width = 0;
|
||||||
} else {
|
} else {
|
||||||
slave_column_width = @intCast(u32, output_box.width);
|
slave_column_width = layout_width;
|
||||||
master_column_width = 0;
|
master_column_width = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -196,12 +202,12 @@ pub const Root = struct {
|
|||||||
while (it.next()) |view| {
|
while (it.next()) |view| {
|
||||||
if (i < master_count) {
|
if (i < master_count) {
|
||||||
// Add the remainder to the first master to ensure every pixel of height is used
|
// Add the remainder to the first master to ensure every pixel of height is used
|
||||||
const master_height = @divTrunc(@intCast(u32, output_box.height), master_count);
|
const master_height = @divTrunc(layout_height, master_count);
|
||||||
const master_height_rem = @intCast(u32, output_box.height) % master_count;
|
const master_height_rem = layout_height % master_count;
|
||||||
|
|
||||||
view.pending_box = View.Box{
|
view.pending_box = View.Box{
|
||||||
.x = 0,
|
.x = @intCast(i32, outer_padding),
|
||||||
.y = @intCast(i32, i * master_height +
|
.y = @intCast(i32, outer_padding + i * master_height +
|
||||||
if (i > 0) master_height_rem else 0),
|
if (i > 0) master_height_rem else 0),
|
||||||
|
|
||||||
.width = master_column_width,
|
.width = master_column_width,
|
||||||
@ -209,12 +215,12 @@ pub const Root = struct {
|
|||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
// Add the remainder to the first slave to ensure every pixel of height is used
|
// Add the remainder to the first slave to ensure every pixel of height is used
|
||||||
const slave_height = @divTrunc(@intCast(u32, output_box.height), slave_count);
|
const slave_height = @divTrunc(layout_height, slave_count);
|
||||||
const slave_height_rem = @intCast(u32, output_box.height) % slave_count;
|
const slave_height_rem = layout_height % slave_count;
|
||||||
|
|
||||||
view.pending_box = View.Box{
|
view.pending_box = View.Box{
|
||||||
.x = @intCast(i32, master_column_width),
|
.x = @intCast(i32, outer_padding + master_column_width),
|
||||||
.y = @intCast(i32, (i - master_count) * slave_height +
|
.y = @intCast(i32, outer_padding + (i - master_count) * slave_height +
|
||||||
if (i > master_count) slave_height_rem else 0),
|
if (i > master_count) slave_height_rem else 0),
|
||||||
|
|
||||||
.width = slave_column_width,
|
.width = slave_column_width,
|
||||||
|
Loading…
Reference in New Issue
Block a user