Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(linux): clean dummy device_id #195

Merged
merged 2 commits into from
Aug 29, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 7 additions & 13 deletions src/platform_impl/linux/event_loop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ use crate::{
keyboard::ModifiersState,
menu::{MenuItem, MenuType},
monitor::MonitorHandle as RootMonitorHandle,
platform_impl::platform::window::hit_test,
platform_impl::platform::{window::hit_test, DEVICE_ID},
window::{CursorIcon, WindowId as RootWindowId},
};

Expand Down Expand Up @@ -433,8 +433,7 @@ impl<T: 'static> EventLoop<T> {
if let Err(e) = tx_clone.send(Event::WindowEvent {
window_id: RootWindowId(id),
event: WindowEvent::CursorEntered {
// FIXME: currently we use a dummy device id, find if we can get device id from gtk
device_id: RootDeviceId(DeviceId(0)),
device_id: DEVICE_ID,
},
}) {
log::warn!(
Expand All @@ -457,8 +456,7 @@ impl<T: 'static> EventLoop<T> {
window_id: RootWindowId(id),
event: WindowEvent::CursorMoved {
position: PhysicalPosition::new(x as f64, y as f64),
// FIXME: currently we use a dummy device id, find if we can get device id from gtk
device_id: RootDeviceId(DeviceId(0)),
device_id: DEVICE_ID,
// this field is depracted so it is fine to pass empty state
modifiers: ModifiersState::empty(),
},
Expand All @@ -474,8 +472,7 @@ impl<T: 'static> EventLoop<T> {
if let Err(e) = tx_clone.send(Event::WindowEvent {
window_id: RootWindowId(id),
event: WindowEvent::CursorLeft {
// FIXME: currently we use a dummy device id, find if we can get device id from gtk
device_id: RootDeviceId(DeviceId(0)),
device_id: DEVICE_ID,
},
}) {
log::warn!("Failed to send cursor left event to event channel: {}", e);
Expand All @@ -496,8 +493,7 @@ impl<T: 'static> EventLoop<T> {
_ => MouseButton::Other(button as u16),
},
state: ElementState::Pressed,
// FIXME: currently we use a dummy device id, find if we can get device id from gtk
device_id: RootDeviceId(DeviceId(0)),
device_id: DEVICE_ID,
// this field is depracted so it is fine to pass empty state
modifiers: ModifiersState::empty(),
},
Expand All @@ -523,8 +519,7 @@ impl<T: 'static> EventLoop<T> {
_ => MouseButton::Other(button as u16),
},
state: ElementState::Released,
// FIXME: currently we use a dummy device id, find if we can get device id from gtk
device_id: RootDeviceId(DeviceId(0)),
device_id: DEVICE_ID,
// this field is depracted so it is fine to pass empty state
modifiers: ModifiersState::empty(),
},
Expand Down Expand Up @@ -569,8 +564,7 @@ impl<T: 'static> EventLoop<T> {
if let Err(e) = tx_clone.send(Event::WindowEvent {
window_id: RootWindowId(id),
event: WindowEvent::KeyboardInput {
// FIXME: currently we use a dummy device id, find if we can get device id from gtk
device_id: RootDeviceId(DeviceId(0)),
device_id: DEVICE_ID,
event,
is_synthetic: false,
},
Expand Down
5 changes: 4 additions & 1 deletion src/platform_impl/linux/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ pub use event_loop::{EventLoop, EventLoopProxy, EventLoopWindowTarget};
pub use monitor::{MonitorHandle, VideoMode};
pub use window::{hit_test, PlatformIcon, Window, WindowId};

use crate::keyboard::Key;
use crate::{event::DeviceId as RootDeviceId, keyboard::Key};

#[derive(Debug, Clone, Eq, PartialEq, Hash)]
pub struct KeyEventExtra {
Expand Down Expand Up @@ -73,3 +73,6 @@ impl DeviceId {
Self(0)
}
}

// FIXME: currently we use a dummy device id, find if we can get device id from gtk
pub(crate) const DEVICE_ID: RootDeviceId = RootDeviceId(DeviceId(0));