4#ifndef QOHOSWINDOWPROXY_H
5#define QOHOSWINDOWPROXY_H
7#include <QtCore/private/qnapi_p.h>
8#include <QtCore/private/qohoscommon_p.h>
9#include <QtCore/qflags.h>
10#include <QtCore/qglobal.h>
11#include <QtCore/qobject.h>
12#include <QtCore/qpoint.h>
13#include <QtCore/qpointer.h>
14#include <QtCore/qrect.h>
15#include <QtCore/qsize.h>
16#include <QtGui/qcolor.h>
17#include <QtGui/qeventpoint.h>
18#include <QtGui/qwindow.h>
23#include <qarkui/input.h>
24#include <qarkui/window.h>
25#include <qohosdisplayinfo.h>
26#include <qohosjsscopedataowner.h>
27#include <qohosplugincore.h>
28#include <qohosqpaenums.h>
29#include <qohosutils.h>
30#include <render/qohoswindowproxydatafactory.h>
31#include <render/qxcomponent.h>
36class QOhosWindowProxy
final
139 static std::shared_ptr<QOhosWindowProxy>
145 QOhosWindowProxy &
operator=(
const QOhosWindowProxy &) =
delete;
146 QOhosWindowProxy &
operator=(QOhosWindowProxy &&) =
delete;
153 void setSize(
const QSize &size);
156 void setCustomCursor(
const QImage &customCursorImage,
const QPoint &hotSpot);
163 const WindowMask &windowMask,
const std::optional<QSize> &ohosMaskSizeOverride = {});
166 void setTitle(
const QString &title);
205 QObject *contextObject, QOhosConsumer<std::vector<NonClientAreaMouseEvent>> mouseEventBatchConsumer);
207 QObject *contextObject, QOhosConsumer<std::vector<NonClientAreaTouchEvent>> touchEventBatchConsumer);
219 std::uint32_t queryLimit = 0);
221 const std::function<
bool(QOhosJsState &jsState,
const QArkUi::JsWindowRef &)> &predicate);
227 enum class EventHandlerFlagBits
229 allowCallWhenAbilityIsTerminating = 1 << 0,
230 allowEventHandlerRegistrationFailure = 1 << 1,
233 struct JsScopeData :
public std::enable_shared_from_this<JsScopeData>
246 WindowProxyType windowProxyType, QNapi::Reference<QNapi::Object> jsWindow,
247 std::shared_ptr<
void> optKeepAliveData,
249 QtOhos::QObjectThreadSafeRef owningQWindowRef);
250 JsScopeData(JsScopeData &&) =
default;
251 JsScopeData &operator=(JsScopeData &&) =
default;
253 JsScopeData(
const JsScopeData &) =
delete;
254 JsScopeData &operator=(
const JsScopeData &) =
delete;
256 std::shared_ptr<
void> registerEventListener(
257 const std::string &eventName,
259 QFlags<EventHandlerFlagBits> eventHandlerFlags);
260 std::shared_ptr<
void> registerSubWindowCloseHandler(
261 QOhosJsState &jsState,
262 std::function<
bool()> handler);
270 void handleWindowRectChangeInGlobalDisplayCallback(
const QtOhos::
CallbackInfo &cbInfo);
273 bool isWindowClosing()
const;
277 bool windowDestroyedFromSystem =
false;
278 std::shared_ptr<
void> optKeepAliveData;
281 std::shared_ptr<
void> m_windowFrameMouseFilterHandle;
282 std::shared_ptr<
void> m_windowFrameTouchFilterHandle;
283 std::shared_ptr<
void> m_eventListenersHandle;
287 struct EventHandlerDescriptor
289 const char *eventName;
291 QFlags<EventHandlerFlagBits> eventHandlerFlags;
294 struct JsThreadInitResult
298 std::string qAbilityInstanceId;
299 std::shared_ptr<
void> jsWindowRegistrationHandle;
303 const std::function<
void(
QtOhos::
JsState &, QOhosConsumer<QtOhos::JsState &, QOhosWindowProxyData>)> &makeWindowProxyDataInJsThread);
306 std::shared_ptr<
void> registerSubWindowCloseHandler(
307 std::function<
void()> handler,
308 bool handlerReturnValue);
310 static const EventHandlerDescriptor eventHandlerDescriptors[];
315 std::string m_qAbilityInstanceId;
316 std::shared_ptr<
void> m_jsWindowRegistrationHandle;
317 std::shared_ptr<
void> m_subWindowCloseRegistrationHandle;
318 std::shared_ptr<
void> m_qtWindowCallbacksReceiverHandle;
319 std::shared_ptr<
void> m_qtNonClientAreaMouseWindowCallbackReceiverHandle;
320 std::shared_ptr<
void> m_qtNonClientAreaTouchWindowCallbackReceiverHandle;
void setSizeParentFillPercentNormalized(const QSizeF &size)
void setSaturation(int saturation)
void setTransparentForInput(bool transparentForInput)
void setNodeAreaChangeHandler(QOhosConsumer< QArkUi::QQtEmbeddedWindowNode::NodeAreaInfo > areaChangeEventConsumer)
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 enableDropDisallowedBadge()
void setNodeVisibilityChangeHandler(QOhosConsumer< bool > visibilityChangedConsumer)
void detachFromParentIfPresent()
QOhosSurface * surfaceOrNull() const
void setFocused(bool focused)
void setBackgroundColor(const QColor &color)
QRect nodeScreenGeometryPixels() const
void setVisibility(bool visible)
void externalContentClickDetected()
QArkUi::QQtEmbeddedWindowNode::NodeAreaInfo nodeAreaInfo() const
void setNodeFocusChangeHandler(QOhosConsumer< bool > focusedChangedConsumer)
QNativeNode(const CreateInfo &nativeNodeCreateInfo)
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)
QArkUi::QEmbeddedWindowNode & embeddedWindowNodeInJsThread()
QOhosForeignWindow(QWindow *qWindow, WId windowId)
void initialize() override
Called as part of QWindow::create(), after constructing the window.
void setVisible(bool visible) override
Reimplemented in subclasses to show the surface if visible is true, and hide it if visible is false.
WId winId() const override
Reimplement in subclasses to return a handle to the native window.
void setGeometry(const QRect &unscaledGeometry) override
This function is called by Qt whenever a window is moved or resized using the QWindow API.
void setParent(const QPlatformWindow *window) override
This function is called to enable native child window in QPA.
bool isForeignWindow() const override
QMargins frameMargins() const override
QOhosPropertiesProvider(QOhosPropertiesStore &store)
std::optional< T > tryGetProperty() const
std::shared_ptr< void > addPropertyWriteCallback(QOhosConsumer< T > propertyWriteCallback)
QOhosPropertiesStore(QObject *qObject)
std::shared_ptr< void > addPropertyWriteCallback(QOhosConsumer< T > propertyWriteCallback)
std::optional< T > tryGetProperty() const
void notifyPropertyWrite(const QByteArray &propertyName)
bool isWindowPcModeEnabled() const
static QOhosSettings & instance()
double fontSizeScale() const
QOhosSettings(const QOhosSettings &)=delete
QOhosSettings(QOhosSettings &&)=delete
QOhosSettings & operator=(const QOhosSettings &)=delete
QOhosSettings & operator=(QOhosSettings &&)=delete
void setExtraUsageBitsForNativeWindowBuffer(std::uint64_t usageSetBits)
::OHNativeWindow * nativeWindow() const
static constexpr ::OH_NativeBuffer_Format bufferFormat
void paintOnNativeWindowSurface(std::function< std::vector<::Region::Rect >(QImage &, ::BufferHandle *)> paintFunc, std::function< void(::BufferHandle *)> onFlushSuccessFunc)
static std::optional< QSize > tryGetBufferGeometryForWindow(::OHNativeWindow *nativeWindow)
void setNativeWindowSurface(::OHNativeWindow *nativeWindow, const std::optional< QSize > &optSurfaceSize)
static QImage::Format mapNativeBufferFormatToQImageFormatOrFail(std::int32_t format)
std::optional< QSize > surfaceResolution() const
QOhosSurface(::OHNativeWindow *nativeWindow)
EGLSurface tryGetOrCreateEGLWindowSurface(EGLDisplay display, EGLConfig config, bool swappingBuffers)
void clearNativeWindowSurface()
void windowStatusChange(QOhosWindowProxy::WindowStatus windowStatus)
void setParentOrReparent(QOhosView &parentView)
bool consumePendingSelfMinimizeEcho()
void setCursor(const QCursor &cursor)
void handleWindowFlagsChange(Qt::WindowFlags previousWindowFlags, Qt::WindowFlags currentWindowFlags)
void addForeignWindowChild(QOhosForeignWindow *foreignWindow)
void handleWindowStateChange(Qt::WindowStates previousWindowState, Qt::WindowStates currentWindowState)
void setFocusable(bool focusable)
QArkUi::QQtEmbeddedWindowNode::NodeAreaInfo nodeAreaInfo() const
QOhosSurface * surfaceOrNull() const
void windowVisibilityChange(bool visibility)
void setPositionOnScreenImmediate(const QPoint &position, QOhosDisplayInfo::JsDisplayId jsDisplayId)
QList< QRect > displayCutoutRects() const
void setTransparentBackground(bool transparent)
void setModality(Qt::WindowModality modality)
bool isFullscreenImmersiveModeEnabled()
void setFramelessWindow(bool frameless)
QPixmap makeSnapshot() const
void setWindowShadowDisabled()
void setWindowTransparentForInput(bool transparentForInput)
void tryDetachFromEmbeddedParent()
ViewType viewType() const
QMargins avoidAreaMargins(QOhosWindowProxy::AvoidAreaType type) const
QWindow * ownerWindow() const
void handleSurfaceContentsUpdated()
void windowRectChanged(QOhosWindowProxy::RectChangeOptions rectChangeOptions)
void windowRectChangedInGlobalDisplay(QOhosWindowProxy::RectChangeOptions rectChangeOptions)
void forceGeometryUpdate()
void externalContentInteractionDetected()
void setWindowMinMaxCloseButtonState(const WindowMinMaxCloseButtonsState &state)
void setWindowMask(const QOhosWindowProxy::WindowMask &windowMask)
void setSizeLimits(const QSize &minSize, const QSize &maxSize)
std::optional< QSize > surfaceResolution() const
void windowTouchOutside()
void nodeAreaChanged(QArkUi::QQtEmbeddedWindowNode::NodeAreaInfo areaChangeEvt)
void handlePaletteChange()
void windowDisplayIdChanged(QOhosDisplayInfo::JsDisplayId)
static std::unique_ptr< QOhosView > createForWindow(QOhosPlatformWindow *window, QOhosPropertiesProvider windowPropertiesProvider)
void setOpacity(qreal opacity)
void setNativeNodeVisibility(bool visible)
void setWindowStaysOnTop(bool staysOnTop)
ViewGeometry viewGeometry() const
void avoidAreaChanged(QOhosWindowProxy::AvoidAreaType avoidAreaType, const QOhosWindowProxy::AvoidArea &avoidArea)
void setSize(const QSize &size)
void setPosition(const QPoint &position)
QOhosView(QWindow *ownerWindow, QSharedPointer< QNativeNode > nativeNode, QOhosPropertiesProvider propertiesProvider)
bool isSubWindowCoveringFullScreen() const
void surfaceStatusChanged(const std::optional< QSize > &optSurfaceSize)
QRect nodeParentRelativeGeometryPixels() const
void setTitle(const QString &title)
void startDrag(const std::vector< QImage > &images, const QPointF &hotspot, const QMimeData &mimeData, QOhosConsumer< Qt::DropAction > dropActionConsumer)
const QOhosView * viewParentOrNull() const
QRect nodeScreenGeometryPixels() const
void setWindowRectAutoSave(bool enabed)
void setSubWindowModalEnabled(ModalityType ModalityType)
QtOhosQpa::enums::ohos::window::MaximizePresentation MaximizePresentation
void setWindowKeepScreenOn(bool keepScreenOn)
void moveWindowToGlobal(const QPoint &position, const MoveConfiguration &moveConfiguration)
static std::shared_ptr< QOhosWindowProxy > createFloatWindow(const FloatWindowCreateInfo &createInfo)
void setWindowMask(const WindowMask &windowMask, const std::optional< QSize > &ohosMaskSizeOverride={})
QArkUi::WindowProperties getWindowProperties() const
void moveWindowToGlobalOrGlobalDisplay(const QPoint &position, std::optional< QOhosDisplayInfo::JsDisplayId > optDisplayId)
void setSubWindowModalDisabled()
void setWindowPrivacyMode(bool privacyMode)
QOhosWindowProxy(const QOhosWindowProxy &)=delete
void resetSubWindowCloseHandler()
QtOhosQpa::enums::ohos::window::WindowEventType WindowEventType
QOhosWindowProxy(QOhosWindowProxy &&)=delete
AvoidArea getWindowAvoidArea(AvoidAreaType type) const
void setWindowLayoutFullScreen(bool isLayoutFullScreen)
std::optional< QOhosDisplayInfo::JsDisplayId > tryGetMainWindowJsDisplayId() const
QtOhosQpa::enums::ohos::bundle::bundleManager::SupportWindowMode SupportWindowMode
void enableDrag(bool enable)
void setWindowCornerRadius(double radius)
QOhosWindowProxyExistingMainWindowCreateInfo ExistingMainWindowCreateInfo
void setSupportedWindowModes(const std::set< SupportWindowMode > &supportedWindowModes)
void removeStartingWindow()
void setWindowSystemBarEnable(const QStringList &names)
std::shared_ptr< QOhosWindowProxy > createSubWindow(const SubWindowCreateInfo &createInfo)
static std::shared_ptr< QOhosWindowProxy > createForExistingMainWindow(const ExistingMainWindowCreateInfo &createInfo)
void setWindowTouchable(bool touchable)
void setTitle(const QString &title)
void setFollowParentMultiScreenPolicy(bool enabled)
void setWindowTopmost(bool topmost)
std::shared_ptr< QXComponentNode > nodeXComponent() const
void setWindowCallbackReceiver(std::unique_ptr< WindowCallbacks > receiver)
static std::vector< QArkUi::JsWindowId > queryWindowIdsByCoordinate(QOhosDisplayInfo::JsDisplayId displayId, const QPoint &queryLocation, std::uint32_t queryLimit=0)
void setSubWindowCloseHandler(std::function< void()> handler, bool handlerReturnValue)
std::optional< bool > isFocused() const
QtOhosQpa::enums::ohos::window::ModalityType ModalityType
void setWindowLimits(const QSize &minSize, const QSize &maxSize)
bool isWindowRectAutoSave() const
void setWindowDecorVisible(bool visible)
void showWindow(const ShowWindowOptions &options=ShowWindowOptions())
QtOhosQpa::enums::ohos::window::RectChangeReason RectChangeReason
void shiftAppWindowFocus(QOhosWindowProxy &targetProxy)
QOhosWindowProxySubWindowCreateInfo SubWindowCreateInfo
void setNonClientAreaMouseWindowCallbackReceiver(QObject *contextObject, QOhosConsumer< std::vector< NonClientAreaMouseEvent > > mouseEventBatchConsumer)
QtOhosQpa::enums::ohos::window::AvoidAreaType AvoidAreaType
void setCustomCursor(const QImage &customCursorImage, const QPoint &hotSpot)
void setWindowTitleMoveEnabled(bool enabled)
void setWindowFocusable(bool focusable)
void setWindowBackgroundColor(const QColor &color)
void setSize(const QSize &size)
QOhosWindowProxyMainWindowCreateInfo MainWindowCreateInfo
void setWindowShadowRadius(double radius)
bool qtIsMainWindow() const
QOhosWindowProxyFloatWindowCreateInfo FloatWindowCreateInfo
void setWindowTitleButtonVisible(bool maximizeVisible, bool minimizeVisible, bool closeVisible)
bool getImmersiveModeEnabledState()
void setPointerStyleSync(const QCursor &cursor)
QList< QRect > getDisplayCutoutRects() const
QtOhosQpa::enums::ohos::window::WindowStatusType WindowStatusType
QOhosWindowProxy & operator=(const QOhosWindowProxy &)=delete
static std::vector< QArkUi::JsWindowId > queryQtManagedWindowIdsByPredicate(const std::function< bool(QOhosJsState &jsState, const QArkUi::JsWindowRef &)> &predicate)
QOhosWindowProxy & operator=(QOhosWindowProxy &&)=delete
WindowLimits getWindowLimits() const
std::string qAbilityInstanceId() const
void maximize(MaximizePresentation maximizePresentation)
void setNonClientAreaTouchWindowCallbackReceiver(QObject *contextObject, QOhosConsumer< std::vector< NonClientAreaTouchEvent > > touchEventBatchConsumer)
static std::shared_ptr< QOhosWindowProxy > createMainWindow(const MainWindowCreateInfo &createInfo)
bool sendEvent(WindowSystemEvent *event) override
JsScopeDataOwner(const JsScopeDataOwner &)=delete
JsScopeData & operator*() const
JsScopeData * operator->() const
JsScopeDataOwner & operator=(const JsScopeDataOwner &)=delete
void addAsyncCleanup(std::function< void(QOhosJsState &, JsScopeData &, QOhosTaskPromise<>)> cleanupFunc)
JsScopeDataOwner & operator=(JsScopeDataOwner &&)=delete
JsScopeDataOwner(JsScopeDataOwner &&)=delete
Combined button and popup list for selecting options.
@ ForwardToGuiApplication
QOhosView * mapQWindowToViewOrNull(QWindow *window)
std::optional< T > tryMapFromQVariant(QVariant variant)
const char * qObjectOhosPropertyName()
std::shared_ptr< QWindowSystemEventHandler > makeApplicationStateTracker()
bool isHandheldDeviceType()
QOhosRuntimeDeviceTypeAndMode
@ HandheldDeviceFullScreen
@ HandheldDeviceWindowPcMode
constexpr QOhosRuntimeDeviceTypeAndMode operator|(QOhosRuntimeDeviceTypeAndMode lhs, QOhosRuntimeDeviceTypeAndMode rhs)
QOhosRuntimeDeviceTypeAndMode queryQOhosRuntimeDeviceAndMode()
void setQOhosPropertyOnQObject(QObject *qObject, T propertyValue)
std::optional< T > tryGetQOhosPropertyFromQObject(QObject *qObject)
Q_DECLARE_METATYPE(QOhosWindowProxy::RectChangeOptions)
QT_END_NAMESPACE Q_DECLARE_METATYPE(QOhosWindowProxy::WindowEvent)
Q_DECLARE_METATYPE(QOhosWindowProxy::AvoidArea)
Q_DECLARE_METATYPE(QOhosWindowProxy::WindowStatus)
QXComponent< QXComponentType::Node > QXComponentNode
bool disableWindowFocusableBeforeLoadContent
std::optional< QOhosDisplayInfo::JsDisplayId > displayId
QOhosConsumer< NonClientAreaMouseEvent > mouseEventsConsumer
void onTouchEventFromArkUi(const QArkUi::TouchEvent &event) const
void onMouseEventFromArkUi(const QArkUi::MouseEvent &event) const
QOhosConsumer< NonClientAreaTouchEvent > touchEventsConsumer
std::optional< QOhosDisplayInfo::JsDisplayId > displayId
std::chrono::milliseconds timestamp
std::chrono::milliseconds timestamp
std::optional< bool > focusOnShow
QOhosConsumer< QOhosWindowProxy::AvoidAreaType, QOhosWindowProxy::AvoidArea > onAvoidAreaChange
QOhosConsumer< QOhosDisplayInfo::JsDisplayId > onWindowDisplayIdChange
QOhosConsumer< QOhosWindowProxy::RectChangeOptions > onWindowRectChange
QOhosConsumer< QOhosWindowProxy::RectChangeOptions > onWindowRectChangeInGlobalDisplay
std::function< void()> onTouchOutside
QOhosConsumer< QOhosWindowProxy::WindowStatus > onWindowStatusChange
QOhosConsumer< QOhosWindowProxy::WindowEvent > onWindowEvent
QOhosConsumer< bool > onWindowVisibilityChange
std::optional< double > maxWidth
std::optional< double > minWidth
std::optional< double > minHeight
std::optional< double > maxHeight