Fix behaviour of window resizing on Windows.

This commit is contained in:
Josh Matthews 2019-06-01 14:40:07 -04:00
parent 9d9fff3b0a
commit 4c0afcea97
3 changed files with 14 additions and 1 deletions

View file

@ -19,6 +19,15 @@ impl GlContext {
GlContext::None => unreachable!(),
}
}
pub fn resize(&mut self, size: glutin::dpi::PhysicalSize) {
if let GlContext::NotCurrent(_) = self {
self.make_current();
}
match self {
GlContext::Current(c) => c.resize(size),
_ => unreachable!(),
}
}
pub fn make_current(&mut self) {
*self = match std::mem::replace(self, GlContext::None) {
GlContext::Current(c) => {

View file

@ -441,7 +441,8 @@ impl WindowPortsMethods for Window {
self.event_queue.borrow_mut().push(WindowEvent::Quit);
},
glutin::WindowEvent::Resized(size) => {
self.gl_context.borrow_mut().window().set_inner_size(size);
let physical_size = size.to_physical(self.device_hidpi_factor().get() as f64);
self.gl_context.borrow_mut().resize(physical_size);
// window.set_inner_size() takes DeviceIndependentPixel.
let (width, height) = size.into();
let new_size = TypedSize2D::new(width, height);