element: Allow overriding default scanout behaviour

This commit is contained in:
Victoria Brekenfeld 2025-07-22 16:39:33 +02:00 • committed by Victoria Brekenfeld
parent be1424f1ca
commit c3d2b5f0b7
8 changed files with 52 additions and 9 deletions

View file

@ -618,6 +618,7 @@ impl CosmicMapped {
location: smithay::utils::Point<i32, smithay::utils::Physical>, location: smithay::utils::Point<i32, smithay::utils::Physical>,
scale: smithay::utils::Scale<f64>, scale: smithay::utils::Scale<f64>,
alpha: f32, alpha: f32,
scanout_override: Option<bool>,
) -> Vec<C> ) -> Vec<C>
where where
R: Renderer + ImportAll + ImportMem + AsGlowRenderer, R: Renderer + ImportAll + ImportMem + AsGlowRenderer,
@ -803,11 +804,19 @@ impl CosmicMapped {
#[cfg_attr(not(feature = "debug"), allow(unused_mut))] #[cfg_attr(not(feature = "debug"), allow(unused_mut))]
elements.extend(match &self.element { elements.extend(match &self.element {
CosmicMappedInternal::Stack(s) => s.render_elements::<R, CosmicMappedRenderElement<R>>( CosmicMappedInternal::Stack(s) => s.render_elements::<R, CosmicMappedRenderElement<R>>(
renderer, location, scale, alpha, renderer,
location,
scale,
alpha,
scanout_override,
), ),
CosmicMappedInternal::Window(w) => w CosmicMappedInternal::Window(w) => w
.render_elements::<R, CosmicMappedRenderElement<R>>( .render_elements::<R, CosmicMappedRenderElement<R>>(
renderer, location, scale, alpha, renderer,
location,
scale,
alpha,
scanout_override,
), ),
_ => unreachable!(), _ => unreachable!(),
}); });

View file

@ -649,6 +649,7 @@ impl CosmicStack {
location: Point<i32, Physical>, location: Point<i32, Physical>,
scale: Scale<f64>, scale: Scale<f64>,
alpha: f32, alpha: f32,
scanout_override: Option<bool>,
) -> Vec<C> ) -> Vec<C>
where where
R: Renderer + ImportAll + ImportMem, R: Renderer + ImportAll + ImportMem,
@ -675,7 +676,11 @@ impl CosmicStack {
let active = p.active.load(Ordering::SeqCst); let active = p.active.load(Ordering::SeqCst);
windows[active].render_elements::<R, CosmicStackRenderElement<R>>( windows[active].render_elements::<R, CosmicStackRenderElement<R>>(
renderer, window_loc, scale, alpha, renderer,
window_loc,
scale,
alpha,
scanout_override,
) )
})); }));

View file

