Fix tests

This commit is contained in:
Ottatop 2024-05-27 15:58:57 -05:00
parent 04b7c0533f
commit 6982587a84
9 changed files with 74 additions and 67 deletions

View file

@ -742,8 +742,7 @@ impl tag_service_server::TagService for TagService {
return; return;
}; };
let (fs_and_up_snapshots, under_fs_snapshots) = let snapshots = state.backend.with_renderer(|renderer| {
state.backend.with_renderer(|renderer| {
capture_snapshots_on_output(&mut state.pinnacle, renderer, &output, []) capture_snapshots_on_output(&mut state.pinnacle, renderer, &output, [])
}); });
@ -756,6 +755,7 @@ impl tag_service_server::TagService for TagService {
state.pinnacle.fixup_xwayland_window_layering(); state.pinnacle.fixup_xwayland_window_layering();
if let Some((fs_and_up_snapshots, under_fs_snapshots)) = snapshots {
output.with_state_mut(|op_state| { output.with_state_mut(|op_state| {
op_state.new_wait_layout_transaction( op_state.new_wait_layout_transaction(
state.pinnacle.loop_handle.clone(), state.pinnacle.loop_handle.clone(),
@ -763,6 +763,7 @@ impl tag_service_server::TagService for TagService {
under_fs_snapshots, under_fs_snapshots,
) )
}); });
}
state.pinnacle.request_layout(&output); state.pinnacle.request_layout(&output);
state.update_keyboard_focus(&output); state.update_keyboard_focus(&output);
@ -786,8 +787,7 @@ impl tag_service_server::TagService for TagService {
return; return;
}; };
let (fs_and_up_snapshots, under_fs_snapshots) = let snapshots = state.backend.with_renderer(|renderer| {
state.backend.with_renderer(|renderer| {
capture_snapshots_on_output(&mut state.pinnacle, renderer, &output, []) capture_snapshots_on_output(&mut state.pinnacle, renderer, &output, [])
}); });
@ -800,6 +800,7 @@ impl tag_service_server::TagService for TagService {
state.pinnacle.fixup_xwayland_window_layering(); state.pinnacle.fixup_xwayland_window_layering();
if let Some((fs_and_up_snapshots, under_fs_snapshots)) = snapshots {
output.with_state_mut(|op_state| { output.with_state_mut(|op_state| {
op_state.new_wait_layout_transaction( op_state.new_wait_layout_transaction(
state.pinnacle.loop_handle.clone(), state.pinnacle.loop_handle.clone(),
@ -807,6 +808,7 @@ impl tag_service_server::TagService for TagService {
under_fs_snapshots, under_fs_snapshots,
) )
}); });
}
state.pinnacle.request_layout(&output); state.pinnacle.request_layout(&output);
state.update_keyboard_focus(&output); state.update_keyboard_focus(&output);
@ -1095,8 +1097,7 @@ impl output_service_server::OutputService for OutputService {
current_scale = f64::max(current_scale, 0.25); current_scale = f64::max(current_scale, 0.25);
let (fs_and_up_snapshots, under_fs_snapshots) = let snapshots = state.backend.with_renderer(|renderer| {
state.backend.with_renderer(|renderer| {
capture_snapshots_on_output(&mut state.pinnacle, renderer, &output, []) capture_snapshots_on_output(&mut state.pinnacle, renderer, &output, [])
}); });
@ -1108,13 +1109,15 @@ impl output_service_server::OutputService for OutputService {
None, None,
); );
if let Some((fs_and_up_snapshots, under_fs_snapshots)) = snapshots {
output.with_state_mut(|op_state| { output.with_state_mut(|op_state| {
op_state.new_wait_layout_transaction( op_state.new_wait_layout_transaction(
state.pinnacle.loop_handle.clone(), state.pinnacle.loop_handle.clone(),
fs_and_up_snapshots, fs_and_up_snapshots,
under_fs_snapshots, under_fs_snapshots,
); )
}); });
}
state.pinnacle.request_layout(&output); state.pinnacle.request_layout(&output);
state.schedule_render(&output); state.schedule_render(&output);

View file

@ -248,7 +248,7 @@ impl window_service_server::WindowService for WindowService {
return; return;
}; };
if let Some((fs_and_up_snapshots, under_fs_snapshots)) = snapshots { if let Some((fs_and_up_snapshots, under_fs_snapshots)) = snapshots.flatten() {
output.with_state_mut(|op_state| { output.with_state_mut(|op_state| {
op_state.new_wait_layout_transaction( op_state.new_wait_layout_transaction(
pinnacle.loop_handle.clone(), pinnacle.loop_handle.clone(),
@ -380,7 +380,7 @@ impl window_service_server::WindowService for WindowService {
let Some(output) = tag.output(pinnacle) else { return }; let Some(output) = tag.output(pinnacle) else { return };
if let Some((fs_and_up_snapshots, under_fs_snapshots)) = snapshots { if let Some((fs_and_up_snapshots, under_fs_snapshots)) = snapshots.flatten() {
output.with_state_mut(|op_state| { output.with_state_mut(|op_state| {
op_state.new_wait_layout_transaction( op_state.new_wait_layout_transaction(
pinnacle.loop_handle.clone(), pinnacle.loop_handle.clone(),
@ -453,7 +453,7 @@ impl window_service_server::WindowService for WindowService {
let Some(output) = tag.output(pinnacle) else { return }; let Some(output) = tag.output(pinnacle) else { return };
if let Some((fs_and_up_snapshots, under_fs_snapshots)) = snapshots { if let Some((fs_and_up_snapshots, under_fs_snapshots)) = snapshots.flatten() {
output.with_state_mut(|op_state| { output.with_state_mut(|op_state| {
op_state.new_wait_layout_transaction( op_state.new_wait_layout_transaction(
pinnacle.loop_handle.clone(), pinnacle.loop_handle.clone(),

View file

@ -107,12 +107,15 @@ impl Backend {
} }
} }
pub fn with_renderer<T>(&mut self, with_renderer: impl FnOnce(&mut GlesRenderer) -> T) -> T { pub fn with_renderer<T>(
&mut self,
with_renderer: impl FnOnce(&mut GlesRenderer) -> T,
) -> Option<T> {
match self { match self {
Backend::Winit(winit) => with_renderer(winit.backend.renderer()), Backend::Winit(winit) => Some(with_renderer(winit.backend.renderer())),
Backend::Udev(udev) => with_renderer(udev.renderer().as_mut()), Backend::Udev(udev) => Some(with_renderer(udev.renderer().ok()?.as_mut())),
#[cfg(feature = "testing")] #[cfg(feature = "testing")]
Backend::Dummy(_) => todo!(), Backend::Dummy(_) => None,
} }
} }

View file

@ -866,10 +866,8 @@ fn render_frame<'a>(
} }
impl Udev { impl Udev {
pub fn renderer(&mut self) -> UdevRenderer<'_> { pub fn renderer(&mut self) -> anyhow::Result<UdevRenderer<'_>> {
self.gpu_manager Ok(self.gpu_manager.single_renderer(&self.primary_gpu)?)
.single_renderer(&self.primary_gpu)
.expect("failed to create multirenderer")
} }
/// A GPU was plugged in. /// A GPU was plugged in.

View file

@ -211,7 +211,9 @@ impl CompositorHandler for State {
if unmapped_window.is_on_active_tag() { if unmapped_window.is_on_active_tag() {
self.update_keyboard_focus(&focused_output); self.update_keyboard_focus(&focused_output);
if let Some((fs_and_up_snapshots, under_fs_snapshots)) = snapshots { if let Some((fs_and_up_snapshots, under_fs_snapshots)) =
snapshots.flatten()
{
focused_output.with_state_mut(|state| { focused_output.with_state_mut(|state| {
state.new_wait_layout_transaction( state.new_wait_layout_transaction(
self.pinnacle.loop_handle.clone(), self.pinnacle.loop_handle.clone(),
@ -253,8 +255,7 @@ impl CompositorHandler for State {
} }
if let Some(output) = window.output(&self.pinnacle) { if let Some(output) = window.output(&self.pinnacle) {
let (fs_and_up_snapshots, under_fs_snapshots) = let snapshots = self.backend.with_renderer(|renderer| {
self.backend.with_renderer(|renderer| {
capture_snapshots_on_output( capture_snapshots_on_output(
&mut self.pinnacle, &mut self.pinnacle,
renderer, renderer,
@ -263,14 +264,16 @@ impl CompositorHandler for State {
) )
}); });
output.with_state_mut(|state| { if let Some((fs_and_up_snapshots, under_fs_snapshots)) = snapshots {
state.new_wait_layout_transaction( output.with_state_mut(|op_state| {
op_state.new_wait_layout_transaction(
self.pinnacle.loop_handle.clone(), self.pinnacle.loop_handle.clone(),
fs_and_up_snapshots, fs_and_up_snapshots,
under_fs_snapshots, under_fs_snapshots,
); )
}); });
} }
}
self.pinnacle.remove_window(&window, true); self.pinnacle.remove_window(&window, true);

View file

@ -21,7 +21,7 @@ impl State {
} }
if let Some(output) = window.output(&self.pinnacle) { if let Some(output) = window.output(&self.pinnacle) {
if let Some((fs_and_up_snapshots, under_fs_snapshots)) = snapshots { if let Some((fs_and_up_snapshots, under_fs_snapshots)) = snapshots.flatten() {
output.with_state_mut(|op_state| { output.with_state_mut(|op_state| {
op_state.new_wait_layout_transaction( op_state.new_wait_layout_transaction(
self.pinnacle.loop_handle.clone(), self.pinnacle.loop_handle.clone(),
@ -52,7 +52,7 @@ impl State {
} }
if let Some(output) = window.output(&self.pinnacle) { if let Some(output) = window.output(&self.pinnacle) {
if let Some((fs_and_up_snapshots, under_fs_snapshots)) = snapshots { if let Some((fs_and_up_snapshots, under_fs_snapshots)) = snapshots.flatten() {
output.with_state_mut(|op_state| { output.with_state_mut(|op_state| {
op_state.new_wait_layout_transaction( op_state.new_wait_layout_transaction(
self.pinnacle.loop_handle.clone(), self.pinnacle.loop_handle.clone(),

View file

@ -73,7 +73,7 @@ impl XdgShellHandler for State {
if let Some(output) = window.output(&self.pinnacle) { if let Some(output) = window.output(&self.pinnacle) {
self.pinnacle.request_layout(&output); self.pinnacle.request_layout(&output);
if let Some((fs_and_up_snapshots, under_fs_snapshots)) = snapshots { if let Some((fs_and_up_snapshots, under_fs_snapshots)) = snapshots.flatten() {
output.with_state_mut(|state| { output.with_state_mut(|state| {
state.new_wait_layout_transaction( state.new_wait_layout_transaction(
self.pinnacle.loop_handle.clone(), self.pinnacle.loop_handle.clone(),

View file

@ -116,7 +116,7 @@ impl XwmHandler for State {
output.with_state_mut(|state| state.focus_stack.set_focus(window.clone())); output.with_state_mut(|state| state.focus_stack.set_focus(window.clone()));
self.update_keyboard_focus(&output); self.update_keyboard_focus(&output);
if let Some((fs_and_up_snapshots, under_fs_snapshots)) = snapshots { if let Some((fs_and_up_snapshots, under_fs_snapshots)) = snapshots.flatten() {
output.with_state_mut(|state| { output.with_state_mut(|state| {
state.new_wait_layout_transaction( state.new_wait_layout_transaction(
self.pinnacle.loop_handle.clone(), self.pinnacle.loop_handle.clone(),
@ -426,7 +426,7 @@ impl State {
self.pinnacle.remove_window(&win, false); self.pinnacle.remove_window(&win, false);
if let Some(output) = win.output(&self.pinnacle) { if let Some(output) = win.output(&self.pinnacle) {
if let Some((fs_and_up_snapshots, under_fs_snapshots)) = snapshots { if let Some((fs_and_up_snapshots, under_fs_snapshots)) = snapshots.flatten() {
output.with_state_mut(|state| { output.with_state_mut(|state| {
state.new_wait_layout_transaction( state.new_wait_layout_transaction(
self.pinnacle.loop_handle.clone(), self.pinnacle.loop_handle.clone(),

View file

@ -267,7 +267,7 @@ impl State {
.fulfilled_requests .fulfilled_requests
.insert(output.clone(), current_pending); .insert(output.clone(), current_pending);
let (fs_and_up_snapshots, under_fs_snapshots) = self.backend.with_renderer(|renderer| { let snapshots = self.backend.with_renderer(|renderer| {
capture_snapshots_on_output(&mut self.pinnacle, renderer, &output, []) capture_snapshots_on_output(&mut self.pinnacle, renderer, &output, [])
}); });
@ -278,7 +278,7 @@ impl State {
output.with_state_mut(|state| { output.with_state_mut(|state| {
if let Some(ts) = state.layout_transaction.as_mut() { if let Some(ts) = state.layout_transaction.as_mut() {
ts.update_pending(pending_windows); ts.update_pending(pending_windows);
} else { } else if let Some((fs_and_up_snapshots, under_fs_snapshots)) = snapshots {
state.layout_transaction = Some(LayoutTransaction::new( state.layout_transaction = Some(LayoutTransaction::new(
self.pinnacle.loop_handle.clone(), self.pinnacle.loop_handle.clone(),
fs_and_up_snapshots, fs_and_up_snapshots,