Exemplo n.º 1
0
void LibinputServer::handleTouchEvent(struct libinput_event *event, Input::TouchEvent::Type type)
{
    auto* touchEvent = libinput_event_get_touch_event(event);
    uint32_t time = libinput_event_touch_get_time(touchEvent);
    int id = libinput_event_touch_get_slot(touchEvent);
    auto& targetPoint = m_touchEvents[id];
    int32_t x, y;
    
    if (type != Input::TouchEvent::Up) {
      x = libinput_event_touch_get_x_transformed(touchEvent, m_pointerBounds.first);
      y = libinput_event_touch_get_y_transformed(touchEvent, m_pointerBounds.second);
    } else {
      // libinput can't return pointer position on touch-up
      x = targetPoint.x;
      y = targetPoint.y;
    }
    targetPoint = Input::TouchEvent::Raw{ type, time, id, x, y };
    
    m_client->handleTouchEvent({
      m_touchEvents,
      type,
      id,
      time
    });
    
    if (type == Input::TouchEvent::Up) {
        targetPoint = Input::TouchEvent::Raw{ Input::TouchEvent::Null, 0, -1, -1, -1 };
    }
}
Exemplo n.º 2
0
void LibInputTouch::handleTouchUp(libinput_event_touch *event)
{
    Q_D(LibInputTouch);

    State *state = d->stateFromEvent(event);

    int slot = libinput_event_touch_get_slot(event);
    QWindowSystemInterface::TouchPoint *touchPoint = state->touchPointAt(slot);
    if (touchPoint) {
        touchPoint->state = Qt::TouchPointReleased;

        Qt::TouchPointStates states = 0;
        Q_FOREACH (const QWindowSystemInterface::TouchPoint &tp, state->touchPoints)
            states |= tp.state;
        if (states == Qt::TouchPointReleased)
            handleTouchFrame(event);
    } else {