mirror of
https://github.com/servo/servo.git
synced 2025-08-03 20:50:07 +01:00
refactor(window): get hidpi factor from winit across platform
This commit is contained in:
parent
679af055e2
commit
e0699492db
1 changed files with 8 additions and 20 deletions
|
@ -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.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue