Skip to content
Permalink
Browse files

Don't process events while borrowing the event loop

  • Loading branch information...
asajeffrey committed Jun 14, 2019
1 parent e381ceb commit ea4b1631dd3e2564c8406267e1a0c3751be3d4bc
Showing with 11 additions and 19 deletions.
  1. +11 −19 ports/glutin/app.rs
@@ -101,29 +101,21 @@ impl App {
}

fn run_loop(self) {
let mut stop = false;
loop {
let mut events_loop = self.events_loop.borrow_mut();
if self.window.is_animating() && !self.suspended.get() {
// We block on compositing (self.handle_events() ends up calling swap_buffers)
events_loop.poll_events(|e| {
if !self.window.is_animating() || self.suspended.get() {
// If there's no animations running then we block on the window event loop.
self.events_loop.borrow_mut().run_forever(|e| {
self.winit_event_to_servo_event(e);
});
stop = self.handle_events();
} else {
// We block on winit's event loop (window events)
events_loop.run_forever(|e| {
self.winit_event_to_servo_event(e);
if self.has_events() && !self.suspended.get() {
stop = self.handle_events();
}
if stop || self.window.is_animating() && !self.suspended.get() {
glutin::ControlFlow::Break
} else {
glutin::ControlFlow::Continue
}
glutin::ControlFlow::Break
});
}
// Grab any other events that may have happened
self.events_loop.borrow_mut().poll_events(|e| {
self.winit_event_to_servo_event(e);
});
// If animations are running, we block on compositing
// (self.handle_events() ends up calling swap_buffers)
let stop = self.handle_events();
if stop {
break;
}

0 comments on commit ea4b163

Please sign in to comment.
You can’t perform that action at this time.