pub struct Surface<S: Shell> { /* private fields */ }
Expand description

A surface.

Implementations§

source§

impl<S: Shell> Surface<S>

source

pub fn parent(&self) -> Option<Rc<Self>>

Get the parent surface of this surface has a subsurface role.

source

pub fn root(self: &Rc<Self>) -> Rc<Self>

Follow the parent link of this surface until the root is reached.

source

pub fn commit( &self, shell: &mut S, scratch_buffer: &mut Vec<S::Token> ) -> Result<(), &'static str>

Commit the pending state to the current state.

Arguments
  • shell - The shell to use to get the current state.
  • scratch_buffer - A scratch buffer to use for temporary storage. we take this argument so we don’t have to allocate a new buffer every time.

Returns if the commit is successful.

TODO: FIXME: this implementation of commit is inaccurate. Per wayland spec, the pending state is not a shadow state, where changes are applied to. Instead it’s a collection of pending changes, that are applied to the current state when commited. The difference is subtle. For example, if buffer transform changes between two damage_buffer requests, both requests should use the new transform; instead of the first using the old transform and the second using the new transform.

source

pub fn object_id(&self) -> u32

Return the object ID of this surface inside the object store of the client owning this surface.

source

pub fn set_current(&self, key: S::Token)

Set the current surface state

source

pub fn set_pending(&self, key: S::Token)

Set the pending surface state.

TODO: this is wrong

source

pub fn pending_key(&self) -> S::Token

Get the pending surface state token.

TODO: this is wrong

source

pub fn current_key(&self) -> S::Token

Get the current surface state token.

source

pub fn pending_mut<'a>(&self, shell: &'a mut S) -> &'a mut SurfaceState<S>

Get a unique reference to the pending surface state.

source

pub fn pending<'a>(&self, shell: &'a S) -> &'a SurfaceState<S>

Get a reference to the pending surface state.

source

pub fn current<'a>(&self, shell: &'a S) -> &'a SurfaceState<S>

Get a reference to the current surface state.

source

pub fn current_mut<'a>(&self, shell: &'a mut S) -> &'a mut SurfaceState<S>

Get a unique reference to the current surface state.

source

pub fn has_role(&self) -> bool

Returns true if the surface has a role attached. This will keep returning true even after the role has been deactivated.

source

pub fn role_is_active(&self) -> bool

Returns true if the surface has a role, and that role is active.

source

pub fn role<T: Role<S>>(&self) -> Option<Ref<'_, T>>

Borrow the role object of the surface.

source

pub fn role_mut<T: Role<S>>(&self) -> Option<RefMut<'_, T>>

Mutably borrow the role object of the surface.

source

pub fn destroy(&self, shell: &mut S, scratch_buffer: &mut Vec<S::Token>)

Destroy a surface and its associated resources.

This function will deactivate the role associated with the surface, if any. (Although, as specified by wl_surface interface v6, the role must be destroyed before the surface. We keep the deactivation here too to support older clients). And also destruct any associated surface states that become orphaned by destroying the surface.

Arguments
  • shell: the shell that owns this surface.
  • scratch_buffer: a scratch buffer used to store the tokens of the surface states for going through them.
source

pub fn deactivate_role(&self, shell: &mut S)

Deactivate the role assigned to this surface.

source

pub fn clear_damage(&self)

Clear buffer damage, NOT IMPLEMENTED YET

source

pub fn set_role<T: Role<S>>(&self, role: T, shell: &mut S)

Assign a role to this surface.

source

pub fn outputs(&self) -> Ref<'_, HashSet<WeakPtr<Output>>>

Get the set of outputs this surface is currently on.

source

pub fn outputs_mut(&self) -> RefMut<'_, HashSet<WeakPtr<Output>>>

Mutably borrow the set of outputs this surface is currently on.

source

pub fn notify_output_changed(&self)

Send an event notifying that the set of outputs this surface is on has changed.

source

pub fn notify_layout_changed(&self, layout: Layout)

Send an event notifying that the layout of this surface has changed.

source

pub fn pointer_event(&self, event: PointerActivity)

Send a pointer event

source

pub fn keyboard_event(&self, event: KeyboardActivity)

Send a keyboard event

Trait Implementations§

source§

impl<S: Shell> Debug for Surface<S>

source§

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

Formats the value using the given formatter. Read more
source§

impl<S: Shell> Drop for Surface<S>

source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

§

impl<S> !RefUnwindSafe for Surface<S>

§

impl<S> !Send for Surface<S>

§

impl<S> !Sync for Surface<S>

§

impl<S> Unpin for Surface<S>where <S as Shell>::Token: Unpin,

§

impl<S> !UnwindSafe for Surface<S>

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Az for T

source§

fn az<Dst>(self) -> Dstwhere T: Cast<Dst>,

Casts the value.
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<Src, Dst> CastFrom<Src> for Dstwhere Src: Cast<Dst>,

source§

fn cast_from(src: Src) -> Dst

Casts the value.
source§

impl<T> CheckedAs for T

source§

fn checked_as<Dst>(self) -> Option<Dst>where T: CheckedCast<Dst>,

Casts the value.
source§

impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere Src: CheckedCast<Dst>,

source§

fn checked_cast_from(src: Src) -> Option<Dst>

Casts the value.
source§

impl<T> From<T> for T

const: unstable · 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 Twhere U: From<T>,

const: unstable · 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<Src, Dst> LosslessTryInto<Dst> for Srcwhere Dst: LosslessTryFrom<Src>,

source§

fn lossless_try_into(self) -> Option<Dst>

Performs the conversion.
source§

impl<Src, Dst> LossyInto<Dst> for Srcwhere Dst: LossyFrom<Src>,

source§

fn lossy_into(self) -> Dst

Performs the conversion.
source§

impl<T> OverflowingAs for T

source§

fn overflowing_as<Dst>(self) -> (Dst, bool)where T: OverflowingCast<Dst>,

Casts the value.
source§

impl<Src, Dst> OverflowingCastFrom<Src> for Dstwhere Src: OverflowingCast<Dst>,

source§

fn overflowing_cast_from(src: Src) -> (Dst, bool)

Casts the value.
source§

impl<T> Same<T> for T

§

type Output = T

Should always be Self
source§

impl<T> SaturatingAs for T

source§

fn saturating_as<Dst>(self) -> Dstwhere T: SaturatingCast<Dst>,

Casts the value.
source§

impl<Src, Dst> SaturatingCastFrom<Src> for Dstwhere Src: SaturatingCast<Dst>,

source§

fn saturating_cast_from(src: Src) -> Dst

Casts the value.
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
const: unstable · source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T> UnwrappedAs for T

source§

fn unwrapped_as<Dst>(self) -> Dstwhere T: UnwrappedCast<Dst>,

Casts the value.
source§

impl<Src, Dst> UnwrappedCastFrom<Src> for Dstwhere Src: UnwrappedCast<Dst>,

source§

fn unwrapped_cast_from(src: Src) -> Dst

Casts the value.
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
source§

impl<T> WrappingAs for T

source§

fn wrapping_as<Dst>(self) -> Dstwhere T: WrappingCast<Dst>,

Casts the value.
source§

impl<Src, Dst> WrappingCastFrom<Src> for Dstwhere Src: WrappingCast<Dst>,

source§

fn wrapping_cast_from(src: Src) -> Dst

Casts the value.