winit: Schedule render after transaction finish
Some checks are pending
CI (Pinnacle) / Build (push) Waiting to run
CI (Pinnacle) / Run tests (push) Waiting to run
CI (Pinnacle) / Check formatting (push) Waiting to run
CI (Pinnacle) / Clippy check (push) Waiting to run

Fixes #255
This commit is contained in:
Ottatop 2024-06-18 17:45:34 -05:00
parent 39fd958fae
commit fe182fdfcb
2 changed files with 13 additions and 9 deletions

View file

@ -254,8 +254,8 @@ impl Winit {
/// Render the winit window if a render has been scheduled. /// Render the winit window if a render has been scheduled.
pub fn render_if_scheduled(&mut self, pinnacle: &mut Pinnacle) { pub fn render_if_scheduled(&mut self, pinnacle: &mut Pinnacle) {
if self.output_render_scheduled { if self.output_render_scheduled {
self.render_winit_window(pinnacle);
self.output_render_scheduled = false; self.output_render_scheduled = false;
self.render_winit_window(pinnacle);
} }
} }
@ -343,7 +343,11 @@ impl Winit {
)); ));
} }
let mut clear_snapshots = false; // HACK: Taking the transaction before creating render elements
// leads to a possibility where the original buffer still gets displayed.
// Need to figure that out.
// In the meantime we take the transaction afterwards and schedule another render.
let mut render_after_transaction_finish = false;
self.output.with_state_mut(|state| { self.output.with_state_mut(|state| {
if state if state
.layout_transaction .layout_transaction
@ -351,16 +355,10 @@ impl Winit {
.is_some_and(|ts| ts.ready()) .is_some_and(|ts| ts.ready())
{ {
state.layout_transaction.take(); state.layout_transaction.take();
clear_snapshots = true; render_after_transaction_finish = true;
} }
}); });
if clear_snapshots {
for win in pinnacle.windows.iter() {
win.with_state_mut(|state| state.snapshot.take());
}
}
let render_res = self.backend.bind().and_then(|_| { let render_res = self.backend.bind().and_then(|_| {
let age = if *full_redraw > 0 { let age = if *full_redraw > 0 {
0 0
@ -447,6 +445,11 @@ impl Winit {
warn!("{}", err); warn!("{}", err);
} }
} }
// At the end cuz borrow checker
if render_after_transaction_finish {
self.schedule_render();
}
} }
} }

View file

@ -403,6 +403,7 @@ impl Pinnacle {
pub fn shutdown(&mut self) { pub fn shutdown(&mut self) {
info!("Shutting down Pinnacle"); info!("Shutting down Pinnacle");
self.loop_signal.stop(); self.loop_signal.stop();
self.loop_signal.wakeup();
if let Some(join_handle) = self.config.config_join_handle.take() { if let Some(join_handle) = self.config.config_join_handle.take() {
join_handle.abort(); join_handle.abort();
} }