ltk_webkit

Struct WebView

Source
pub struct WebView { /* private fields */ }
Expand description

A WebKit-rendered view that can be embedded into an LTK widget tree via WebView::element.

Implementations§

Source§

impl WebView

Source

pub fn new(width: f32, height: f32, url: &str) -> Result<Self, String>

Create a new WebView, connect it to the user’s Wayland session, and start loading url. The view does not render until tick is pumped from the host application’s event loop.

Source

pub fn resize(&self, width: f32, height: f32)

Resize the embedded view. Updates both the reserved space the LTK [External] widget claims and the WPEView buffer dimensions, so click coordinates keep mapping 1:1 and WebKit re-renders to the new size.

Source

pub fn tick(&self)

Drive WPE’s GMainLoop forward by one non-blocking iteration. Call this from the host application’s per-frame poll (LTK’s App::poll_external is the obvious place).

Source

pub fn pointer_press(&self, x: f64, y: f64)

Forward a left-button press to the embedded view at WPEView pixel coordinates (x, y). Pair with Self::pointer_release for a click; intermediate Self::pointer_move calls between the two construct a drag (which WebKit interprets as text selection over selectable content).

Source

pub fn pointer_release(&self, x: f64, y: f64)

Forward a left-button release to the embedded view.

Source

pub fn click_at(&self, x: f64, y: f64)

Convenience: synthesise a complete press + release click at (x, y). Useful for tests / scripted interactions; real user clicks should go through Self::pointer_press / Self::pointer_release so drags work.

Source

pub fn touch_down(&self, id: u32, x: f64, y: f64)

Forward a touchscreen finger-down to the embedded view. The touch stream (touch_down / touch_move / touch_up per finger id) feeds WebKit’s own gesture recognition: tap becomes click, drag becomes kinetic scroll, two fingers pinch-zoom — none of which the mouse-event path can express.

Source

pub fn touch_move(&self, id: u32, x: f64, y: f64)

Source

pub fn touch_up(&self, id: u32, x: f64, y: f64)

Source

pub fn scroll(&self, x: f64, y: f64, dx: f64, dy: f64)

Forward a wheel / touchpad scroll event to the embedded view. x, y are in WPEView pixel coordinates (same as the host pointer), dx/dy are scroll deltas in pixels (positive = down/right, matching WPE convention).

Source

pub fn pointer_move(&self, x: f64, y: f64)

Forward a pointer-move event to the embedded view at WPEView pixel coordinates (x, y). WebKit needs this to update hover state, fire mouseenter / mouseleave, and decide which cursor it wants — without it the cursor query through Self::cursor_shape stays at Default.

Source

pub fn send_key( &self, keysym: u32, keycode: u32, pressed: bool, ctrl: bool, shift: bool, )

Forward a keyboard event to the embedded view. keysym is the xkbcommon keysym (the symbol the user effectively pressed, after xkb layout translation); keycode is the raw hardware scancode the compositor delivered. pressed selects DOWN vs UP; ctrl and shift populate the WPEModifiers bitfield.

Source

pub fn take_redraw_request(&self) -> bool

Returns true once for every new buffer WebKit has produced since the previous call. The host’s invalidate_after should return InvalidationScope::All whenever this is true so LTK redraws and the new frame becomes visible — keeping the surface from getting stuck on a stale (sometimes black) frame when the compositor’s frame-callback chain pauses during a resize. Idle ticks return false, so static pages cost zero redraws.

Source

pub fn cursor_shape(&self) -> CursorShape

The cursor shape WebKit currently wants for the embedded view. Mirrors the most recent mouse-target-changed signal payload. The host application surfaces this through [ltk::App::cursor_override].

Source

pub fn element<Msg: Clone + 'static>(&self) -> Element<Msg>

Build an LTK [Element] that composites this WebView’s pixels into the parent widget tree. Uses the dimensions most recently passed to Self::resize (or the constructor) as the preferred size; the actual laid-out rect is captured by the draw closure on every frame and used to drive auto-resize + input coordinate translation.

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
§

impl<T> Downcast<T> for T

§

fn downcast(&self) -> &T

§

impl<T> Downcast for T
where T: Any,

§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Sync + Send>

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

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

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

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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.
§

impl<T> Upcast<T> for T

§

fn upcast(&self) -> Option<&T>

§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

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
§

fn with_current_subscriber(self) -> WithDispatch<Self>

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

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,