mirror of
https://github.com/pinnacle-comp/pinnacle.git
synced 2024-12-27 21:58:18 +01:00
Change renders to take outputs
This commit is contained in:
parent
ebe745d091
commit
698d13bfda
1 changed files with 20 additions and 45 deletions
|
@ -299,11 +299,7 @@ pub fn run_udev() -> anyhow::Result<()> {
|
||||||
if let Err(err) = libinput_context.resume() {
|
if let Err(err) = libinput_context.resume() {
|
||||||
tracing::error!("Failed to resume libinput context: {:?}", err);
|
tracing::error!("Failed to resume libinput context: {:?}", err);
|
||||||
}
|
}
|
||||||
for (node, backend) in udev
|
for backend in udev.backends.values_mut() {
|
||||||
.backends
|
|
||||||
.iter_mut()
|
|
||||||
.map(|(handle, backend)| (*handle, backend))
|
|
||||||
{
|
|
||||||
backend.drm.activate();
|
backend.drm.activate();
|
||||||
for surface in backend.surfaces.values_mut() {
|
for surface in backend.surfaces.values_mut() {
|
||||||
if let Err(err) = surface.compositor.surface().reset_state() {
|
if let Err(err) = surface.compositor.surface().reset_state() {
|
||||||
|
@ -315,9 +311,12 @@ pub fn run_udev() -> anyhow::Result<()> {
|
||||||
// otherwise
|
// otherwise
|
||||||
surface.compositor.reset_buffers();
|
surface.compositor.reset_buffers();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for output in data.state.space.outputs().cloned().collect::<Vec<_>>() {
|
||||||
data.state
|
data.state
|
||||||
.loop_handle
|
.loop_handle
|
||||||
.insert_idle(move |data| data.state.render(node, None));
|
.insert_idle(move |data| data.state.render_surface(&output));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1125,42 +1124,28 @@ impl State {
|
||||||
//
|
//
|
||||||
// If latency is a problem then future me can deal with it :)
|
// If latency is a problem then future me can deal with it :)
|
||||||
self.loop_handle.insert_idle(move |data| {
|
self.loop_handle.insert_idle(move |data| {
|
||||||
data.state.render(dev_id, Some(crtc));
|
data.state.render_surface(&output);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Render to the [`RenderSurface`] associated with the provided `crtc`,
|
/// Render to the [`RenderSurface`] associated with the given `output`.
|
||||||
/// or all [`RenderSurface`]s on all available crtcs if `None`.
|
fn render_surface(&mut self, output: &Output) {
|
||||||
fn render(&mut self, node: DrmNode, crtc: Option<crtc::Handle>) {
|
|
||||||
let udev = self.backend.udev_mut();
|
let udev = self.backend.udev_mut();
|
||||||
|
|
||||||
let device_backend = match udev.backends.get_mut(&node) {
|
let Some(UdevOutputData {
|
||||||
Some(backend) => backend,
|
device_id,
|
||||||
None => {
|
crtc,
|
||||||
tracing::error!("Trying to render on non-existent backend {}", node);
|
mode: _,
|
||||||
return;
|
}) = output.user_data().get()
|
||||||
}
|
else {
|
||||||
|
return;
|
||||||
};
|
};
|
||||||
|
|
||||||
if let Some(crtc) = crtc {
|
|
||||||
self.render_surface(node, crtc);
|
|
||||||
} else {
|
|
||||||
let crtcs: Vec<_> = device_backend.surfaces.keys().copied().collect();
|
|
||||||
for crtc in crtcs {
|
|
||||||
self.render_surface(node, crtc);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Render to the [`RenderSurface`] associated with the given `crtc`.
|
|
||||||
fn render_surface(&mut self, node: DrmNode, crtc: crtc::Handle) {
|
|
||||||
let udev = self.backend.udev_mut();
|
|
||||||
|
|
||||||
let Some(surface) = udev
|
let Some(surface) = udev
|
||||||
.backends
|
.backends
|
||||||
.get_mut(&node)
|
.get_mut(device_id)
|
||||||
.and_then(|device| device.surfaces.get_mut(&crtc))
|
.and_then(|device| device.surfaces.get_mut(crtc))
|
||||||
else {
|
else {
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
|
@ -1223,17 +1208,6 @@ impl State {
|
||||||
texture
|
texture
|
||||||
});
|
});
|
||||||
|
|
||||||
let output = if let Some(output) = self.space.outputs().find(|o| {
|
|
||||||
let udev_op_data = o.user_data().get::<UdevOutputData>();
|
|
||||||
udev_op_data
|
|
||||||
.is_some_and(|data| data.device_id == surface.device_id && data.crtc == crtc)
|
|
||||||
}) {
|
|
||||||
output.clone()
|
|
||||||
} else {
|
|
||||||
// somehow we got called with an invalid output
|
|
||||||
return;
|
|
||||||
};
|
|
||||||
|
|
||||||
let windows = self
|
let windows = self
|
||||||
.focus_state
|
.focus_state
|
||||||
.focus_stack
|
.focus_stack
|
||||||
|
@ -1245,7 +1219,7 @@ impl State {
|
||||||
let result = render_surface(
|
let result = render_surface(
|
||||||
surface,
|
surface,
|
||||||
&mut renderer,
|
&mut renderer,
|
||||||
&output,
|
output,
|
||||||
&self.space,
|
&self.space,
|
||||||
&windows,
|
&windows,
|
||||||
&self.override_redirect_windows,
|
&self.override_redirect_windows,
|
||||||
|
@ -1304,9 +1278,10 @@ impl State {
|
||||||
crtc,
|
crtc,
|
||||||
);
|
);
|
||||||
let timer = Timer::from_duration(refresh_time);
|
let timer = Timer::from_duration(refresh_time);
|
||||||
|
let output = output.clone();
|
||||||
self.loop_handle
|
self.loop_handle
|
||||||
.insert_source(timer, move |_, _, data| {
|
.insert_source(timer, move |_, _, data| {
|
||||||
data.state.render(node, Some(crtc));
|
data.state.render_surface(&output);
|
||||||
TimeoutAction::Drop
|
TimeoutAction::Drop
|
||||||
})
|
})
|
||||||
.expect("failed to schedule frame timer");
|
.expect("failed to schedule frame timer");
|
||||||
|
|
Loading…
Reference in a new issue