api: remove ::dummy from Id types

`::dummy` was used for testing purposes and became redundant after
adding e.g. `from_raw` and `into_raw` methods on `Id` types.
This commit is contained in:
daxpedda 2024-09-29 15:49:45 +02:00 committed by GitHub
parent 6e1b9fa24d
commit 32cd1ad9a7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
35 changed files with 219 additions and 352 deletions

View file

@ -30,7 +30,7 @@ use sink::EventSink;
use super::state::{WindowCompositorUpdate, WinitState};
use super::window::state::FrameCallbackState;
use super::{logical_to_physical_rounded, DeviceId, WindowId};
use super::{logical_to_physical_rounded, WindowId};
type WaylandDispatcher = calloop::Dispatcher<'static, WaylandSource<WinitState>, WinitState>;

View file

@ -2,9 +2,8 @@
use std::vec::Drain;
use super::{DeviceId, WindowId};
use crate::event::{DeviceEvent, DeviceId as RootDeviceId, Event, WindowEvent};
use crate::platform_impl::platform::DeviceId as PlatformDeviceId;
use super::WindowId;
use crate::event::{DeviceEvent, Event, WindowEvent};
use crate::window::WindowId as RootWindowId;
/// An event loop's sink to deliver events from the Wayland event callbacks
@ -27,11 +26,8 @@ impl EventSink {
/// Add new device event to a queue.
#[inline]
pub fn push_device_event(&mut self, event: DeviceEvent, device_id: DeviceId) {
self.window_events.push(Event::DeviceEvent {
event,
device_id: RootDeviceId(PlatformDeviceId::Wayland(device_id)),
});
pub fn push_device_event(&mut self, event: DeviceEvent) {
self.window_events.push(Event::DeviceEvent { event, device_id: None });
}
/// Add new window event to a queue.

View file

@ -21,16 +21,11 @@ mod window;
#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct DeviceId;
impl DeviceId {
pub const fn dummy() -> Self {
DeviceId
}
}
#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct FingerId(i32);
impl FingerId {
#[cfg(test)]
pub const fn dummy() -> Self {
FingerId(0)
}

View file

@ -17,7 +17,7 @@ use crate::keyboard::ModifiersState;
use crate::platform_impl::common::xkb::Context;
use crate::platform_impl::wayland::event_loop::sink::EventSink;
use crate::platform_impl::wayland::state::WinitState;
use crate::platform_impl::wayland::{self, DeviceId, WindowId};
use crate::platform_impl::wayland::{self, WindowId};
impl Dispatch<WlKeyboard, KeyboardData, WinitState> for WinitState {
fn event(
@ -369,10 +369,9 @@ fn key_input(
None => return,
};
let device_id = crate::event::DeviceId(crate::platform_impl::DeviceId::Wayland(DeviceId));
if let Some(mut key_context) = keyboard_state.xkb_context.key_context() {
let event = key_context.process_key_event(keycode, state, repeat);
let event = WindowEvent::KeyboardInput { device_id, event, is_synthetic: false };
let event = WindowEvent::KeyboardInput { device_id: None, event, is_synthetic: false };
event_sink.push_window_event(event, window_id);
}
}

View file

@ -30,7 +30,7 @@ use crate::dpi::{LogicalPosition, PhysicalPosition};
use crate::event::{ElementState, MouseButton, MouseScrollDelta, TouchPhase, WindowEvent};
use crate::platform_impl::wayland::state::WinitState;
use crate::platform_impl::wayland::{self, DeviceId, WindowId};
use crate::platform_impl::wayland::{self, WindowId};
pub mod relative_pointer;
@ -59,8 +59,6 @@ impl PointerHandler for WinitState {
},
};
let device_id = crate::event::DeviceId(crate::platform_impl::DeviceId::Wayland(DeviceId));
for event in events {
let surface = &event.surface;
@ -124,8 +122,10 @@ impl PointerHandler for WinitState {
},
// Regular events on the main surface.
PointerEventKind::Enter { .. } => {
self.events_sink
.push_window_event(WindowEvent::CursorEntered { device_id }, window_id);
self.events_sink.push_window_event(
WindowEvent::CursorEntered { device_id: None },
window_id,
);
window.pointer_entered(Arc::downgrade(themed_pointer));
@ -133,7 +133,7 @@ impl PointerHandler for WinitState {
pointer.winit_data().inner.lock().unwrap().surface = Some(window_id);
self.events_sink.push_window_event(
WindowEvent::CursorMoved { device_id, position },
WindowEvent::CursorMoved { device_id: None, position },
window_id,
);
},
@ -144,11 +144,11 @@ impl PointerHandler for WinitState {
pointer.winit_data().inner.lock().unwrap().surface = None;
self.events_sink
.push_window_event(WindowEvent::CursorLeft { device_id }, window_id);
.push_window_event(WindowEvent::CursorLeft { device_id: None }, window_id);
},
PointerEventKind::Motion { .. } => {
self.events_sink.push_window_event(
WindowEvent::CursorMoved { device_id, position },
WindowEvent::CursorMoved { device_id: None, position },
window_id,
);
},
@ -164,7 +164,7 @@ impl PointerHandler for WinitState {
ElementState::Released
};
self.events_sink.push_window_event(
WindowEvent::MouseInput { device_id, state, button },
WindowEvent::MouseInput { device_id: None, state, button },
window_id,
);
},
@ -209,7 +209,7 @@ impl PointerHandler for WinitState {
};
self.events_sink.push_window_event(
WindowEvent::MouseWheel { device_id, delta, phase },
WindowEvent::MouseWheel { device_id: None, delta, phase },
window_id,
)
},

View file

@ -66,10 +66,9 @@ impl Dispatch<ZwpRelativePointerV1, GlobalData, WinitState> for RelativePointerS
},
_ => return,
};
state.events_sink.push_device_event(
DeviceEvent::MouseMotion { delta: (dx_unaccel, dy_unaccel) },
super::DeviceId,
);
state
.events_sink
.push_device_event(DeviceEvent::MouseMotion { delta: (dx_unaccel, dy_unaccel) });
}
}

View file

@ -10,7 +10,7 @@ use tracing::warn;
use crate::dpi::LogicalPosition;
use crate::event::{Touch, TouchPhase, WindowEvent};
use crate::platform_impl::wayland::state::WinitState;
use crate::platform_impl::wayland::{self, DeviceId, FingerId};
use crate::platform_impl::wayland::{self, FingerId};
impl TouchHandler for WinitState {
fn down(
@ -44,9 +44,7 @@ impl TouchHandler for WinitState {
self.events_sink.push_window_event(
WindowEvent::Touch(Touch {
device_id: crate::event::DeviceId(crate::platform_impl::DeviceId::Wayland(
DeviceId,
)),
device_id: None,
phase: TouchPhase::Started,
location: location.to_physical(scale_factor),
force: None,
@ -89,9 +87,7 @@ impl TouchHandler for WinitState {
self.events_sink.push_window_event(
WindowEvent::Touch(Touch {
device_id: crate::event::DeviceId(crate::platform_impl::DeviceId::Wayland(
DeviceId,
)),
device_id: None,
phase: TouchPhase::Ended,
location: touch_point.location.to_physical(scale_factor),
force: None,
@ -136,9 +132,7 @@ impl TouchHandler for WinitState {
self.events_sink.push_window_event(
WindowEvent::Touch(Touch {
device_id: crate::event::DeviceId(crate::platform_impl::DeviceId::Wayland(
DeviceId,
)),
device_id: None,
phase: TouchPhase::Moved,
location: touch_point.location.to_physical(scale_factor),
force: None,
@ -170,9 +164,7 @@ impl TouchHandler for WinitState {
self.events_sink.push_window_event(
WindowEvent::Touch(Touch {
device_id: crate::event::DeviceId(crate::platform_impl::DeviceId::Wayland(
DeviceId,
)),
device_id: None,
phase: TouchPhase::Cancelled,
location,
force: None,