bool TouchInputHandler::handleImpl(GdkEvent* event) { XOJ_CHECK_TYPE(TouchInputHandler); GdkEventSequence* sequence = gdk_event_get_event_sequence(event); // Disallow multitouch if (this->currentSequence && this->currentSequence != sequence) { return false; } if (event->type == GDK_TOUCH_BEGIN && this->currentSequence == nullptr) { this->currentSequence = sequence; actionStart(event); } if (event->type == GDK_TOUCH_UPDATE) { actionMotion(event); } if (event->type == GDK_TOUCH_END || event->type == GDK_TOUCH_CANCEL) { actionEnd(event); this->currentSequence = nullptr; } return false; }
bool GtkTouchContextHelper::handleEvent(GdkEvent* touchEvent) { #ifndef GTK_API_VERSION_2 uint32_t sequence = GPOINTER_TO_UINT(gdk_event_get_event_sequence(touchEvent)); switch (touchEvent->type) { case GDK_TOUCH_BEGIN: { ASSERT(!m_touchEvents.contains(sequence)); GUniquePtr<GdkEvent> event(gdk_event_copy(touchEvent)); m_touchEvents.add(sequence, std::move(event)); break; } case GDK_TOUCH_UPDATE: { auto it = m_touchEvents.find(sequence); ASSERT(it != m_touchEvents.end()); it->value.reset(gdk_event_copy(touchEvent)); break; } case GDK_TOUCH_END: ASSERT(m_touchEvents.contains(sequence)); m_touchEvents.remove(sequence); break; default: return false; } #endif // GTK_API_VERSION_2 return true; }