Use keyboard_types::KeyboardEvent directly instead of wrapping it
This commit is contained in:
parent
546b0d6eae
commit
0a6a0bdffd
|
@ -1,10 +1,6 @@
|
|||
use crate::{WindowInfo, Point};
|
||||
use keyboard_types::KeyboardEvent;
|
||||
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
pub enum KeyboardEvent {
|
||||
KeyPressed(keyboard_types::KeyboardEvent),
|
||||
KeyReleased(keyboard_types::KeyboardEvent),
|
||||
}
|
||||
use crate::{WindowInfo, Point};
|
||||
|
||||
|
||||
#[derive(Debug, Copy, Clone, Eq, PartialEq)]
|
||||
|
|
|
@ -15,7 +15,7 @@ use objc::{
|
|||
use uuid::Uuid;
|
||||
|
||||
use crate::{
|
||||
Event, KeyboardEvent, MouseButton, MouseEvent, Point, WindowHandler,
|
||||
Event, MouseButton, MouseEvent, Point, WindowHandler,
|
||||
WindowOpenOptions
|
||||
};
|
||||
use crate::MouseEvent::{ButtonPressed, ButtonReleased};
|
||||
|
@ -351,9 +351,7 @@ extern "C" fn key_down<H: WindowHandler>(this: &Object, _: Sel, event: id){
|
|||
};
|
||||
|
||||
if let Some(key_event) = state.process_native_key_event(event){
|
||||
let event = Event::Keyboard(KeyboardEvent::KeyPressed(key_event));
|
||||
|
||||
state.trigger_event(event);
|
||||
state.trigger_event(Event::Keyboard(key_event));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -364,8 +362,6 @@ extern "C" fn key_up<H: WindowHandler>(this: &Object, _: Sel, event: id){
|
|||
};
|
||||
|
||||
if let Some(key_event) = state.process_native_key_event(event){
|
||||
let event = Event::Keyboard(KeyboardEvent::KeyReleased(key_event));
|
||||
|
||||
state.trigger_event(event);
|
||||
state.trigger_event(Event::Keyboard(key_event));
|
||||
}
|
||||
}
|
|
@ -23,7 +23,7 @@ use raw_window_handle::{
|
|||
};
|
||||
|
||||
use crate::{
|
||||
Event, KeyboardEvent, MouseButton, MouseEvent, Parent::WithParent, ScrollDelta, WindowEvent,
|
||||
Event, MouseButton, MouseEvent, Parent::WithParent, ScrollDelta, WindowEvent,
|
||||
WindowHandler, WindowInfo, WindowOpenOptions, WindowScalePolicy, Size, Point, PhySize, PhyPoint,
|
||||
};
|
||||
|
||||
|
|
|
@ -11,8 +11,8 @@ use raw_window_handle::{
|
|||
|
||||
use super::XcbConnection;
|
||||
use crate::{
|
||||
Event, KeyboardEvent, MouseButton, MouseCursor, MouseEvent, Parent,
|
||||
ScrollDelta, WindowEvent, WindowHandler, WindowInfo, WindowOpenOptions,
|
||||
Event, MouseButton, MouseCursor, MouseEvent, Parent, ScrollDelta,
|
||||
WindowEvent, WindowHandler, WindowInfo, WindowOpenOptions,
|
||||
WindowScalePolicy, PhyPoint, PhySize,
|
||||
};
|
||||
|
||||
|
@ -396,26 +396,18 @@ impl Window {
|
|||
xcb::KEY_PRESS => {
|
||||
let event = unsafe { xcb::cast_event::<xcb::KeyPressEvent>(&event) };
|
||||
|
||||
let event = Event::Keyboard(KeyboardEvent::KeyPressed(
|
||||
convert_key_press_event(&event)
|
||||
));
|
||||
|
||||
handler.on_event(
|
||||
self,
|
||||
event
|
||||
Event::Keyboard(convert_key_press_event(&event))
|
||||
);
|
||||
}
|
||||
|
||||
xcb::KEY_RELEASE => {
|
||||
let event = unsafe { xcb::cast_event::<xcb::KeyReleaseEvent>(&event) };
|
||||
|
||||
let event = Event::Keyboard(KeyboardEvent::KeyReleased(
|
||||
convert_key_release_event(&event)
|
||||
));
|
||||
|
||||
handler.on_event(
|
||||
self,
|
||||
event
|
||||
Event::Keyboard(convert_key_release_event(&event))
|
||||
);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue