extract mouse movement
parent
193580f370
commit
a955ab55a7
|
@ -32,6 +32,15 @@ void XcbDevice::handleEvents() {
|
|||
for (size_t i = 0; i < pending_events.size(); ++i) {
|
||||
xcb_generic_event_t *event = pending_events.at(i);
|
||||
switch (event->response_type & ~0x80) {
|
||||
case XCB_MOTION_NOTIFY: {
|
||||
xcb_motion_notify_event_t* motion = reinterpret_cast<xcb_motion_notify_event_t *>(event);
|
||||
auto find = windows.find(motion->event);
|
||||
if(find != windows.end()){
|
||||
assert(find->second);
|
||||
find->second->mouseMoveEvent(motion->event_x, motion->event_y);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case XCB_EXPOSE: {
|
||||
xcb_expose_event_t *expose =
|
||||
reinterpret_cast<xcb_expose_event_t *>(event);
|
||||
|
@ -134,7 +143,9 @@ Own<XcbWindow> XcbDevice::createXcbWindow(const VideoMode &video_mode,
|
|||
uint32_t eventmask = XCB_EVENT_MASK_EXPOSURE | XCB_EVENT_MASK_KEY_PRESS |
|
||||
XCB_EVENT_MASK_KEY_RELEASE |
|
||||
XCB_EVENT_MASK_BUTTON_PRESS |
|
||||
XCB_EVENT_MASK_BUTTON_RELEASE;
|
||||
XCB_EVENT_MASK_BUTTON_RELEASE |
|
||||
XCB_EVENT_MASK_POINTER_MOTION |
|
||||
XCB_EVENT_MASK_BUTTON_MOTION;
|
||||
uint32_t valuelist[] = {eventmask, xcb_colormap, 0};
|
||||
uint32_t valuemask = XCB_CW_EVENT_MASK | XCB_CW_COLORMAP;
|
||||
|
||||
|
|
|
@ -76,8 +76,7 @@ void XcbWindow::mouseEvent(int16_t x, int16_t y, uint16_t state, bool pressed) {
|
|||
}
|
||||
}
|
||||
|
||||
void XcbWindow::mouseMoveEvent(int16_t x, int16_t y, uint16_t state,
|
||||
uint8_t move_type) {
|
||||
void XcbWindow::mouseMoveEvent(int16_t x, int16_t y) {
|
||||
if (x < 0 || y < 0) {
|
||||
return;
|
||||
}
|
||||
|
@ -88,7 +87,7 @@ void XcbWindow::mouseMoveEvent(int16_t x, int16_t y, uint16_t state,
|
|||
}
|
||||
if (event_feeder) {
|
||||
event_feeder->feed(Window::VariantEvent{
|
||||
Window::Event::Mouse{state, move_type > 0 ? true : false, ux, uy}});
|
||||
Window::Event::MouseMove{ux, uy}});
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -40,8 +40,7 @@ public:
|
|||
|
||||
void resizeEvent(size_t x, size_t y, size_t width, size_t height);
|
||||
void mouseEvent(int16_t x, int16_t y, uint16_t state, bool pressed);
|
||||
void mouseMoveEvent(int16_t x, int16_t y, uint16_t state,
|
||||
uint8_t move_type);
|
||||
void mouseMoveEvent(int16_t x, int16_t y);
|
||||
void keyboardEvent(int16_t x, int16_t y, uint32_t keycode, bool pressed,
|
||||
bool repeat);
|
||||
};
|
||||
|
|
|
@ -34,8 +34,6 @@ public:
|
|||
};
|
||||
|
||||
struct MouseMove {
|
||||
uint16_t button_mask;
|
||||
uint8_t type;
|
||||
uint32_t x;
|
||||
uint32_t y;
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue