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

@ -5,6 +5,7 @@
- On X11, input method creation first tries to use the value from the user's `XMODIFIERS` environment variable, so application developers should no longer need to manually call `XSetLocaleModifiers`. If that fails, fallbacks are tried, which should prevent input method initialization from ever outright failing.
- Fixed thread safety issues with input methods on X11.
- Add support for `Touch` for win32 backend.
- Fixed `Window::get_inner_size` and friends to return the size in pixels instead of points when using HIDPI displays on OSX.
# Version 0.11.3 (2018-03-28)

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));
}
}