Update scanout output for cursor surfaces

Also schedule render when they commit
This commit is contained in:
Ottatop 2024-08-12 12:13:50 -05:00
parent f1bcd8357b
commit fca6a6c5f5
4 changed files with 87 additions and 11 deletions

View file

@ -423,6 +423,15 @@ impl CompositorHandler for State {
.cloned()
{
vec![output] // surface is a layer surface
} else if matches!(self.pinnacle.cursor_state.cursor_image(), CursorImageStatus::Surface(s) if s == surface)
{
// This is a cursor surface
// TODO: granular
self.pinnacle.space.outputs().cloned().collect()
} else if self.pinnacle.dnd_icon.as_ref() == Some(surface) {
// This is a dnd icon
// TODO: granular
self.pinnacle.space.outputs().cloned().collect()
} else if let Some(output) = self
.pinnacle
.space

View file

@ -7,18 +7,14 @@ use std::{
use smithay::{
backend::renderer::element::{
self,
surface::WaylandSurfaceRenderElement,
texture::{TextureBuffer, TextureRenderElement},
utils::RescaleRenderElement,
Element,
surface::WaylandSurfaceRenderElement, utils::RescaleRenderElement, Element,
},
desktop::Space,
reexports::calloop::{
timer::{TimeoutAction, Timer},
LoopHandle,
},
utils::{Logical, Point, Scale, Serial, Transform},
utils::{Logical, Point, Scale, Serial},
};
use crate::{

View file

@ -29,7 +29,7 @@ use smithay::{
use crate::{
backend::{udev::UdevRenderer, Backend},
layout::transaction::{LayoutTransaction, SnapshotRenderElement, SnapshotTarget},
layout::transaction::SnapshotRenderElement,
pinnacle_render_elements,
state::{State, WithState},
window::WindowElement,

View file

@ -53,7 +53,9 @@ use smithay::{
},
utils::{Clock, Monotonic},
wayland::{
compositor::{self, CompositorClientState, CompositorState, SurfaceData},
compositor::{
self, with_surface_tree_downward, CompositorClientState, CompositorState, SurfaceData,
},
cursor_shape::CursorShapeManagerState,
fractional_scale::{with_fractional_scale, FractionalScaleManagerState},
idle_notify::IdleNotifierState,
@ -490,9 +492,22 @@ impl Pinnacle {
// the frame callbacks across potentially multiple outputs, and for regular windows and
// layer-shell surfaces it avoids sending frame callbacks to invisible surfaces.
let current_primary_output = surface_primary_scanout_output(surface, states);
if matches!(self.cursor_state.cursor_image(), CursorImageStatus::Surface(s) if s == surface)
{
tracing::info!(
"cursor primary scanout output: {:?}",
current_primary_output.as_ref().map(|o| o.name())
);
}
// tracing::info!(
// "current primary output is {:?}",
// current_primary_output.as_ref().map(|o| o.name())
// op_count = self.outputs.len(),
// "current primary output is {:?}, wl_output {:?}",
// current_primary_output.as_ref().map(|o| o.name()),
// current_primary_output
// .as_ref()
// .and_then(|o| { self.outputs.get(o) }),
// );
if current_primary_output.as_ref() != Some(output) {
// return self
@ -586,7 +601,9 @@ impl Pinnacle {
offscreen_id.clone().unwrap_or_else(|| Id::from(surface)),
output,
render_element_states,
default_primary_scanout_output_compare,
// TODO:
// default_primary_scanout_output_compare,
|_, _, op, _| op,
);
if let Some(output) = primary_scanout_output {
@ -617,6 +634,60 @@ impl Pinnacle {
}
});
}
if let Some(lock_surface) = output.with_state(|state| state.lock_surface.clone()) {
with_surface_tree_downward(
lock_surface.wl_surface(),
(),
|_, _, _| compositor::TraversalAction::DoChildren(()),
|surface, states, _| {
update_surface_primary_scanout_output(
surface,
output,
states,
render_element_states,
default_primary_scanout_output_compare,
);
},
|_, _, _| true,
);
}
if let Some(dnd) = self.dnd_icon.as_ref() {
with_surface_tree_downward(
dnd,
(),
|_, _, _| compositor::TraversalAction::DoChildren(()),
|surface, states, _| {
update_surface_primary_scanout_output(
surface,
output,
states,
render_element_states,
default_primary_scanout_output_compare,
);
},
|_, _, _| true,
);
}
if let CursorImageStatus::Surface(surface) = self.cursor_state.cursor_image() {
with_surface_tree_downward(
surface,
(),
|_, _, _| compositor::TraversalAction::DoChildren(()),
|surface, states, _| {
update_surface_primary_scanout_output(
surface,
output,
states,
render_element_states,
default_primary_scanout_output_compare,
);
},
|_, _, _| true,
);
}
}
pub fn send_dmabuf_feedback(