From c3d2b5f0b78c222518ba8df542fa3b5537269489 Mon Sep 17 00:00:00 2001 From: Victoria Brekenfeld Date: Tue, 22 Jul 2025 16:39:33 +0200 Subject: [PATCH] element: Allow overriding default scanout behaviour --- src/shell/element/mod.rs | 13 +++++++++++-- src/shell/element/stack.rs | 7 ++++++- src/shell/element/surface.rs | 29 ++++++++++++++++++++++++----- src/shell/element/window.rs | 7 ++++++- src/shell/grabs/moving.rs | 1 + src/shell/layout/floating/mod.rs | 1 + src/shell/layout/tiling/mod.rs | 2 ++ src/shell/workspace.rs | 1 + 8 files changed, 52 insertions(+), 9 deletions(-) diff --git a/src/shell/element/mod.rs b/src/shell/element/mod.rs index 05181a08..20ff8c26 100644 --- a/src/shell/element/mod.rs +++ b/src/shell/element/mod.rs @@ -618,6 +618,7 @@ impl CosmicMapped { location: smithay::utils::Point, scale: smithay::utils::Scale, alpha: f32, + scanout_override: Option, ) -> Vec where R: Renderer + ImportAll + ImportMem + AsGlowRenderer, @@ -803,11 +804,19 @@ impl CosmicMapped { #[cfg_attr(not(feature = "debug"), allow(unused_mut))] elements.extend(match &self.element { CosmicMappedInternal::Stack(s) => s.render_elements::>( - renderer, location, scale, alpha, + renderer, + location, + scale, + alpha, + scanout_override, ), CosmicMappedInternal::Window(w) => w .render_elements::>( - renderer, location, scale, alpha, + renderer, + location, + scale, + alpha, + scanout_override, ), _ => unreachable!(), }); diff --git a/src/shell/element/stack.rs b/src/shell/element/stack.rs index 33b4b57a..b6909993 100644 --- a/src/shell/element/stack.rs +++ b/src/shell/element/stack.rs @@ -649,6 +649,7 @@ impl CosmicStack { location: Point, scale: Scale, alpha: f32, + scanout_override: Option, ) -> Vec where R: Renderer + ImportAll + ImportMem, @@ -675,7 +676,11 @@ impl CosmicStack { let active = p.active.load(Ordering::SeqCst); windows[active].render_elements::>( - renderer, window_loc, scale, alpha, + renderer, + window_loc, + scale, + alpha, + scanout_override, ) })); diff --git a/src/shell/element/surface.rs b/src/shell/element/surface.rs index 0f64bcf9..b9785603 100644 --- a/src/shell/element/surface.rs +++ b/src/shell/element/surface.rs @@ -12,7 +12,7 @@ use smithay::{ element::{ surface::{render_elements_from_surface_tree, WaylandSurfaceRenderElement}, utils::select_dmabuf_feedback, - AsRenderElements, RenderElementStates, + AsRenderElements, Kind, RenderElementStates, }, ImportAll, Renderer, }, @@ -27,7 +27,7 @@ use smithay::{ output::Output, reexports::{ wayland_protocols::{ - wp::presentation_time::server::wp_presentation_feedback::Kind, + wp::presentation_time::server::wp_presentation_feedback::Kind as PresentationKind, xdg::{ decoration::zv1::server::zxdg_toplevel_decoration_v1::Mode as DecorationMode, shell::server::xdg_toplevel::State as ToplevelState, @@ -699,7 +699,7 @@ impl CosmicSurface { presentation_feedback_flags: F2, ) where F1: FnMut(&WlSurface, &SurfaceData) -> Option + Copy, - F2: FnMut(&WlSurface, &SurfaceData) -> Kind + Copy, + F2: FnMut(&WlSurface, &SurfaceData) -> PresentationKind + Copy, { self.0.take_presentation_feedback( output_feedback, @@ -760,6 +760,7 @@ impl CosmicSurface { location: Point, scale: Scale, alpha: f32, + scanout_override: Option, ) -> Vec where R: Renderer + ImportAll, @@ -776,7 +777,16 @@ impl CosmicSurface { location, scale, alpha, - FRAME_TIME_FILTER, + scanout_override + .map(|val| { + if val { + Kind::ScanoutCandidate + } else { + Kind::Unspecified + } + .into() + }) + .unwrap_or(FRAME_TIME_FILTER), ) } WindowSurface::X11(surface) => { @@ -790,7 +800,16 @@ impl CosmicSurface { location, scale, alpha, - FRAME_TIME_FILTER, + scanout_override + .map(|val| { + if val { + Kind::ScanoutCandidate + } else { + Kind::Unspecified + } + .into() + }) + .unwrap_or(FRAME_TIME_FILTER), ) } } diff --git a/src/shell/element/window.rs b/src/shell/element/window.rs index ab195e47..7181832b 100644 --- a/src/shell/element/window.rs +++ b/src/shell/element/window.rs @@ -350,6 +350,7 @@ impl CosmicWindow { location: Point, scale: Scale, alpha: f32, + scanout_override: Option, ) -> Vec where R: Renderer + ImportAll + ImportMem, @@ -368,7 +369,11 @@ impl CosmicWindow { elements.extend(self.0.with_program(|p| { p.window.render_elements::>( - renderer, window_loc, scale, alpha, + renderer, + window_loc, + scale, + alpha, + scanout_override, ) })); diff --git a/src/shell/grabs/moving.rs b/src/shell/grabs/moving.rs index 49457105..9ade2ff9 100644 --- a/src/shell/grabs/moving.rs +++ b/src/shell/grabs/moving.rs @@ -187,6 +187,7 @@ impl MoveGrabState { .to_physical_precise_round(output_scale), output_scale, alpha, + Some(false), ); let p_elements = self .window diff --git a/src/shell/layout/floating/mod.rs b/src/shell/layout/floating/mod.rs index db35afbb..efe9f79f 100644 --- a/src/shell/layout/floating/mod.rs +++ b/src/shell/layout/floating/mod.rs @@ -1468,6 +1468,7 @@ impl FloatingLayout { .to_physical_precise_round(output_scale), output_scale.into(), alpha, + None, ); if let Some(anim) = self.animations.get(elem) { diff --git a/src/shell/layout/tiling/mod.rs b/src/shell/layout/tiling/mod.rs index a8bfd26b..a4361579 100644 --- a/src/shell/layout/tiling/mod.rs +++ b/src/shell/layout/tiling/mod.rs @@ -4983,6 +4983,7 @@ where geo.loc.as_logical().to_physical_precise_round(output_scale) - elem_geometry.loc, Scale::from(output_scale), alpha, + None, ); elements.extend(window_elements.into_iter().flat_map(|element| { @@ -5470,6 +5471,7 @@ where - elem_geometry.loc, Scale::from(output_scale), alpha, + None, ); if swap_desc diff --git a/src/shell/workspace.rs b/src/shell/workspace.rs index e597cdf9..4449d451 100644 --- a/src/shell/workspace.rs +++ b/src/shell/workspace.rs @@ -1556,6 +1556,7 @@ impl Workspace { render_loc, output_scale.into(), alpha, + Some(true), ) .into_iter() .map(|elem| RescaleRenderElement::from_element(elem, render_loc, scale))