12class QOhosAxisEventHandler
final :
public std::enable_shared_from_this<QOhosAxisEventHandler>
16 QtOhos::QThreadSafeRef<QWindow> qWindowRef,
17 QtOhos::QThreadSafeRef<QOhosInputMethodEventHandler> imEventHandlerRef);
22 QtOhos::QThreadSafeRef<QWindow> m_qWindowRef;
23 QtOhos::QThreadSafeRef<QOhosInputMethodEventHandler> m_imEventHandlerRef;
25 QOhosConsumer<
const QOhosNativeGestureEvent &> m_nativeGesturesHandler;
74 const auto now =
std::chrono::steady_clock::now();
76 auto eventTimestamp = OH_ArkUI_UIInputEvent_GetEventTime(event);
77 QPointF localPosition;
78 QPointF screenPosition;
79 std::tie(localPosition, screenPosition) = getLocalAndGlobalPointsFromUiInputEvent(event);
80 double horizontalAxisValue = OH_ArkUI_AxisEvent_GetHorizontalAxisValue(event);
81 double verticalAxisValue = OH_ArkUI_AxisEvent_GetVerticalAxisValue(event);
82 auto eventToolType = OH_ArkUI_UIInputEvent_GetToolType(event);
83 auto eventAxisAction = OH_ArkUI_AxisEvent_GetAxisAction(event);
84 std::int32_t wheelScrollLines;
85 wheelScrollLines = OH_ArkUI_AxisEvent_GetScrollStep(event);
87 if (!qFuzzyIsNull(horizontalAxisValue) || !qFuzzyIsNull(verticalAxisValue)) {
89 .timestamp = eventTimestamp,
90 .localPoint = localPosition,
91 .globalPoint = screenPosition,
92 .horizontalValue = horizontalAxisValue,
93 .verticalValue = verticalAxisValue,
94 .eventToolType = eventToolType,
95 .axisAction = eventAxisAction,
96 .wheelScrollLines = wheelScrollLines,
97 .modifiers = readKeyModifiersFromOhosUiInputEvent(event),
100 auto weakSelf = QtOhos::makeWeakPtr(shared_from_this());
101 m_imEventHandlerRef.visitInQtThreadIfAlive(
102 [weakSelf, ohosWheelEvent, qWindowRef = m_qWindowRef](
auto &eventHandler) {
103 auto sharedSelf = weakSelf.lock();
107 eventHandler.onMouseWheelEvent(ohosWheelEvent, qWindowRef.data());
111 const auto totalScale = OH_ArkUI_AxisEvent_GetPinchAxisScaleValue(event);
113 if (qFuzzyIsNull(horizontalAxisValue) && qFuzzyIsNull(verticalAxisValue) && !qFuzzyIsNull(totalScale)) {
114 const auto deviceType = QArkUi::getTouchDeviceType(event);
115 const auto gestureType = getQtGestureType(
116 static_cast<InputEvent_AxisAction>(eventAxisAction)).valueOr(Qt::ZoomNativeGesture);
120 .gestureTimestamp = eventTimestamp,
122 .localPosition = localPosition,
123 .displayBasedPosition = screenPosition,
124 .gestureType = gestureType,
125 .deviceType = deviceType,
128 m_nativeGesturesHandler(newEvent);