Clean project structure.
This commit is contained in:
parent
78a4fa99ff
commit
947bf937fd
496 changed files with 206 additions and 137 deletions
75
src/ui/windows/ui_interfaces/x11/XcbEventInterface.cpp
Normal file
75
src/ui/windows/ui_interfaces/x11/XcbEventInterface.cpp
Normal file
|
@ -0,0 +1,75 @@
|
|||
#include "XcbEventInterface.h"
|
||||
|
||||
#include "KeyboardEvent.h"
|
||||
#include "DiscretePoint.h"
|
||||
#include "MouseEvent.h"
|
||||
#include "PaintEvent.h"
|
||||
#include "Keyboard.h"
|
||||
|
||||
#include <xcb/xcb.h>
|
||||
|
||||
std::unique_ptr<XcbEventInterface> XcbEventInterface::Create()
|
||||
{
|
||||
return std::make_unique<XcbEventInterface>();
|
||||
}
|
||||
|
||||
std::unique_ptr<KeyboardEvent> XcbEventInterface::ConvertKeyPress(xcb_key_press_event_t* event, Keyboard* keyboard) const
|
||||
{
|
||||
auto ui_event = KeyboardEvent::Create();
|
||||
ui_event->setAction(KeyboardEvent::Action::Pressed);
|
||||
|
||||
if (auto function = keyboard->getFunction(event->detail); function != Keyboard::Function::UNSET)
|
||||
{
|
||||
ui_event->setFunction(function);
|
||||
}
|
||||
else
|
||||
{
|
||||
ui_event->setKeyString(keyboard->getKeyString(event->detail));
|
||||
}
|
||||
return ui_event;
|
||||
}
|
||||
|
||||
std::unique_ptr<KeyboardEvent> XcbEventInterface::ConvertKeyRelease(xcb_key_press_event_t* event, Keyboard* keyboard) const
|
||||
{
|
||||
auto ui_event = KeyboardEvent::Create();
|
||||
ui_event->setAction(KeyboardEvent::Action::Released);
|
||||
|
||||
if (auto function = keyboard->getFunction(event->detail); function != Keyboard::Function::UNSET)
|
||||
{
|
||||
ui_event->setFunction(function);
|
||||
}
|
||||
else
|
||||
{
|
||||
ui_event->setKeyString(keyboard->getKeyString(event->detail));
|
||||
}
|
||||
return ui_event;
|
||||
}
|
||||
|
||||
std::unique_ptr<MouseEvent> XcbEventInterface::ConvertButtonPress(xcb_button_press_event_t* event) const
|
||||
{
|
||||
auto ui_event = MouseEvent::Create();
|
||||
auto x = static_cast<unsigned>(event->event_x);
|
||||
auto y = static_cast<unsigned>(event->event_y);
|
||||
ui_event->SetClientLocation(DiscretePoint(x, y));
|
||||
|
||||
auto screen_x = static_cast<unsigned>(event->root_x);
|
||||
auto screen_y = static_cast<unsigned>(event->root_y);
|
||||
ui_event->SetScreenLocation(DiscretePoint(x, y));
|
||||
ui_event->SetAction(MouseEvent::Action::Pressed);
|
||||
return ui_event;
|
||||
}
|
||||
|
||||
std::unique_ptr<MouseEvent> XcbEventInterface::ConvertButtonRelease(xcb_button_press_event_t* event) const
|
||||
{
|
||||
auto ui_event = MouseEvent::Create();
|
||||
auto x = static_cast<unsigned>(event->event_x);
|
||||
auto y = static_cast<unsigned>(event->event_y);
|
||||
ui_event->SetClientLocation(DiscretePoint(x, y));
|
||||
|
||||
auto screen_x = static_cast<unsigned>(event->root_x);
|
||||
auto screen_y = static_cast<unsigned>(event->root_y);
|
||||
ui_event->SetScreenLocation(DiscretePoint(x, y));
|
||||
|
||||
ui_event->SetAction(MouseEvent::Action::Released);
|
||||
return ui_event;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue