Skip to content

zgx 0.1.10

Latest

Choose a tag to compare

@wingleeio wingleeio released this 04 Nov 11:32
· 925 commits to main since this release
Immutable release. Only release title and notes can be modified.

A release for apps that run plugins: what a plugin may reach is now the host's to decide (ScriptHost::guard and its new GuardKinds, fetch_policy, reserve_prefix, decision controls, sealed regions, a top layer), and a host can ask where a plugin's additions show and forget its state as it is uninstalled. It also has lists that scroll with the view around them, a window's full-screen state in scripts, glass on Linux and in Windows' popups, and terminals that follow the theme.

Three things change for a plugin, each with its migration under Changed: Capability::Override("*") no longer reaches the app's modules, a plugin's ui.slot is named <plugin>.…, and its shortcuts need a modifier or a grant. The app's own scripts are as they were.

Published with it: zgx-cosmic-text 0.19.10 (a family's nearest face for a weight it lacks).

Apps from crates.io get upstream winit, not the copy patched in this repository, and a fix that lives only in that copy doesn't reach them. In this release that is two: glass blurring on Wayland compositors other than KWin, and set_theme on Windows holding through a system change. Entries that need the patch say so, earlier releases' too, and releasing lists all it does; getting started has the [patch.crates-io] lines that take the repository's.

Changed: what to check in an existing app

  • WindowOptions has a new field, caption_height (zgx-desktop): a WindowOptions written out field by field stops compiling. Migrate: end it with ..Default::default(), or set caption_height: None (the default).
  • Capability::Override("*") no longer reaches the app's modules (zgx-script): replacing a module runs as the app's own code, so it takes a grant that says so. Capability::OverrideElement(target) is for ui.contribute { replace } and ui.filter, Capability::OverrideModule("@app/…") for ui.override, each with "*" for any. The older Override reads by what it names, so Override("#x"), Override("*") for elements and Override("@app/x") work as before. Migrate: a plugin given Override("*") that overrides modules needs OverrideModule("*"); in zgx.json, override-module:* beside override:*.
  • A plugin offers only slots of its own (zgx-script): ui.slot(name) in a plugin's VM takes <plugin>.…, so a plugin can't pose as the app's slot or another's and take what is contributed there. Migrate: name a plugin's slot <plugin>.name, and have what contributes to it say so. The app's own scripts name theirs as before.
  • A plugin's shortcut has a modifier (zgx-script): ui.command { key = "k" } from a plugin (no modifier, or Shift alone on a character) would take that key from every field, page and terminal, and is now an error; one a state or function says is dropped as it reads so, in ScriptHost::dropped_shortcuts. Migrate: give it a modifier, or grant the plugin Capability::Named("zgx.command.bare_keys").

Added

  • Decision controls no plugin reaches or covers (zgx-script): ui.decision { key, … } holds controls drawn and hit over all a plugin opens, in the room it keeps in flow, scrolling with it.
    • A plugin can't make one, or get into one; replacing, hiding or disabling what declares one is refused and reported.
    • While one is mounted, a plugin's popups, tooltips and context menus stay in the window, under it (zgx::compose::PopupsInWindow).
    • ScriptHost::decision_shown(key) says whether it is on screen, for a host's fallback in its top layer. In Rust, zgx::compose::hoist.
  • ScriptHost::guard covers terminals, web pages and what else leaves the interface (zgx-script): new GuardKinds Term (ui.term, by its command or the shell: refused, it raises and nothing starts), TermInput (a terminal's :input, :paste, :binding), Web (src, :load, :html, html, and each navigation the platform starts: a link, a form, a redirect, a page's script, history), Clipboard, Dialog, File, Folder and Notification. A refused src leaves the page where it was; a refused navigation is cancelled and reported. What a page fetches once loaded, and in-page history steps, no platform shows: docs/plugins.md says so, and lists what isn't asked.
  • ScriptHost::guard is asked of links, pictures, windows, kept values and a download's dialog (zgx-script, zgx): new GuardKinds OpenLink (a link in text opening, on a click or its Open Link item, through zgx's new platform::LinkGuard service), Picture (a remote picture, apart from Fetch), Window (ui.window: refused, it raises and nothing opens) and Persist (ui.persist: refused, it starts from what is saved and its writes are held in memory, so a preview in the app's VM looks as the app does and overwrites nothing), and a download's d:ask() under Dialog. ScriptHost::keep_held_state saves what was held, when the person keeps what they previewed; ScriptHost::drop_held_state or quitting lets it go. A refused ui.fetch rejects its promise rather than raising, so a top level isn't failed and what handles a failure says so.
  • A host's top layer (zgx): View::top_layer is a layer filling the window, above every other layer, dialog and popover and live under them, for the host's own controls that no plugin may cover. A script's z can't reach it.
  • zgx inspect key taps modifiers alone (zgx-script): zgx inspect key alt (or ctrl+shift) holds them and lets them go, as a window reports a tap, so what watches ui.modifiers (an Alt-to-show menu bar) can be driven; it used to fail with "unknown key".
  • A window's glass blurs the desktop behind it on Linux (zgx-desktop): a window with glass asks the Wayland compositor to blur what is behind it. It was only transparent before, so on KWin, which blurs only what asks, it was see-through. From crates.io that reaches KWin alone, through its own blur protocol (upstream winit's with_blur). With the repository's winit (getting started) it goes through the standard ext-background-effect-v1 first, so Hyprland blurs too. How strong the blur is stays the compositor's (Hyprland: decoration:blur, and only with blur enabled there).
  • A list can scroll with the scroll view around it (zgx, zgx-script): ui.list { …, virtualize = "ancestor" } (Rust: View::virtualize_in_ancestor) is as tall as all its rows and builds only those the scroll view around it shows, plus its overscan, again as that view scrolls or resizes. A panel that scrolls as a whole, its sections lists, builds about 20 rows of 302 instead of all of them. With height or heights: Tab and focus go through its rows, a row asked for (scroll_to_row) or found in the page scrolls that view to it, and a reload finds focus again on its row. Opt-in: a list's rows otherwise build as before.
  • ScriptHost::contribution_bounds(plugin) (zgx-script, with zgx's NodeHandle::window_bounds): where what a plugin added shows in the window now, a box for each thing mounted in a slot or before, after or in place of an element, through any transforms and zooms. What a ui.filter changes stays the app's own. Costs nothing without plugins.
  • ScriptHost::forget_state(script) (zgx-script): for uninstalling a plugin, "plugin:<name>" forgets its ui.state and ui.persist values, what waits to be saved and its saved files, gone by the time it returns; a write already queued can't bring them back.
  • An app can police what its plugins reach over the network (zgx-script, zgx-run): ScriptHost::fetch_policy(impl FetchPolicy) is asked of a request's URL, of every address its host resolves to, and of its headers, with the plugin's name as the caller (None for the app). zgx-run asks it on every redirect, before connecting to any address (so a name that later resolves to this device or the LAN is refused too), and for ui.fetch, remote images and ui.socket alike. A plugin's refused or failed remote image is its own: the app showing the same URL fetches it at once, not after that plugin's backoff. A plugin never takes a proxy from the environment, and never sets Host, Connection, Transfer-Encoding, TE, Upgrade or Proxy-*, with or without a policy. A host with a transport of its own reads the same with Body::caller, Body::fetch_policy, Socket::caller and Socket::fetch_policy.
  • ScriptHost::reserve_prefix(prefix) (zgx-script): keeps prefix and prefix.… for the app's own scripts: no plugin, whatever it is named or granted, offers a ui.slot or declares a ui.command id so named.
  • ScriptHost::guard(|kind, name| …) (zgx-script, with GuardKind): asked before the app's own scripts reach a host action, async action or function (by name), or a ui.fetch, remote picture or ui.socket (by URL), each time; an Err stops it, its text the script's error. For previewing someone's template in the app's VM. A host that sets none reads one thread-local flag at each.
  • Sealed regions (zgx-script): ui.sealed { … } is a region no plugin contributes into, replaces, filters, targets or draws over (a Settings page). In it, ui.plugin_page { plugin = name } shows what that plugin alone gives ui.contribute("plugin_page", …), cut to its box, portals included (zgx::compose::confined).
  • Terminals take their colours from the theme (zgx, zgx-terminal, zgx-desktop): the tokens terminal.foreground, terminal.background, terminal.cursor, terminal.cursor_text, terminal.selection_background, terminal.selection_foreground and terminal.ansi.0 to terminal.ansi.15 colour a terminal where the theme sets them, and follow a theme switch, the system's appearance or a theme = scoped over the terminal live, scrollback included, without restarting it. Under Ghostty they go over the user's own Ghostty configuration; in the engine-drawn terminal (Linux, Windows) over its palette. No built-in theme sets them, and one left unset keeps the terminal's own colour, so an app that never sets them sees no change. VS Code themes set them from their terminal.* colours. Before, switching an app to a light theme left Ghostty's text in the user's dark colours, pale on white. In Rust: zgx::terminal::TerminalColors and follow_theme_colors, and TerminalBackend::set_colors.
  • ui.window.full_screen and ui.window.full_screen_transition (zgx-script, zgx-desktop): whether the app's window is in full screen, however it went in or out (the green button, Ctrl+Cmd+F, the menu, Mission Control, a script), and, while macOS animates it, which way it goes and about how long it takes ({ phase = "entering" | "leaving", duration }, nil otherwise and always on Linux and Windows). ui.window.controls is nil in full screen, so a title bar laid out around the traffic lights can slide over as they go. Rust hosts have WindowContext::full_screen_transition (FullScreenTransition) beside WindowInfo::fullscreen, and pass both to scripts with ScriptHost::window_full_screen.
  • WindowOptions::caption_height (zgx-desktop; caption_height in zgx.json): how tall Titlebar::Inset's caption buttons are on Windows, in the content's points, so they span an app's title bar at any zoom. Drawing, hit-testing and WindowInfo::controls all use it. Unset, they stay 32 points of the display.

Performance

  • Text inputs a width change reached lay out once, however many: each text input whose width changed ran a layout pass of its own, from the root, for what the input before it had just dirtied: N inputs, N + 1 passes a frame while a window resized (9 at 8 inputs). They now draw from the frame's layout, and the frame's next pass lays out what they dirtied: 2 passes a frame at any number of inputs.

Fixed

  • A window keeps drawing through a full-screen transition, and says where its title bar's buttons end up (zgx-desktop, macOS): AppKit counts a window covered while it animates its snapshot of it, and zgx stopped drawing for those 0.55 s, with ui.window.shown false meanwhile; now it goes on, and counts the window covered only if it still is once the transition is over. Through a transition ui.window.controls and titlebar_area hold where they end up (nil going in; their place going out), never AppKit's place partway. full_screen_transition's duration is as long as the last one that way took, about 0.55 s at first, where AppKit's resize estimate said 0.35 s in and 0.07 s out.
  • Text taking its colour from a token around it follows every theme switch (zgx): a text inheriting $text.primary (or any colour token) from a row or button around it took the new theme's colour on the first switch and kept it after: the second switch's paint-only style run saw nothing of its own change and resolved the inherited size and family again, but not the colour. Sidebar rows and button labels kept the old scheme's text after switching themes twice. The inherited colour is resolved again with them.
  • A layer over the window doesn't dim it (zgx): a portal made a layer (View::layer: ui.toast's host, a heads-up) or shown at a caret got a modal's backdrop (backdrop, #00000082) over the whole window, though a layer has none: every toast dimmed the window while it showed. Only a modal has one now.
  • A list scrolled with the view around it follows a box clipping it (zgx): a virtualize = "ancestor" list inside a box that eases open (or shut) now builds the rows the box shows as it grows, not only once the scroll view moves; before, reopened, it showed none until a scroll.
  • One bad menu item no longer costs the whole menu bar, and every shortcut with it (zgx-desktop, zgx-script). In Zeron, a plugin's sheet called set_menus without the app's commands, and every shortcut died until relaunch. Three things are fixed:
    • WindowFactory::set_menus (and Application::menus) refused the whole bar when one item had no label, repeated another's action, or had an accelerator another item held or no key names (⌘é, ⌘?). Now that item is left out, or keeps no shortcut, and the rest is shown. Each problem is written on stderr (zgx: menus: …) when it first appears. set_menus errs only when the application is closed. Its docs now say it replaces every window's menus at once.
    • A plugin whose script failed as it loaded kept the ui.commands and ui.windows it had declared before failing. They stayed in the menu bar, and run_command returned false for them. Everything it declared now goes with it.
    • On macOS, a menu bar AppKit could not make (Event::MenusChanged, or the first bar) ended the app. Now it is reported, the last good bar stays, and a first bar falls back to the standard application and Window menus.
  • A family without the weight asked for draws in its nearest face: Medium (500) text in a family with Regular and Bold alone, most installed families, drew in another family (the fallback list's first with a Medium). It draws in the face CSS's font matching picks in its own family (zgx-cosmic-text 0.19.10). Thanks to @katulevskiy.
  • A popover's arrow is painted as its panel is, as it changes (zgx): the arrow took a copy of the panel's styles as it mounted, so a panel whose background, border or opacity followed state (a reactive style) drew its arrow in the colour it had first. The arrow takes what the panel's reactive style gives each time it runs.
  • A popup's glass blurs on Windows (zgx-gpu, zgx-desktop): a menu, popover or tooltip with backdrop_blur showed what's behind it sharp, as a popup's window has nothing of the app's to blur. It now blurs what its window last drew under it, taken again when the window repaints there, at the cost of a texture the popup's size while it shows and a copy per redraw. Past its window's edge, or over another popup, what's behind still shows through its fill.
  • A font token a script names a family for takes it: a script's theme override (theme = { ["font.sans"] = "Inter" }) or ui.theme.tokens gave a font token a family's name as text, which the theme refused for a font token, so the override was dropped and text kept the default family. It is read as a theme file reads a font token's word: a CSS font-family list, its first family. Thanks to @katulevskiy.
  • The terminal follows the theme's monospaced font: the engine-drawn terminal drew its grid and its composition in the platform's monospaced font whatever the theme said. It takes font.mono from the theme scope its view mounts in, and follows it as it changes (the cell measured again, every row made again). Where the theme names none, it keeps the platform's monospaced font. The Ghostty backend on macOS keeps its own font settings. Thanks to @katulevskiy.
  • Windows' caption buttons show everywhere, in the app's own ink, and agree when zoomed (zgx-desktop): they were an icon font, which a Windows 10 tester saw as empty boxes; they are now drawn as boxes and bars of whole pixels, with no font. They followed the system's light or dark, not the app's, so they were invisible on a light app on a dark system. They are now inked from the app's theme, as its own title bar controls are (text.secondary at rest, text.primary under the pointer, text.tertiary in a window in the back, over its hover and pressed; Close keeps its red), with an outline icon's line weight, so this changes how every Windows app's caption buttons look. With the repository's winit (getting started), set_theme on Windows also updates theme() and a system change no longer undoes it; from crates.io, a system change puts the window's own light or dark (its Mica) back to the system's, while the buttons stay in the app's ink. In a zoomed window the buttons drawn, hit-tested and reported disagreed (at 150%: 207 pixels drawn, 138 clickable); all three, snap layouts included, now read one geometry and stay 46 by 32 points of the display, whatever the zoom. A window that isn't resizable, or whose smallest and largest sizes match, no longer shows Maximize or answers resize bands.
  • Windows' Transparency effects setting is honoured (zgx-desktop): ui.prefers.reduced_transparency and SystemPreferences report EnableTransparency, and follow it as it changes. With it off, glass is opaque, as on macOS.
  • In a zoomed window on macOS, baked loops and opaque GPU views lie where their boxes are (zgx-gpu, zgx-desktop): their Core Animation layers were placed in the zoomed window's points where the host layer's hold no zoom, so a ring with a looping shaderTime floated up and left of its row at 110%, further the further from the window's corner, and was too small. A host sets it with GpuRenderer::set_zoom. A window read back shows the caret there too.

Crates: zgx, zgx-components, zgx-gpu, zgx-3d, zgx-desktop, zgx-terminal, zgx-script, zgx-run and zgx-ghostty-sys 0.1.10.