From edfb4b03f47ff29cd28d186c40b1da7fc70a2d59 Mon Sep 17 00:00:00 2001 From: Kirill Chibisov Date: Tue, 15 Oct 2024 17:26:43 +0300 Subject: [PATCH] chore: remove platform FingerId The same as for `WindowId`. --- src/event.rs | 23 +++++++++++---- src/platform/mod.rs | 1 + src/platform_impl/android/mod.rs | 25 +++++----------- src/platform_impl/apple/appkit/mod.rs | 10 ------- src/platform_impl/apple/mod.rs | 2 ++ src/platform_impl/apple/uikit/mod.rs | 10 ------- src/platform_impl/apple/uikit/view.rs | 19 ++++++------ src/platform_impl/linux/mod.rs | 18 ------------ src/platform_impl/linux/wayland/mod.rs | 10 ------- .../linux/wayland/seat/touch/mod.rs | 29 ++++++++++--------- .../linux/x11/event_processor.rs | 9 +++--- src/platform_impl/linux/x11/mod.rs | 15 ---------- src/platform_impl/mod.rs | 1 + src/platform_impl/orbital/mod.rs | 10 ------- src/platform_impl/web/event.rs | 24 +-------------- src/platform_impl/web/mod.rs | 1 - src/platform_impl/web/web_sys/event.rs | 5 ++-- src/platform_impl/windows/event_loop.rs | 9 +++--- src/platform_impl/windows/keyboard.rs | 10 +++---- src/platform_impl/windows/mod.rs | 12 -------- 20 files changed, 71 insertions(+), 172 deletions(-) diff --git a/src/event.rs b/src/event.rs index 2420f6f85c..7c56417d4a 100644 --- a/src/event.rs +++ b/src/event.rs @@ -634,12 +634,23 @@ impl DeviceId { /// Whenever a touch event is received it contains a `FingerId` which uniquely identifies the finger /// used for the current interaction. #[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)] -pub struct FingerId(pub(crate) platform_impl::FingerId); +pub struct FingerId(pub(crate) usize); impl FingerId { - #[cfg(test)] - pub(crate) const fn dummy() -> Self { - FingerId(platform_impl::FingerId::dummy()) + /// Convert the [`FingerId`] into the underlying integer. + /// + /// This is useful if you need to pass the ID across an FFI boundary, or store it in an atomic. + #[allow(dead_code)] + pub(crate) const fn into_raw(self) -> usize { + self.0 + } + + /// Construct a [`FingerId`] from the underlying integer. + /// + /// This should only be called with integers returned from [`FingerId::into_raw`]. + #[allow(dead_code)] + pub(crate) const fn from_raw(id: usize) -> Self { + Self(id) } } @@ -1154,7 +1165,7 @@ mod tests { ($closure:expr) => {{ #[allow(unused_mut)] let mut x = $closure; - let fid = event::FingerId::dummy(); + let fid = event::FingerId::from_raw(0); #[allow(deprecated)] { @@ -1291,7 +1302,7 @@ mod tests { }); let _ = event::StartCause::Init.clone(); - let fid = crate::event::FingerId::dummy().clone(); + let fid = crate::event::FingerId::from_raw(0).clone(); HashSet::new().insert(fid); let mut set = [fid, fid, fid]; set.sort_unstable(); diff --git a/src/platform/mod.rs b/src/platform/mod.rs index 4f59303ed9..c6b0e1b45c 100644 --- a/src/platform/mod.rs +++ b/src/platform/mod.rs @@ -21,6 +21,7 @@ pub mod windows; #[cfg(any(x11_platform, docsrs))] pub mod x11; +#[allow(unused_imports)] #[cfg(any( windows_platform, macos_platform, diff --git a/src/platform_impl/android/mod.rs b/src/platform_impl/android/mod.rs index c784e7d839..263dac7020 100644 --- a/src/platform_impl/android/mod.rs +++ b/src/platform_impl/android/mod.rs @@ -15,7 +15,7 @@ use crate::application::ApplicationHandler; use crate::cursor::Cursor; use crate::dpi::{PhysicalPosition, PhysicalSize, Position, Size}; use crate::error::{EventLoopError, NotSupportedError, RequestError}; -use crate::event::{self, DeviceId, Force, StartCause, SurfaceSizeWriter}; +use crate::event::{self, DeviceId, FingerId, Force, StartCause, SurfaceSizeWriter}; use crate::event_loop::{ ActiveEventLoop as RootActiveEventLoop, ControlFlow, DeviceEvents, EventLoopProxy as RootEventLoopProxy, OwnedDisplayHandle as RootOwnedDisplayHandle, @@ -107,7 +107,7 @@ pub struct EventLoop { running: bool, pending_redraw: bool, cause: StartCause, - primary_pointer: FingerId, + primary_pointer: Option, ignore_volume_keys: bool, combining_accent: Option, } @@ -141,7 +141,7 @@ impl EventLoop { Ok(Self { android_app: android_app.clone(), - primary_pointer: FingerId::dummy(), + primary_pointer: None, window_target: ActiveEventLoop { app: android_app.clone(), control_flow: Cell::new(ControlFlow::default()), @@ -342,14 +342,14 @@ impl EventLoop { "Input event {device_id:?}, {action:?}, loc={position:?}, \ pointer={pointer:?}, tool_type={tool_type:?}" ); - let finger_id = event::FingerId(FingerId(pointer.pointer_id())); + let finger_id = FingerId::from_raw(pointer.pointer_id() as usize); let force = Some(Force::Normalized(pointer.pressure() as f64)); match action { MotionAction::Down | MotionAction::PointerDown => { let primary = action == MotionAction::Down; if primary { - self.primary_pointer = finger_id.0; + self.primary_pointer = Some(finger_id); } let event = event::WindowEvent::PointerEntered { device_id, @@ -382,7 +382,7 @@ impl EventLoop { app.window_event(&self.window_target, GLOBAL_WINDOW, event); }, MotionAction::Move => { - let primary = self.primary_pointer == finger_id.0; + let primary = self.primary_pointer == Some(finger_id); let event = event::WindowEvent::PointerMoved { device_id, primary, @@ -401,10 +401,10 @@ impl EventLoop { MotionAction::Up | MotionAction::PointerUp | MotionAction::Cancel => { let primary = action == MotionAction::Up || (action == MotionAction::Cancel - && self.primary_pointer == finger_id.0); + && self.primary_pointer == Some(finger_id)); if primary { - self.primary_pointer = FingerId::dummy(); + self.primary_pointer = None; } if let MotionAction::Up | MotionAction::PointerUp = action { @@ -745,15 +745,6 @@ impl OwnedDisplayHandle { } } -#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)] -pub struct FingerId(i32); - -impl FingerId { - pub const fn dummy() -> Self { - FingerId(0) - } -} - #[derive(Clone, Copy, Debug, Default, Eq, PartialEq)] pub struct PlatformSpecificWindowAttributes; diff --git a/src/platform_impl/apple/appkit/mod.rs b/src/platform_impl/apple/appkit/mod.rs index 48c1d9e872..17a593a1dc 100644 --- a/src/platform_impl/apple/appkit/mod.rs +++ b/src/platform_impl/apple/appkit/mod.rs @@ -26,13 +26,3 @@ pub(crate) use self::window_delegate::PlatformSpecificWindowAttributes; pub(crate) use crate::cursor::OnlyCursorImageSource as PlatformCustomCursorSource; pub(crate) use crate::icon::NoIcon as PlatformIcon; pub(crate) use crate::platform_impl::Fullscreen; - -#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)] -pub struct FingerId; - -impl FingerId { - #[cfg(test)] - pub const fn dummy() -> Self { - FingerId - } -} diff --git a/src/platform_impl/apple/mod.rs b/src/platform_impl/apple/mod.rs index 559492c8b5..7bb4af90e1 100644 --- a/src/platform_impl/apple/mod.rs +++ b/src/platform_impl/apple/mod.rs @@ -7,7 +7,9 @@ mod notification_center; #[cfg(not(target_os = "macos"))] mod uikit; +#[allow(unused_imports)] #[cfg(target_os = "macos")] pub use self::appkit::*; +#[allow(unused_imports)] #[cfg(not(target_os = "macos"))] pub use self::uikit::*; diff --git a/src/platform_impl/apple/uikit/mod.rs b/src/platform_impl/apple/uikit/mod.rs index b81fda2d3b..d000e978f3 100644 --- a/src/platform_impl/apple/uikit/mod.rs +++ b/src/platform_impl/apple/uikit/mod.rs @@ -21,16 +21,6 @@ pub(crate) use crate::cursor::{ pub(crate) use crate::icon::NoIcon as PlatformIcon; pub(crate) use crate::platform_impl::Fullscreen; -#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)] -pub struct FingerId(usize); - -impl FingerId { - #[cfg(test)] - pub const fn dummy() -> Self { - FingerId(0) - } -} - #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct KeyEventExtra {} diff --git a/src/platform_impl/apple/uikit/view.rs b/src/platform_impl/apple/uikit/view.rs index e6a297a2ad..21fa353e4d 100644 --- a/src/platform_impl/apple/uikit/view.rs +++ b/src/platform_impl/apple/uikit/view.rs @@ -14,11 +14,10 @@ use objc2_ui_kit::{ use super::app_state::{self, EventWrapper}; use super::window::WinitUIWindow; -use super::FingerId; use crate::dpi::PhysicalPosition; use crate::event::{ - ButtonSource, ElementState, Event, FingerId as RootFingerId, Force, KeyEvent, PointerKind, - PointerSource, TouchPhase, WindowEvent, + ButtonSource, ElementState, Event, FingerId, Force, KeyEvent, PointerKind, PointerSource, + TouchPhase, WindowEvent, }; use crate::keyboard::{Key, KeyCode, KeyLocation, NamedKey, NativeKeyCode, PhysicalKey}; use crate::platform_impl::KeyEventExtra; @@ -35,7 +34,7 @@ pub struct WinitViewState { pinch_last_delta: Cell, pan_last_delta: Cell, - primary_finger: Cell>, + primary_finger: Cell>, fingers: Cell, } @@ -519,7 +518,7 @@ impl WinitView { ) }; let window_id = window.id(); - let finger_id = RootFingerId(FingerId(touch_id)); + let finger_id = FingerId::from_raw(touch_id); let ivars = self.ivars(); @@ -529,15 +528,17 @@ impl WinitView { true } else { ivars.fingers.set(ivars.fingers.get() + 1); + // Keep the primary finger around until we clear all the fingers to + // recognize it when user briefly removes it. match ivars.primary_finger.get() { - Some(primary_id) => primary_id == touch_id, + Some(primary_id) => primary_id == finger_id, None => { debug_assert_eq!( ivars.fingers.get(), 1, "number of fingers were not counted correctly" ); - ivars.primary_finger.set(Some(touch_id)); + ivars.primary_finger.set(Some(finger_id)); true }, } @@ -575,7 +576,7 @@ impl WinitView { let (primary, source) = if let UITouchType::Pencil = touch_type { (true, PointerSource::Unknown) } else { - (ivars.primary_finger.get().unwrap() == touch_id, PointerSource::Touch { + (ivars.primary_finger.get().unwrap() == finger_id, PointerSource::Touch { finger_id, force, }) @@ -597,7 +598,7 @@ impl WinitView { true } else { ivars.fingers.set(ivars.fingers.get() - 1); - let primary = ivars.primary_finger.get().unwrap() == touch_id; + let primary = ivars.primary_finger.get().unwrap() == finger_id; if ivars.fingers.get() == 0 { ivars.primary_finger.set(None); } diff --git a/src/platform_impl/linux/mod.rs b/src/platform_impl/linux/mod.rs index 7fefb3b485..68b12bf0e3 100644 --- a/src/platform_impl/linux/mod.rs +++ b/src/platform_impl/linux/mod.rs @@ -107,24 +107,6 @@ impl Default for PlatformSpecificWindowAttributes { pub(crate) static X11_BACKEND: Lazy, XNotSupported>>> = Lazy::new(|| Mutex::new(XConnection::new(Some(x_error_callback)).map(Arc::new))); -#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)] -pub enum FingerId { - #[cfg(x11_platform)] - X(x11::FingerId), - #[cfg(wayland_platform)] - Wayland(wayland::FingerId), -} - -impl FingerId { - #[cfg(test)] - pub const fn dummy() -> Self { - #[cfg(wayland_platform)] - return FingerId::Wayland(wayland::FingerId::dummy()); - #[cfg(all(not(wayland_platform), x11_platform))] - return FingerId::X(x11::FingerId::dummy()); - } -} - #[derive(Debug, Clone, PartialEq, Eq, Hash, PartialOrd, Ord)] pub enum MonitorHandle { #[cfg(x11_platform)] diff --git a/src/platform_impl/linux/wayland/mod.rs b/src/platform_impl/linux/wayland/mod.rs index d85134fc29..6cf0c3cf1e 100644 --- a/src/platform_impl/linux/wayland/mod.rs +++ b/src/platform_impl/linux/wayland/mod.rs @@ -17,16 +17,6 @@ mod state; mod types; mod window; -#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)] -pub struct FingerId(i32); - -impl FingerId { - #[cfg(test)] - pub const fn dummy() -> Self { - FingerId(0) - } -} - /// Get the WindowId out of the surface. #[inline] fn make_wid(surface: &WlSurface) -> WindowId { diff --git a/src/platform_impl/linux/wayland/seat/touch/mod.rs b/src/platform_impl/linux/wayland/seat/touch/mod.rs index ca9d0b7554..3e41010154 100644 --- a/src/platform_impl/linux/wayland/seat/touch/mod.rs +++ b/src/platform_impl/linux/wayland/seat/touch/mod.rs @@ -8,9 +8,9 @@ use sctk::seat::touch::{TouchData, TouchHandler}; use tracing::warn; use crate::dpi::LogicalPosition; -use crate::event::{ButtonSource, ElementState, PointerKind, PointerSource, WindowEvent}; +use crate::event::{ButtonSource, ElementState, FingerId, PointerKind, PointerSource, WindowEvent}; +use crate::platform_impl::wayland; use crate::platform_impl::wayland::state::WinitState; -use crate::platform_impl::wayland::{self, FingerId}; impl TouchHandler for WinitState { fn down( @@ -40,12 +40,15 @@ impl TouchHandler for WinitState { // Update the state of the point. let location = LogicalPosition::::from(position); + // Only update primary finger once we don't have any touch. + if seat_state.touch_map.is_empty() { + seat_state.first_touch_id = Some(id); + } + let primary = seat_state.first_touch_id == Some(id); seat_state.touch_map.insert(id, TouchPoint { surface, location }); - let primary = seat_state.first_touch_id.get_or_insert(id) == &id; let position = location.to_physical(scale_factor); - let finger_id = - crate::event::FingerId(crate::platform_impl::FingerId::Wayland(FingerId(id))); + let finger_id = FingerId::from_raw(id as usize); self.events_sink.push_window_event( WindowEvent::PointerEntered { @@ -93,7 +96,10 @@ impl TouchHandler for WinitState { // Update the primary touch point. let primary = seat_state.first_touch_id == Some(id); - if primary { + // Reset primary finger once all the other fingers are lifted to not transfer primary + // finger to some other finger and still accept it when it's briefly moved between the + // windows. + if seat_state.touch_map.is_empty() { seat_state.first_touch_id = None; } @@ -104,8 +110,7 @@ impl TouchHandler for WinitState { }; let position = touch_point.location.to_physical(scale_factor); - let finger_id = - crate::event::FingerId(crate::platform_impl::FingerId::Wayland(FingerId(id))); + let finger_id = FingerId::from_raw(id as usize); self.events_sink.push_window_event( WindowEvent::PointerButton { @@ -167,9 +172,7 @@ impl TouchHandler for WinitState { primary, position: touch_point.location.to_physical(scale_factor), source: PointerSource::Touch { - finger_id: crate::event::FingerId(crate::platform_impl::FingerId::Wayland( - FingerId(id), - )), + finger_id: FingerId::from_raw(id as usize), force: None, }, }, @@ -201,9 +204,7 @@ impl TouchHandler for WinitState { device_id: None, primary, position: Some(position), - kind: PointerKind::Touch(crate::event::FingerId( - crate::platform_impl::FingerId::Wayland(FingerId(id)), - )), + kind: PointerKind::Touch(FingerId::from_raw(id as usize)), }, window_id, ); diff --git a/src/platform_impl/linux/x11/event_processor.rs b/src/platform_impl/linux/x11/event_processor.rs index 54848119d8..6ce100e850 100644 --- a/src/platform_impl/linux/x11/event_processor.rs +++ b/src/platform_impl/linux/x11/event_processor.rs @@ -22,8 +22,9 @@ use xkbcommon_dl::xkb_mod_mask_t; use crate::dpi::{PhysicalPosition, PhysicalSize}; use crate::event::{ - ButtonSource, DeviceEvent, DeviceId, ElementState, Event, Ime, MouseButton, MouseScrollDelta, - PointerKind, PointerSource, RawKeyEvent, SurfaceSizeWriter, TouchPhase, WindowEvent, + ButtonSource, DeviceEvent, DeviceId, ElementState, Event, FingerId, Ime, MouseButton, + MouseScrollDelta, PointerKind, PointerSource, RawKeyEvent, SurfaceSizeWriter, TouchPhase, + WindowEvent, }; use crate::keyboard::ModifiersState; use crate::platform_impl::common::xkb::{self, XkbState}; @@ -33,7 +34,7 @@ use crate::platform_impl::platform::x11::ActiveEventLoop; use crate::platform_impl::x11::atoms::*; use crate::platform_impl::x11::util::cookie::GenericEventCookie; use crate::platform_impl::x11::{ - mkdid, mkfid, mkwid, util, CookieResultExt, Device, DeviceInfo, Dnd, DndState, ImeReceiver, + mkdid, mkwid, util, CookieResultExt, Device, DeviceInfo, Dnd, DndState, ImeReceiver, ScrollOrientation, UnownedWindow, WindowId, }; @@ -1390,7 +1391,7 @@ impl EventProcessor { } let device_id = Some(mkdid(xev.deviceid as xinput::DeviceId)); - let finger_id = mkfid(id); + let finger_id = FingerId::from_raw(id as usize); match phase { xinput2::XI_TouchBegin => { diff --git a/src/platform_impl/linux/x11/mod.rs b/src/platform_impl/linux/x11/mod.rs index 8e72449025..e4aa8f0614 100644 --- a/src/platform_impl/linux/x11/mod.rs +++ b/src/platform_impl/linux/x11/mod.rs @@ -805,17 +805,6 @@ impl<'a> Deref for DeviceInfo<'a> { } } -#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)] -pub struct FingerId(u32); - -impl FingerId { - #[cfg(test)] - #[allow(unused)] - pub const fn dummy() -> Self { - FingerId(0) - } -} - #[derive(Clone)] pub struct EventLoopProxy { ping: Ping, @@ -994,10 +983,6 @@ fn mkdid(w: xinput::DeviceId) -> DeviceId { DeviceId::from_raw(w as i64) } -fn mkfid(w: u32) -> crate::event::FingerId { - crate::event::FingerId(crate::platform_impl::FingerId::X(FingerId(w))) -} - #[derive(Debug)] pub struct Device { _name: String, diff --git a/src/platform_impl/mod.rs b/src/platform_impl/mod.rs index bd55440b89..1425c1b151 100644 --- a/src/platform_impl/mod.rs +++ b/src/platform_impl/mod.rs @@ -22,6 +22,7 @@ use self::apple as platform; use self::linux as platform; #[cfg(orbital_platform)] use self::orbital as platform; +#[allow(unused_imports)] pub use self::platform::*; #[cfg(web_platform)] use self::web as platform; diff --git a/src/platform_impl/orbital/mod.rs b/src/platform_impl/orbital/mod.rs index 28e48de523..b0f05a12a8 100644 --- a/src/platform_impl/orbital/mod.rs +++ b/src/platform_impl/orbital/mod.rs @@ -99,16 +99,6 @@ impl TimeSocket { #[derive(Default, Debug, Copy, Clone, PartialEq, Eq, Hash)] pub(crate) struct PlatformSpecificEventLoopAttributes {} -#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)] -pub struct FingerId; - -impl FingerId { - #[cfg(test)] - pub const fn dummy() -> Self { - FingerId - } -} - #[derive(Clone, Copy, Debug, Default, Eq, PartialEq)] pub struct PlatformSpecificWindowAttributes; diff --git a/src/platform_impl/web/event.rs b/src/platform_impl/web/event.rs index 5d016aab82..69f2860e56 100644 --- a/src/platform_impl/web/event.rs +++ b/src/platform_impl/web/event.rs @@ -1,4 +1,4 @@ -use crate::event::{DeviceId, FingerId as RootFingerId}; +use crate::event::DeviceId; pub(crate) fn mkdid(pointer_id: i32) -> Option { if let Ok(pointer_id) = u32::try_from(pointer_id) { @@ -10,25 +10,3 @@ pub(crate) fn mkdid(pointer_id: i32) -> Option { None } } - -#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)] -pub struct FingerId { - pointer_id: i32, -} - -impl FingerId { - pub fn new(pointer_id: i32) -> Self { - Self { pointer_id } - } - - #[cfg(test)] - pub const fn dummy() -> Self { - Self { pointer_id: -1 } - } -} - -impl From for RootFingerId { - fn from(id: FingerId) -> Self { - Self(id) - } -} diff --git a/src/platform_impl/web/mod.rs b/src/platform_impl/web/mod.rs index 1fb80c093f..3ea7c07b55 100644 --- a/src/platform_impl/web/mod.rs +++ b/src/platform_impl/web/mod.rs @@ -37,7 +37,6 @@ pub(crate) use cursor::{ CustomCursorSource as PlatformCustomCursorSource, }; -pub use self::event::FingerId; pub(crate) use self::event_loop::{ ActiveEventLoop, EventLoop, EventLoopProxy, OwnedDisplayHandle, PlatformSpecificEventLoopAttributes, diff --git a/src/platform_impl/web/web_sys/event.rs b/src/platform_impl/web/web_sys/event.rs index 8d56459c3f..ed7f03ba8a 100644 --- a/src/platform_impl/web/web_sys/event.rs +++ b/src/platform_impl/web/web_sys/event.rs @@ -6,9 +6,8 @@ use wasm_bindgen::prelude::wasm_bindgen; use wasm_bindgen::{JsCast, JsValue}; use web_sys::{KeyboardEvent, MouseEvent, Navigator, PointerEvent, WheelEvent}; -use super::super::FingerId; use super::Engine; -use crate::event::{MouseButton, MouseScrollDelta, PointerKind}; +use crate::event::{FingerId, MouseButton, MouseScrollDelta, PointerKind}; use crate::keyboard::{Key, KeyLocation, ModifiersState, NamedKey, PhysicalKey}; bitflags::bitflags! { @@ -164,7 +163,7 @@ pub fn mouse_scroll_delta( pub fn pointer_type(event: &PointerEvent, pointer_id: i32) -> PointerKind { match event.pointer_type().as_str() { "mouse" => PointerKind::Mouse, - "touch" => PointerKind::Touch(FingerId::new(pointer_id).into()), + "touch" => PointerKind::Touch(FingerId::from_raw(pointer_id as usize)), _ => PointerKind::Unknown, } } diff --git a/src/platform_impl/windows/event_loop.rs b/src/platform_impl/windows/event_loop.rs index 317fa483fb..5c8fcf22dc 100644 --- a/src/platform_impl/windows/event_loop.rs +++ b/src/platform_impl/windows/event_loop.rs @@ -65,8 +65,7 @@ use crate::application::ApplicationHandler; use crate::dpi::{PhysicalPosition, PhysicalSize}; use crate::error::{EventLoopError, RequestError}; use crate::event::{ - Event, FingerId as RootFingerId, Force, Ime, RawKeyEvent, SurfaceSizeWriter, TouchPhase, - WindowEvent, + Event, FingerId, Force, Ime, RawKeyEvent, SurfaceSizeWriter, TouchPhase, WindowEvent, }; use crate::event_loop::{ ActiveEventLoop as RootActiveEventLoop, ControlFlow, DeviceEvents, @@ -87,7 +86,7 @@ use crate::platform_impl::platform::window::InitData; use crate::platform_impl::platform::window_state::{ CursorFlags, ImeState, WindowFlags, WindowState, }; -use crate::platform_impl::platform::{raw_input, util, wrap_device_id, FingerId, Fullscreen}; +use crate::platform_impl::platform::{raw_input, util, wrap_device_id, Fullscreen}; use crate::platform_impl::Window; use crate::utils::Lazy; use crate::window::{ @@ -2012,7 +2011,7 @@ unsafe fn public_window_callback_inner( let position = PhysicalPosition::new(x, y); let window_id = WindowId::from_raw(window as usize); - let finger_id = RootFingerId(FingerId { id: input.dwID }); + let finger_id = FingerId::from_raw(input.dwID as usize); let primary = util::has_flag(input.dwFlags, TOUCHEVENTF_PRIMARY); if util::has_flag(input.dwFlags, TOUCHEVENTF_DOWN) { @@ -2183,7 +2182,7 @@ unsafe fn public_window_callback_inner( let position = PhysicalPosition::new(x, y); let window_id = WindowId::from_raw(window as usize); - let finger_id = RootFingerId(FingerId { id: pointer_info.pointerId }); + let finger_id = FingerId::from_raw(pointer_info.pointerId as usize); let primary = util::has_flag(pointer_info.pointerFlags, POINTER_FLAG_PRIMARY); if util::has_flag(pointer_info.pointerFlags, POINTER_FLAG_DOWN) { diff --git a/src/platform_impl/windows/keyboard.rs b/src/platform_impl/windows/keyboard.rs index 02d1316e7c..d360a1d363 100644 --- a/src/platform_impl/windows/keyboard.rs +++ b/src/platform_impl/windows/keyboard.rs @@ -97,7 +97,7 @@ impl KeyEventBuilder { MatchResult::MessagesToDispatch(self.pending.complete_multi(key_events)) }, WM_KILLFOCUS => { - // sythesize keyup events + // synthesize keyup events let kbd_state = get_kbd_state(); let key_events = Self::synthesize_kbd_state(ElementState::Released, &kbd_state); MatchResult::MessagesToDispatch(self.pending.complete_multi(key_events)) @@ -333,11 +333,11 @@ impl KeyEventBuilder { // We are synthesizing the press event for caps-lock first for the following reasons: // 1. If caps-lock is *not* held down but *is* active, then we have to synthesize all // printable keys, respecting the caps-lock state. - // 2. If caps-lock is held down, we could choose to sythesize its keypress after every other - // key, in which case all other keys *must* be sythesized as if the caps-lock state was - // be the opposite of what it currently is. + // 2. If caps-lock is held down, we could choose to synthesize its keypress after every + // other key, in which case all other keys *must* be sythesized as if the caps-lock state + // was be the opposite of what it currently is. // -- - // For the sake of simplicity we are choosing to always sythesize + // For the sake of simplicity we are choosing to always synthesize // caps-lock first, and always use the current caps-lock state // to determine the produced text if is_key_pressed!(VK_CAPITAL) { diff --git a/src/platform_impl/windows/mod.rs b/src/platform_impl/windows/mod.rs index 6164c635fd..977599d8b3 100644 --- a/src/platform_impl/windows/mod.rs +++ b/src/platform_impl/windows/mod.rs @@ -59,18 +59,6 @@ impl Default for PlatformSpecificWindowAttributes { unsafe impl Send for PlatformSpecificWindowAttributes {} unsafe impl Sync for PlatformSpecificWindowAttributes {} -#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)] -pub struct FingerId { - id: u32, -} - -impl FingerId { - #[cfg(test)] - pub const fn dummy() -> Self { - FingerId { id: 0 } - } -} - fn wrap_device_id(id: u32) -> DeviceId { DeviceId::from_raw(id as i64) }