tauri-apps/tauri
tauri-runtime-wry
Active contributors: Lucas Fernandes Nogueira, Amr Bashir, Tony
Purpose
crates/tauri-runtime-wry is the default implementation of the tauri-runtime trait set. It wires Tauri to:
- TAO for native windows (via
tauri-apps/tao, a fork ofwinitextended with menu and tray support). - WRY for webviews (via
tauri-apps/wry, which targets WKWebView on macOS/iOS, WebView2 on Windows, WebKitGTK on Linux, and the Android System WebView).
This is the largest single source file in the repository — crates/tauri-runtime-wry/src/lib.rs is 5,383 lines. Most of that is the cross-platform implementation of WindowDispatch/WebviewDispatch and the translation of TAO/WRY events into the backend-agnostic tauri-runtime event types.
Directory layout
crates/tauri-runtime-wry/
├── Cargo.toml # Re-exports tao + wry; many target_os= deps for GTK / objc2 / windows
├── src/
│ ├── lib.rs # 5,383 lines: Wry runtime, event loop, dispatchers, message routing
│ ├── undecorated_resizing.rs # Manual hit-testing for borderless windows
│ ├── util.rs
│ ├── webview.rs
│ ├── dialog/ # Native dialog wrappers
│ ├── monitor/
│ └── window/
└── build.rsKey abstractions
| Type | File | Role |
|---|---|---|
Wry<T> |
crates/tauri-runtime-wry/src/lib.rs |
The Runtime impl; wraps a TAO EventLoop. |
WryHandle<T> |
crates/tauri-runtime-wry/src/lib.rs |
The RuntimeHandle impl; Send/Sync proxy that posts user events to the loop. |
WryWindowDispatcher / WryWebviewDispatcher |
crates/tauri-runtime-wry/src/lib.rs |
The WindowDispatch / WebviewDispatch impls; send messages to the event loop. |
Message<T> / WindowMessage / WebviewMessage / EventLoopWindowTarget |
crates/tauri-runtime-wry/src/lib.rs |
Internal command enum routed through the event loop. |
WindowWrapper, WebContextStore |
crates/tauri-runtime-wry/src/lib.rs |
Internal bookkeeping: mapping from WindowId/WebviewId to live native objects. |
undecorated_resizing::* |
crates/tauri-runtime-wry/src/undecorated_resizing.rs |
Hit-testing for decorations: false windows so users can still resize from edges. |
How it works
The runtime implements TAO's EventLoop::run callback. Every iteration:
- TAO produces a raw event (
WindowEvent,UserEvent,RedrawRequested,Resumed,Suspended, …). - The runtime translates it into either:
- A
tauri_runtime::WindowEvent/WebviewEventand forwards it to the registered Tauri callbacks, or - An internal
Message<T>it produced itself (e.g. "create new window", "set title") that needs to mutate native state.
- A
- WRY-side events (
page-load, navigation, IPC postMessage) are bridged in via the WRY callbacks set during webview construction.
graph TD
TAO["TAO EventLoop"] --> RouteEvent["match raw event"]
RouteEvent -->|window/UI event| Translate["translate to runtime::WindowEvent"]
Translate --> Core["tauri core callback"]
RouteEvent -->|user message| Apply["apply WindowMessage / WebviewMessage"]
Apply --> Native["TAO Window / WRY Webview"]
WRYIPC["WRY IPC handler"] --> CoreIPC["tauri core IPC entry"]Custom URI scheme handlers (tauri://, asset://, isolation://) are registered on the WRY WebViewBuilder. The runtime exposes register_uri_scheme_protocol on WindowDispatch so the core crate can install handlers per-webview.
Cargo features
The crate forwards a number of features through to WRY/TAO:
unstable— turns on WRY's unstable APIs (e.g. multi-webview-per-window).x11,dbus,linux-libxdo— Linux subsystems.macos-private-api,macos-proxy— macOS-only knobs.tracing,devtools,common-controls-v6— narrower.
Integration points
- Up: consumed by
crates/tauriwhen thewryCargo feature is enabled (the default). The core crate aliasesWry = tauri_runtime_wry::Wry<EventLoopMessage>. - Down: depends on
tauri-runtime(trait),wry(tauri-apps/wry),tao(tauri-apps/tao) plus a long list of platform deps (gtk,webkit2gtk,objc2,windows,webview2-com,muda,tray-icon).
Entry points for modification
| Goal | Start here |
|---|---|
| Translate a new TAO/WRY event type | crates/tauri-runtime-wry/src/lib.rs (search WindowEvent:: arms) |
Implement a new WindowDispatch/WebviewDispatch method |
Same file (search match webview_message { / match window_message {) |
| Tweak hit-testing for borderless windows | crates/tauri-runtime-wry/src/undecorated_resizing.rs |
| Adjust dialog rendering | crates/tauri-runtime-wry/src/dialog/ |
| Add platform-specific window-creation behaviour | The platform-gated blocks inside Wry::create_window in lib.rs |
See tauri-runtime for the trait, tauri for the consumer, and systems/ipc-and-commands for how IPC traverses this layer.
Built by Factory AutoWiki from public repository content. It is a generated preview for codebase exploration, not source-maintained documentation.