chore: remove platform DeviceId

The same as for `WindowId`.
This commit is contained in:
Kirill Chibisov
2024-10-11 11:15:54 +03:00
committed by GitHub
parent da2268ae22
commit 4e3165f3d8
18 changed files with 79 additions and 123 deletions

View File

@@ -9,16 +9,13 @@ use wasm_bindgen::JsCast;
use web_sys::{Document, KeyboardEvent, Navigator, PageTransitionEvent, PointerEvent, WheelEvent};
use web_time::{Duration, Instant};
use super::super::event;
use super::super::main_thread::MainThreadMarker;
use super::super::monitor::MonitorHandler;
use super::super::DeviceId;
use super::backend;
use super::state::State;
use crate::dpi::PhysicalSize;
use crate::event::{
DeviceEvent, DeviceId as RootDeviceId, ElementState, Event, RawKeyEvent, StartCause,
WindowEvent,
};
use crate::event::{DeviceEvent, ElementState, Event, RawKeyEvent, StartCause, WindowEvent};
use crate::event_loop::{ControlFlow, DeviceEvents};
use crate::platform::web::{PollStrategy, WaitUntilStrategy};
use crate::platform_impl::platform::backend::EventListenerHandle;
@@ -286,7 +283,7 @@ impl Shared {
}
// chorded button event
let device_id = DeviceId::new(event.pointer_id()).map(RootDeviceId);
let device_id = event::mkdid(event.pointer_id());
if let Some(button) = backend::event::mouse_button(&event) {
let state = if backend::event::mouse_buttons(&event).contains(button.into()) {
@@ -344,7 +341,7 @@ impl Shared {
let button = backend::event::mouse_button(&event).expect("no mouse button pressed");
runner.send_event(Event::DeviceEvent {
device_id: DeviceId::new(event.pointer_id()).map(RootDeviceId),
device_id: event::mkdid(event.pointer_id()),
event: DeviceEvent::Button {
button: button.to_id().into(),
state: ElementState::Pressed,
@@ -363,7 +360,7 @@ impl Shared {
let button = backend::event::mouse_button(&event).expect("no mouse button pressed");
runner.send_event(Event::DeviceEvent {
device_id: DeviceId::new(event.pointer_id()).map(RootDeviceId),
device_id: event::mkdid(event.pointer_id()),
event: DeviceEvent::Button {
button: button.to_id().into(),
state: ElementState::Released,

View File

@@ -10,9 +10,7 @@ use super::super::{lock, KeyEventExtra};
use super::runner::{EventWrapper, WeakShared};
use super::{backend, runner, EventLoopProxy};
use crate::error::{NotSupportedError, RequestError};
use crate::event::{
DeviceId as RootDeviceId, ElementState, Event, KeyEvent, TouchPhase, WindowEvent,
};
use crate::event::{ElementState, Event, KeyEvent, TouchPhase, WindowEvent};
use crate::event_loop::{
ActiveEventLoop as RootActiveEventLoop, ControlFlow, DeviceEvents,
EventLoopProxy as RootEventLoopProxy, OwnedDisplayHandle as RootOwnedDisplayHandle,
@@ -210,11 +208,7 @@ impl ActiveEventLoop {
runner.send_events(focus.into_iter().chain(iter::once(Event::WindowEvent {
window_id,
event: WindowEvent::PointerLeft {
device_id: device_id.map(RootDeviceId),
position: Some(position),
kind,
},
event: WindowEvent::PointerLeft { device_id, position: Some(position), kind },
})))
}
});
@@ -235,11 +229,7 @@ impl ActiveEventLoop {
runner.send_events(focus.into_iter().chain(iter::once(Event::WindowEvent {
window_id,
event: WindowEvent::PointerEntered {
device_id: device_id.map(RootDeviceId),
position,
kind,
},
event: WindowEvent::PointerEntered { device_id, position, kind },
})))
}
});
@@ -250,10 +240,8 @@ impl ActiveEventLoop {
let has_focus = has_focus.clone();
let modifiers = self.modifiers.clone();
move |pointer_id, events| {
move |device_id, events| {
runner.send_events(events.flat_map(|(active_modifiers, position, source)| {
let device_id = pointer_id.map(RootDeviceId);
let modifiers = (has_focus.get() && modifiers.get() != active_modifiers)
.then(|| {
modifiers.set(active_modifiers);
@@ -285,8 +273,6 @@ impl ActiveEventLoop {
}
});
let device_id = device_id.map(RootDeviceId);
runner.send_events(modifiers.into_iter().chain([Event::WindowEvent {
window_id,
event: WindowEvent::PointerButton { device_id, state, position, button },
@@ -299,7 +285,7 @@ impl ActiveEventLoop {
let runner = self.runner.clone();
let modifiers = self.modifiers.clone();
move |active_modifiers, pointer_id, position, button| {
move |active_modifiers, device_id, position, button| {
let modifiers = (modifiers.get() != active_modifiers).then(|| {
modifiers.set(active_modifiers);
Event::WindowEvent {
@@ -308,7 +294,6 @@ impl ActiveEventLoop {
}
});
let device_id = pointer_id.map(RootDeviceId);
runner.send_events(modifiers.into_iter().chain(iter::once(Event::WindowEvent {
window_id,
event: WindowEvent::PointerButton {
@@ -326,7 +311,7 @@ impl ActiveEventLoop {
let has_focus = has_focus.clone();
let modifiers = self.modifiers.clone();
move |active_modifiers, pointer_id, position, button| {
move |active_modifiers, device_id, position, button| {
let modifiers =
(has_focus.get() && modifiers.get() != active_modifiers).then(|| {
modifiers.set(active_modifiers);
@@ -336,8 +321,6 @@ impl ActiveEventLoop {
}
});
let device_id = pointer_id.map(RootDeviceId);
runner.send_events(modifiers.into_iter().chain(iter::once(Event::WindowEvent {
window_id,
event: WindowEvent::PointerButton {