pub struct OverlaySpec<Message: Clone> {
pub id: OverlayId,
pub layer: Layer,
pub anchor: Anchor,
pub size: (u32, u32),
pub exclusive_zone: i32,
pub keyboard_exclusive: bool,
pub input_region: Option<Vec<Rect>>,
pub view: Element<Message>,
pub on_dismiss: Option<Message>,
pub anchor_widget_id: Option<WidgetId>,
}Expand description
Description of an additional layer-shell surface rendered on top of the main application surface.
Apps return a list of these from App::overlays each frame. The runtime
creates one Wayland layer-shell surface per active overlay, renders its
view to its own canvas, and dispatches input to it
independently of the main surface. Overlays share the same message type as
the main app — messages emitted by widgets inside an overlay are delivered
to App::update exactly like messages from the main view.
Overlays are useful for building shells whose main surface sits behind
regular app windows (e.g. a homescreen on Layer::Background) while
still exposing on-demand panels above everything (launcher, quick
settings, power menu…).
Fields§
§id: OverlayIdStable identifier, used to diff overlays between frames.
layer: LayerWayland layer for this overlay. Typically Layer::Overlay or
Layer::Top.
anchor: AnchorScreen edges to anchor to.
size: (u32, u32)Desired size ( width, height ) in logical pixels. 0 in either
component means “fill available space in that dimension”.
exclusive_zone: i32Exclusive zone in pixels reserved from the anchored edge.
-1 requests focus without reserving space, 0 is the default for
transient overlays that should not push other surfaces around.
keyboard_exclusive: boolWhen true, the compositor sends keyboard events to this overlay
without requiring a click first.
input_region: Option<Vec<Rect>>Interactive input region as a list of rects (logical pixels). Only
these areas receive pointer/touch input; the rest passes through.
None means the full surface receives input.
view: Element<Message>Widget tree for this overlay.
on_dismiss: Option<Message>Message sent when the overlay should be dismissed. The runtime fires it in three situations:
- The compositor sends
xdg_popup.popup_done(xdg-popup mode) — typically when the user clicks outside the popup with the grab fully active. - The user presses pointer / touch on the main surface while
the overlay is still mapped, and the press does not fall on
the trigger rect identified by
Self::anchor_widget_id. This covers compositors (notably Mutter) that route the button to the parent surface instead of breaking the popup grab when the cursor was already over the parent. - The user presses Escape while at least one xdg-popup overlay is open.
The application is expected to flip its is_open flag (or
equivalent) to false in update() so the next frame stops
returning the spec from App::overlays. The runtime is
idempotent if the message arrives more than once for the same
open / close cycle.
anchor_widget_id: Option<WidgetId>When set, the overlay is rendered as a Wayland xdg-popup
anchored to the rect of the widget tagged with this
crate::types::WidgetId in the previous frame’s layout — the
standard mechanism for combo / context-menu / tooltip popups in
xdg-shell applications. The compositor positions the popup
adjacent to the anchor and is allowed to flip it (drop-up
instead of drop-down) when there is not enough room.
When this field is None, the overlay is rendered as a
wlr-layer-shell surface — the path used by shells,
panels, lock screens and overlays that need full-surface
coverage. In that mode layer / anchor / exclusive_zone /
keyboard_exclusive carry the placement; for the popup mode
they are ignored.
Auto Trait Implementations§
impl<Message> Freeze for OverlaySpec<Message>where
Message: Freeze,
impl<Message> !RefUnwindSafe for OverlaySpec<Message>
impl<Message> !Send for OverlaySpec<Message>
impl<Message> !Sync for OverlaySpec<Message>
impl<Message> Unpin for OverlaySpec<Message>where
Message: Unpin,
impl<Message> !UnwindSafe for OverlaySpec<Message>
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<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§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.§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.§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.§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.§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<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