Skip to main content

ViewEmbedder

Trait ViewEmbedder 

Source
pub trait ViewEmbedder {
    // Required methods
    fn add_view(
        &self,
        layer: &Arc<dyn CompositionLayer>,
        metrics: ViewMetrics,
        host: Rc<dyn ViewHost>,
        initial_data: Option<String>,
    ) -> Result<EmbeddedView, ViewError>;
    fn send_pointer_reports(&self, reports: Vec<PointerReport>);
    fn send_view_focus_event(&self, event: ViewFocusEvent);
}
Expand description

What the app uses to embed views of its own, as Flutter’s embedder does: adding one on a layer it makes and places, which answers the view’s handle (EmbeddedView), and handing any view input (Platform::view_embedder).

Required Methods§

Source

fn add_view( &self, layer: &Arc<dyn CompositionLayer>, metrics: ViewMetrics, host: Rc<dyn ViewHost>, initial_data: Option<String>, ) -> Result<EmbeddedView, ViewError>

Flutter’s AddView, for the app: asks for a view that draws into layer, which the app made with the platform’s compositor, opaque or not, and places itself, at metrics, asking what it asks of the system of host. Constraints in metrics that are not tight leave the view’s size to its content, within them, and host hears it with each frame of a new size (ViewHost::view_size_changed). The view arrives as a window’s does, through EmbedderClient::view_added, carrying the handle’s request id (View::request_id) and initial_data (View::initial_data), which says what it is for, as a window’s does (Platform::request_view); it is in sight until the app says otherwise (EmbeddedView::set_in_sight), its frames follow the screen its metrics name, and it is removed when the handle is dropped. Refused at once, with ViewError::Unsupported, where the host cannot draw a view into layer.

Source

fn send_pointer_reports(&self, reports: Vec<PointerReport>)

Flutter’s SendPointerEvent, for the app: what pointing devices did over any view, a window’s included, which the framework hears as it hears the host’s own reports (EmbedderClient::pointer_reports), through the one converter that numbers every pointer. Each device of a forwarded stream (its mouse, trackpad and pen, and each touch from landing to lifting) takes a device number no other stream uses, a random 64-bit one for now, since the converter keeps one state per device number, a forwarding app’s own host numbers its devices as this one does, 0, 1, 2 upward, and two streams with no order between them would mix their devices’ states in one (native-surfaces decision 36).

Source

fn send_view_focus_event(&self, event: ViewFocusEvent)

Flutter’s SendViewFocusEvent, for the app: a view’s focus change, which the framework hears as it hears the host’s own (EmbedderClient::view_focus_changed), so that the keys the host reports go where the framework’s focus is.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§