diff --git a/src/x11/window.rs b/src/x11/window.rs index 3e1b3d2..dc28bc0 100644 --- a/src/x11/window.rs +++ b/src/x11/window.rs @@ -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::(&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::(&event) }; let detail = event.detail(); - handler.on_event(self, Event::KeyUp(detail)); + handler.on_event(self, Event::Keyboard(KeyboardEvent::KeyReleased(detail as u32))); } _ => {