Fix text scaling in Bar

Before, we were missing the initial events from the wl_output, including
the scale. This meant that we weren't scaling the bar clock correctly.
To fix it, we just moved the wl_global binding into the .wl_output event

We also got rid of the hashmap of outputs in Globals and Context.
This commit is contained in:
Ben Buhse 2026-02-16 19:09:33 -06:00
commit 9b0bac12ff
No known key found for this signature in database
GPG key ID: 7916ACFCD38FD0B4
4 changed files with 22 additions and 52 deletions

View file

@ -88,7 +88,9 @@ pub fn initSurface(bar: *Bar) !void {
// TODO: Add padding to config
const vertical_padding = 5;
const bar_height: u31 = @intCast(bar.fcft_fonts.height + 2 * vertical_padding);
// Set size wants logical pixels, so we have to scale the height
const logical_font_height = @divFloor(bar.fcft_fonts.height, @as(i32, bar.font_scale));
const bar_height: u31 = @intCast(logical_font_height + 2 * vertical_padding);
layer_surface.setSize(0, bar_height);
layer_surface.setAnchor(.{ .top = options.position == .top, .bottom = options.position == .bottom, .left = true, .right = true });
@ -366,7 +368,7 @@ fn getFcftFonts(fonts: []const u8, scale: u31) !*fcft.Font {
while (it.next()) |font| {
if (scale > 1) {
// If scale >1, we append :dpi so we can scale the font
log.debug("bwbuhse {d} {d}", .{ base_dpi, scale });
log.debug("Scaling font DPI: base={d} scale={d}", .{ base_dpi, scale });
const scaled = try arena_alloc.dupeZ(
u8,
try std.fmt.allocPrint(arena_alloc, "{s}:dpi={}", .{ font, @as(u32, base_dpi) * scale }),