refactor(window): get hidpi factor from winit across platform

This commit is contained in:
OJ Kwon 2018-06-29 19:28:02 -07:00 committed by UK992
parent 679af055e2
commit e0699492db

View file

@ -620,14 +620,7 @@ impl Window {
Some(device_pixels_per_px) => TypedScale::new(device_pixels_per_px),
None => match opts::get().output_file {
Some(_) => TypedScale::new(1.0),
None => self.platform_hidpi_factor()
}
}
}
#[cfg(not(target_os = "windows"))]
fn platform_hidpi_factor(&self) -> TypedScale<f32, DeviceIndependentPixel, DevicePixel> {
match self.kind {
None => match self.kind {
WindowKind::Window(ref window, ..) => {
TypedScale::new(window.get_hidpi_factor() as f32)
}
@ -636,12 +629,7 @@ impl Window {
}
}
}
#[cfg(target_os = "windows")]
fn platform_hidpi_factor(&self) -> TypedScale<f32, DeviceIndependentPixel, DevicePixel> {
let hdc = unsafe { user32::GetDC(::std::ptr::null_mut()) };
let ppi = unsafe { gdi32::GetDeviceCaps(hdc, winapi::wingdi::LOGPIXELSY) };
TypedScale::new(ppi as f32 / 96.0)
}
}
/// Has no effect on Android.