Apply Rect to Buffer.borderedRectangle
Also set it to have all fields with a default of 0 since we use that quite a bit and it saves writing it.
This commit is contained in:
parent
515e94320b
commit
a37f72f0d7
5 changed files with 21 additions and 42 deletions
|
|
@ -95,19 +95,16 @@ fn bufferListener(_: *wl.Buffer, event: wl.Buffer.Event, buffer: *Buffer) void {
|
||||||
|
|
||||||
pub fn borderedRectangle(
|
pub fn borderedRectangle(
|
||||||
buffer: Buffer,
|
buffer: Buffer,
|
||||||
x: u31,
|
rect: utils.Rect,
|
||||||
y: u31,
|
|
||||||
width: u31,
|
|
||||||
height: u31,
|
|
||||||
border_width: u31,
|
border_width: u31,
|
||||||
scale: u31,
|
scale: u31,
|
||||||
background_color: *const pixman.Color,
|
background_color: *const pixman.Color,
|
||||||
border_color: *const pixman.Color,
|
border_color: *const pixman.Color,
|
||||||
) void {
|
) void {
|
||||||
const render_x: i16 = @intCast(x * scale);
|
const render_x: i16 = @intCast(rect.x * @as(i32, scale));
|
||||||
const render_y: i16 = @intCast(y * scale);
|
const render_y: i16 = @intCast(rect.y * @as(i32, scale));
|
||||||
const render_width: u16 = @intCast(width * scale);
|
const render_width: u16 = @intCast(rect.width * scale);
|
||||||
const render_height: u16 = @intCast(height * scale);
|
const render_height: u16 = @intCast(rect.height * scale);
|
||||||
const render_border_width: u16 = @intCast(border_width * scale);
|
const render_border_width: u16 = @intCast(border_width * scale);
|
||||||
|
|
||||||
// Background fill
|
// Background fill
|
||||||
|
|
|
||||||
|
|
@ -17,20 +17,10 @@ name: ?[]const u8 = null,
|
||||||
|
|
||||||
// Output geometry
|
// Output geometry
|
||||||
scale: u31 = 1,
|
scale: u31 = 1,
|
||||||
geometry: Rect = .{
|
geometry: Rect = .{},
|
||||||
.x = 0,
|
|
||||||
.y = 0,
|
|
||||||
.width = 0,
|
|
||||||
.height = 0,
|
|
||||||
},
|
|
||||||
|
|
||||||
// Area left after layer shell surfaces take exclusive area
|
// Area left after layer shell surfaces take exclusive area
|
||||||
usable_geometry: Rect = .{
|
usable_geometry: Rect = .{},
|
||||||
.x = 0,
|
|
||||||
.y = 0,
|
|
||||||
.width = 0,
|
|
||||||
.height = 0,
|
|
||||||
},
|
|
||||||
|
|
||||||
// Information for this Output's wallpaper
|
// Information for this Output's wallpaper
|
||||||
wallpaper_render_scale: u31 = 0,
|
wallpaper_render_scale: u31 = 0,
|
||||||
|
|
|
||||||
|
|
@ -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);
|
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 focused_tags = tag_overlay.output.tags;
|
||||||
const occupied_tags = tag_overlay.output.occupiedTags();
|
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 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));
|
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) {
|
if (occupied_tags & (@as(u32, 1) << @intCast(current_tag)) != 0) {
|
||||||
buffer.borderedRectangle(
|
buffer.borderedRectangle(
|
||||||
x + options.square_inner_padding,
|
.{
|
||||||
y + options.square_inner_padding,
|
.x = x + options.square_inner_padding,
|
||||||
options.square_size - 2 * options.square_inner_padding,
|
.y = y + options.square_inner_padding,
|
||||||
options.square_size - 2 * 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,
|
options.square_border_width,
|
||||||
scale,
|
scale,
|
||||||
occupied_color,
|
occupied_color,
|
||||||
|
|
|
||||||
|
|
@ -9,12 +9,7 @@ context: *Context,
|
||||||
river_window_v1: *river.WindowV1,
|
river_window_v1: *river.WindowV1,
|
||||||
river_node_v1: *river.NodeV1,
|
river_node_v1: *river.NodeV1,
|
||||||
|
|
||||||
rect: utils.Rect = .{
|
rect: utils.Rect = .{},
|
||||||
.width = 0,
|
|
||||||
.height = 0,
|
|
||||||
.x = 0,
|
|
||||||
.y = 0,
|
|
||||||
},
|
|
||||||
|
|
||||||
fullscreen: bool = false,
|
fullscreen: bool = false,
|
||||||
maximized: bool = false,
|
maximized: bool = false,
|
||||||
|
|
@ -23,12 +18,7 @@ tags: u32 = 0x0001,
|
||||||
output: ?*Output,
|
output: ?*Output,
|
||||||
|
|
||||||
floating: bool = false,
|
floating: bool = false,
|
||||||
floating_rect: utils.Rect = .{
|
floating_rect: utils.Rect = .{},
|
||||||
.width = 0,
|
|
||||||
.height = 0,
|
|
||||||
.x = 0,
|
|
||||||
.y = 0,
|
|
||||||
},
|
|
||||||
|
|
||||||
initialized: bool = false,
|
initialized: bool = false,
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -13,10 +13,10 @@ pub const RiverColor = struct {
|
||||||
};
|
};
|
||||||
|
|
||||||
pub const Rect = struct {
|
pub const Rect = struct {
|
||||||
width: u31,
|
width: u31 = 0,
|
||||||
height: u31,
|
height: u31 = 0,
|
||||||
x: i32,
|
x: i32 = 0,
|
||||||
y: i32,
|
y: i32 = 0,
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Parse a color in the format 0xRRGGBB or 0xRRGGBBAA and convert it to
|
/// Parse a color in the format 0xRRGGBB or 0xRRGGBBAA and convert it to
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue