ltk

Struct OverlaySpec

Source
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: OverlayId

Stable identifier, used to diff overlays between frames.

§layer: Layer

Wayland layer for this overlay. Typically Layer::Overlay or Layer::Top.

§anchor: Anchor

Screen 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: i32

Exclusive 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: bool

When 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:

  1. The compositor sends xdg_popup.popup_done (xdg-popup mode) — typically when the user clicks outside the popup with the grab fully active.
  2. 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.
  3. 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> 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.
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