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:
parent
85ea3f1d5d
commit
d29f7f34aa
34 changed files with 252 additions and 248 deletions
|
|
@ -1415,7 +1415,7 @@ unsafe extern "system" fn public_window_callback<T: 'static>(
|
|||
// Only sent on Windows 8.1 or newer. On Windows 7 and older user has to log out to change
|
||||
// DPI, therefore all applications are closed while DPI is changing.
|
||||
winuser::WM_DPICHANGED => {
|
||||
use crate::event::WindowEvent::HiDpiFactorChanged;
|
||||
use crate::event::WindowEvent::DpiChanged;
|
||||
|
||||
// This message actually provides two DPI values - x and y. However MSDN says that
|
||||
// "you only need to use either the X-axis or the Y-axis value when scaling your
|
||||
|
|
@ -1499,8 +1499,8 @@ unsafe extern "system" fn public_window_callback<T: 'static>(
|
|||
|
||||
let _ = subclass_input.send_event_unbuffered(Event::WindowEvent {
|
||||
window_id: RootWindowId(WindowId(window)),
|
||||
event: HiDpiFactorChanged {
|
||||
hidpi_factor: new_dpi_factor,
|
||||
event: DpiChanged {
|
||||
scale_factor: new_dpi_factor,
|
||||
new_inner_size: &mut new_physical_inner_size,
|
||||
},
|
||||
});
|
||||
|
|
|
|||
|
|
@ -203,7 +203,7 @@ impl MonitorHandle {
|
|||
}
|
||||
|
||||
#[inline]
|
||||
pub fn hidpi_factor(&self) -> f64 {
|
||||
pub fn scale_factor(&self) -> f64 {
|
||||
dpi_to_scale_factor(get_monitor_dpi(self.0).unwrap_or(96))
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -164,7 +164,7 @@ impl Window {
|
|||
|
||||
#[inline]
|
||||
pub fn set_outer_position(&self, position: Position) {
|
||||
let (x, y): (i32, i32) = position.to_physical::<i32>(self.hidpi_factor()).into();
|
||||
let (x, y): (i32, i32) = position.to_physical::<i32>(self.scale_factor()).into();
|
||||
|
||||
let window_state = Arc::clone(&self.window_state);
|
||||
let window = self.window.clone();
|
||||
|
|
@ -249,7 +249,7 @@ impl Window {
|
|||
|
||||
#[inline]
|
||||
pub fn set_inner_size(&self, size: Size) {
|
||||
let dpi_factor = self.hidpi_factor();
|
||||
let dpi_factor = self.scale_factor();
|
||||
let (width, height) = size.to_physical::<u32>(dpi_factor).into();
|
||||
|
||||
let window_state = Arc::clone(&self.window_state);
|
||||
|
|
@ -356,13 +356,13 @@ impl Window {
|
|||
}
|
||||
|
||||
#[inline]
|
||||
pub fn hidpi_factor(&self) -> f64 {
|
||||
pub fn scale_factor(&self) -> f64 {
|
||||
self.window_state.lock().dpi_factor
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn set_cursor_position(&self, position: Position) -> Result<(), ExternalError> {
|
||||
let dpi_factor = self.hidpi_factor();
|
||||
let dpi_factor = self.scale_factor();
|
||||
let (x, y) = position.to_physical::<i32>(dpi_factor).into();
|
||||
|
||||
let mut point = POINT { x, y };
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue