Make DeviceId/WindowId::dummy() safe (#3784)
This commit is contained in:
parent
bf97def398
commit
5b8f5cb54a
15 changed files with 28 additions and 33 deletions
|
|
@ -2,7 +2,7 @@
|
|||
pub struct DeviceId(pub i32);
|
||||
|
||||
impl DeviceId {
|
||||
pub const unsafe fn dummy() -> Self {
|
||||
pub const fn dummy() -> Self {
|
||||
Self(0)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -369,7 +369,7 @@ impl Shared {
|
|||
}
|
||||
|
||||
runner.send_event(Event::DeviceEvent {
|
||||
device_id: RootDeviceId(unsafe { DeviceId::dummy() }),
|
||||
device_id: RootDeviceId(DeviceId::dummy()),
|
||||
event: DeviceEvent::Key(RawKeyEvent {
|
||||
physical_key: backend::event::key_code(&event),
|
||||
state: ElementState::Pressed,
|
||||
|
|
@ -387,7 +387,7 @@ impl Shared {
|
|||
}
|
||||
|
||||
runner.send_event(Event::DeviceEvent {
|
||||
device_id: RootDeviceId(unsafe { DeviceId::dummy() }),
|
||||
device_id: RootDeviceId(DeviceId::dummy()),
|
||||
event: DeviceEvent::Key(RawKeyEvent {
|
||||
physical_key: backend::event::key_code(&event),
|
||||
state: ElementState::Released,
|
||||
|
|
|
|||
|
|
@ -150,7 +150,7 @@ impl ActiveEventLoop {
|
|||
}
|
||||
});
|
||||
|
||||
let device_id = RootDeviceId(unsafe { DeviceId::dummy() });
|
||||
let device_id = RootDeviceId(DeviceId::dummy());
|
||||
|
||||
runner.send_events(
|
||||
iter::once(Event::WindowEvent {
|
||||
|
|
@ -186,7 +186,7 @@ impl ActiveEventLoop {
|
|||
}
|
||||
});
|
||||
|
||||
let device_id = RootDeviceId(unsafe { DeviceId::dummy() });
|
||||
let device_id = RootDeviceId(DeviceId::dummy());
|
||||
|
||||
runner.send_events(
|
||||
iter::once(Event::WindowEvent {
|
||||
|
|
|
|||
|
|
@ -431,7 +431,7 @@ impl Drop for Inner {
|
|||
pub struct WindowId(pub(crate) u32);
|
||||
|
||||
impl WindowId {
|
||||
pub const unsafe fn dummy() -> Self {
|
||||
pub const fn dummy() -> Self {
|
||||
Self(0)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue