chore: remove platform DeviceId
The same as for `WindowId`.
This commit is contained in:
parent
da2268ae22
commit
4e3165f3d8
18 changed files with 79 additions and 123 deletions
|
|
@ -107,15 +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 DeviceId {
|
||||
#[cfg(x11_platform)]
|
||||
X(x11::DeviceId),
|
||||
#[cfg(wayland_platform)]
|
||||
#[allow(unused)]
|
||||
Wayland(wayland::DeviceId),
|
||||
}
|
||||
|
||||
#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
||||
pub enum FingerId {
|
||||
#[cfg(x11_platform)]
|
||||
|
|
|
|||
|
|
@ -17,10 +17,6 @@ mod state;
|
|||
mod types;
|
||||
mod window;
|
||||
|
||||
/// Dummy device id, since Wayland doesn't have device events.
|
||||
#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
||||
pub struct DeviceId;
|
||||
|
||||
#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
||||
pub struct FingerId(i32);
|
||||
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ use xkbcommon_dl::xkb_mod_mask_t;
|
|||
|
||||
use crate::dpi::{PhysicalPosition, PhysicalSize};
|
||||
use crate::event::{
|
||||
ButtonSource, DeviceEvent, ElementState, Event, Ime, MouseButton, MouseScrollDelta,
|
||||
ButtonSource, DeviceEvent, DeviceId, ElementState, Event, Ime, MouseButton, MouseScrollDelta,
|
||||
PointerKind, PointerSource, RawKeyEvent, SurfaceSizeWriter, TouchPhase, WindowEvent,
|
||||
};
|
||||
use crate::keyboard::ModifiersState;
|
||||
|
|
@ -33,8 +33,8 @@ 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, DeviceId, DeviceInfo, Dnd, DndState,
|
||||
ImeReceiver, ScrollOrientation, UnownedWindow, WindowId,
|
||||
mkdid, mkfid, mkwid, util, CookieResultExt, Device, DeviceInfo, Dnd, DndState, ImeReceiver,
|
||||
ScrollOrientation, UnownedWindow, WindowId,
|
||||
};
|
||||
|
||||
/// The maximum amount of X modifiers to replay.
|
||||
|
|
@ -319,7 +319,7 @@ impl EventProcessor {
|
|||
let mut devices = self.devices.borrow_mut();
|
||||
if let Some(info) = DeviceInfo::get(&self.target.xconn, device as _) {
|
||||
for info in info.iter() {
|
||||
devices.insert(DeviceId(info.deviceid as _), Device::new(info));
|
||||
devices.insert(mkdid(info.deviceid as xinput::DeviceId), Device::new(info));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1119,7 +1119,7 @@ impl EventProcessor {
|
|||
slice::from_raw_parts(event.valuators.mask, event.valuators.mask_len as usize)
|
||||
};
|
||||
let mut devices = self.devices.borrow_mut();
|
||||
let physical_device = match devices.get_mut(&DeviceId(event.sourceid as xinput::DeviceId)) {
|
||||
let physical_device = match devices.get_mut(&mkdid(event.sourceid as xinput::DeviceId)) {
|
||||
Some(device) => device,
|
||||
None => return,
|
||||
};
|
||||
|
|
@ -1178,7 +1178,7 @@ impl EventProcessor {
|
|||
if device_info.deviceid == event.sourceid
|
||||
|| device_info.attachment == event.sourceid
|
||||
{
|
||||
let device_id = DeviceId(device_info.deviceid as _);
|
||||
let device_id = mkdid(device_info.deviceid as xinput::DeviceId);
|
||||
if let Some(device) = devices.get_mut(&device_id) {
|
||||
device.reset_scroll_position(device_info);
|
||||
}
|
||||
|
|
@ -1273,8 +1273,8 @@ impl EventProcessor {
|
|||
let device_id = self
|
||||
.devices
|
||||
.borrow()
|
||||
.get(&DeviceId(xev.deviceid as xinput::DeviceId))
|
||||
.map(|device| mkdid(device.attachment as _));
|
||||
.get(&mkdid(xev.deviceid as xinput::DeviceId))
|
||||
.map(|device| mkdid(device.attachment as xinput::DeviceId));
|
||||
|
||||
let event = Event::WindowEvent {
|
||||
window_id,
|
||||
|
|
@ -1520,7 +1520,7 @@ impl EventProcessor {
|
|||
self.init_device(info.deviceid as xinput::DeviceId);
|
||||
} else if 0 != info.flags & (xinput2::XISlaveRemoved | xinput2::XIMasterRemoved) {
|
||||
let mut devices = self.devices.borrow_mut();
|
||||
devices.remove(&DeviceId(info.deviceid as xinput::DeviceId));
|
||||
devices.remove(&mkdid(info.deviceid as xinput::DeviceId));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ use x11rb::xcb_ffi::ReplyOrIdError;
|
|||
|
||||
use crate::application::ApplicationHandler;
|
||||
use crate::error::{EventLoopError, RequestError};
|
||||
use crate::event::{Event, StartCause, WindowEvent};
|
||||
use crate::event::{DeviceId, Event, StartCause, WindowEvent};
|
||||
use crate::event_loop::{
|
||||
ActiveEventLoop as RootActiveEventLoop, ControlFlow, DeviceEvents,
|
||||
OwnedDisplayHandle as RootOwnedDisplayHandle,
|
||||
|
|
@ -805,9 +805,6 @@ impl<'a> Deref for DeviceInfo<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
||||
pub struct DeviceId(xinput::DeviceId);
|
||||
|
||||
#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
||||
pub struct FingerId(u32);
|
||||
|
||||
|
|
@ -993,8 +990,8 @@ impl<'a, E: fmt::Debug> CookieResultExt for Result<VoidCookie<'a>, E> {
|
|||
fn mkwid(w: xproto::Window) -> crate::window::WindowId {
|
||||
crate::window::WindowId::from_raw(w as _)
|
||||
}
|
||||
fn mkdid(w: xinput::DeviceId) -> crate::event::DeviceId {
|
||||
crate::event::DeviceId(crate::platform_impl::DeviceId::X(DeviceId(w)))
|
||||
fn mkdid(w: xinput::DeviceId) -> DeviceId {
|
||||
DeviceId::from_raw(w as i64)
|
||||
}
|
||||
|
||||
fn mkfid(w: u32) -> crate::event::FingerId {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue