Skip to main content

PlatformWindow

Struct PlatformWindow 

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

A platform window wrapping a winit window, wgpu surface, renderer, and AccessKit adapter for screen reader support.

Implementations§

Source§

impl PlatformWindow

Source

pub async fn new_with_a11y(window: Window, event_loop: &ActiveEventLoop) -> Self

Create a new platform window from a winit window. The event_loop parameter is needed for the AccessKit adapter.

Source

pub async fn new(window: Window) -> Self

Create a platform window without AccessKit (for contexts without ActiveEventLoop).

Source

pub fn window(&self) -> &Window

Source

pub fn window_arc(&self) -> Arc<Window> ⓘ

Get a clonable Arc reference to the underlying winit window. Used by teksilo_platform::create_title_bar_host and other components that need shared ownership of the window.

Source

pub fn renderer(&self) -> &Renderer

Source

pub fn renderer_mut(&mut self) -> &mut Renderer

Source

pub fn scale_factor(&self) -> f64

Source

pub fn set_scale_factor(&mut self, factor: f64)

Source

pub fn resize(&mut self, new_size: PhysicalSize<u32>)

Resize the surface.

Source

pub fn surface_size(&self) -> (u32, u32)

Get current surface dimensions.

Source

pub fn reconfigure_surface(&mut self)

Reconfigure the surface with the current config. Use after a Lost or Outdated surface error.

Source

pub fn render_frame( &mut self, frame: &RenderFrame, clear_color: [f32; 4], ) -> FrameOutcome

Render a frame to the surface.

Source

pub fn capture_offscreen( &mut self, frame: &RenderFrame, clear_color: [f32; 4], crop: Option<Rect>, ) -> (Vec<u8>, u32, u32)

Render frame into an offscreen texture and read it back as tightly-packed RGBA8 bytes, returning (rgba, width, height).

Used by the debug-only automation bridge to capture a live window without going through the swapchain — the surface texture is configured RENDER_ATTACHMENT only (no COPY_SRC), so it can’t be read back directly. The offscreen texture uses the window’s own surface format so it matches the renderer’s pipelines; a BGRA readback is swizzled to RGBA here so the output is always RGBA. With crop = Some(rect) (physical pixels, clamped to the surface) only that sub-rectangle is returned. Returns an empty (vec, 0, 0) if the crop is fully outside the surface.

Note: a native WebView subview composites on top of the wgpu surface and is invisible to this readback (a transparent hole).

Source

pub fn request_redraw(&self)

Source

pub fn update_accessibility(&mut self, update: TreeUpdate)

Push an AccessKit TreeUpdate to the adapter (called after layout).

Source

pub fn update_accessibility_with( &mut self, build: impl FnOnce() -> Option<TreeUpdate>, previous: impl FnOnce() -> TreeUpdate, )

Push an update the adapter builds only when it is actually going to be delivered, and only when build says there is one worth sending.

The caller decides inside the closure, because that is where the decision belongs: update_if_active runs its closure only when an assistive technology is attached, and on Linux it runs it under the adapter’s own state lock. Deciding outside would build a tree for nobody on every frame, and would make the throttle count frames nothing was listening to.

build returning None means “nothing to deliver”; the previously delivered tree is re-sent, which the consumer treats as a no-op.

Source

pub fn accessibility_needs_full_tree(&self) -> bool

Whether an assistive technology has asked this window for its tree and has not yet been given a full one.

Set by the activation handler, which runs on whichever thread the platform’s accessibility layer calls it from, and cleared by the first delivery after it — so a reader that attaches mid-session gets a complete tree rather than a geometry patch onto a tree it has never seen.

Source

pub fn take_accessibility_needs_full_tree(&self) -> bool

Clear the flag above, reporting what it was.

Source

pub fn process_accessibility_event(&mut self, event: &WindowEvent)

Forward a winit WindowEvent to the AccessKit adapter.

Source

pub fn drain_accessibility_actions(&self) -> Vec<ActionRequest>

Drain any pending AccessKit action requests from the adapter.

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

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

Source§

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

Source§

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.
Source§

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.
Source§

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.
Source§

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.
Source§

impl<T> Downcast<T> for T

Source§

fn downcast(&self) -> &T

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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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

Source§

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

Source§

impl<T> WasmNotSend for T
where T: Send,

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