Trait DecorationsFrame

pub trait DecorationsFrame: Sized {
Show 16 methods // Required methods fn on_click( &mut self, timestamp: Duration, click: FrameClick, pressed: bool, ) -> Option<FrameAction>; fn click_point_moved( &mut self, timestamp: Duration, surface_id: &ObjectId, x: f64, y: f64, ) -> Option<CursorIcon>; fn click_point_left(&mut self); fn update_state(&mut self, state: WindowState); fn update_wm_capabilities( &mut self, wm_capabilities: WindowManagerCapabilities, ); fn resize(&mut self, width: NonZero<u32>, height: NonZero<u32>); fn set_scaling_factor(&mut self, scale_factor: f64); fn location(&self) -> (i32, i32); fn subtract_borders( &self, width: NonZero<u32>, height: NonZero<u32>, ) -> (Option<NonZero<u32>>, Option<NonZero<u32>>); fn add_borders(&self, width: u32, height: u32) -> (u32, u32); fn is_dirty(&self) -> bool; fn set_hidden(&mut self, hidden: bool); fn is_hidden(&self) -> bool; fn set_resizable(&mut self, resizable: bool); fn draw(&mut self) -> bool; fn set_title(&mut self, title: impl Into<String>);
}
Available on crate feature wayland and Linux only.
Expand description

The interface for the client side decorations.

Required Methods§

fn on_click( &mut self, timestamp: Duration, click: FrameClick, pressed: bool, ) -> Option<FrameAction>

Emulate click on the decorations.

The click is a variant of click to use, see FrameClick for more information. timestamp is the time when event happened.

The return value is a FrameAction you should apply, this action could be ignored.

The location of the click is the one passed to Self::click_point_moved.

fn click_point_moved( &mut self, timestamp: Duration, surface_id: &ObjectId, x: f64, y: f64, ) -> Option<CursorIcon>

Emulate pointer moved event on the decorations frame.

The x and y are location in the surface local coordinates relative to the surface. timestamp is the time when event happened.

The return value is the new cursor icon you should apply to provide better visual feedback for the user. However, you might want to ignore it, if you’re using touch events to drive the movements.

fn click_point_left(&mut self)

All clicks left the decorations.

This function should be called when input leaves the decorations.

fn update_state(&mut self, state: WindowState)

Update the state of the frame.

The state is usually obtained from the xdg_toplevel::configure event.

fn update_wm_capabilities(&mut self, wm_capabilities: WindowManagerCapabilities)

Update the window manager capabilites.

The capabilites are usually obtained from the xdg_toplevel::wm_capabilities event.

fn resize(&mut self, width: NonZero<u32>, height: NonZero<u32>)

Resize the window to the new size.

The size must be without the borders, as in [Self::subtract_borders] were used on it.

Note: The Self::update_state and Self::update_wm_capabilities must be applied before calling this function.

§Panics

Panics when resizing the hidden frame.

fn set_scaling_factor(&mut self, scale_factor: f64)

Set the scaling of the decorations frame.

If the decorations frame is not supporting fractional scaling it’ll ceil the scaling factor.

fn location(&self) -> (i32, i32)

Return the coordinates of the top-left corner of the borders relative to the content.

Values must thus be non-positive.

fn subtract_borders( &self, width: NonZero<u32>, height: NonZero<u32>, ) -> (Option<NonZero<u32>>, Option<NonZero<u32>>)

Subtract the borders from the given width and height.

None will be returned for the particular dimension when the given value for it was too small.

fn add_borders(&self, width: u32, height: u32) -> (u32, u32)

Add the borders to the given width and height.

Passing zero for both width and height could be used to get the size of the decorations frame.

fn is_dirty(&self) -> bool

Whether the given frame is dirty and should be redrawn.

fn set_hidden(&mut self, hidden: bool)

Set the frame as hidden.

The frame must be visible by default.

fn is_hidden(&self) -> bool

Get the frame hidden state.

Get the state of the last DecorationsFrame::set_hidden.

fn set_resizable(&mut self, resizable: bool)

Mark the frame as resizable.

By default the frame is resizable.

fn draw(&mut self) -> bool

Draw the decorations frame.

Return true when the main surface must be redrawn as well. This usually happens when sync is being set on the internal subsurfaces and they’ve changed their size.

The user of the frame must commit the base surface afterwards.

fn set_title(&mut self, title: impl Into<String>)

Set the frames title.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

§

impl<State> DecorationsFrame for AdwaitaFrame<State>

§

fn update_state(&mut self, state: WindowState)

§

fn update_wm_capabilities(&mut self, wm_capabilities: WindowManagerCapabilities)

§

fn set_hidden(&mut self, hidden: bool)

§

fn set_resizable(&mut self, resizable: bool)

§

fn resize(&mut self, width: NonZero<u32>, height: NonZero<u32>)

§

fn draw(&mut self) -> bool

§

fn subtract_borders( &self, width: NonZero<u32>, height: NonZero<u32>, ) -> (Option<NonZero<u32>>, Option<NonZero<u32>>)

§

fn add_borders(&self, width: u32, height: u32) -> (u32, u32)

§

fn location(&self) -> (i32, i32)

§

fn set_title(&mut self, title: impl Into<String>)

§

fn on_click( &mut self, timestamp: Duration, click: FrameClick, pressed: bool, ) -> Option<FrameAction>

§

fn set_scaling_factor(&mut self, scale_factor: f64)

§

fn click_point_moved( &mut self, _timestamp: Duration, surface: &ObjectId, x: f64, y: f64, ) -> Option<CursorIcon>

§

fn click_point_left(&mut self)

§

fn is_dirty(&self) -> bool

§

fn is_hidden(&self) -> bool

Implementors§