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 authored and wash2 committed Apr 12, 2024
1 parent 4097d48 commit 18070ad
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.map(|parent| {
self.subcompositor.get_subsurface(surface, parent, queue_handle, subsurface_data)
})
}
}

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

0 comments on commit 18070ad

Please sign in to comment.