compositor: return value from Token::with_surface_data

This commit is contained in:
Victor Berger 2017-09-05 21:23:17 +02:00
parent aab56047f0
commit db6bad1676
1 changed files with 3 additions and 5 deletions

View File

@ -287,17 +287,15 @@ impl<U: Send + 'static, R: Send + 'static, H: Handler<U, R> + Send + 'static> Co
/// ///
/// If the surface is not managed by the CompositorGlobal that provided this token, this /// If the surface is not managed by the CompositorGlobal that provided this token, this
/// will panic (having more than one compositor is not supported). /// will panic (having more than one compositor is not supported).
pub fn with_surface_data<F>(&self, surface: &wl_surface::WlSurface, f: F) pub fn with_surface_data<F, T>(&self, surface: &wl_surface::WlSurface, f: F) -> T
where where
F: FnOnce(&mut SurfaceAttributes<U>), F: FnOnce(&mut SurfaceAttributes<U>) -> T,
{ {
assert!( assert!(
resource_is_registered::<_, CompositorHandler<U, R, H>>(surface, self.hid), resource_is_registered::<_, CompositorHandler<U, R, H>>(surface, self.hid),
"Accessing the data of foreign surfaces is not supported." "Accessing the data of foreign surfaces is not supported."
); );
unsafe { unsafe { SurfaceData::<U, R>::with_data(surface, f) }
SurfaceData::<U, R>::with_data(surface, f);
}
} }
} }