From e0699492db7eae268b0ff59d5c217f827a63033e Mon Sep 17 00:00:00 2001 From: OJ Kwon Date: Fri, 29 Jun 2018 19:28:02 -0700 Subject: [PATCH] refactor(window): get hidpi factor from winit across platform --- ports/servo/glutin_app/window.rs | 28 ++++++++-------------------- 1 file changed, 8 insertions(+), 20 deletions(-) diff --git a/ports/servo/glutin_app/window.rs b/ports/servo/glutin_app/window.rs index 16beaa01904..514b1f8c076 100644 --- a/ports/servo/glutin_app/window.rs +++ b/ports/servo/glutin_app/window.rs @@ -620,30 +620,18 @@ 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() + None => match self.kind { + WindowKind::Window(ref window, ..) => { + TypedScale::new(window.get_hidpi_factor() as f32) + } + WindowKind::Headless(..) => { + TypedScale::new(1.0) + } + } } } } - #[cfg(not(target_os = "windows"))] - fn platform_hidpi_factor(&self) -> TypedScale { - match self.kind { - WindowKind::Window(ref window, ..) => { - TypedScale::new(window.get_hidpi_factor() as f32) - } - WindowKind::Headless(..) => { - TypedScale::new(1.0) - } - } - } - - #[cfg(target_os = "windows")] - fn platform_hidpi_factor(&self) -> TypedScale { - 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. pub fn set_cursor(&self, cursor: CursorKind) { match self.kind {