pub struct DisplayOwnership { /* private fields */ }Expand description
A handler that turns the input pipeline off or on based on whether the Scenic owns the display.
This allows us to turn off keyboard processing when the user switches away from the product (e.g. terminal) into virtual console.
See the README.md file in this crate for details.
§Safety and Concurrency
This struct uses RefCell to manage internal state. While DisplayOwnership
logic is split between multiple tasks (handle_ownership_change and
handle_unhandled_input_event), safety is maintained because:
- The pipeline runs on a single-threaded
LocalExecutor. - Borrows of
RefCells (likeownershipandkey_state) are never held acrossawaitpoints.
If asynchronous calls are added to critical sections in the future,
ensure that all borrows are dropped before the await.
Implementations§
Source§impl DisplayOwnership
impl DisplayOwnership
Sourcepub fn new(
display_ownership_event: impl AsHandleRef + 'static,
input_handlers_node: &Node,
) -> Rc<Self>
pub fn new( display_ownership_event: impl AsHandleRef + 'static, input_handlers_node: &Node, ) -> Rc<Self>
Creates a new handler that watches display_ownership_event for events.
The display_ownership_event is assumed to be an [Event] obtained from
fuchsia.ui.composition.internal.DisplayOwnership/GetEvent. There
isn’t really a way for this code to know here whether this is true or
not, so implementor beware.
Sourcepub async fn handle_ownership_change(
self: &Rc<Self>,
output: UnboundedSender<InputEvent>,
) -> Result<()>
pub async fn handle_ownership_change( self: &Rc<Self>, output: UnboundedSender<InputEvent>, ) -> Result<()>
Watches for display ownership changes and sends cancel/sync events.
NOTE: RefCell safety relies on the single-threaded nature of the executor.
No borrows of ownership or key_state must be held across the await
below to avoid panics if handle_unhandled_input_event runs while this
task is suspended.
Trait Implementations§
Source§impl UnhandledInputHandler for DisplayOwnership
impl UnhandledInputHandler for DisplayOwnership
Source§fn handle_unhandled_input_event<'async_trait>(
self: Rc<Self>,
unhandled_input_event: UnhandledInputEvent,
) -> Pin<Box<dyn Future<Output = Vec<InputEvent>> + 'async_trait>>where
Self: 'async_trait,
fn handle_unhandled_input_event<'async_trait>(
self: Rc<Self>,
unhandled_input_event: UnhandledInputEvent,
) -> Pin<Box<dyn Future<Output = Vec<InputEvent>> + 'async_trait>>where
Self: 'async_trait,
fn set_handler_healthy(self: Rc<Self>)
fn set_handler_unhealthy(self: Rc<Self>, msg: &str)
fn get_name(&self) -> &'static str
Source§fn interest(&self) -> Vec<InputEventType>
fn interest(&self) -> Vec<InputEventType>
Auto Trait Implementations§
impl !Freeze for DisplayOwnership
impl !RefUnwindSafe for DisplayOwnership
impl !Send for DisplayOwnership
impl !Sync for DisplayOwnership
impl Unpin for DisplayOwnership
impl !UnwindSafe for DisplayOwnership
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
Source§impl<T, D> Encode<Ambiguous1, D> for Twhere
D: ResourceDialect,
impl<T, D> Encode<Ambiguous1, D> for Twhere
D: ResourceDialect,
Source§impl<T, D> Encode<Ambiguous2, D> for Twhere
D: ResourceDialect,
impl<T, D> Encode<Ambiguous2, D> for Twhere
D: ResourceDialect,
Source§impl<T> InputHandler for Twhere
T: UnhandledInputHandler,
impl<T> InputHandler for Twhere
T: UnhandledInputHandler,
Source§fn handle_input_event<'async_trait>(
self: Rc<T>,
input_event: InputEvent,
) -> Pin<Box<dyn Future<Output = Vec<InputEvent>> + 'async_trait>>where
T: 'async_trait,
fn handle_input_event<'async_trait>(
self: Rc<T>,
input_event: InputEvent,
) -> Pin<Box<dyn Future<Output = Vec<InputEvent>> + 'async_trait>>where
T: 'async_trait,
fn set_handler_healthy(self: Rc<T>)
fn set_handler_unhealthy(self: Rc<T>, msg: &str)
Source§fn interest(&self) -> Vec<InputEventType>
fn interest(&self) -> Vec<InputEventType>
§impl<T> InstanceFromServiceTransport<T> for T
impl<T> InstanceFromServiceTransport<T> for T
§fn from_service_transport(handle: T) -> T
fn from_service_transport(handle: T) -> T
T to [Self]Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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