Skip to content

dvui: run-dvui, dvui's demo and floating windows as OS windows - #4

Merged
foxnne merged 4 commits into
mainfrom
dvui/run-dvui
Oct 10, 2026
Merged

foxnne merged 4 commits into
mainfrom
dvui/run-dvui

Conversation

@foxnne

@foxnne foxnne commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

Part of fizzyedit/fizzy#281. Pins fizzy at main (189c7d5dac1b: fizzy.addDvui from fizzyedit/fizzy#326, app-framed windows from fizzyedit/fizzy#338, and the overlapping-window press fix from fizzyedit/fizzy#341) and the replay app's SDK at 0.2.20. That makes it supersede #3.

zig build run-dvui is a plain dvui app on fizzy's backend: dvui's own widgets and dvui's demo, nothing of fizzy the editor. Each floating window is an OS window of its own, and looks as it does inside the main window: dvui's header and close X, no OS title bar or minimise and zoom buttons (viewports.Frame.app). The OS moves a window by its header; the floating window resizes itself from its edges, as dvui's does anywhere, and its window follows. That's the demonstration the upstream dvui proposals (drawRetained, screensSet) point to.

How it works (dvui/main.zig, about 250 lines). Any floating window can go out, by its dvui id: the app's own, or dvui's demo (found by its tag's rect, since dvui gives a floating window's tag to the box inside it). dvui keeps where each is in its data (_rect), and the app moves that into the window's band and reads it back. There is one dvui.Window and one frame.

  • Before drawing:
    • each floating window not yet out opens a viewport over its place in the main window (viewports.open);
    • one the OS moved or resized follows its window (osPlaced);
    • each window's band is a dvui screen (dvui.screensSet), so dvui keeps the floating window in it.
  • Drawing: dvui draws the floating windows as it would anywhere.
  • After drawing:
    • Window.drawRetained runs;
    • each OS window is placed (viewports.place), told its header is where the OS drags it from (hints), and handed its picture: the subwindows in its band, taken out of the frame (viewports.Picture).

-Ddvui-backend=sdl3 builds the same code on dvui's own SDL3 backend, which has no viewports (viewports_none). The floating windows then stay in the main window, as in any dvui app.

Floating windows only for now. Menus and dialogs as windows of their own need the app to say which subwindows are menus, and that comes later.

