#include "XcbEventInterface.h" #include "KeyboardEvent.h" #include "DiscretePoint.h" #include "MouseEvent.h" #include "PaintEvent.h" #include "Keyboard.h" #include std::unique_ptr XcbEventInterface::Create() { return std::make_unique(); } std::unique_ptr XcbEventInterface::ConvertKeyPress(xcb_key_press_event_t* event, Keyboard* keyboard) const { auto ui_event = KeyboardEvent::Create(); ui_event->SetAction(KeyboardEvent::Action::Pressed); ui_event->SetKeyString(keyboard->GetKeyString(event->detail)); return ui_event; } std::unique_ptr XcbEventInterface::ConvertKeyRelease(xcb_key_press_event_t* event, Keyboard* keyboard) const { auto ui_event = KeyboardEvent::Create(); ui_event->SetAction(KeyboardEvent::Action::Released); ui_event->SetKeyString(keyboard->GetKeyString(event->detail)); return ui_event; } std::unique_ptr XcbEventInterface::ConvertButtonPress(xcb_button_press_event_t* event) const { auto ui_event = MouseEvent::Create(); auto x = static_cast(event->event_x); auto y = static_cast(event->event_y); ui_event->SetClientLocation(DiscretePoint(x, y)); auto screen_x = static_cast(event->root_x); auto screen_y = static_cast(event->root_y); ui_event->SetScreenLocation(DiscretePoint(x, y)); ui_event->SetAction(MouseEvent::Action::Pressed); return ui_event; } std::unique_ptr XcbEventInterface::ConvertButtonRelease(xcb_button_press_event_t* event) const { auto ui_event = MouseEvent::Create(); auto x = static_cast(event->event_x); auto y = static_cast(event->event_y); ui_event->SetClientLocation(DiscretePoint(x, y)); auto screen_x = static_cast(event->root_x); auto screen_y = static_cast(event->root_y); ui_event->SetScreenLocation(DiscretePoint(x, y)); ui_event->SetAction(MouseEvent::Action::Released); return ui_event; }