Rename hidpi_factor to scale_factor (#1334)

* Rename hidpi_factor to scale_factor

* Deprecate WINIT_HIDPI_FACTOR environment variable in favor of WINIT_X11_SCALE_FACTOR

* Rename HiDpiFactorChanged to DpiChanged and update docs

I'm renaming it to DpiChanged instead of ScaleFactorChanged, since I'd
like Winit to expose the raw DPI value at some point in the near future,
and DpiChanged is a more apt name for that purpose.

* Format

* Fix macos and ios again

* Fix bad macos rebase
This commit is contained in:
Osspial 2020-01-03 14:52:27 -05:00
parent 85ea3f1d5d
commit d29f7f34aa
34 changed files with 252 additions and 248 deletions

View file

@ -734,8 +734,8 @@ impl<T> EventLoop<T> {
callback(Event::WindowEvent {
window_id,
event: WindowEvent::HiDpiFactorChanged {
hidpi_factor: dpi,
event: WindowEvent::DpiChanged {
scale_factor: dpi,
new_inner_size: &mut new_inner_size,
},
});
@ -1007,7 +1007,7 @@ impl fmt::Debug for MonitorHandle {
native_identifier: u32,
size: PhysicalSize<u32>,
position: PhysicalPosition<i32>,
hidpi_factor: i32,
scale_factor: i32,
}
let monitor_id_proxy = MonitorHandle {
@ -1015,7 +1015,7 @@ impl fmt::Debug for MonitorHandle {
native_identifier: self.native_identifier(),
size: self.size(),
position: self.position(),
hidpi_factor: self.hidpi_factor(),
scale_factor: self.scale_factor(),
};
monitor_id_proxy.fmt(f)
@ -1055,7 +1055,7 @@ impl MonitorHandle {
}
#[inline]
pub fn hidpi_factor(&self) -> i32 {
pub fn scale_factor(&self) -> i32 {
self.mgr
.with_info(&self.proxy, |_, info| info.scale_factor)
.unwrap_or(1)

View file

@ -221,7 +221,7 @@ impl Window {
}
pub fn inner_size(&self) -> PhysicalSize<u32> {
let dpi = self.hidpi_factor() as f64;
let dpi = self.scale_factor() as f64;
let size = LogicalSize::<f64>::from(*self.size.lock().unwrap());
size.to_physical(dpi)
}
@ -232,7 +232,7 @@ impl Window {
#[inline]
pub fn outer_size(&self) -> PhysicalSize<u32> {
let dpi = self.hidpi_factor() as f64;
let dpi = self.scale_factor() as f64;
let (w, h) = self.size.lock().unwrap().clone();
// let (w, h) = super::wayland_window::add_borders(w as i32, h as i32);
let size = LogicalSize::<f64>::from((w, h));
@ -242,7 +242,7 @@ impl Window {
#[inline]
// NOTE: This will only resize the borders, the contents must be updated by the user
pub fn set_inner_size(&self, size: Size) {
let dpi = self.hidpi_factor() as f64;
let dpi = self.scale_factor() as f64;
let (w, h) = size.to_logical::<u32>(dpi).into();
self.frame.lock().unwrap().resize(w, h);
*(self.size.lock().unwrap()) = (w, h);
@ -250,7 +250,7 @@ impl Window {
#[inline]
pub fn set_min_inner_size(&self, dimensions: Option<Size>) {
let dpi = self.hidpi_factor() as f64;
let dpi = self.scale_factor() as f64;
self.frame
.lock()
.unwrap()
@ -259,7 +259,7 @@ impl Window {
#[inline]
pub fn set_max_inner_size(&self, dimensions: Option<Size>) {
let dpi = self.hidpi_factor() as f64;
let dpi = self.scale_factor() as f64;
self.frame
.lock()
.unwrap()
@ -272,7 +272,7 @@ impl Window {
}
#[inline]
pub fn hidpi_factor(&self) -> i32 {
pub fn scale_factor(&self) -> i32 {
get_dpi_factor(&self.surface)
}