Skip to content

Commit

Permalink
Move resume/suspend to top of file
Browse files Browse the repository at this point in the history
  • Loading branch information
nicoburns committed Jul 23, 2024
1 parent 16f53b8 commit bd25108
Showing 1 changed file with 26 additions and 26 deletions.
52 changes: 26 additions & 26 deletions packages/dioxus-blitz/src/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,32 @@ impl<'a, Doc: DocumentLike> View<'a, Doc> {
}

impl<'a, Doc: DocumentLike> View<'a, Doc> {
pub fn resume(&mut self, rt: &tokio::runtime::Runtime) {
let device = self.viewport.make_device();
self.dom.as_mut().set_stylist_device(device);
self.dom.as_mut().set_scale(self.viewport.scale());

rt.block_on(self.renderer.resume(&self.viewport));

if !self.renderer.is_active() {
panic!("Renderer failed to resume");
};

self.dom.as_mut().resolve();

self.waker = Some(crate::waker::tao_waker(
&self.event_loop_proxy,
self.window_id(),
));
self.renderer
.render(self.dom.as_ref(), self.viewport.scale_f64(), self.devtools);
}

pub fn suspend(&mut self) {
self.waker = None;
self.renderer.suspend();
}

pub(crate) fn poll(&mut self) -> bool {
match &self.waker {
None => false,
Expand Down Expand Up @@ -393,32 +419,6 @@ impl<'a, Doc: DocumentLike> View<'a, Doc> {
}
}
}

pub fn resume(&mut self, rt: &tokio::runtime::Runtime) {
let device = self.viewport.make_device();
self.dom.as_mut().set_stylist_device(device);
self.dom.as_mut().set_scale(self.viewport.scale());

rt.block_on(self.renderer.resume(&self.viewport));

if !self.renderer.is_active() {
panic!("Renderer failed to resume");
};

self.dom.as_mut().resolve();

self.waker = Some(crate::waker::tao_waker(
&self.event_loop_proxy,
self.window_id(),
));
self.renderer
.render(self.dom.as_ref(), self.viewport.scale_f64(), self.devtools);
}

pub fn suspend(&mut self) {
self.waker = None;
self.renderer.suspend();
}
}

/// Initialize the default menu bar.
Expand Down

0 comments on commit bd25108

Please sign in to comment.