Skip to main content

SurfacePlacement

Struct SurfacePlacement 

Source
pub struct SurfacePlacement {
    pub role: SurfaceRole,
    pub anchor: SurfaceAnchor,
    pub align: SurfaceAlign,
    pub size: SurfaceSize,
    pub margin: (i32, i32, i32, i32),
    pub scrim: bool,
    pub dismiss_on_outside: bool,
    pub timeout: Option<Duration>,
    pub input_transparent: bool,
    pub keyboard: KeyboardMode,
    pub output: Option<String>,
}
Expand description

A backend-agnostic description of a secondary surface: where it sits, how big it is, and how it behaves (scrim, outside-dismiss, auto-timeout). The intent lives here; a backend derives its own surface config from it. Reusable by a windowed app (as an in-window portal) and by a shell (as a real layer-shell surface) alike.

Fields§

§role: SurfaceRole§anchor: SurfaceAnchor§align: SurfaceAlign§size: SurfaceSize§margin: (i32, i32, i32, i32)

Gap from the screen edges, as (top, right, bottom, left). A full-screen scrim scaffold applies the whole tuple as padding (so the panel floats off every edge, not just the anchored one); a directly-anchored surface applies it as the compositor margin.

§scrim: bool

Dim (and, with dismiss_on_outside, capture) the area behind the panel.

§dismiss_on_outside: bool

A press outside the panel dismisses the surface.

§timeout: Option<Duration>

Auto-dismiss after this long; None keeps it until closed explicitly.

§input_transparent: bool

The surface passes pointer input through to whatever is beneath it (a click-through OSD).

§keyboard: KeyboardMode

How much of the keyboard the surface needs; a backend maps this to its own focus model (e.g. layer-shell keyboard interactivity). Defaults to KeyboardMode::None, so a panel is display-only and never steals the keyboard.

§output: Option<String>

The monitor to place the surface on by name; None = the active/default output.

Implementations§

Source§

impl SurfacePlacement

Source

pub fn new(role: SurfaceRole, anchor: SurfaceAnchor) -> Self

Source

pub fn overlay() -> Self

A modal that owns the screen: centred, scrimmed, dismissed by a press outside, and holding the keyboard from the moment it maps so the first keystroke after the keybind is already typed into it.

Source

pub fn drawer(anchor: SurfaceAnchor) -> Self

Source

pub fn osd() -> Self

Source

pub fn float() -> Self

Source

pub fn align(self, align: SurfaceAlign) -> Self

Source

pub fn size(self, size: SurfaceSize) -> Self

Source

pub fn margin(self, margin: (i32, i32, i32, i32)) -> Self

Source

pub fn inset(self, px: i32) -> Self

Source

pub fn scrim(self, scrim: bool) -> Self

Source

pub fn dismiss_on_outside(self, dismiss: bool) -> Self

Source

pub fn timeout(self, timeout: Duration) -> Self

Source

pub fn input_transparent(self, transparent: bool) -> Self

Source

pub fn keyboard(self, wants_keyboard: bool) -> Self

Opt the surface into focus-on-interaction, for panels that host editable text (a search box, a note title). Sugar for keyboard_mode with OnDemand/None.

Source

pub fn keyboard_mode(self, mode: KeyboardMode) -> Self

Sets exactly how much of the keyboard the surface takes.

Source

pub fn wants_keyboard(&self) -> bool

Whether the surface takes keyboard focus at all.

Source

pub fn output(self, output: Option<String>) -> Self

Source

pub fn needs_scaffold(&self) -> bool

Whether the surface needs a full-viewport scaffold (to draw a scrim or catch outside presses) rather than being anchored directly at its content size.

Trait Implementations§

Source§

impl Clone for SurfacePlacement

Source§

fn clone(&self) -> SurfacePlacement

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for SurfacePlacement

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

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<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.
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