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
impl PlatformWindow
Sourcepub async fn new_with_a11y(window: Window, event_loop: &ActiveEventLoop) -> Self
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.
Sourcepub async fn new(window: Window) -> Self
pub async fn new(window: Window) -> Self
Create a platform window without AccessKit (for contexts without ActiveEventLoop).
pub fn window(&self) -> &Window
Sourcepub fn window_arc(&self) -> Arc<Window> ⓘ
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.
pub fn renderer(&self) -> &Renderer
pub fn renderer_mut(&mut self) -> &mut Renderer
pub fn scale_factor(&self) -> f64
pub fn set_scale_factor(&mut self, factor: f64)
Sourcepub fn resize(&mut self, new_size: PhysicalSize<u32>)
pub fn resize(&mut self, new_size: PhysicalSize<u32>)
Resize the surface.
Sourcepub fn surface_size(&self) -> (u32, u32)
pub fn surface_size(&self) -> (u32, u32)
Get current surface dimensions.
Sourcepub fn reconfigure_surface(&mut self)
pub fn reconfigure_surface(&mut self)
Reconfigure the surface with the current config. Use after a Lost or Outdated surface error.
Sourcepub fn render_frame(
&mut self,
frame: &RenderFrame,
clear_color: [f32; 4],
) -> FrameOutcome
pub fn render_frame( &mut self, frame: &RenderFrame, clear_color: [f32; 4], ) -> FrameOutcome
Render a frame to the surface.
Sourcepub fn capture_offscreen(
&mut self,
frame: &RenderFrame,
clear_color: [f32; 4],
crop: Option<Rect>,
) -> (Vec<u8>, u32, u32)
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).
pub fn request_redraw(&self)
Sourcepub fn update_accessibility(&mut self, update: TreeUpdate)
pub fn update_accessibility(&mut self, update: TreeUpdate)
Push an AccessKit TreeUpdate to the adapter (called after layout).
Sourcepub fn update_accessibility_with(
&mut self,
build: impl FnOnce() -> Option<TreeUpdate>,
previous: impl FnOnce() -> TreeUpdate,
)
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.
Sourcepub fn accessibility_needs_full_tree(&self) -> bool
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.
Sourcepub fn take_accessibility_needs_full_tree(&self) -> bool
pub fn take_accessibility_needs_full_tree(&self) -> bool
Clear the flag above, reporting what it was.
Sourcepub fn process_accessibility_event(&mut self, event: &WindowEvent)
pub fn process_accessibility_event(&mut self, event: &WindowEvent)
Forward a winit WindowEvent to the AccessKit adapter.
Sourcepub fn drain_accessibility_actions(&self) -> Vec<ActionRequest>
pub fn drain_accessibility_actions(&self) -> Vec<ActionRequest>
Drain any pending AccessKit action requests from the adapter.
Auto Trait Implementations§
impl !Freeze for PlatformWindow
impl !RefUnwindSafe for PlatformWindow
impl !Sync for PlatformWindow
impl !UnwindSafe for PlatformWindow
impl Send for PlatformWindow
impl Unpin for PlatformWindow
impl UnsafeUnpin for PlatformWindow
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
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>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
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)
fn as_any(&self) -> &(dyn Any + 'static)
&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)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.