Skip to content

Commit

Permalink
add way to make subsurfaces from surfaces
Browse files Browse the repository at this point in the history
  • Loading branch information
maxhbooth committed Apr 11, 2024
1 parent f3587a9 commit d4cca5a
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/subcompositor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,21 @@ impl SubcompositorState {
self.subcompositor.get_subsurface(&surface, &parent, queue_handle, subsurface_data);
(subsurface, surface)
}

pub fn subsurface_from_surface<State>(
&self,
surface: &WlSurface,
queue_handle: &QueueHandle<State>,
) -> Option<WlSubsurface>
where
State: Dispatch<WlSurface, SurfaceData> + Dispatch<WlSubsurface, SubsurfaceData> + 'static,
{
let parent = surface.data::<SurfaceData>().unwrap().parent_surface();
let subsurface_data = SubsurfaceData::new(surface.clone());
parent.and_then(|parent| {
Some(self.subcompositor.get_subsurface(surface, &parent, queue_handle, subsurface_data))
})
}
}

impl<D> Dispatch<WlSubsurface, SubsurfaceData, D> for SubcompositorState
Expand Down

0 comments on commit d4cca5a

Please sign in to comment.