Verification, macOS

  • Builds from the URL pin at main: zig build dvui, dvui -Ddvui-backend=sdl3, all three shapes, studio -Dzon-layout=true and replay.
  • On fizzy's backend: the app starts with dvui's demo and two floating windows. Each is an OS window exactly its float's size (demo 606×614, floats 280×180), opened over its place in the main window. No warnings, and it quits within 400 ms on SIGTERM (backend: an idle app quits at once on SIGTERM fizzy#337).
  • By @foxnne, on screen: dragging, closing, and clicks in overlapping windows work (after backend: a press goes to the window it lands on, where windows overlap fizzy#341).
  • On dvui's SDL3 backend: one window, the floating windows inside it, no warnings.
  • Builds from the URL pin at main: dvui on both backends, all three shapes, studio -Dzon-layout=true and replay.

🤖 Generated with Claude Code

foxnne and others added 2 commits October 9, 2026 22:05
`dvui/main.zig` on fizzy's backend through `fizzy.addDvui`; `-Ddvui-backend=sdl3` builds it on
dvui's own backend, the floating windows in the main window.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
foxnne added a commit to fizzyedit/fizzy that referenced this pull request Oct 10, 2026
Part of #281: what example-app's `run-dvui` builds on. Stacked on #326
(on #324); review those first. The example-app side is
fizzyedit/example-app#4.

**`fizzy.addDvui(fizzy_dep, root_module, backend)`** gives an outside
app's module dvui on one of two backends:
- `.fizzy`: fizzy's own, where each floating window can be an OS window
of its own;
- `.sdl3`: dvui's own SDL3 backend, which has the main window only.

The module gets `dvui` (fizzy's pin), its `backend`, and
`viewports_none` (#324), so the same app code builds on either:

```zig
const backend = @import("backend");
const viewports = if (@hasDecl(backend, "viewports")) backend.viewports else @import("viewports_none");
```

On fizzy's backend it also gets `platform`, and on macOS the backend's
Objective-C compiled into it. `build/exe.zig`'s backend switch is now
`nativeDvui`, shared by fizzy's own executable and `addDvui`.

## Two fixes a plain dvui app needed

1. **The main window's drawable was acquired with a copy pass still
open** (`GpuRenderer.acquireSwapchain`). The frame's texture uploads had
left it open, and SDL asserted on every frame ("Cannot acquire a
swapchain texture during a pass"). Fizzy never hit this because it draws
its frame into a target first. Any dvui app draws straight into the
window. The fix ends the copy pass before acquiring, as `presentInto`
and `clearPass` already do.
2. **`platform`'s menu-bar exports weren't emitted** (`FizzyMenu*`).
`macos/menu_target.m` calls them and is compiled into every macOS app on
the backend, but Zig emits an `export fn` only when analysis reaches its
file. Fizzy reaches `platform/menu.zig` through its menu bar; a dvui app
with none failed to link. Now `platform/root.zig` references them, and
they're `pub`.

## Verification

- **Fizzy:** `zig build`, `test` (514/515, 1 skipped),
`test-integration` (358/358), `check-web`, `test-sdk-version`, the
backend's tests (46/46), and the Windows and Linux cross-builds pass on
macOS. The soak tape ends in a passing verdict (1,429 viewport presents,
no leaks, nothing logged as an error).
- **example-app's `run-dvui`, built against this branch, on macOS:**
- **On fizzy's backend:** it opens its main window and two floating
windows. Each is an OS window of its own, opened over its place in the
main window (window list: main at 540,332; floats at 652,476 and
684,500, each 280×212). No assertions or warnings, and it quits cleanly
on SIGTERM.
- **With `-Ddvui-backend=sdl3`:** the same app shows only its main
window, with the floating windows in it. No warnings.
- **Not seen:** I couldn't screenshot, since this session has no
screen-recording permission. Window positions and the logs are what I
checked, not how they look.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@foxnne
foxnne changed the base branch from build/pin-main-0.2.20 to main October 10, 2026 16:09
@foxnne
foxnne marked this pull request as ready for review October 10, 2026 16:09
Each floating window that goes out opens framed by the app (`viewports.Frame.app`): its own header
and close button, no OS title bar. Any floating window can go out, by its dvui id, dvui's demo
included; fizzy pinned at main with `viewports.Frame` and the overlapping-window press fix.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@foxnne foxnne changed the title dvui: run-dvui, a plain dvui app whose floating windows are OS windows dvui: run-dvui, dvui's demo and floating windows as OS windows Oct 10, 2026
@foxnne
foxnne merged commit ee59abb into main Oct 10, 2026
1 check passed
foxnne added a commit to fizzyedit/fizzy that referenced this pull request Oct 10, 2026
…ds (#343)

Part of #281.

`scripts/check-examples.sh`, which CI's Linux job runs against each PR's
own tree, now also builds example-app's `run-dvui`
(fizzyedit/example-app#4, merged), twice:
- `zig build dvui`, on fizzy's backend (`fizzy.addDvui`, `viewports`);
- `zig build dvui -Ddvui-backend=sdl3`, the same code on dvui's own SDL3
backend through `viewports_none`.

A change to the backend package's `viewports`, `Picture`, `Frame` or the
stand-in that would break a plain dvui app now fails here before it
lands, as the shapes and the replay app already do.

**Verification:** `EXAMPLES_DIR=~/dev/fizzyedit
scripts/check-examples.sh` on macOS. example-plugin, the three shapes,
studio as data, the replay app and the dvui app on both backends all
build.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant