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
qohosscreenmanager.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 QOHOSSCREENMANAGER_H
5#define QOHOSSCREENMANAGER_H
6
7#include <QObject>
8#include <QPointer>
9#include <QtCore/private/qnapi_p.h>
10#include <QtCore/private/qohoscommon_p.h>
11#include <map>
12#include <memory>
13#include <qohosdisplayinfo.h>
14#include <qohosplatformscreen.h>
15#include <qohosplugincore.h>
16
18
19class QOhosScreenManager final : public QObject
20{
22
23public:
25
28
29private:
30 using JsDisplayId = QOhosDisplayInfo::JsDisplayId;
31
32 class QOhosPlatformScreenHolder
33 {
34 public:
35 explicit QOhosPlatformScreenHolder(const QOhosDisplayInfo &displayInfo);
36
37 QOhosPlatformScreenHolder(const QOhosPlatformScreenHolder &) = delete;
38 QOhosPlatformScreenHolder(QOhosPlatformScreenHolder &&) = delete;
39 QOhosPlatformScreenHolder &operator=(const QOhosPlatformScreenHolder &) = delete;
40 QOhosPlatformScreenHolder &operator=(QOhosPlatformScreenHolder &&) = delete;
41
42 ~QOhosPlatformScreenHolder();
43
44 QOhosPlatformScreen *platformScreenOrNull() const;
45
46 private:
47 QPointer<QOhosPlatformScreen> m_platformScreen;
48 };
49
50 void handleDisplayChangedCallbackInQtThread(const QOhosDisplayInfo &displayInfo);
51 void handleDisplayAdded(const QOhosDisplayInfo &displayInfo);
52 void handleDisplayRemoved(QOhosDisplayInfo::JsDisplayId displayId);
53 void handleDisplayAvailableAreaChanged(JsDisplayId jsDisplayID, QRectF availableArea);
54
55 QOhosPlatformScreenHolder *platformScreenHolderForDisplayIdOrNull(QOhosDisplayInfo::JsDisplayId displayId) const;
56 void addScreen(QOhosDisplayInfo displayInfo);
57 void removeScreenIfExists(QOhosDisplayInfo::JsDisplayId displayId);
58 void updatePrimaryPlatformScreenIfNeeded();
59
60 class JsScopeData : public std::enable_shared_from_this<JsScopeData>
61 {
62 public:
71
72 static std::shared_ptr<JsScopeData> create(QtOhos::JsState &jsState, CreateInfo createInfo);
73
74 std::vector<QOhosDisplayInfo> getRegisteredDisplayInfos();
75
76 private:
77 JsScopeData(QtOhos::JsState &);
78
79 void initialize(QtOhos::JsState &jsState, CreateInfo createInfo);
80 void registerDisplayCallbackListener(
81 QNapi::Object displayModule, const std::string &eventName,
82 QOhosConsumer<QtOhos::JsState &, QOhosDisplayInfo::JsDisplayId> handleFunction);
83 bool tryRegisterDisplay(QtOhos::JsState &jsState, JsDisplayId displayId);
84 void unregisterDisplay(JsDisplayId displayId);
85
86 std::vector<QOhosDisplayInfo> m_registeredDisplayInfos;
87 std::vector<std::shared_ptr<void>> m_destroyNotifiers;
88 std::map<JsDisplayId, std::shared_ptr<void>> m_perDisplayDestroyNotifiers;
89 QOhosConsumer<QtOhos::JsState &, JsDisplayId, QRectF> m_availableAreaChangedCb;
90 };
91
92 std::shared_ptr<JsScopeData> m_jsScopeData;
93 JsDisplayId m_primaryDisplayId;
94 std::map<JsDisplayId, std::unique_ptr<QOhosPlatformScreenHolder>> m_displays;
95};
96
97QT_END_NAMESPACE
98
99#endif
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
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.
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.
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.
void onMouseWheelEvent(const QOhosWheelEvent &event, QWindow *window)
void onNonClientAreaTouchEvents(QWindow *targetWindow, std::vector< QOhosWindowProxy::NonClientAreaTouchEvent > eventBatch)
void onGestureEventFromNativeNode(QWindow *targetWindow, std::int64_t timestamp, qreal value, QPointF localPosition, QPointF screenPosition, Qt::NativeGestureType gestureType, QInputDevice::DeviceType deviceType)
void onMouseEvent(const QOhosMouseEvent &mouseEvent)
void onTouchEventFromJsWindow(QWindow *optTargetWindow, const QList< QWindowSystemInterface::TouchPoint > &touchPoints)
void onTouchEventFromXComponent(QWindow *targetWindow, std::chrono::nanoseconds timeStamp, const std::vector< QOhosTouchEventTouchPointData > &touchPoints, QInputDevice::DeviceType deviceType)
void onHoverEvent(bool isHover, const QPointF &local, const QPointF &global, QWindow *window)
void onNonClientAreaMouseEvents(QWindow *targetWindow, std::vector< QOhosWindowProxy::NonClientAreaMouseEvent > eventBatch)
void onKeyEvent(const QOhosKeyEvent &keyEvent, QWindow *targetWindow)
virtual bool equals(const QOhosKeyEvent &other) const =0
virtual QOhosOptional< QOhosQtKeyEvent > tryConvertToQOhosQtKeyEvent() const =0
virtual ~QOhosKeyEvent()
std::enable_if_t< qohosplugincore_h_detail::isQOhosOptional< QOhosInvokeResult< Func, T > >, QOhosInvokeResult< Func, T > > andThen(Func &&func) const
static void setMainWindowGeometryPersistencePolicy(WindowGeometryPersistencePolicy policy)
QOhosScreenManager * screenManager() const
QPlatformOpenGLContext * createPlatformOpenGLContext(QOpenGLContext *context) const override
Factory function for QPlatformOpenGLContext.
QOhosPlatformClipboard * clipboard() const override
Accessor for the platform integration's clipboard.
QPlatformOffscreenSurface * createPlatformOffscreenSurface(QOffscreenSurface *surface) const override
Factory function for QOffscreenSurface.
static void setDefaultDisplayMetrics(const QOhosDisplayInfo &m_displayInfo)
bool hasCapability(Capability cap) const override
QPlatformInputContext * inputContext() const override
Returns the platforms input context.
QPlatformFontDatabase * fontDatabase() const override
Accessor for the platform integration's fontdatabase.
QPlatformServices * services() const override
QPlatformNativeInterface * nativeInterface() const override
QOpenGLContext * createOpenGLContext(EGLContext context, EGLDisplay display, QOpenGLContext *shareContext) const override
QPlatformWindow * createPlatformWindow(QWindow *window) const override
Factory function for QPlatformWindow.
static QOhosPlatformIntegration * instance()
QPlatformTheme * createPlatformTheme(const QString &name) const override
QVariant styleHint(StyleHint hint) const override
QStringList themeNames() const override
static WindowGeometryPersistencePolicy getMainWindowGeometryPersistencePolicy()
Qt::WindowState defaultWindowState(Qt::WindowFlags flags) const override
QPlatformWindow * createForeignWindow(QWindow *, WId) const override
QOhosInputMethodEventHandler * inputMethodEventHandler() const
QPlatformBackingStore * createPlatformBackingStore(QWindow *window) const override
Factory function for QPlatformBackingStore.
QOhosPlatformIntegration(const QStringList &paramList)
QAbstractEventDispatcher * createEventDispatcher() const override
Factory function for the GUI event dispatcher.
void initialize() override
Performs initialization steps that depend on having an event dispatcher available.
static QOhosSystemLocale * systemLocale()
static void setSystemLocale(QOhosSystemLocale *systemLocale)
void setDisplayIdFromOhos(QOhosOptional< QOhosDisplayInfo::JsDisplayId > displayId)
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.
QOhosPlatformScreen * platformScreenForDisplayIdOrNull(QOhosDisplayInfo::JsDisplayId displayId) const
QOhosPlatformScreen * platformScreenForDisplayIdOrFail(QOhosDisplayInfo::JsDisplayId displayId) const
QOhosSurface * surfaceOrNull() const
void setWindowMask(const QOhosWindowProxy::WindowMask &windowMask)
void lower()
ViewGeometry viewGeometry() const
bool startMoving()
bool isSubWindowCoveringFullScreen() const
void raise()
static QWindowProxyRegistry & instance()
bool isWindowPcModeEnabled()
Combined button and popup list for selecting options.
bool isWindowRotatedByTabletScreenRotation(QWindow *window, QOhosWindowProxy::RectChangeOptions rectChangeOptions)
Qt::KeyboardModifiers convertOhosToQtKeyboardModifiers(QFlags< OhosKeyboardModifier > ohosKeysModifiers)
QFlags< OhosKeyboardModifier > readKeyModifiersFromKeyState(QSpan< const OhosKeyToModifier > keysToModifiers)
QFlags< OhosKeyboardModifier > readKeyModifiersFromOhosUiInputEvent(::ArkUI_UIInputEvent *uiInputEvent)
OhosKeyboardModifier
QOhosRuntimeDeviceTypeAndMode queryQOhosRuntimeDeviceAndMode()
::Input_KeyStateAction keyStateActionKeyActive
std::vector<::Input_KeyCode > keysToCheck
std::int32_t(* getKeyStateActionFunc)(const ::Input_KeyState *)
OhosKeyboardModifier modifier
QFlags< OhosKeyboardModifier > modifiers
QPointer< QWindow > targetWindow
std::chrono::milliseconds timestampMs
Qt::KeyboardModifiers modifiers
QEvent::Type keyAction
Qt::KeyboardModifiers guiApplicationKeyboardModifiers
quint32 nativeKeyCode
QOhosConsumer< QtOhos::JsState &, JsDisplayId > displayAddedCb
QOhosConsumer< QtOhos::JsState &, JsDisplayId, QRectF > displayAvailableAreaChangedCb
QOhosConsumer< QtOhos::JsState &, JsDisplayId > displayRemovedCb
std::vector< QOhosDisplayInfo > displayInfos
QOhosConsumer< QtOhos::JsState &, JsDisplayId > displayChangedCb
::OH_NativeXComponent_TouchPoint touchPoint
QFlags< OhosKeyboardModifier > modifiers