diff options
Diffstat (limited to 'src/macos.zig')
| -rw-r--r-- | src/macos.zig | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/src/macos.zig b/src/macos.zig index bbfb8c08..d0d379de 100644 --- a/src/macos.zig +++ b/src/macos.zig @@ -92,6 +92,7 @@ pub const Image = extern struct { iw: u32, ih: u32, rgba: [*]const u8, + paper_bg: u32, }; pub const Runtime = extern struct { @@ -902,6 +903,11 @@ export fn pardes_window_opacity() u8 { return st.core.settings.window_opacity; } +/// Public AppKit backdrop strength, independent of background paint opacity. +export fn pardes_window_blur() u8 { + return if (state) |st| st.core.settings.window_blur else 0; +} + fn taglineFontPercent(core: ?*const pardes.Pardes) u8 { return if (core) |p| p.settings.font.tagline_percent else pardes.config.gui_tagline_font_percent; } @@ -1879,6 +1885,10 @@ fn collectImages(st: *State, surface: *const pardes.Surface) void { .iw = @intCast(place.iw), .ih = @intCast(place.ih), .rgba = place.rgba.ptr, + .paper_bg = if (place.native.paper_bg) |bg| + @as(u32, bg[0]) << 16 | @as(u32, bg[1]) << 8 | bg[2] + else + color_default, }; st.images_len += 1; } @@ -2611,6 +2621,7 @@ test "pardes.h declares every export the way it is defined" { try expectSameAbi(@TypeOf(c.pardes_active_dirty), @TypeOf(pardes_active_dirty)); try expectSameAbi(@TypeOf(c.pardes_theme_bg), @TypeOf(pardes_theme_bg)); try expectSameAbi(@TypeOf(c.pardes_window_opacity), @TypeOf(pardes_window_opacity)); + try expectSameAbi(@TypeOf(c.pardes_window_blur), @TypeOf(pardes_window_blur)); } test "pardes.h matches the Zig boundary" { @@ -2941,3 +2952,21 @@ test "mac tag layer ABI preserves logical capacity and physical grip" { try std.testing.expectEqual(@as(u8, 'G'), canonical[18].text[0]); try std.testing.expectEqual(encodeCell(.{}).len, canonical[10].len); } + +test "mac window blur builtin reaches the ABI without changing opacity" { + try std.testing.expectEqual(@as(u8, 0), pardes_window_blur()); + const gpa = std.testing.allocator; + const core = try pardes.Pardes.init(gpa, .{ .tty_only = true, .cols = 8, .rows = 3 }); + defer core.deinit(); + state = .{ .gpa = gpa, .threaded = undefined, .io = std.testing.io, .core = core, .runtime = .{}, .config_arena = .init(gpa), .prompt_rcs = .{} }; + defer { + state.?.config_arena.deinit(); + state = null; + } + try std.testing.expect(core.executeBuiltinLine(0, "WindowOpacity 71")); + for ([_][]const u8{ "WindowBlur 0", "WindowBlur 40", "WindowBlur 100", "WindowBlur 101", "WindowBlur 0" }, [_]u8{ 0, 40, 100, 100, 0 }) |command, expected| { + try std.testing.expect(core.executeBuiltinLine(0, command)); + try std.testing.expectEqual(expected, pardes_window_blur()); + try std.testing.expectEqual(@as(u8, 71), pardes_window_opacity()); + } +} |
