Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qohosnativexcomponentinputhandler.h
Go to the documentation of this file.
1// Copyright (C) 2025 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#ifndef QOHOSNATIVEXCOMPONENTINPUTHANDLER_H
5#define QOHOSNATIVEXCOMPONENTINPUTHANDLER_H
6
7#include <QtCore/QPointer>
8#include <QtCore/QtGlobal>
9#include <QtGui/QWindow>
10#include <QtGui/qinputdevice.h>
11#include <ace/xcomponent/native_interface_xcomponent.h>
12#include <arkui/ui_input_event.h>
13#include <qohosinputmethodeventhandler.h>
14#include <qohosplugincore.h>
15#include <render/qohosnativegestureshandler.h>
16#include <render/qxcomponent.h>
17
19
20class QOhosNativeXComponentInputHandler final
21 : public QEnableSharedFromThis<QOhosNativeXComponentInputHandler>
22{
23public:
25 QXComponentRender xcomponent,
26 QtOhos::QThreadSafeRef<QWindow> qWindowRef,
27 QtOhos::QThreadSafeRef<QOhosInputMethodEventHandler> imEventHandlerRef);
28
29 void handleTouchEvent(void *nativeWindow);
30 void handleMouseEvent(void *nativeWindow);
31 void handleHoverEvent(void *nativeWindow, bool isHover);
32 void handleKeyEvent();
33
34private:
35 struct MouseEvent
36 {
37 std::chrono::steady_clock::time_point timestamp;
38 ::OH_NativeXComponent_MouseEvent event;
39 };
40
41 struct TouchEvent
42 {
43 std::chrono::steady_clock::time_point timestamp;
44 std::chrono::nanoseconds touchTimeStamp;
45 std::vector<QOhosTouchEventTouchPointData> touchPoints;
46 QInputDevice::DeviceType deviceType;
47 };
48
49 static bool mayDropMouseEvent(
50 std::chrono::steady_clock::time_point now,
51 const MouseEvent &event, const MouseEvent &nextEvent);
52
53 void processMouseEventsInQtThread(std::vector<MouseEvent> &&batch);
54 void processTouchEventsInQtThread(std::vector<TouchEvent> &&batch);
55 void invokeMethodLaterIfSelfExists(
56 QtOhos::QObjectThreadSafeRef ctxRef,
57 std::function<void(QOhosNativeXComponentInputHandler &component)>);
58
59 QXComponentRender m_xComponent;
60 QtOhos::QThreadSafeRef<QWindow> m_qWindowRef;
61 QtOhos::QThreadSafeRef<QOhosInputMethodEventHandler> m_imEventHandlerRef;
62
63 std::function<void(std::function<void(std::vector<MouseEvent> &)>)> m_optMouseEventsHandler;
64 QOhosConsumer<TouchEvent> m_optTouchEventsHandler;
65
66 std::shared_ptr<QOhosKeyEvent> m_lastKeyEvent;
67};
68
69QT_END_NAMESPACE
70
71#endif
void setParentOrReparent(ParentDescriptor parent)
static const std::int32_t minimumNodeZIndexValue
void setSizeParentFillPercentNormalized(const QSizeF &size)
void setSaturation(int saturation)
QRectF geometry() const
void setTransparentForInput(bool transparentForInput)
void setPosition(QPoint position)
void setContrast(int contrast)
QRect nodeParentRelativeGeometryPixels() const
void startDrag(const std::vector< QImage > &images, const QPointF &hotspot, const QMimeData &mimeData, QOhosConsumer< Qt::DropAction > dropActionConsumer)
void setNodeVisibilityChangeHandler(QOhosConsumer< bool > visibilityChangedConsumer)
void detachFromParentIfPresent()
QOhosSurface * surfaceOrNull() const
void setFocused(bool focused)
void setBackgroundColor(const QColor &color)
void fillToParent(const QSize &surfaceResolution)
QRect nodeScreenGeometryPixels() const
void setNodeAreaChangeHandler(QOhosConsumer< QArkUi::QQtEmbeddedWindowNode::AreaChangeEvent > areaChangeEventConsumer)
void setVisibility(bool visible)
void setNodeFocusChangeHandler(QOhosConsumer< bool > focusedChangedConsumer)
QNativeNode(const CreateInfo &nativeNodeCreateInfo)
WId windowId() const
void addForeignWindowChild(QOhosForeignWindow *foreignWindow)
void setSize(const QSizeF &size)
void setFocusable(bool focusable)
void setBrightness(int brightness)
void setParent(std::shared_ptr< QXComponentNode > xComponent)
void setParent(QNativeNode &other)
virtual void handleQOhosHoverEvent(bool hovered)=0
virtual ~QOhosHoverEventsGenerator()
virtual void handleQOhosMouseEvent(const QOhosMouseEvent &mouseEvent)=0
QOhosNativeXComponentInputHandler(QXComponentRender xcomponent, QtOhos::QThreadSafeRef< QWindow > qWindowRef, QtOhos::QThreadSafeRef< QOhosInputMethodEventHandler > imEventHandlerRef)
void handleHoverEvent(void *nativeWindow, bool isHover)
std::enable_if_t< qohosplugincore_h_detail::isQOhosOptional< QOhosInvokeResult< Func, T > >, QOhosInvokeResult< Func, T > > andThen(Func &&func) const
static QOhosPlatformIntegration * instance()
QOhosInputMethodEventHandler * inputMethodEventHandler() const
void onHoverEvent(bool isHover) override
void onInputEvent(InputEventType inputEventType, ::OHNativeWindow *window) override
CallbackReceiver(QXComponentRender xComponent, QtOhos::QThreadSafeRef< QWindow > windowRef, QtOhos::QThreadSafeRef< QOhosInputMethodEventHandler > imEventHandlerRef, std::function< void(SurfaceEventType, ::OHNativeWindow *, QOhosOptional< QSize >)> surfaceEventHandler)
void onSurfaceEvent(SurfaceEventType surfaceEventType, ::OHNativeWindow *nativeWindow) override
Combined button and popup list for selecting options.
QArkUi::QXComponentCallbackReceiver::InputEventType InputEventType
QOhosOptional<::ArkUI_RenderFit > tryMapRenderFitPolicyToArkUi(QOhosPlatformWindow::NativeNodeRenderFitPolicy renderFitPolicy)
bool getHoveredStateFromHoverEvent(::ArkUI_UIInputEvent *uiInputEvent)
QArkUi::QXComponentCallbackReceiver::SurfaceEventType SurfaceEventType
bool isNativeNodeApiMouseEventsEnabled()
void runInJsThreadAndWait(const std::function< void(JsState &)> &task)
QOhosOptional<::ArkUI_DropOperation > tryMapQOhosArkUiDropOperationFromQt(Qt::DropAction dropAction)
::ArkUI_DropOperation getQOhosDragEventDropOperation(::ArkUI_DragEvent *dragEvent)
std::shared_ptr< QOhosHoverEventsGenerator > makeQOhosHoverEventsGenerator(QtOhos::QThreadSafeRef< QWindow > qWindowRef, QtOhos::QThreadSafeRef< QOhosInputMethodEventHandler > imEventHandlerRef)
QOhosOptional< void > makeEmptyQOhosOptional()
QXComponent< QXComponentType::Render > QXComponentRender
Definition qxcomponent.h:43
QXComponent< QXComponentType::Node > QXComponentNode
Definition qxcomponent.h:44