/// Updates the current surface state by applying a single `SurfaceCommand`.
Updates the current surface state by applying a single `SurfaceCommand`.
Updates the current surface state by applying a single ` SurfaceCommand ` .
fn apply(&mut self, command: SurfaceCommand) -> Result<(), Error> {
        match command {
            SurfaceCommand::AttachBuffer(attachment) => {
                self.content = Some(attachment.clone());
            }
            SurfaceCommand::ClearBuffer => {}
            SurfaceCommand::Frame(callback) => {
                self.frame_callbacks.push(callback);
            }
            SurfaceCommand::SetOpaqueRegion(region) => {
                self.opaque_region = region;
            }
            SurfaceCommand::SetViewportCropParams(params) => {
                self.crop_params = Some(params);
            }
            SurfaceCommand::ClearViewportCropParams => {
                self.crop_params = None;
            }
            SurfaceCommand::SetViewportScaleParams(params) => {
                self.scale_params = Some(params);
            }
            SurfaceCommand::ClearViewportScaleParams => {
                self.scale_params = None;
            }
            SurfaceCommand::SetWindowGeometry(geometry) => {
                self.window_geometry = Some(geometry);
            }
            SurfaceCommand::SetPosition(x, y) => {
                self.position = (x, y);
            }
            SurfaceCommand::AddSubsurface(surface_ref, subsurface_ref) => {
                self.subsurfaces.push((surface_ref, Some(subsurface_ref)));
            }
            SurfaceCommand::PlaceSubsurface(params) => {
                let sibling_index = if let Some(index) =
                    self.subsurfaces.iter().position(|x| x.0 == params.sibling)
                {
                    index
                } else {
                    return Err(format_err!("Invalid sibling id {}", params.sibling.id()));
                };
                let sibling_entry = self.subsurfaces.remove(sibling_index);
                let anchor_index = if let Some(index) =
                    self.subsurfaces.iter().position(|x| x.1 == Some(params.subsurface))
                {
                    index
                } else {
                    return Err(format_err!("Invalid subsurface id {}", params.subsurface.id()));
                };
                let new_index = match params.relation {
                    SurfaceRelation::Below => anchor_index,
                    SurfaceRelation::Above => anchor_index + 1,
                };
                self.subsurfaces.insert(new_index, sibling_entry);
            }
        };
        Ok(())
    }
fn apply ( & mut self , command : SurfaceCommand ) -> Result < ( ) , Error > { match command { SurfaceCommand :: AttachBuffer ( attachment ) => { self . content = Some ( attachment . clone ( ) ) ; } SurfaceCommand :: ClearBuffer => { } SurfaceCommand :: Frame ( callback ) => { self . frame_callbacks . push ( callback ) ; } SurfaceCommand :: SetOpaqueRegion ( region ) => { self . opaque_region = region ; } SurfaceCommand :: SetViewportCropParams ( params ) => { self . crop_params = Some ( params ) ; } SurfaceCommand :: ClearViewportCropParams => { self . crop_params = None ; } SurfaceCommand :: SetViewportScaleParams ( params ) => { self . scale_params = Some ( params ) ; } SurfaceCommand :: ClearViewportScaleParams => { self . scale_params = None ; } SurfaceCommand :: SetWindowGeometry ( geometry ) => { self . window_geometry = Some ( geometry ) ; } SurfaceCommand :: SetPosition ( x , y ) => { self . position = ( x , y ) ; } SurfaceCommand :: AddSubsurface ( surface_ref , subsurface_ref ) => { self . subsurfaces . push ( ( surface_ref , Some ( subsurface_ref ) ) ) ; } SurfaceCommand :: PlaceSubsurface ( params ) => { let sibling_index = if let Some ( index ) = self . subsurfaces . iter ( ) . position ( | x | x . 0 == params . sibling ) { index } else { return Err ( format_err ! ( " " params sibling id ( ) ) ) ; } ; let sibling_entry = self . subsurfaces . remove ( sibling_index ) ; let anchor_index = if let Some ( index ) = self . subsurfaces . iter ( ) . position ( | x | x . 1 == Some ( params . subsurface ) ) { index } else { return Err ( format_err ! ( " " params subsurface id ( ) ) ) ; } ; let new_index = match params . relation { SurfaceRelation :: Below => anchor_index , SurfaceRelation :: Above => anchor_index + 1 , } ; self . subsurfaces . insert ( new_index , sibling_entry ) ; } } ; Ok ( ( ) ) }
Updates the current surface state by applying a single `SurfaceCommand`.
Updates the current surface state by applying a single ` SurfaceCommand ` .
&mut self
command
SurfaceCommand