kms: Dmabuf Feedback support

This commit is contained in:
Victoria Brekenfeld 2023-03-09 17:39:47 +01:00
parent 486266f7bb
commit c8bb417d9b
8 changed files with 234 additions and 26 deletions

View file

@ -25,7 +25,7 @@ use smithay::{
Bind, Blit, BufferType, ExportMem, ImportAll, ImportMem, Offscreen, Renderer,
},
},
desktop::{layer_map_for_output, space::SpaceElement},
desktop::{layer_map_for_output, space::SpaceElement, utils::surface_primary_scanout_output},
output::Output,
reexports::wayland_server::{
protocol::{wl_buffer::WlBuffer, wl_shm::Format as ShmFormat, wl_surface::WlSurface},
@ -33,7 +33,8 @@ use smithay::{
},
utils::{IsAlive, Logical, Physical, Rectangle, Scale, Transform},
wayland::{
dmabuf::get_dmabuf,
compositor::with_states,
dmabuf::{get_dmabuf, SurfaceDmabufFeedbackState},
seat::WaylandFocus,
shm::{with_buffer_contents, with_buffer_contents_mut},
},
@ -178,9 +179,21 @@ impl ScreencopyHandler for State {
.get_client(surface.id())
.ok()
.and_then(|client| {
// has the client requested surface-feedback? If yes it is properly rendering on the node of the display
if with_states(&surface, |data| {
SurfaceDmabufFeedbackState::from_states(data).is_some()
}) {
if let Some(output) = with_states(&surface, |data| {
surface_primary_scanout_output(&surface, data)
}) {
return kms.target_node_for_output(&output);
}
}
// else lets check the global drm-node the client got either through default-feedback or wl_drm
if let Some(normal_client) = client.get_data::<ClientState>() {
return normal_client.drm_node.clone();
}
// last but not least all xwayland-surfaces should also share a single node
if let Some(xwayland_client) = client.get_data::<XWaylandClientData>() {
return xwayland_client.user_data().get::<DrmNode>().cloned();
}