Commit graph

1,792 commits

Author SHA1 Message Date
Sabin Regmi
7ab7f324b3
Use fallback cell size when glyphs missing (#942)
Replace unwraps when querying the first glyph with safe handling and provide a fallback monospace cell size if no glyph is available (e.g. on wasm while fonts are still loading). Computes a reasonable width/height from the current font_size (width = 0.6 * font_size, height = font_size) so the editor can render on first draw instead of aborting. Keeps existing cell_size and cell_offset_y calculations based on the chosen dimensions.
2026-03-14 12:13:04 +01:00
Jason Yau
f3178e65a6
Fix windows build error (#944)
* regenerate windows-rs to export missing functions

* fix compilation errors on windows

* import WS_EX_TOOLWINDOW from windows-rs instead of customizing the constant

---------

Co-authored-by: jasonqiu <jasonqiuchen@outlook.com>
2026-03-14 12:12:50 +01:00
Sabin Regmi
5a6eacd7ef
ft floating panel on macos (#945) 2026-03-14 12:12:35 +01:00
offline-ant
fe5cd60087
platform: rework custom MSE playback sessions (#946)
Co-authored-by: ant <ant@offline.click>
2026-03-14 12:12:21 +01:00
offline-ant
8189d8eab2
compositor: add projected quad and offscreen surface primitives (#947)
* draw: add draw-list transform helpers for projected composition

* draw: unroll rounded box shadow sampling in SDF shader

* platform: honor per-draw depth_write across backends

* compositor: add projected quad and offscreen surface primitives

---------

Co-authored-by: ant <ant@offline.click>
2026-03-14 12:12:05 +01:00
Kevin Boos
1feaac5494
Fix HtmlLink attribute init to handle any attr order (#948) 2026-03-14 12:11:42 +01:00
Kevin Boos
2ebeb20262
fix tooltip by force-drawing the draw list upon show/hide (#950)
Without this, the tooltip will not necessarily be shown upon its
first call to `show()`, especially if the CalloutTooltip wrapper
is driving it.
2026-03-14 12:11:32 +01:00
offline-ant
7dd4597e83
Fix PulseAudio input stream dedupe (#951)
* Fix PulseAudio input stream dedupe

* Fix PulseAudio input callback userdata cast

* Fix PulseAudio threaded mainloop waits

---------

Co-authored-by: ant <ant@offline.click>
2026-03-14 12:11:18 +01:00
Kevin Boos
f337fcd9be
Support image rotation in degrees (#952)
This was previously a feature but was lost in the 2.0 migration
2026-03-14 12:11:01 +01:00
wyenox
67d6ed2906
Fix and optimize widget search to return the shallowest match in the tree (#949) 2026-03-14 07:49:32 +01:00
Admin
f040a2f2a6 hands back! 2026-03-12 16:57:25 +01:00
Admin
bca911513d xr otw 2026-03-12 15:51:30 +01:00
Sabin Regmi
2e900f48af
Clippy Fixes Only (#939)
* clippy fixes on draw

* more clippy fixes

* more clippy fixes

* more small nits
2026-03-12 14:59:41 +01:00
Sabin Regmi
3242b11afc
Windows Blur, System Composition (#940)
* Initial plan

* feat(platform): add window visuals API and M1 backdrop wiring

Co-authored-by: wheregmis <26774729+wheregmis@users.noreply.github.com>

* feat(uizoo): add M2 GlassPanel widget and demo tab

Co-authored-by: wheregmis <26774729+wheregmis@users.noreply.github.com>

* blue example

* Apply backdrop intensity and transparency

macOS: apply visuals.backdrop_intensity to the NSVisualEffectView alpha (clamped) so backdrop intensity affects the effect view.

Windows: honor visuals.backdrop_intensity by computing an alpha-packed accent color, toggle WS_EX_LAYERED for transparent windows, call SetLayeredWindowAttributes and DwmExtendFrameIntoClientArea when needed, and set the AccentPolicy accordingly (enable blur for transparent or non-none backdrops, set gradient_color based on intensity, and set accent_flags depending on DWM attribute result).

Tests: update expected backdrop_intensity in a unit test from 4.0/1.0 to 0.25 and assert a platform op is emitted. These changes ensure backdrop intensity and transparency settings are respected across platforms.

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: wheregmis <26774729+wheregmis@users.noreply.github.com>
2026-03-12 14:57:09 +01:00
Admin
61a70d0ebd xr 2026-03-12 13:30:40 +01:00
Admin
0c80201e66 makepad splash 2026-03-12 09:49:30 +01:00
Admin
1bad158945 fixup 2026-03-12 09:39:47 +01:00
Admin
7895cd34fc fixup 2026-03-12 09:39:16 +01:00
Admin
cde02e2e48 fix 2026-03-11 18:15:12 +01:00
Sabin Regmi
bba8868caf
Optimize font loading and add SharedBytes (#938)
Introduce selective font loading and a SharedBytes abstraction with mmap support to reduce memory and IO overhead when handling fonts.

Key changes:
- Add SharedBytes (with MappedBytes using memmap2) and stats; switch FontData to SharedBytes and update loader/loader tests.
- Platform: add memmap2 dependency (non-wasm), new platform API helpers get_resource_abs_path and get_resource_font_bytes to prefer mmap'ed files and fall back to owned bytes.
- Font family/load changes: ensure_fonts_loaded_for_text and update_font_definitions now accept optional text to load only needed fallback fonts (CJK/emoji) based on text content and resource basename heuristics.
- Avoid eager loading of heavy bundled fallback fonts (LXGWWenKai*, NotoColorEmoji.ttf) when loading all script resources.
- Add env override MAKEPAD_TEXT_ATLAS_SIZE for text atlas size parsing and tests; add related parsing helpers and tests.
- Minor fixes: safer transmute for font_face data slice and several unit tests to validate behavior.

Overall this reduces unnecessary font resource reads/mmap usage and allows tuning text atlas size via environment.
2026-03-11 16:25:35 +01:00
Admin
feb1ecd55f dock fix 2026-03-11 10:19:58 +01:00
Admin
a6eb9906a0 hiccup 2026-03-11 10:19:58 +01:00
Admin
5170eed9af working 2026-03-11 10:19:58 +01:00
Sabin Regmi
ffbeadc173
Hotreloading Nits (#936)
* Add wasm server_manager and ownership guard

Introduce a new wasm server_manager module that implements WasmServerOwnershipGuard to manage per-workspace lock files, PID/port ownership, and safe replacement of stale or live servers. Integrate the guard into compile::run by preparing and activating the guard before starting the HTTP server; start_wasm_server now accepts the guard, returns a Result, checks bind success, activates the guard, and propagates thread join errors. The server manager includes platform-specific PID handling, port-probing, lock read/write/remove helpers, and unit tests exercising startup scenarios and lock lifecycle. Also add mod declaration and apply minor formatting/refactor cleanups across compile.rs (error formatting, whitespace, and logging improvements).

* Add startup mutex and port occupant diagnostics

Rename server_manager into top-level module and add startup mutex handling and improved diagnostics. Introduces atomic lock writes (write_file_atomically), a StartupMutexGuard with configurable timeouts/polling, and logic to detect/recover stale startup locks to prevent concurrent wasm run startups. Extends ServerManagerProbes with describe_port_occupant and implements platform-specific detection (lsof on Unix, netstat/tasklist on Windows) to provide clearer errors when ports are occupied. Updates imports (main.rs, compile.rs, mod.rs) and adds unit tests covering startup lock behavior and unknown-occupant error text.

* Improve hot-reload logging and delivery

Add clearer logging and error handling for wasm hot-reload events. Introduces hot_reload_display_name to extract a user-friendly file name, logs when a hotreload is detected, and checks tx.send result to avoid panics when the watcher channel is closed. broadcast_hot_reload_event now logs whether events were skipped (no /$watch clients) or sent and includes the delivered client count with proper pluralization.

* Check lock PID owns port and add startup timestamp

Require that a lock's PID both be alive and actually own the server port to be considered a live lock (classify_lock_state now takes listen_addr). Add parsing of a started_at timestamp in startup locks and use now_unix_millis to age out stale startup locks even if the PID is alive. Extend ServerManagerProbes with now_unix_millis and pid_owns_port, implement port_occupant_info and PortOccupant to centralize occupant detection/refinement for unix and windows, and refactor describe_port_occupant to use it. Update tests and MockProbes to exercise PID ownership checks and startup-lock aging; add tests for PID reuse (treated as stale if it doesn't own the port) and for startup lock aging.

* Hot reload: dedupe sites, add logging

Avoid duplicate ScriptMod sites during hot reload and improve diagnostics. collect_compiled_sites_for_file now tracks seen ScriptModKey values to prevent pushing duplicates. handle_cx_live_edit counts processed files and logs how many overrides were applied and from how many changed files. forward_hot_reload_fs_event logs each detected file and reports if the watcher channel is closed. Minor import cleanup and a helper hot_reload_display_name were added for nicer log output.

* shared core for reload

* Warn and fallback to unminified JS on write error

When writing the minified JS file fails, log a warning and fall back to copying the original JS file instead of returning an error. This avoids failing the build on IO/write errors (e.g. permissions or disk issues) while preserving the previous behavior of using the unminified copy when reading fails. No change to successful minification path.
2026-03-10 12:47:38 +01:00
Kevin Boos
c344dcd4fb
Support hiding a dock tabs bar (#937) 2026-03-10 08:00:44 +01:00
offline-ant
c44b456ebc
studio/runview: wait for app-ready before Wayland swapchain bootstrap (#935)
Co-authored-by: ant <ant@offline.click>
2026-03-09 20:07:03 +01:00
offline-ant
5407f085e7
studio/runview: fix Wayland bootstrap and control-text input (#934)
* studio/runview: fix Wayland stdin-loop bootstrap

* wayland: ignore control text input commits

* tools: ignore generated python bytecode

---------

Co-authored-by: ant <ant@offline.click>
2026-03-09 19:34:49 +01:00
Admin
609655aa5c wasm hotloading 2026-03-09 19:34:00 +01:00
Admin
39d107a09b wasm hotloading 2026-03-09 19:26:08 +01:00
Sabin Regmi
9cf8128f15
WASM Binary Optimization + Splitting (#925)
* wip

* Handle wasm data segments and manage brotli artifacts

Add full support for parsing, encoding and rewriting Wasm data segments: introduce WasmDataSegmentKind (Active/Passive), helpers to encode varints and const i32 exprs, and functions to rewrite the data section or replace a section payload. Update wasm_split_data_segments to preserve passive segments and data.count (section 12), only extract active segments into a separate split blob, and adjust segment counting and tests accordingly.

Bump brotli dependency to 8.0 in tools, and add remove_brotli_artifact to remove leftover .br files when brotli compression is disabled. Call this cleanup in cargo_makepad build/copy paths and when removing split data, and add .bin MIME mapping and print mapping for .bin in the server output. Tests updated to cover passive segments and data_count preservation.

* Support split data v2 and wasm rebuild

Add support for a new split data format (version 2) and the ability to rebuild a WASM module with its data section. wasm_bridge.js: parse v1/v2 split blobs, return {version, segments}, add varint encode/decode helpers, encode split-data section payloads, implement rebuild_split_wasm, fetch-and-instantiate logic to fetch both wasm and split blobs and handle v1 preloaded splits or rebuild for v2. wasm_strip.rs: bump split data version to 2, include segment kind and memory_index in encoded split data, preserve passive segments, update encoding/decoding and tests, and return the updated segment count. tools/cargo_makepad/src/wasm/compile.rs: separate target spec directories for threaded vs single builds (threads/single).

* basic splitting

* Instantiate secondary Wasm module in threads

Store and expose a compiled secondary WebAssembly module from the primary module, and ensure worker contexts (Web Worker and AudioWorklet) instantiate that secondary module before running thread entrypoints. Changes: save _secondary_module on primary_wasm in wasm_bridge, include secondary_module in WasmWebBrowser info, and add async instantiate_secondary logic + awaits in audio_worklet and web_worker so the secondary module is instantiated with {env, primary: primary_wasm.exports} prior to initializing stack/TLS or starting execution. This ensures the secondary module can import primary exports in threaded contexts and prevents race conditions by waiting for instantiation to complete.

* more cleanups

* more cleanup

* wip

* remove double wasm pump

* cleanup

* Cold-first auto wasm split with fallback

Add a cold-only function-splitting mode and automatic fallback to preserve startup-safe behavior. Introduces wasm_split_functions_cold() and a split_auto flag to run a cold-first pass that moves defer-safe cold functions to a secondary wasm; if no useful cold candidates are found the build falls back to the normal startup-path function split so the app still gets a secondary payload.

Changes include: update to CLI help text, new split_auto handling in WasmConfig, AutoSplitOutcome variants, compile logic to prefer cold-only splits then fall back to the regular split, adjusted logging for automatic mode, and README wording clarifications. Files touched: README.md, libs/wasm_strip/src/wasm_strip.rs, tools/cargo_makepad/src/main.rs, tools/cargo_makepad/src/wasm/compile.rs, tools/cargo_makepad/src/wasm/mod.rs.

* Tune brotli compression parameters

Adjust brotli settings in tools/cargo_makepad/src/wasm/compile.rs: increase buffer size from 4KB to 64KB, lower quality from 12 to 11, and raise window size from 22 to 24. This balances throughput and compression ratio for larger wasm artifacts—bigger buffer and window can improve compression effectiveness while slightly reducing CPU cost by lowering quality.

* Add optional wasm-opt optimization flag

Introduce an optional --wasm-opt option that runs Binaryen's wasm-opt -Os on built wasm when available. Adds a wasm_opt flag to WasmConfig (default false), parses the CLI option, and integrates a try_wasm_opt helper that writes a temp wasm, invokes wasm-opt, reads back the optimized output and prints size/reporting while gracefully falling back on errors. The wasm-opt step runs before the existing split/strip pipeline. Also updates CLI help text, minor Cargo.toml formatting changes, and removes a vendor UPSTREAM.md reference.

* update readme

* Shorten split exports to $s/$p and use base62

Rename split-related exports/imports to shorter identifiers and compress numeric indices using base62. Changes: export/table slot prefix changed from "__mp_split_table"/"__mp_split_slot_*" to "$s" and the primary import namespace from "primary" to "$p" across wasm_bridge, audio_worklet, and web_worker. Introduces encode_base62 in wasm_strip to emit $f/$t/$m/$g names with base62-encoded indices, and updates primary/secondary module generation and tests accordingly. Also includes minor JS formatting/whitespace cleanups and small safety/compatibility tweaks during WebAssembly instantiation.

* Preload WASM modules and set cache headers

Inject modulepreload links into generated HTML (conditionally including wasm_bridge and bindgen when bindgen is enabled, otherwise preloading web_gl only) to improve module loading. Also change served asset Cache-Control from max-age=0 to max-age=86400 (1 day) for both brotli-compressed and uncompressed responses to enable client caching and reduce repeated fetches.

* Minify JS when copying before brotli

Add a lightweight JS minifier and apply it in cp_brotli for .js files. Introduces minify_js which strips line/block comments, collapses unnecessary whitespace, preserves strings/escaped characters and simple regex literals (heuristic), and removes empty lines. cp_brotli now attempts to read and minify .js input and write the minified output to the destination (falling back to cp on read error), then continues to optionally brotli-compress the result. This reduces payload size prior to compression with a small, simple minification step.

* Format web.js and disable XR capability checks

Apply consistent JS formatting (spacing, brace placement, object literal spacing, and minor whitespace cleanups) across platform/src/os/web/web.js. Replace the previous XR capability detection with a no-op (query_xr_capabilities now returns Promise.all([])) and remove the await call in load_deps so XR checks are not performed during startup. Also includes minor non-functional tweaks (timers, audio worklet messaging formatting, fetch call spacing, and various input/keyboard handler cleanups). Overall changes are primarily stylistic with the notable behavior change of disabling XR capability probing.

* Add WASM no-cache headers; remove web video arms

Set Cache-Control to "no-store, must-revalidate" (plus Pragma/Expires) for .wasm responses while keeping max-age=86400 for other assets; wire these into the HTTP response headers. Also remove the explicit VideoSource::InMemory and VideoSource::Filesystem match arms from the web platform code (they previously logged errors and emitted VideoDecodingError events).
2026-03-09 18:52:49 +01:00
Admin
fbde8812a3 linux filechange 2026-03-09 18:34:05 +01:00
Admin
bdf760b58b wasm media 2026-03-09 18:00:25 +01:00
Admin
7a9274ebf8 wasm media 2026-03-09 17:43:54 +01:00
Admin
612f3b9cd8 hotreloading 2026-03-09 17:25:14 +01:00
Admin
e23a8b3f26 fix uid 2026-03-09 16:42:43 +01:00
offline-ant
cceb499765
studio/runview: fix Wayland stdin-loop bootstrap (#933)
Co-authored-by: ant <ant@offline.click>
2026-03-09 09:24:54 +01:00
Admin
928521e994 mipmapping 2026-03-09 09:18:33 +01:00
Admin
def4c5f6e6 fix script mods 2026-03-08 18:20:07 +01:00
Admin
e79e374375 live reloading 2026-03-08 17:25:27 +01:00
Admin
38d08cab0b bootstrap change 2026-03-08 13:36:58 +01:00
Admin
ba51dceee4 undo integer attribute change 2026-03-08 13:11:57 +01:00
offline-ant
7c7d91b8ad
platform: video/camera subsystem with media plugin architecture (#929)
Video playback: extended API with volume, playback rate, seek ranges,
buffered ranges, can_play_type, audio-only mode. Unified player wrapping
native backend (AVPlayer/GStreamer/MediaFoundation) with software fallback.
YUV shader pipeline (BT.601/709/2020, NV12 biplanar, rotation).

Camera: V4L2 backend (Linux), expanded NDK Camera2 (Android), AVCapture
stream refactor (iOS/macOS) with shared session architecture. NV12
zero-copy paths on iOS (CVMetalTextureCache) and Android (AImage planes).
Camera preview modes (texture/native/auto).

Video encoding: H264 hardware encode on Apple (VideoToolbox) and Android
(MediaCodec). Camera-to-encoder pipeline with pixel buffer passthrough.

Media plugin system: externalized codec implementation via MediaPlugin
trait. MsePlayer, VideoFrameDecoder, MediaVideoEncoder, SoftwareVideoPlayer
interfaces. Runtime codec capability query and merge.

Includes camera example app.

Co-authored-by: ant <ant@offline.click>
2026-03-08 13:10:58 +01:00
offline-ant
c22cf23cf0
platform: popup window API with X11/Wayland support (#911)
- Add popup window type for context menus and dropdowns
- Wayland: xdg_popup with grab for compositor-driven dismiss
- X11: override-redirect windows with pointer grab
- Explicit-close semantics: app must handle PopupDismissed
- Fix Wayland crash on repeated context menu open/close
- Emit WindowClosed before PopupDismissed in PopupDone

Co-authored-by: ant <ant@offline.click>
2026-03-08 13:10:45 +01:00
offline-ant
814fe4d9cd
platform: native mobile selection handles (#930)
* platform: popup window API with X11/Wayland support

- Add popup window type for context menus and dropdowns
- Wayland: xdg_popup with grab for compositor-driven dismiss
- X11: override-redirect windows with pointer grab
- Explicit-close semantics: app must handle PopupDismissed
- Fix Wayland crash on repeated context menu open/close
- Emit WindowClosed before PopupDismissed in PopupDone

* platform: native mobile selection handles

iOS: custom UIView selection handles with UIPanGestureRecognizer (all versions),
UITextSelectionDisplayInteraction for native highlights (iOS 16+),
MakepadSelectionRect for UITextInput protocol.

Android: custom SelectionHandleView with GradientDrawable oval, touch drag
listeners, JNI bridge for handle drag events.

Widgets: TextFlow clipboard action integration (show on touch up with selection,
hide on touch down/focus lost, TextCut handler), PortalList select-all and
clipboard actions, selection bounding rect computation for popup positioning.

Includes text_selection example app.

---------

Co-authored-by: ant <ant@offline.click>
2026-03-08 12:15:31 +01:00
Admin
cb87a70b74 terminal selection 2026-03-08 11:53:36 +01:00
Admin
3d7852d0b3 remove dep 2026-03-08 11:43:23 +01:00
Lutz
3e8e09fbe9
fix: Single-slot UInt/SInt instance attributes render incorrectly (#922)
Co-authored-by: Lutz Paelike <lutz.paelike@ehealthafrica.org>
2026-03-08 11:26:52 +01:00
offline-ant
04dea089bd
platform: small fixes and quality improvements (#928)
- Android log levels: map log! macro levels to Android log priorities
  (ERROR=6, WARN=5, INFO=4). Some devices suppress DEBUG by default.
- cargo-makepad android: show help text instead of panicking on missing
  or invalid subcommand.
- Android build: discover .class files dynamically instead of hardcoding
  ~25 individual paths. Add Java 8 source/target flags.
- Remove deprecated AsyncTask import from MakepadNetwork.java.
- Studio stdout: add newline after JSON messages for JSON-lines parsing.
- Studio stdout: skip profiler timing in stdout mode to avoid overhead.
- Script thread: fix panic on empty call stack in call_has_me/call_has_try.
- Cursor: reset to Default on FingerHoverOut in TextFlow and TextInput.

Co-authored-by: ant <ant@offline.click>
2026-03-08 11:24:18 +01:00
offline-ant
27b910ff6c
platform: cycle tap count after triple-click so fast double-clicks keep working (#931)
process_tap_count incremented without bound. TextInput handles
tap_count 2 (select word) and 3 (select all) but ignored counts
>= 4. Rapid repeated double-clicks produced tap counts of 4, 5, 6...
hitting the _ => {} fallthrough and doing nothing.

Cycle the counter back to 1 after reaching 3 (1->2->3->1->2->3).

Co-authored-by: ant <ant@offline.click>
2026-03-08 11:22:12 +01:00
Admin
ec505b27f0 script api for slide panel 2026-03-08 10:57:03 +01:00