kms: change from thread_local approach to wiring scanout node through function calls to detect scanout candidates

This commit is contained in:
Ericky Dos Santos 2026-07-01 11:05:56 -04:00 committed by Jacob Kauffmann
parent 012c77ec81
commit 031fdc389a
12 changed files with 140 additions and 68 deletions

View file

@ -943,6 +943,7 @@ impl LockedDevice<'_> {
output,
CursorMode::All,
None,
None,
)
.with_context(|| "Failed to render outputs")?,
None => Vec::new(),

View file

@ -978,6 +978,7 @@ impl KmsGuard<'_> {
output,
CursorMode::All,
None,
None,
)
.with_context(|| "Failed to render outputs")?;
@ -1088,6 +1089,7 @@ impl KmsGuard<'_> {
output,
CursorMode::All,
None,
None,
)
.with_context(|| "Failed to render outputs")?;
@ -1132,6 +1134,7 @@ impl KmsGuard<'_> {
output,
CursorMode::All,
None,
None,
)
.with_context(|| "Failed to render outputs")?;

View file

@ -8,7 +8,7 @@ use crate::{
init_shaders, output_elements,
},
config::ScreenFilter,
shell::{Shell, element::surface::ScanoutTargetNodeGuard},
shell::Shell,
state::SurfaceDmabufFeedback,
utils::prelude::*,
wayland::handlers::{
@ -1057,24 +1057,22 @@ impl SurfaceThreadState {
vrr = has_active_fullscreen;
}
let mut elements = {
let _scanout_node = ScanoutTargetNodeGuard::new(Some(self.target_node));
output_elements(
Some(&render_node),
&mut renderer,
&self.shell,
self.clock.now(),
self.mirroring.as_ref().unwrap_or(&self.output),
CursorMode::All,
#[cfg(not(feature = "debug"))]
None,
#[cfg(feature = "debug")]
Some((&self.egui, &self.timings)),
)
.map_err(|err| {
anyhow::format_err!("Failed to accumulate elements for rendering: {:?}", err)
})?
};
let mut elements = output_elements(
Some(&render_node),
&mut renderer,
&self.shell,
self.clock.now(),
self.mirroring.as_ref().unwrap_or(&self.output),
CursorMode::All,
#[cfg(not(feature = "debug"))]
None,
#[cfg(feature = "debug")]
Some((&self.egui, &self.timings)),
Some(self.target_node),
)
.map_err(|err| {
anyhow::format_err!("Failed to accumulate elements for rendering: {:?}", err)
})?;
if vrr && fullscreen_drives_refresh_rate && !self.timings.past_min_render_time(&self.clock)
{

View file

@ -475,6 +475,7 @@ pub fn cursor_elements<'a, 'frame, R>(
output: &Output,
mode: CursorMode,
exclude_dnd_icon: bool,
scanout_node: Option<DrmNode>,
) -> Vec<CosmicElement<R>>
where
R: AsGlowRenderer,
@ -549,7 +550,14 @@ where
.lock()
.unwrap()
.as_ref()
.map(|state| state.render::<CosmicMappedRenderElement<R>, R>(renderer, output, theme))
.map(|state| {
state.render::<CosmicMappedRenderElement<R>, R>(
renderer,
output,
theme,
scanout_node,
)
})
{
elements.extend(grab_elements.into_iter().map(|elem| {
CosmicElement::MoveGrab(RescaleRenderElement::from_element(
@ -615,6 +623,7 @@ pub fn output_elements<R>(
output: &Output,
cursor_mode: CursorMode,
_fps: Option<(&EguiState, &Timings)>,
scanout_node: Option<DrmNode>,
) -> Result<Vec<CosmicElement<R>>, RenderError<R::Error>>
where
R: AsGlowRenderer,
@ -690,6 +699,7 @@ where
workspace,
cursor_mode,
element_filter,
scanout_node,
)?;
#[cfg(feature = "debug")]
@ -713,6 +723,7 @@ pub fn workspace_elements<R>(
current: (WorkspaceHandle, usize),
cursor_mode: CursorMode,
element_filter: ElementFilter,
scanout_node: Option<DrmNode>,
) -> Result<Vec<CosmicElement<R>>, RenderError<R::Error>>
where
R: AsGlowRenderer,
@ -743,6 +754,7 @@ where
output,
cursor_mode,
element_filter == ElementFilter::ExcludeWorkspaceOverview,
scanout_node,
));
let shell = shell.read();
@ -907,7 +919,7 @@ where
elements.extend(
layout
.render_popups(renderer, alpha)
.render_popups(renderer, alpha, scanout_node)
.into_iter()
.map(Into::into)
.flat_map(crop_to_output)
@ -951,6 +963,7 @@ where
active_hint,
alpha,
theme.cosmic(),
scanout_node,
)
.into_iter()
.map(Into::into)
@ -966,6 +979,7 @@ where
!move_active && is_active_space,
overview.clone(),
theme.cosmic(),
scanout_node,
) {
Ok(elements) => {
elements
@ -995,6 +1009,7 @@ where
resize_indicator.clone(),
active_hint,
theme.cosmic(),
scanout_node,
) {
Ok(elements) => {
elements
@ -1511,6 +1526,7 @@ where
current,
cursor_mode,
element_filter,
None,
)?;
if let Some(additional_damage) = additional_damage {