chore: remove platform FingerId
The same as for `WindowId`.
This commit is contained in:
parent
c8c1eca3c7
commit
edfb4b03f4
20 changed files with 71 additions and 172 deletions
|
|
@ -107,24 +107,6 @@ impl Default for PlatformSpecificWindowAttributes {
|
|||
pub(crate) static X11_BACKEND: Lazy<Mutex<Result<Arc<XConnection>, 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)]
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -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::<f64>::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,
|
||||
);
|
||||
|
|
|
|||
|
|
@ -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 => {
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue