Skip to main content

WebViewRenderer

Struct WebViewRenderer 

Source
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 edge

Implementations§

Source§

impl WebViewRenderer

Source

pub fn new(config: &AppConfig) -> Result<Self>

Source

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.

Source

pub fn set_outbox(&mut self, outbox: Arc<Mutex<Vec<String>>>)

Attach an external outbox so other runtimes (e.g. a Node extension host) can push messages to the frontend. Each entry is a JSON string emitted as window.__RDESKTOP_IPC__(<json>).

Trait Implementations§

Source§

impl Renderer for WebViewRenderer

Source§

fn init(&mut self) -> Result<()>

Initialize the renderer.
Source§

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<()>

Load a URL in the specified window.
Source§

fn load_html(&self, window: WindowHandle, html: &str) -> Result<()>

Load HTML content directly.
Source§

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>)

Set the IPC handler for messages from the frontend.
Source§

fn send_to_frontend(&self, window: WindowHandle, message: &str) -> Result<()>

Send a message to the frontend JavaScript.
Source§

fn set_title(&self, window: WindowHandle, title: &str) -> Result<()>

Set the window title.
Source§

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<()>

Set whether the window is resizable.
Source§

fn set_visible(&self, window: WindowHandle, visible: bool) -> Result<()>

Show or hide the window.
Source§

fn close_window(&mut self, window: WindowHandle) -> Result<()>

Close a window.
Source§

fn minimize_window(&self, window: WindowHandle) -> Result<()>

Minimize the window.
Source§

fn maximize_window(&self, window: WindowHandle) -> Result<()>

Toggle maximize/restore.
Source§

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<()>

Toggle fullscreen mode.
Source§

fn is_fullscreen(&self, _window: WindowHandle) -> Result<bool>

Check whether the window is currently fullscreen.
Source§

fn start_drag(&self, window: WindowHandle) -> Result<()>

Begin an interactive window drag. Read more
Source§

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<()>

Set whether the window has OS decorations (title bar + borders).
Source§

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<()>

Run the main event loop. This blocks until the application exits.
Source§

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>

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>

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§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more