Fix macOS window sizes to follow convention with changelog entry (#435)

* Fix macOS window sizes to follow convention

* Add changelog entry
This commit is contained in:
Ed Barnard 2018-04-05 20:51:15 +01:00 committed by Francesca Frangipane
parent 580321b56f
commit 591e0d9b8e
2 changed files with 7 additions and 3 deletions

View file

@ -560,22 +560,25 @@ impl Window2 {
pub fn get_inner_size(&self) -> Option<(u32, u32)> {
unsafe {
let view_frame = NSView::frame(*self.view);
Some((view_frame.size.width as u32, view_frame.size.height as u32))
let factor = self.hidpi_factor() as f64; // API convention is that size is in physical pixels
Some(((view_frame.size.width*factor) as u32, (view_frame.size.height*factor) as u32))
}
}
#[inline]
pub fn get_outer_size(&self) -> Option<(u32, u32)> {
let factor = self.hidpi_factor() as f64; // API convention is that size is in physical pixels
unsafe {
let window_frame = NSWindow::frame(*self.window);
Some((window_frame.size.width as u32, window_frame.size.height as u32))
Some(((window_frame.size.width*factor) as u32, (window_frame.size.height*factor) as u32))
}
}
#[inline]
pub fn set_inner_size(&self, width: u32, height: u32) {
let factor = self.hidpi_factor() as f64; // API convention is that size is in physical pixels
unsafe {
NSWindow::setContentSize_(*self.window, NSSize::new(width as f64, height as f64));
NSWindow::setContentSize_(*self.window, NSSize::new((width as f64)/factor, (height as f64)/factor));
}
}