Introduce FingerId (#3783)

This commit is contained in:
daxpedda 2024-08-08 00:36:36 +02:00 committed by GitHub
parent f07153b8e0
commit 9dff801f93
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
24 changed files with 329 additions and 113 deletions

View file

@ -43,6 +43,15 @@ impl DeviceId {
// Constant device ID; to be removed when if backend is updated to report real device IDs.
pub(crate) const DEVICE_ID: RootDeviceId = RootDeviceId(DeviceId);
#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct FingerId;
impl FingerId {
pub const fn dummy() -> Self {
FingerId
}
}
#[derive(Debug)]
pub enum OsError {
CGError(core_graphics::base::CGError),

View file

@ -38,6 +38,15 @@ impl DeviceId {
pub(crate) const DEVICE_ID: RootDeviceId = RootDeviceId(DeviceId);
#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct FingerId(usize);
impl FingerId {
pub const fn dummy() -> Self {
FingerId(0)
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct KeyEventExtra {}

View file

@ -14,9 +14,9 @@ use objc2_ui_kit::{
use super::app_state::{self, EventWrapper};
use super::window::WinitUIWindow;
use super::DEVICE_ID;
use super::{FingerId, DEVICE_ID};
use crate::dpi::PhysicalPosition;
use crate::event::{Event, Force, Touch, TouchPhase, WindowEvent};
use crate::event::{Event, FingerId as RootFingerId, Force, Touch, TouchPhase, WindowEvent};
use crate::window::{WindowAttributes, WindowId as RootWindowId};
pub struct WinitViewState {
@ -480,7 +480,7 @@ impl WinitView {
} else {
None
};
let touch_id = touch as *const UITouch as u64;
let touch_id = touch as *const UITouch as usize;
let phase = touch.phase();
let phase = match phase {
UITouchPhase::Began => TouchPhase::Started,
@ -502,7 +502,7 @@ impl WinitView {
window_id: RootWindowId(window.id()),
event: WindowEvent::Touch(Touch {
device_id: DEVICE_ID,
id: touch_id,
finger_id: RootFingerId(FingerId(touch_id)),
location: physical_location,
force,
phase,