diff --git a/src/Buffer.zig b/src/Buffer.zig index 4d685f2..464fd09 100644 --- a/src/Buffer.zig +++ b/src/Buffer.zig @@ -95,19 +95,16 @@ fn bufferListener(_: *wl.Buffer, event: wl.Buffer.Event, buffer: *Buffer) void { pub fn borderedRectangle( buffer: Buffer, - x: u31, - y: u31, - width: u31, - height: u31, + rect: utils.Rect, border_width: u31, scale: u31, background_color: *const pixman.Color, border_color: *const pixman.Color, ) void { - const render_x: i16 = @intCast(x * scale); - const render_y: i16 = @intCast(y * scale); - const render_width: u16 = @intCast(width * scale); - const render_height: u16 = @intCast(height * scale); + const render_x: i16 = @intCast(rect.x * @as(i32, scale)); + const render_y: i16 = @intCast(rect.y * @as(i32, scale)); + const render_width: u16 = @intCast(rect.width * scale); + const render_height: u16 = @intCast(rect.height * scale); const render_border_width: u16 = @intCast(border_width * scale); // Background fill diff --git a/src/Output.zig b/src/Output.zig index 6a15438..54b5875 100644 --- a/src/Output.zig +++ b/src/Output.zig @@ -17,20 +17,10 @@ name: ?[]const u8 = null, // Output geometry scale: u31 = 1, -geometry: Rect = .{ - .x = 0, - .y = 0, - .width = 0, - .height = 0, -}, +geometry: Rect = .{}, // Area left after layer shell surfaces take exclusive area -usable_geometry: Rect = .{ - .x = 0, - .y = 0, - .width = 0, - .height = 0, -}, +usable_geometry: Rect = .{}, // Information for this Output's wallpaper wallpaper_render_scale: u31 = 0, diff --git a/src/TagOverlay.zig b/src/TagOverlay.zig index 3538bde..3049eb6 100644 --- a/src/TagOverlay.zig +++ b/src/TagOverlay.zig @@ -198,7 +198,7 @@ pub fn render(tag_overlay: *TagOverlay) !void { } const buffer = try context.buffer_pool.nextBuffer(context.wl_shm, render_width, render_height); - buffer.borderedRectangle(0, 0, tag_overlay.width, tag_overlay.height, options.border_width, scale, &options.background_color, &options.border_color); + buffer.borderedRectangle(.{ .width = tag_overlay.width, .height = tag_overlay.height }, options.border_width, scale, &options.background_color, &options.border_color); const focused_tags = tag_overlay.output.tags; const occupied_tags = tag_overlay.output.occupiedTags(); @@ -218,14 +218,16 @@ pub fn render(tag_overlay: *TagOverlay) !void { const x = options.border_width + @as(u31, @intCast((tag + 1) * options.square_padding)) + @as(u31, @intCast(tag * options.square_size)); const y = options.border_width + @as(u31, @intCast((row + 1) * options.square_padding)) + @as(u31, @intCast(row * options.square_size)); - buffer.borderedRectangle(x, y, options.square_size, options.square_size, options.square_border_width, scale, bg_color, border_color); + buffer.borderedRectangle(.{ .x = x, .y = y, .width = options.square_size, .height = options.square_size }, options.square_border_width, scale, bg_color, border_color); if (occupied_tags & (@as(u32, 1) << @intCast(current_tag)) != 0) { buffer.borderedRectangle( - x + options.square_inner_padding, - y + options.square_inner_padding, - options.square_size - 2 * options.square_inner_padding, - options.square_size - 2 * options.square_inner_padding, + .{ + .x = x + options.square_inner_padding, + .y = y + options.square_inner_padding, + .width = options.square_size - 2 * options.square_inner_padding, + .height = options.square_size - 2 * options.square_inner_padding, + }, options.square_border_width, scale, occupied_color, diff --git a/src/Window.zig b/src/Window.zig index 8da5337..ed55093 100644 --- a/src/Window.zig +++ b/src/Window.zig @@ -9,12 +9,7 @@ context: *Context, river_window_v1: *river.WindowV1, river_node_v1: *river.NodeV1, -rect: utils.Rect = .{ - .width = 0, - .height = 0, - .x = 0, - .y = 0, -}, +rect: utils.Rect = .{}, fullscreen: bool = false, maximized: bool = false, @@ -23,12 +18,7 @@ tags: u32 = 0x0001, output: ?*Output, floating: bool = false, -floating_rect: utils.Rect = .{ - .width = 0, - .height = 0, - .x = 0, - .y = 0, -}, +floating_rect: utils.Rect = .{}, initialized: bool = false, diff --git a/src/utils.zig b/src/utils.zig index d162bf9..850c590 100644 --- a/src/utils.zig +++ b/src/utils.zig @@ -13,10 +13,10 @@ pub const RiverColor = struct { }; pub const Rect = struct { - width: u31, - height: u31, - x: i32, - y: i32, + width: u31 = 0, + height: u31 = 0, + x: i32 = 0, + y: i32 = 0, }; /// Parse a color in the format 0xRRGGBB or 0xRRGGBBAA and convert it to