Add window title and wm info to Bar

This commit adds the focused window title to the left side of the bar
and some WM info (primary count/ratio and # of visible/total windows) to
the right side.

It also adds new vertical_padding and horizontal_padding config options
for the bar.
This commit is contained in:
Ben Buhse 2026-02-27 10:42:08 -06:00
commit efd0222899
No known key found for this signature in database
GPG key ID: 7916ACFCD38FD0B4
9 changed files with 231 additions and 51 deletions

View file

@ -523,10 +523,16 @@ pub fn manage(output: *Output) void {
Config.min_primary_ratio,
Config.max_primary_ratio,
);
if (output.bar) |*bar| {
bar.pending_render.draw = true;
}
}
if (output.pending_manage.primary_count) |primary_count| {
// Don't allow less than 1 primary
output.primary_count = @max(1, primary_count);
if (output.bar) |*bar| {
bar.pending_render.draw = true;
}
}
if (output.pending_manage.single_window_ratio) |single_window_ratio| {
output.single_window_ratio = std.math.clamp(
@ -580,6 +586,10 @@ pub fn manage(output: *Output) void {
};
}
}
if (output.bar) |*bar| {
bar.pending_render.draw = true;
}
}
if (output.bar) |*bar| {
@ -794,6 +804,15 @@ pub fn occupiedTags(output: *Output) u32 {
return occupied_tags;
}
pub fn countVisible(output: *Output) usize {
var visible: usize = 0;
var it = output.windows.iterator(.forward);
while (it.next()) |window| {
if (window.tags & output.tags != 0) visible += 1;
}
return visible;
}
const std = @import("std");
const assert = std.debug.assert;
const mem = std.mem;