kms: Dmabuf feedback support

This commit is contained in:
Victoria Brekenfeld 2023-03-31 13:57:37 +02:00
parent 636d38921a
commit bc49507353
8 changed files with 267 additions and 36 deletions

View file

@ -2,13 +2,17 @@ use std::time::Duration;
use smithay::{
backend::renderer::{
element::{surface::WaylandSurfaceRenderElement, AsRenderElements},
element::{
surface::WaylandSurfaceRenderElement, utils::select_dmabuf_feedback, AsRenderElements,
RenderElementStates,
},
ImportAll, Renderer,
},
desktop::{
utils::{
send_frames_surface_tree, take_presentation_feedback_surface_tree,
with_surfaces_surface_tree, OutputPresentationFeedback,
send_dmabuf_feedback_surface_tree, send_frames_surface_tree,
take_presentation_feedback_surface_tree, with_surfaces_surface_tree,
OutputPresentationFeedback,
},
Window,
},
@ -34,6 +38,8 @@ use smithay::{
xwayland::{xwm::X11Relatable, X11Surface},
};
use crate::state::SurfaceDmabufFeedback;
space_elements! {
#[derive(Debug, Clone, PartialEq)]
pub CosmicSurface;
@ -369,7 +375,7 @@ impl CosmicSurface {
{
match self {
CosmicSurface::Wayland(window) => {
window.send_frame(output, time, throttle, primary_scan_out_output)
window.send_frame(output, time, throttle, primary_scan_out_output);
}
CosmicSurface::X11(surface) => {
if let Some(wl_surface) = surface.wl_surface() {
@ -386,6 +392,47 @@ impl CosmicSurface {
}
}
pub fn send_dmabuf_feedback<F1>(
&self,
output: &Output,
feedback: &SurfaceDmabufFeedback,
render_element_states: &RenderElementStates,
primary_scan_out_output: F1,
) where
F1: FnMut(&WlSurface, &SurfaceData) -> Option<Output> + Copy,
{
match self {
CosmicSurface::Wayland(window) => {
window.send_dmabuf_feedback(output, primary_scan_out_output, |surface, _| {
select_dmabuf_feedback(
surface,
render_element_states,
&feedback.render_feedback,
&feedback.scanout_feedback,
)
})
}
CosmicSurface::X11(surface) => {
if let Some(wl_surface) = surface.wl_surface() {
send_dmabuf_feedback_surface_tree(
&wl_surface,
output,
primary_scan_out_output,
|surface, _| {
select_dmabuf_feedback(
surface,
render_element_states,
&feedback.render_feedback,
&feedback.scanout_feedback,
)
},
)
}
}
_ => unreachable!(),
}
}
pub fn take_presentation_feedback<F1, F2>(
&self,
output_feedback: &mut OutputPresentationFeedback,

View file

@ -5,6 +5,7 @@ use crate::{
shell::{
element::{window::CosmicWindowRenderElement, CosmicMapped, CosmicMappedRenderElement},
focus::target::{KeyboardFocusTarget, PointerFocusTarget},
CosmicSurface,
},
utils::prelude::*,
};
@ -91,6 +92,10 @@ impl MoveGrabState {
.active_window()
.send_frame(output, time, throttle, primary_scan_out_output)
}
pub fn window(&self) -> CosmicSurface {
self.window.active_window()
}
}
pub struct MoveSurfaceGrab {