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: boolDim (and, with dismiss_on_outside, capture) the area behind the panel.
dismiss_on_outside: boolA press outside the panel dismisses the surface.
timeout: Option<Duration>Auto-dismiss after this long; None keeps it until closed explicitly.
input_transparent: boolThe surface passes pointer input through to whatever is beneath it (a click-through OSD).
keyboard: KeyboardModeHow 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
impl SurfacePlacement
pub fn new(role: SurfaceRole, anchor: SurfaceAnchor) -> Self
Sourcepub fn overlay() -> Self
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.
pub fn drawer(anchor: SurfaceAnchor) -> Self
pub fn osd() -> Self
pub fn float() -> Self
pub fn align(self, align: SurfaceAlign) -> Self
pub fn size(self, size: SurfaceSize) -> Self
pub fn margin(self, margin: (i32, i32, i32, i32)) -> Self
pub fn inset(self, px: i32) -> Self
pub fn scrim(self, scrim: bool) -> Self
pub fn dismiss_on_outside(self, dismiss: bool) -> Self
pub fn timeout(self, timeout: Duration) -> Self
pub fn input_transparent(self, transparent: bool) -> Self
Sourcepub fn keyboard(self, wants_keyboard: bool) -> Self
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.
Sourcepub fn keyboard_mode(self, mode: KeyboardMode) -> Self
pub fn keyboard_mode(self, mode: KeyboardMode) -> Self
Sets exactly how much of the keyboard the surface takes.
Sourcepub fn wants_keyboard(&self) -> bool
pub fn wants_keyboard(&self) -> bool
Whether the surface takes keyboard focus at all.
pub fn output(self, output: Option<String>) -> Self
Sourcepub fn needs_scaffold(&self) -> bool
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
impl Clone for SurfacePlacement
Source§fn clone(&self) -> SurfacePlacement
fn clone(&self) -> SurfacePlacement
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more