Only send the request-redraw on the next animation frame

This commit is contained in:
Ryan Goldstein 2019-04-29 15:39:43 -04:00
parent fe5e300062
commit 9f801cf79e

View file

@ -12,7 +12,7 @@ use stdweb::{
unstable::TryInto unstable::TryInto
}; };
use stdweb::web::{ use stdweb::web::{
document, document, window,
html_element::CanvasElement, html_element::CanvasElement,
}; };
@ -21,7 +21,6 @@ pub struct MonitorHandle;
impl MonitorHandle { impl MonitorHandle {
pub fn get_hidpi_factor(&self) -> f64 { pub fn get_hidpi_factor(&self) -> f64 {
// TODO
1.0 1.0
} }
@ -72,10 +71,10 @@ impl Window {
register(&target.runner, &canvas); register(&target.runner, &canvas);
let runner = target.runner.clone(); let runner = target.runner.clone();
let redraw = Box::new(move || runner.send_event(Event::WindowEvent { let redraw = Box::new(move || window().request_animation_frame(|| runner.send_event(Event::WindowEvent {
window_id: RootWI(WindowId), window_id: RootWI(WindowId),
event: WindowEvent::RedrawRequested event: WindowEvent::RedrawRequested
})); })));
let window = Window { let window = Window {
canvas, canvas,
@ -95,7 +94,6 @@ impl Window {
height: 768.0, height: 768.0,
}) })
} }
// TODO: most of these are no-op, but should they stay here just in case?
window.set_min_dimensions(attr.min_dimensions); window.set_min_dimensions(attr.min_dimensions);
window.set_max_dimensions(attr.max_dimensions); window.set_max_dimensions(attr.max_dimensions);
window.set_resizable(attr.resizable); window.set_resizable(attr.resizable);
@ -191,7 +189,6 @@ impl Window {
#[inline] #[inline]
pub fn get_hidpi_factor(&self) -> f64 { pub fn get_hidpi_factor(&self) -> f64 {
// TODO
1.0 1.0
} }
@ -286,7 +283,7 @@ impl Window {
#[inline] #[inline]
pub fn set_window_icon(&self, _window_icon: Option<Icon>) { pub fn set_window_icon(&self, _window_icon: Option<Icon>) {
// TODO: should this set the favicon? // Currently an intentional no-op
} }
#[inline] #[inline]