@ -12,7 +12,7 @@ use smithay::{
element::{ element::{
surface::{render_elements_from_surface_tree, WaylandSurfaceRenderElement}, surface::{render_elements_from_surface_tree, WaylandSurfaceRenderElement},
utils::select_dmabuf_feedback, utils::select_dmabuf_feedback,
AsRenderElements, RenderElementStates, AsRenderElements, Kind, RenderElementStates,
}, },
ImportAll, Renderer, ImportAll, Renderer,
}, },
@ -27,7 +27,7 @@ use smithay::{
output::Output, output::Output,
reexports::{ reexports::{
wayland_protocols::{ wayland_protocols::{
wp::presentation_time::server::wp_presentation_feedback::Kind, wp::presentation_time::server::wp_presentation_feedback::Kind as PresentationKind,
xdg::{ xdg::{
decoration::zv1::server::zxdg_toplevel_decoration_v1::Mode as DecorationMode, decoration::zv1::server::zxdg_toplevel_decoration_v1::Mode as DecorationMode,
shell::server::xdg_toplevel::State as ToplevelState, shell::server::xdg_toplevel::State as ToplevelState,
@ -699,7 +699,7 @@ impl CosmicSurface {
presentation_feedback_flags: F2, presentation_feedback_flags: F2,
) where ) where
F1: FnMut(&WlSurface, &SurfaceData) -> Option<Output> + Copy, F1: FnMut(&WlSurface, &SurfaceData) -> Option<Output> + Copy,
F2: FnMut(&WlSurface, &SurfaceData) -> Kind + Copy, F2: FnMut(&WlSurface, &SurfaceData) -> PresentationKind + Copy,
{ {
self.0.take_presentation_feedback( self.0.take_presentation_feedback(
output_feedback, output_feedback,
@ -760,6 +760,7 @@ impl CosmicSurface {
location: Point<i32, Physical>, location: Point<i32, Physical>,
scale: Scale<f64>, scale: Scale<f64>,
alpha: f32, alpha: f32,
scanout_override: Option<bool>,
) -> Vec<C> ) -> Vec<C>
where where
R: Renderer + ImportAll, R: Renderer + ImportAll,
@ -776,7 +777,16 @@ impl CosmicSurface {
location, location,
scale, scale,
alpha, alpha,
FRAME_TIME_FILTER, scanout_override
.map(|val| {
if val {
Kind::ScanoutCandidate
} else {
Kind::Unspecified
}
.into()
})
.unwrap_or(FRAME_TIME_FILTER),
) )
} }
WindowSurface::X11(surface) => { WindowSurface::X11(surface) => {
@ -790,7 +800,16 @@ impl CosmicSurface {
location, location,
scale, scale,
alpha, alpha,
FRAME_TIME_FILTER, scanout_override
.map(|val| {
if val {
Kind::ScanoutCandidate
} else {
Kind::Unspecified
}
.into()
})
.unwrap_or(FRAME_TIME_FILTER),
) )
} }
} }

View file

@ -350,6 +350,7 @@ impl CosmicWindow {
location: Point<i32, Physical>, location: Point<i32, Physical>,
scale: Scale<f64>, scale: Scale<f64>,
alpha: f32, alpha: f32,
scanout_override: Option<bool>,
) -> Vec<C> ) -> Vec<C>
where where
R: Renderer + ImportAll + ImportMem, R: Renderer + ImportAll + ImportMem,
@ -368,7 +369,11 @@ impl CosmicWindow {
elements.extend(self.0.with_program(|p| { elements.extend(self.0.with_program(|p| {
p.window.render_elements::<R, CosmicWindowRenderElement<R>>( p.window.render_elements::<R, CosmicWindowRenderElement<R>>(
renderer, window_loc, scale, alpha, renderer,
window_loc,
scale,
alpha,
scanout_override,
) )
})); }));

View file

@ -187,6 +187,7 @@ impl MoveGrabState {
.to_physical_precise_round(output_scale), .to_physical_precise_round(output_scale),
output_scale, output_scale,
alpha, alpha,
Some(false),
); );
let p_elements = self let p_elements = self
.window .window

View file

@ -1468,6 +1468,7 @@ impl FloatingLayout {
.to_physical_precise_round(output_scale), .to_physical_precise_round(output_scale),
output_scale.into(), output_scale.into(),
alpha, alpha,
None,
); );
if let Some(anim) = self.animations.get(elem) { if let Some(anim) = self.animations.get(elem) {

View file

@ -4983,6 +4983,7 @@ where
geo.loc.as_logical().to_physical_precise_round(output_scale) - elem_geometry.loc, geo.loc.as_logical().to_physical_precise_round(output_scale) - elem_geometry.loc,
Scale::from(output_scale), Scale::from(output_scale),
alpha, alpha,
None,
); );
elements.extend(window_elements.into_iter().flat_map(|element| { elements.extend(window_elements.into_iter().flat_map(|element| {
@ -5470,6 +5471,7 @@ where
- elem_geometry.loc, - elem_geometry.loc,
Scale::from(output_scale), Scale::from(output_scale),
alpha, alpha,
None,
); );
if swap_desc if swap_desc

View file

@ -1556,6 +1556,7 @@ impl Workspace {
render_loc, render_loc,
output_scale.into(), output_scale.into(),
alpha, alpha,
Some(true),
) )
.into_iter() .into_iter()
.map(|elem| RescaleRenderElement::from_element(elem, render_loc, scale)) .map(|elem| RescaleRenderElement::from_element(elem, render_loc, scale))