Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions backend/src/SDLBackend.zig
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ const dvui = @import("dvui");
const GpuRenderer = @import("GpuRenderer.zig");
pub const viewport_map = @import("viewport_map.zig");
const TouchSlots = @import("touch_slots.zig");
const glass_look = @import("glass_look");
/// The OS windows besides the main one an app draws with (`Viewport`).
pub const glass_look = @import("glass_look");
const viewports = @import("viewports.zig");
pub const viewports = @import("viewports.zig");
/// dvui's floating windows as OS windows of their own from the one frame (`floatingWindowOs`).
pub const os_windows = @import("os_windows.zig");
/// What this backend keeps count of as it runs (`health`).
Expand Down
7 changes: 5 additions & 2 deletions backend/src/viewports_none.zig
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,12 @@
//! null, so an app's floats, menus and dialogs stay in the main window.
//!
//! An app that builds on either kind of backend imports this beside it and takes the backend's
//! own where it has one:
//! own where its build linked the backend package (fizzy passes that as a build option):
//!
//! const viewports = if (@hasDecl(backend, "viewports")) backend.viewports else @import("viewports_none");
//! const viewports = if (linked_fizzy_backend) backend.viewports else @import("viewports_none");
//!
//! Not `@hasDecl(backend, "viewports")`: a declaration that loses its `pub` is invisible to it,
//! and the app would quietly keep every float in its main window.
const dvui = @import("dvui");

/// A window's Liquid Glass this frame, as the backend package's (`platform.window.WindowGlassLook`):
Expand Down
4 changes: 4 additions & 0 deletions build/exe.zig
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,10 @@ pub fn addFizzyExecutableForTarget(
exe.root_module.addImport("platform", platformModule(b, native, resolved_target, optimize, macos_sdl_paths));
// On dvui's own SDL3 backend (`-Dnative-backend=sdl3`), which has no viewports.
exe.root_module.addImport("viewports_none", fizzy_backend.viewportsNoneModule(backendDependency(b), dvui_mod));
// Which of the two the executable links (`backend_native.viewports`).
const native_backend_opts = b.addOptions();
native_backend_opts.addOption(bool, "fizzy", native_backend == .fizzy);
exe.root_module.addImport("native_backend", native_backend_opts.createModule());

// The glass look the backend dresses OS windows with; `core` takes the same module.
const glass_look = fizzy_backend.glassLookModule(backendDependency(b));
Expand Down
4 changes: 3 additions & 1 deletion src/backend/backend_native.zig
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,9 @@ pub fn windowGlass(win: *dvui.Window, look: WindowGlassLook) bool {
/// OS windows besides the main one, each showing a part of the one frame — a float popped out
/// (`plans/POPOUT_WINDOWS_PLAN.md`): the backend package's, for any dvui app on it. On dvui's own
/// SDL3 backend (`-Dnative-backend=sdl3`) there are none, as on the web, and floats stay in.
pub const viewports = if (@hasDecl(@import("backend"), "viewports")) @import("backend").viewports else @import("viewports_none");
/// Chosen by the backend the build linked, not by looking for the declaration: a `viewports` the
/// backend stops exporting fails the build here instead of quietly keeping every float in.
pub const viewports = if (@import("native_backend").fizzy) @import("backend").viewports else @import("viewports_none");

/// Fizzy keeps the window's geometry in `layout.zon`, beside its regions — one file for where the
/// window and everything in it were left, and the file it has always kept the frame in.
Expand Down
Loading