Make size/position types generic over pixel type (#1277)

* Begin implementing DPI generics

* Fix multithreaded example

* Format

* Fix serde test

* hopefully fix most of the errors

* Fix dpi module errors

* More error fixings

* Format

* fix macos errors

* Another error pass

* Replace bad type signatures

* more fixins
This commit is contained in:
Osspial 2020-01-04 01:33:07 -05:00
parent b16042a047
commit 3a1e694c2f
40 changed files with 388 additions and 336 deletions

View file

@ -707,7 +707,7 @@ unsafe extern "system" fn public_window_callback<T: 'static>(
let windowpos = lparam as *const winuser::WINDOWPOS;
if (*windowpos).flags & winuser::SWP_NOMOVE != winuser::SWP_NOMOVE {
let physical_position =
PhysicalPosition::new((*windowpos).x as f64, (*windowpos).y as f64);
PhysicalPosition::new((*windowpos).x as u32, (*windowpos).y as u32);
subclass_input.send_event(Event::WindowEvent {
window_id: RootWindowId(WindowId(window)),
event: Moved(physical_position),
@ -829,8 +829,8 @@ unsafe extern "system" fn public_window_callback<T: 'static>(
});
}
let x = windowsx::GET_X_LPARAM(lparam) as f64;
let y = windowsx::GET_Y_LPARAM(lparam) as f64;
let x = windowsx::GET_X_LPARAM(lparam) as i32;
let y = windowsx::GET_Y_LPARAM(lparam) as i32;
let position = PhysicalPosition::new(x, y);
subclass_input.send_event(Event::WindowEvent {
@ -1489,8 +1489,8 @@ unsafe extern "system" fn public_window_callback<T: 'static>(
// We calculate our own size because the default suggested rect doesn't do a great job
// of preserving the window's logical size.
let suggested_physical_inner_size = old_physical_inner_size
.to_logical(old_dpi_factor)
.to_physical(new_dpi_factor);
.to_logical::<f64>(old_dpi_factor)
.to_physical::<u32>(new_dpi_factor);
// `allow_resize` prevents us from re-applying DPI adjustment to the restored size after
// exiting fullscreen (the restored size is already DPI adjusted).