Move take_presentation_feedback

This commit is contained in:
Ottatop 2023-09-20 16:54:39 -05:00
parent c83f136cf7
commit 4cffb28e25
4 changed files with 44 additions and 50 deletions

View file

@ -85,10 +85,8 @@ use smithay_drm_extras::{
use crate::{
config::api::msg::{Args, OutgoingMsg},
render::{pointer::PointerElement, CustomRenderElements},
state::{
take_presentation_feedback, Backend, CalloopData, State, SurfaceDmabufFeedback, WithState,
},
render::{pointer::PointerElement, take_presentation_feedback, CustomRenderElements},
state::{Backend, CalloopData, State, SurfaceDmabufFeedback, WithState},
window::WindowElement,
};

View file

@ -34,8 +34,8 @@ use smithay::{
};
use crate::{
render::pointer::PointerElement,
state::{take_presentation_feedback, Backend, CalloopData, State, WithState},
render::{pointer::PointerElement, take_presentation_feedback},
state::{Backend, CalloopData, State, WithState},
};
use super::BackendData;

View file

@ -6,13 +6,17 @@ use smithay::{
backend::renderer::{
element::{
self, surface::WaylandSurfaceRenderElement, texture::TextureBuffer, AsRenderElements,
Wrap,
RenderElementStates, Wrap,
},
ImportAll, ImportMem, Renderer, Texture,
},
desktop::{
layer_map_for_output,
space::{SpaceElement, SpaceRenderElements, SurfaceTree},
utils::{
surface_presentation_feedback_flags_from_states, surface_primary_scanout_output,
OutputPresentationFeedback,
},
Space,
},
input::pointer::{CursorImageAttributes, CursorImageStatus},
@ -325,3 +329,37 @@ where
output_render_elements
}
// TODO: docs
pub fn take_presentation_feedback(
output: &Output,
space: &Space<WindowElement>,
render_element_states: &RenderElementStates,
) -> OutputPresentationFeedback {
let mut output_presentation_feedback = OutputPresentationFeedback::new(output);
space.elements().for_each(|window| {
if space.outputs_for_element(window).contains(output) {
window.take_presentation_feedback(
&mut output_presentation_feedback,
surface_primary_scanout_output,
|surface, _| {
surface_presentation_feedback_flags_from_states(surface, render_element_states)
},
);
}
});
let map = smithay::desktop::layer_map_for_output(output);
for layer_surface in map.layers() {
layer_surface.take_presentation_feedback(
&mut output_presentation_feedback,
surface_primary_scanout_output,
|surface, _| {
surface_presentation_feedback_flags_from_states(surface, render_element_states)
},
);
}
output_presentation_feedback
}

View file

@ -25,16 +25,8 @@ use crate::{
};
use calloop::{channel::Sender, futures::Scheduler, RegistrationToken};
use smithay::{
backend::renderer::element::RenderElementStates,
desktop::{
utils::{
surface_presentation_feedback_flags_from_states, surface_primary_scanout_output,
OutputPresentationFeedback,
},
PopupManager, Space,
},
desktop::{PopupManager, Space},
input::{keyboard::XkbConfig, pointer::CursorImageStatus, Seat, SeatState},
output::Output,
reexports::{
calloop::{
self, channel::Event, generic::Generic, Interest, LoopHandle, LoopSignal, Mode,
@ -399,40 +391,6 @@ pub struct SurfaceDmabufFeedback<'a> {
pub scanout_feedback: &'a DmabufFeedback,
}
// TODO: docs
pub fn take_presentation_feedback(
output: &Output,
space: &Space<WindowElement>,
render_element_states: &RenderElementStates,
) -> OutputPresentationFeedback {
let mut output_presentation_feedback = OutputPresentationFeedback::new(output);
space.elements().for_each(|window| {
if space.outputs_for_element(window).contains(output) {
window.take_presentation_feedback(
&mut output_presentation_feedback,
surface_primary_scanout_output,
|surface, _| {
surface_presentation_feedback_flags_from_states(surface, render_element_states)
},
);
}
});
let map = smithay::desktop::layer_map_for_output(output);
for layer_surface in map.layers() {
layer_surface.take_presentation_feedback(
&mut output_presentation_feedback,
surface_primary_scanout_output,
|surface, _| {
surface_presentation_feedback_flags_from_states(surface, render_element_states)
},
);
}
output_presentation_feedback
}
pub struct ApiState {
// TODO: this may not need to be in an arc mutex because of the move to async
/// The stream API messages are being sent through