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
qohosinputmethodeventhandler.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 QOHOSINPUTMETHODEVENTHANDLER_H
5#define QOHOSINPUTMETHODEVENTHANDLER_H
6
7#include <ace/xcomponent/native_interface_xcomponent.h>
8#include <qpa/qwindowsysteminterface.h>
9#include <QtCore/private/qohoscommon_p.h>
10#include <QtCore/qflags.h>
11#include <QtCore/qglobal.h>
12#include <QtCore/qlist.h>
13#include <QtCore/qmap.h>
14#include <QtCore/qobject.h>
15#include <QtCore/qpointer.h>
16#include <qohoskeyevent.h>
17#include <qohoskeymodifiers.h>
18#include <qohosplugincore.h>
19#include <render/qohoswindowproxy.h>
20#include <chrono>
21#include <memory>
22#include <set>
23#include <unordered_map>
24#include <utility>
25
27
29
30class QOhosNativeXComponent;
31
40
53
65
73
84
86{
88
89public:
92
94 QWindow *targetWindow, std::chrono::nanoseconds timeStamp,
95 const std::vector<QOhosTouchEventTouchPointData> &touchPoints,
96 QInputDevice::DeviceType deviceType, QFlags<OhosKeyboardModifier> modifiers);
98 QWindow *optTargetWindow,
99 const QList<QWindowSystemInterface::TouchPoint> &touchPoints);
100 void onGestureEventFromNativeNode(const QOhosGestureEvent &gestureEvent);
101
102 void onKeyEvent(const QOhosKeyEvent &keyEvent, QWindow *targetWindow);
103 void onMouseEvent(const QOhosMouseEvent &mouseEvent);
104 void onHoverEvent(const QOhosHoverEvent &hoverEvent);
105 void onMouseWheelEvent(const QOhosWheelEvent &event, QWindow *window);
106 void onNonClientAreaMouseEvents(QWindow *targetWindow, std::vector<QOhosWindowProxy::NonClientAreaMouseEvent> eventBatch);
107 void onNonClientAreaTouchEvents(QWindow *targetWindow, std::vector<QOhosWindowProxy::NonClientAreaTouchEvent> eventBatch);
108
110
111 void grabMouse(QWindow *window);
112 void stopAnyMouseGrab();
113 void grabKeyboard(QWindow *window);
114 void stopAnyKeyboardGrab();
115
116 QPoint cursorPosition() const;
117
118private:
119 struct QWindowSystemInterfaceTouchEvent
120 {
121 QWindow *targetWindow;
122 QList<QWindowSystemInterface::TouchPoint> touchPoints;
123 QInputDevice *touchDevice;
124 std::chrono::milliseconds timestampMs;
125 QFlags<OhosKeyboardModifier> modifiers;
126 QOhosOptional<QPoint> singleTouchPointEventGlobalPosition;
127 };
128
129 QInputDevice *getPointingDeviceOrCreate(QInputDevice::DeviceType deviceType);
130
131 QOhosOptional<std::pair<QWindow *, std::uint64_t>> getLastTouchedWindowWithSeqNoIfPresent() const;
132 void handleMouseEvent(const QOhosMouseEvent &wsiEvent);
133 void handleTouchEvent(const QWindowSystemInterfaceTouchEvent &touchEvent);
134 void updateWindowsUnderTouchPoints(const QWindowSystemInterfaceTouchEvent &touchEvent);
135 void registerOnWindowCloseToResetMouseButtonsState(QWindow *window);
136
137 std::unordered_map<QInputDevice::DeviceType, QInputDevice *> m_pointingDevices;
138
139 Qt::MouseButtons m_mouseButtonsState = Qt::NoButton;
140 std::shared_ptr<void> m_lastMouseEventViewLifetimeTrackerHandle;
141
143 QPointer<QWindow> m_currentMouseGrabbingWindow;
144 QPointer<QWindow> m_currentKeyboardGrabbingWindow;
145 QMap<Qt::Key, ushort> m_autoRepeatCountMap;
146 QOhosOptional<QOhosMouseEvent> m_lastWsiMouseEvent;
147 QOhosOptional<QWindowSystemInterfaceTouchEvent> m_lastWsiTouchEvent;
148};
149
150QT_END_NAMESPACE
151
152#endif // QOHOSINPUTMETHODEVENTHANDLER_H
QOhosFloatingWindow(QWindow *window)
~QOhosFloatingWindow() override
void requestActivateWindow() override
Reimplement to let Qt be able to request activation/focus for a window.
void setVisible(bool visible) override
Reimplemented in subclasses to show the surface if visible is true, and hide it if visible is false.
bool startSystemMove() override
Reimplement this method to start a system move operation if the system supports it and return true to...
QOhosView * ownedViewOrNull() const override
void onWindowStateChanged(Qt::WindowStates oldWindowState, Qt::WindowStates currentWindowState) override
WId winId() const override
Reimplement in subclasses to return a handle to the native window.
void initialize() override
Called as part of QWindow::create(), after constructing the window.
void onWindowFlagsChanged(Qt::WindowFlags previousWindowFlags, Qt::WindowFlags currentWindowFlags) override
bool windowEvent(QEvent *event) override
Reimplement this method to be able to do any platform specific event handling.
void setGeometry(const QRect &rect) override
This function is called by Qt whenever a window is moved or resized using the QWindow API.
QOhosSurface * ownedSurfaceOrNull() const override
void setMask(const QRegion &region) override
Reimplement to be able to let Qt set the mask of a window.
void lower() override
Reimplement to be able to let Qt lower windows to the bottom of the desktop.
void raise() override
Reimplement to be able to let Qt raise windows to the top of the desktop.
QtOhos::enums::ohos::inputMethod::TextInputType TextInputType
void update(Qt::InputMethodQueries queries) override
Notification on editor updates.
QRectF keyboardRect() const override
This function can be reimplemented to return virtual keyboard rectangle in currently active window co...
void setSoftwareKeyboardVisibilityStatus(bool visible)
void showInputPanel() override
Request to show input panel.
void invokeAction(QInputMethod::Action action, int cursorPosition) override
Called when the word currently being composed in the input item is tapped by the user.
void setLastInputTypeToTriggerSoftKeyboard(RequestKeyboardReason inputType)
void reset() override
Method to be called when input method needs to be reset.
void hideInputPanel() override
Request to hide input panel.
bool isValid() const override
Returns input context validity.
bool eventFilter(QObject *obj, QEvent *event) override
Filters events if this object has been installed as an event filter for the watched object.
bool isInputPanelVisible() const override
Returns input panel visibility status.
QtOhos::enums::ohos::inputMethod::EnterKeyType EnterKeyType
QObject * focusObjectOrNull() const
void setFocusObject(QObject *object) override
This virtual method gets called to notify updated focus to object.
bool isAnimating() const override
This function can be reimplemented to return true whenever input method is animating shown or hidden.
QtOhos::enums::ohos::inputMethod::Direction Direction
void onMouseWheelEvent(const QOhosWheelEvent &event, QWindow *window)
void onNonClientAreaTouchEvents(QWindow *targetWindow, std::vector< QOhosWindowProxy::NonClientAreaTouchEvent > eventBatch)
void onHoverEvent(const QOhosHoverEvent &hoverEvent)
void onMouseEvent(const QOhosMouseEvent &mouseEvent)
void onTouchEventFromJsWindow(QWindow *optTargetWindow, const QList< QWindowSystemInterface::TouchPoint > &touchPoints)
void onGestureEventFromNativeNode(const QOhosGestureEvent &gestureEvent)
void onTouchEventFromXComponent(QWindow *targetWindow, std::chrono::nanoseconds timeStamp, const std::vector< QOhosTouchEventTouchPointData > &touchPoints, QInputDevice::DeviceType deviceType, QFlags< OhosKeyboardModifier > modifiers)
void onNonClientAreaMouseEvents(QWindow *targetWindow, std::vector< QOhosWindowProxy::NonClientAreaMouseEvent > eventBatch)
void onKeyEvent(const QOhosKeyEvent &keyEvent, QWindow *targetWindow)
void setDisplayIdFromOhos(std::optional< QOhosDisplayInfo::JsDisplayId > displayId)
void setExposedFromOhos(bool exposed)
void initialize() override
Called as part of QWindow::create(), after constructing the window.
void notifyInputSystemsWindowActiveStatusChanged(bool active)
void requestActivateWindow() override
Reimplement to let Qt be able to request activation/focus for a window.
bool isWindowPcModeEnabled() const
static QOhosSettings & instance()
QOhosSurface * surfaceOrNull() const
void setWindowMask(const QOhosWindowProxy::WindowMask &windowMask)
void lower()
bool startMoving()
void raise()
QtOhos::enums::ohos::window::AvoidAreaType AvoidAreaType
QtOhos::enums::ohos::window::RectChangeReason RectChangeReason
QtOhos::enums::ohos::window::WindowEventType WindowEventType
QtOhos::enums::ohos::window::WindowStatusType WindowStatusType
static QWindowProxyRegistry & instance()
Combined button and popup list for selecting options.
bool isWindowRotatedByTabletScreenRotation(QWindow *window, QOhosWindowProxy::RectChangeOptions rectChangeOptions)
Qt::NativeGestureType gestureType
QInputDevice::DeviceType deviceType
QPointer< QWindow > targetWindow
QPointer< QWindow > targetWindow
QInputDevice::DeviceType deviceType
QFlags< OhosKeyboardModifier > modifiers
QPointer< QWindow > targetWindow
std::chrono::milliseconds timestampMs
::OH_NativeXComponent_TouchPoint touchPoint
::OH_NativeXComponent_TouchPointToolType toolType
QFlags< OhosKeyboardModifier > modifiers