diff --git a/src/subcompositor.rs b/src/subcompositor.rs index b54e83dbb..61ff920db 100644 --- a/src/subcompositor.rs +++ b/src/subcompositor.rs @@ -42,6 +42,21 @@ impl SubcompositorState { self.subcompositor.get_subsurface(&surface, &parent, queue_handle, subsurface_data); (subsurface, surface) } + + pub fn subsurface_from_surface( + &self, + surface: &WlSurface, + queue_handle: &QueueHandle, + ) -> Option + where + State: Dispatch + Dispatch + 'static, + { + let parent = surface.data::().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 Dispatch for SubcompositorState