diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-21 21:07:11 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-21 22:26:19 -0300 |
| commit | 603692c8effa9bf85a5fddc1afd1ac896227c0d3 (patch) | |
| tree | 6847c49e39ce97f23377da79629f1d8af6175d8a | |
| parent | 40a24ca96be07778dfac7c789d936c732c0cc567 (diff) | |
| download | pardes-603692c8effa9bf85a5fddc1afd1ac896227c0d3.tar.gz pardes-603692c8effa9bf85a5fddc1afd1ac896227c0d3.zip | |
pair: a window's facts are its client's (P47): a client window applies the session's WindowOpacity to the view it draws, as the own window does at the request (dev/gui/gui.zig: the window's half of `syncWindowOpacity` is `applyWindowOpacity`, the own window answers the core with it as before, `Client.own` applies each opacity it has not taken, `Client.opacity`, null again at a join, and answers nothing: a replica cannot change the core), and `Font` is the core's word in every desktop build as Fonts is (core/exec.zig gated it by the frontend's build, `pardes.font_picker`, so a terminal build's core ignored it while a window build's asked the machine's fonts: a window pair's session is the tui binary and its client window's replay made a host call the session's tape lacks, diverged and, with no daemon, was let go; a window client of a terminal's session typing Font on the own path diverged and joined again: `builtins.capabilities.font_picker` now, core/root.zig's `fonts` likewise, `may_wait`'s Font row beside Fonts' in core/replica.zig, dev/fonts.zig's comment); a terminal's own view still refuses Font (`viewCapabilities`), a session with no window leaves the request pending and the client window follows it (`syncReplicaFont`); the corpus through a pair's client window under PARDES_TERM_BYTES is byte-identical to tree3's for frames 0-62 (58-59 the opacity, 61 the font, 62 the resize), the own window through the same prefix 77 of 77; frame 63 on (an addon loaded by path) is the next wall (reports/pardes-pair-9.md); core-test 896/1056, shell-test 1098/1101
Co-Authored-By: Claude Opus <[email protected]>
Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T
| -rw-r--r-- | core/exec.zig | 3 | ||||
| -rw-r--r-- | core/replica.zig | 8 | ||||
| -rw-r--r-- | core/root.zig | 4 | ||||
| -rw-r--r-- | dev/fonts.zig | 6 | ||||
| -rw-r--r-- | dev/gui/gui.zig | 32 |
5 files changed, 38 insertions, 15 deletions
diff --git a/core/exec.zig b/core/exec.zig index 52f54541..99868434 100644 --- a/core/exec.zig +++ b/core/exec.zig @@ -20,7 +20,6 @@ const python_lang = blk: { @setEvalBranchQuota(20_000); break :blk @import("grammar_manifest.zig").byName("python").?; }; -const font_picker = pardes.font_picker; const fonts = pardes.fonts; const Pane = panes.Pane; const MAX_COLS = pardes.MAX_COLS; @@ -1014,7 +1013,7 @@ pub fn applySettingBuiltin(p: *Pardes, setting: config.Settings.Setting, arg: ?[ return p.reportFailure(v.active, text.print("Theme: no theme \"{s}\"; like it: {s}; Themes lists all", .{ shown, colors.themesNear(near[0..@min(room, near.len)], want) })); }, .font => { - if (comptime !font_picker) return; + if (comptime !pardes.builtins.capabilities.font_picker) return; const spec = config.Settings.FontSpec.parse(arg orelse return) orelse return; // The session's machine's fonts, a question to its disk: a // client's replay takes the session's answer, never its own. diff --git a/core/replica.zig b/core/replica.zig index 817d2c19..44fa922f 100644 --- a/core/replica.zig +++ b/core/replica.zig @@ -6784,12 +6784,10 @@ const may_wait = [_]Wait{ .{ .what = "*", .on = .addon, .stop = "a kind's close", .why = "a kind's pane closed: its state let go on the session" }, .{ .what = "*", .on = .addon, .stop = "a kind's word", .why = "a word to a kind (a key it takes as one): its own state" }, .{ .what = "*", .on = .addon, .stop = "a kind's open", .why = "a kind's pane opened (`Life`): its state made on the session" }, -} ++ (if (pardes.font_picker) [_]Wait{ - // A window's view (the font words are a window's). +} ++ (if (pardes.builtins.capabilities.font_picker) [_]Wait{ + // A window's view's words, which a terminal's build has too: a window + // client of its session runs them. .{ .what = "Font *", .on = .any, .stop = "fonts", .why = "the session's machine's fonts, its disk" }, -} else [_]Wait{}) ++ (if (pardes.builtins.capabilities.font_picker) [_]Wait{ - // ...and Fonts a terminal's build has too, which a window client of its - // session runs (exec.zig's Font, a window build's alone, does not). .{ .what = "Fonts", .on = .any, .stop = "fonts", .why = "the session's machine's fonts, its disk" }, } else [_]Wait{}); diff --git a/core/root.zig b/core/root.zig index 8c325935..ce7df47c 100644 --- a/core/root.zig +++ b/core/root.zig @@ -115,7 +115,9 @@ const Loc = Jump.Loc; pub const can_attach = platform == .tui or platform == .gui; -pub const fonts = if (font_picker) @import("dev").fonts else struct {}; +/// The machine's fonts: every desktop build's, which steps a window's Font +/// as the window does (builtins.capabilities), and the Mac's. +pub const fonts = if (builtins.capabilities.font_picker) @import("dev").fonts else struct {}; pub const Pane = panes.Pane; const Text = panes.Text; diff --git a/dev/fonts.zig b/dev/fonts.zig index 540e3a60..3d69c8a1 100644 --- a/dev/fonts.zig +++ b/dev/fonts.zig @@ -4,9 +4,9 @@ //! because the core has no font and the shells have no builtin dispatch. //! //! It lives at src/ rather than under gui/ because two shells draw their own -//! text. It is compiled only behind `pardes.font_picker` (gui or macos), so -//! the tui binary never opens a font directory, and the browser has none to -//! open. +//! text. It is compiled behind `builtins.capabilities.font_picker` (a +//! desktop build, whose terminal steps a window's Fonts and Font as the +//! window does, or the Mac's): the browser has none to open. //! //! No fontconfig and no CoreText. Enumerating fonts is a walk over a handful //! of well-known directories, and the one thing the picker must know about diff --git a/dev/gui/gui.zig b/dev/gui/gui.zig index 4e074a6a..da9a9150 100644 --- a/dev/gui/gui.zig +++ b/dev/gui/gui.zig @@ -1132,6 +1132,9 @@ const Client = struct { titled: bool = false, moving: bool = false, blink: ?Blink = null, + /// The session's WindowOpacity this window last took (P47: each + /// window applies it to the view it draws; none answers the core). + opacity: ?u8 = null, fn deinit(cl: *Client) void { cl.pending.deinit(cl.gpa); @@ -1173,6 +1176,7 @@ const Client = struct { const g = cl.g; const core = l.link.r.core(); g.session_font_request = null; + cl.opacity = null; cl.shell.core = core; cl.shell.gview = cl.joins.joined.view; cl.shell.surface = null; @@ -1206,6 +1210,14 @@ const Client = struct { const link = &l.link; l.frames.period_ns = refreshNs(g); if (syncReplicaFont(g, &cl.in.core.settings.font, gpa)) link.dirty = true; + const opacity = cl.in.core.settings.window_opacity; + if (cl.opacity != opacity) { + cl.opacity = opacity; + if (applyWindowOpacity(g, opacity) catch return false) |why| { + log.warn("WindowOpacity: {s}", .{why}); + } else g.applied_window_opacity = opacity; + link.dirty = true; + } if (scrollRows(g, &cl.in, gpa)) link.dirty = true; if (fitTaglineFont(g, g.facts.tagline_percent)) link.dirty = true; const geom = windowCells(g); @@ -3027,12 +3039,24 @@ fn finishWindowOpacity(core: *pardes.Pardes, applied: *u8, failure: ?[]const u8) fn syncWindowOpacity(g: *Gui, core: *pardes.Pardes) void { if (!core.settings.window_opacity_pending) return; + const failure = applyWindowOpacity(g, core.settings.window_opacity) catch blk: { + core.quit = true; + break :blk null; + }; + finishWindowOpacity(core, &g.applied_window_opacity, failure); +} + +/// What the window does at a WindowOpacity, the own window's and a +/// client's (P47: a window's facts are the process's that draws it): why +/// it cannot, or null; error.NoWindow when it was made again and could +/// not be. +fn applyWindowOpacity(g: *Gui, opacity: u8) error{NoWindow}!?[]const u8 { // The first opacity under 100 on Wayland: the window made again, // transparent, presenting through SDL_Renderer from then on (the // capture's format, the swapchain's, is one it uploads). At a start's // own WindowOpacity this is before its first frame, so unseen. const unorm = g.present.swapchain_format == c.SDL_GPU_TEXTUREFORMAT_B8G8R8A8_UNORM or g.present.swapchain_format == c.SDL_GPU_TEXTUREFORMAT_R8G8B8A8_UNORM; - if (g.wayland and !g.present.surface_opacity and core.settings.window_opacity < 100 and unorm) { + if (g.wayland and !g.present.surface_opacity and opacity < 100 and unorm) { // A `--detach` session's window stays hidden. const hidden = c.SDL_GetWindowFlags(g.window) & c.SDL_WINDOW_HIDDEN; const mode = g.present.present_mode; @@ -3048,16 +3072,16 @@ fn syncWindowOpacity(g: *Gui, core: *pardes.Pardes) void { g.present.surface_opacity = false; g.present.present_mode = mode; g.win_flags &= ~@as(c.SDL_WindowFlags, c.SDL_WINDOW_TRANSPARENT); - if (!reopenWindow(g)) core.quit = true; + if (!reopenWindow(g)) return error.NoWindow; } g.win_flags &= ~hidden; } // Offscreen captures also support per-pixel alpha. Never approximate this // with SDL_SetWindowOpacity: that would make foreground text translucent. - finishWindowOpacity(core, &g.applied_window_opacity, if (g.present.surface_opacity or g.present.capture or core.settings.window_opacity == 100) + return if (g.present.surface_opacity or g.present.capture or opacity == 100) null else - "background transparency requires a native Wayland or alpha-capable SDL window"); + "background transparency requires a native Wayland or alpha-capable SDL window"; } fn present(ctx: ?*anyopaque, surface: *const pardes.Surface) bool { |
