mirror of
https://github.com/italicsjenga/winit-sonoma-fix.git
synced 2025-01-11 21:31:29 +11:00
iOS: convert touch positions to physical (#1551)
This commit is contained in:
parent
b4c6cdf9a3
commit
007b195a5e
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
- On Windows, fix window intermittently hanging when `ControlFlow` was set to `Poll`.
|
- On Windows, fix window intermittently hanging when `ControlFlow` was set to `Poll`.
|
||||||
- On Windows, fix `WindowBuilder::with_maximized` being ignored.
|
- On Windows, fix `WindowBuilder::with_maximized` being ignored.
|
||||||
|
- On iOS, touch positions are now properly converted to physical pixels.
|
||||||
|
|
||||||
# 0.22.1 (2020-04-16)
|
# 0.22.1 (2020-04-16)
|
||||||
|
|
||||||
|
|
|
@ -6,6 +6,7 @@ use objc::{
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
|
dpi::PhysicalPosition,
|
||||||
event::{DeviceId as RootDeviceId, Event, Force, Touch, TouchPhase, WindowEvent},
|
event::{DeviceId as RootDeviceId, Event, Force, Touch, TouchPhase, WindowEvent},
|
||||||
platform::ios::MonitorHandleExtIOS,
|
platform::ios::MonitorHandleExtIOS,
|
||||||
platform_impl::platform::{
|
platform_impl::platform::{
|
||||||
|
@ -209,7 +210,7 @@ unsafe fn get_view_class(root_view_class: &'static Class) -> &'static Class {
|
||||||
if touch == nil {
|
if touch == nil {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
let location: CGPoint = msg_send![touch, locationInView: nil];
|
let logical_location: CGPoint = msg_send![touch, locationInView: nil];
|
||||||
let touch_type: UITouchType = msg_send![touch, type];
|
let touch_type: UITouchType = msg_send![touch, type];
|
||||||
let force = if os_supports_force {
|
let force = if os_supports_force {
|
||||||
let trait_collection: id = msg_send![object, traitCollection];
|
let trait_collection: id = msg_send![object, traitCollection];
|
||||||
|
@ -248,12 +249,19 @@ unsafe fn get_view_class(root_view_class: &'static Class) -> &'static Class {
|
||||||
_ => panic!("unexpected touch phase: {:?}", phase as i32),
|
_ => panic!("unexpected touch phase: {:?}", phase as i32),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
let physical_location = {
|
||||||
|
let scale_factor: CGFloat = msg_send![object, contentScaleFactor];
|
||||||
|
PhysicalPosition::from_logical::<(f64, f64), f64>(
|
||||||
|
(logical_location.x as _, logical_location.y as _),
|
||||||
|
scale_factor,
|
||||||
|
)
|
||||||
|
};
|
||||||
touch_events.push(EventWrapper::StaticEvent(Event::WindowEvent {
|
touch_events.push(EventWrapper::StaticEvent(Event::WindowEvent {
|
||||||
window_id: RootWindowId(window.into()),
|
window_id: RootWindowId(window.into()),
|
||||||
event: WindowEvent::Touch(Touch {
|
event: WindowEvent::Touch(Touch {
|
||||||
device_id: RootDeviceId(DeviceId { uiscreen }),
|
device_id: RootDeviceId(DeviceId { uiscreen }),
|
||||||
id: touch_id,
|
id: touch_id,
|
||||||
location: (location.x as f64, location.y as f64).into(),
|
location: physical_location,
|
||||||
force,
|
force,
|
||||||
phase,
|
phase,
|
||||||
}),
|
}),
|
||||||
|
|
Loading…
Reference in a new issue