pub struct WebViewRenderer { /* private fields */ }Expand description
WebView-based renderer using wry + tao.
Platform backends:
- Windows: WebView2 (Edge Chromium)
- macOS: WKWebView (WebKit)
- Linux: WebKitGTK
§Frameless / Custom Title Bar
Set decorations = false in WindowConfig to create a frameless window.
The frontend can use window.__RDESKTOP_WINDOW__ to control the window:
window.__RDESKTOP_WINDOW__.minimize()
window.__RDESKTOP_WINDOW__.maximize()
window.__RDESKTOP_WINDOW__.close()
window.__RDESKTOP_WINDOW__.startDrag() // drag from custom title bar
window.__RDESKTOP_WINDOW__.startResize('bottom-right') // resize from edgeImplementations§
Source§impl WebViewRenderer
impl WebViewRenderer
pub fn new(config: &AppConfig) -> Result<Self>
Sourcepub fn set_asset_root(&mut self, root: impl Into<PathBuf>) -> Result<()>
pub fn set_asset_root(&mut self, root: impl Into<PathBuf>) -> Result<()>
Register a local directory as the renderer’s rdesktop:// asset root.
Native WebViews cannot reliably load Vite module assets from
file:// or NavigateToString() because of origin and module-CORS
rules. Serving the built frontend through a framework-owned protocol
gives the page a stable origin on every desktop backend.
Trait Implementations§
Source§impl Renderer for WebViewRenderer
impl Renderer for WebViewRenderer
Source§fn create_window(&mut self, config: &WindowConfig) -> Result<WindowHandle>
fn create_window(&mut self, config: &WindowConfig) -> Result<WindowHandle>
Create a new window with the given configuration.
Source§fn load_url(&self, window: WindowHandle, url: &str) -> Result<()>
fn load_url(&self, window: WindowHandle, url: &str) -> Result<()>
Load a URL in the specified window.
Source§fn load_html(&self, window: WindowHandle, html: &str) -> Result<()>
fn load_html(&self, window: WindowHandle, html: &str) -> Result<()>
Load HTML content directly.
Source§fn eval_script(&self, window: WindowHandle, script: &str) -> Result<()>
fn eval_script(&self, window: WindowHandle, script: &str) -> Result<()>
Execute JavaScript in the specified window.
Source§fn set_ipc_handler(&mut self, handler: Box<dyn IpcHandler>)
fn set_ipc_handler(&mut self, handler: Box<dyn IpcHandler>)
Set the IPC handler for messages from the frontend.
Source§fn send_to_frontend(&self, window: WindowHandle, message: &str) -> Result<()>
fn send_to_frontend(&self, window: WindowHandle, message: &str) -> Result<()>
Send a message to the frontend JavaScript.
Source§fn set_size(&self, window: WindowHandle, width: u32, height: u32) -> Result<()>
fn set_size(&self, window: WindowHandle, width: u32, height: u32) -> Result<()>
Set the window size.
Source§fn set_resizable(&self, window: WindowHandle, resizable: bool) -> Result<()>
fn set_resizable(&self, window: WindowHandle, resizable: bool) -> Result<()>
Set whether the window is resizable.
Source§fn set_visible(&self, window: WindowHandle, visible: bool) -> Result<()>
fn set_visible(&self, window: WindowHandle, visible: bool) -> Result<()>
Show or hide the window.
Source§fn close_window(&mut self, window: WindowHandle) -> Result<()>
fn close_window(&mut self, window: WindowHandle) -> Result<()>
Close a window.
Source§fn minimize_window(&self, window: WindowHandle) -> Result<()>
fn minimize_window(&self, window: WindowHandle) -> Result<()>
Minimize the window.
Source§fn maximize_window(&self, window: WindowHandle) -> Result<()>
fn maximize_window(&self, window: WindowHandle) -> Result<()>
Toggle maximize/restore.
Source§fn is_maximized(&self, _window: WindowHandle) -> Result<bool>
fn is_maximized(&self, _window: WindowHandle) -> Result<bool>
Check whether the window is currently maximized.
Source§fn set_fullscreen(&self, window: WindowHandle, fullscreen: bool) -> Result<()>
fn set_fullscreen(&self, window: WindowHandle, fullscreen: bool) -> Result<()>
Toggle fullscreen mode.
Source§fn is_fullscreen(&self, _window: WindowHandle) -> Result<bool>
fn is_fullscreen(&self, _window: WindowHandle) -> Result<bool>
Check whether the window is currently fullscreen.
Source§fn start_drag(&self, window: WindowHandle) -> Result<()>
fn start_drag(&self, window: WindowHandle) -> Result<()>
Begin an interactive window drag. Read more
Source§fn start_resize(&self, window: WindowHandle, edge: ResizeEdge) -> Result<()>
fn start_resize(&self, window: WindowHandle, edge: ResizeEdge) -> Result<()>
Begin an interactive window resize. Read more
Source§fn set_decorations(&self, window: WindowHandle, decorations: bool) -> Result<()>
fn set_decorations(&self, window: WindowHandle, decorations: bool) -> Result<()>
Set whether the window has OS decorations (title bar + borders).
Source§fn set_always_on_top(&self, window: WindowHandle, always: bool) -> Result<()>
fn set_always_on_top(&self, window: WindowHandle, always: bool) -> Result<()>
Set the window’s always-on-top state.
Source§fn run(self: Box<Self>) -> Result<()>
fn run(self: Box<Self>) -> Result<()>
Run the main event loop. This blocks until the application exits.
Source§fn kind(&self) -> RendererKind
fn kind(&self) -> RendererKind
Get the renderer kind.
Source§fn load_html_with_base_url(
&self,
window: WindowHandle,
html: &str,
base_url: &str,
) -> Result<(), RdesktopError>
fn load_html_with_base_url( &self, window: WindowHandle, html: &str, base_url: &str, ) -> Result<(), RdesktopError>
Load HTML content with a document base URL for relative assets. Read more
Source§fn set_click_through(
&self,
_window: WindowHandle,
_enabled: bool,
) -> Result<(), RdesktopError>
fn set_click_through( &self, _window: WindowHandle, _enabled: bool, ) -> Result<(), RdesktopError>
Enable or disable click-through: when enabled, pointer events fall
through the window to whatever is behind it (used by wallpaper and
click-through overlays). Applied at window creation by default; this
method allows toggling it at runtime where the platform supports it. Read more
Auto Trait Implementations§
impl !Freeze for WebViewRenderer
impl !RefUnwindSafe for WebViewRenderer
impl !Sync for WebViewRenderer
impl !UnwindSafe for WebViewRenderer
impl Send for WebViewRenderer
impl Unpin for WebViewRenderer
impl UnsafeUnpin for WebViewRenderer
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more