1
0
Fork 0
This commit is contained in:
Billy Messenger 2020-09-11 11:43:46 -05:00
parent ddbc95a2ed
commit 52580cc2a9

View file

@ -219,7 +219,7 @@ impl Window {
let wm_delete_window = self.xcb_connection.atoms.wm_delete_window.unwrap_or(xcb::NONE);
if wm_delete_window == data32[0] {
handler.on_event(self, Event::WillClose);
handler.on_event(self, Event::Window(WindowEvent::WillClose));
// FIXME: handler should decide whether window stays open or not
self.event_loop_running = false;
@ -237,7 +237,7 @@ impl Window {
if detail != 4 && detail != 5 {
handler.on_event(
self,
Event::CursorMotion(event.event_x() as i32, event.event_y() as i32),
Event::Mouse(MouseEvent::CursorMoved { x: event.event_x() as i32, y: event.event_y() as i32 }),
);
}
}
@ -250,24 +250,24 @@ impl Window {
4 => {
handler.on_event(
self,
Event::MouseScroll(MouseScroll {
x_delta: 0.0,
y_delta: 1.0,
}),
Event::Mouse(MouseEvent::WheelScrolled(ScrollDelta::Lines {
x: 0.0,
y: 1.0,
})),
);
}
5 => {
handler.on_event(
self,
Event::MouseScroll(MouseScroll {
x_delta: 0.0,
y_delta: -1.0,
}),
Event::Mouse(MouseEvent::WheelScrolled(ScrollDelta::Lines {
x: 0.0,
y: -1.0,
})),
);
}
detail => {
let button_id = mouse_id(detail);
handler.on_event(self, Event::MouseDown(button_id));
handler.on_event(self, Event::Mouse(MouseEvent::ButtonPressed(button_id)));
}
}
}
@ -278,7 +278,7 @@ impl Window {
if detail != 4 && detail != 5 {
let button_id = mouse_id(detail);
handler.on_event(self, Event::MouseUp(button_id));
handler.on_event(self, Event::Mouse(MouseEvent::ButtonReleased(button_id)));
}
}
@ -290,14 +290,14 @@ impl Window {
let event = unsafe { xcb::cast_event::<xcb::KeyPressEvent>(&event) };
let detail = event.detail();
handler.on_event(self, Event::KeyDown(detail));
handler.on_event(self, Event::Keyboard(KeyboardEvent::KeyPressed(detail as u32)));
}
xcb::KEY_RELEASE => {
let event = unsafe { xcb::cast_event::<xcb::KeyReleaseEvent>(&event) };
let detail = event.detail();
handler.on_event(self, Event::KeyUp(detail));
handler.on_event(self, Event::Keyboard(KeyboardEvent::KeyReleased(detail as u32)));
}
_ => {