7#include <QtCore/private/qohoscommon_p.h>
8#include <QtCore/qflags.h>
9#include <QtCore/qglobal.h>
10#include <QtCore/qharmonyjsobjectref.h>
11#include <QtCore/qmimedata.h>
12#include <QtCore/qobject.h>
13#include <QtCore/qpoint.h>
14#include <QtCore/qpointer.h>
15#include <QtCore/qsharedpointer.h>
16#include <QtCore/qsize.h>
17#include <QtCore/qstring.h>
18#include <QtGui/qimage.h>
19#include <QtGui/qwindow.h>
22#include <qohosdisplayinfo.h>
23#include <qohosforeignwindow.h>
24#include <qohosplatformwindow.h>
25#include <qohosplugincore.h>
26#include <qohosruntimedevicetypeandmode.h>
27#include <qohossettings.h>
28#include <qohoswindowproperty.h>
29#include <render/qnativenode.h>
30#include <render/qohossurface.h>
31#include <render/qohoswindowproxy.h>
38enum class ViewGeometryPersistencePolicy
102 QWindow *ownerWindow, QSharedPointer<QNativeNode> nativeNode,
105 void setSizeLimits(
const QSize &minSize,
const QSize &maxSize);
107 void setSize(
const QSize &size);
114 void setTitle(
const QString &title);
135 const std::vector<QImage> &images,
const QPointF &hotspot,
136 const QMimeData &mimeData, QOhosConsumer<Qt::DropAction> dropActionConsumer);
139 Qt::WindowStates previousWindowState, Qt::WindowStates currentWindowState);
141 Qt::WindowFlags previousWindowFlags, Qt::WindowFlags currentWindowFlags);
185 void applyPhoneWindowChrome(JsCallBatch &jsCallBatch);
193 struct SystemUpdateDataProperty
195 std::optional<T> optPendingUpdateRequest;
205 struct SystemUpdateData
207 WindowModeOnlySystemUpdateDataProperty<QSize> size;
208 WindowModeOnlySystemUpdateDataProperty<std::pair<QSize, QSize>> sizeLimits;
209 WindowModeOnlySystemUpdateDataProperty<std::pair<QPoint, std::optional<QOhosDisplayInfo::JsDisplayId>>> position;
210 SystemUpdateDataProperty<
bool> visibility;
211 NoTabletSystemUpdateDataProperty<
bool> backgroundTransparent;
212 SystemUpdateDataProperty<QCursor> cursor;
213 NoTabletSystemUpdateDataProperty<
bool> focusable;
214 SystemUpdateDataProperty<QColor> backgroundColor;
215 SystemUpdateDataProperty<
int> brightness;
216 SystemUpdateDataProperty<
int> contrast;
217 SystemUpdateDataProperty<
int> saturation;
218 SystemUpdateDataProperty<
bool> windowTransparentForInput;
219 WindowModeOnlySystemUpdateDataProperty<Qt::WindowModality> modality;
220 WindowModeOnlySystemUpdateDataProperty<QString> title;
221 WindowModeOnlySystemUpdateDataProperty<WindowMinMaxCloseButtonsState> windowMinMaxCloseButtonsState;
222 WindowModeOnlySystemUpdateDataProperty<
bool> windowStaysOnTop;
223 WindowModeOnlySystemUpdateDataProperty<
bool> frameless;
226 static constexpr auto makeSystemUpdateDataPropertyUpdateFuncPairsTuple()
229 return std::make_tuple(
230 std::make_pair(&SystemUpdateData::position, &QOhosView::updateWindowPosition),
231 std::make_pair(&SystemUpdateData::sizeLimits, &QOhosView::updateWindowSizeLimits),
232 std::make_pair(&SystemUpdateData::size, &QOhosView::updateWindowSize),
233 std::make_pair(&SystemUpdateData::backgroundTransparent, &QOhosView::updateWindowBackgroundTransparency),
234 std::make_pair(&SystemUpdateData::cursor, &QOhosView::updateWindowCursor),
235 std::make_pair(&SystemUpdateData::focusable, &QOhosView::updateWindowFocusable),
236 std::make_pair(&SystemUpdateData::backgroundColor, &QOhosView::updateWindowBackgroundColor),
237 std::make_pair(&SystemUpdateData::brightness, &QOhosView::updateWindowBrightness),
238 std::make_pair(&SystemUpdateData::contrast, &QOhosView::updateWindowContrast),
239 std::make_pair(&SystemUpdateData::saturation, &QOhosView::updateWindowSaturation),
240 std::make_pair(&SystemUpdateData::windowTransparentForInput, &QOhosView::updateWindowTransparentForInput),
241 std::make_pair(&SystemUpdateData::modality, &QOhosView::updateWindowModality),
242 std::make_pair(&SystemUpdateData::title, &QOhosView::updateWindowTitle),
243 std::make_pair(&SystemUpdateData::windowMinMaxCloseButtonsState, &QOhosView::updateWindowMinMaxCloseButtonsState),
244 std::make_pair(&SystemUpdateData::windowStaysOnTop, &QOhosView::updateWindowStaysOnTop),
245 std::make_pair(&SystemUpdateData::frameless, &QOhosView::updateWindowFrameless));
249 void setSystemUpdateProperty(SystemUpdateDataProperty<T, SupportedModes> SystemUpdateData::*property,
const T &value);
251 void scheduleSystemUpdateIfNeeded();
252 void updateWindowSize(
const QSize &size, JsCallBatch &jsCallBatch);
253 void updateWindowSizeLimits(
const std::pair<QSize, QSize> &sizeLimits, JsCallBatch &jsCallBatch);
254 void updateWindowPosition(
255 const std::pair<QPoint, std::optional<QOhosDisplayInfo::JsDisplayId>> &position, JsCallBatch &jsCallBatch);
256 void updateWindowBackgroundTransparency(
bool transparent, JsCallBatch &jsCallBatch);
257 void updateWindowCursor(
const QCursor &cursor, JsCallBatch &jsCallBatch);
258 void updateWindowFocusable(
bool focusable, JsCallBatch &jsCallBatch);
259 void updateWindowBackgroundColor(
const QColor &color, JsCallBatch &jsCallBatch);
260 void updateWindowBrightness(
int brightness, JsCallBatch &jsCallBatch);
261 void updateWindowContrast(
int contast, JsCallBatch &jsCallBatch);
262 void updateWindowSaturation(
int saturation, JsCallBatch &jsCallBatch);
263 void updateWindowTransparentForInput(
bool transparentForInput, JsCallBatch &jsCallBatch);
264 void updateWindowModality(Qt::WindowModality modality, JsCallBatch &jsCallBatch);
265 void updateWindowTitle(
const QString &title, JsCallBatch &jsCallBatch);
267 void updateWindowStaysOnTop(
bool staysOnTop, JsCallBatch &jsCallBatch);
268 void updateWindowFrameless(
bool frameless, JsCallBatch &jsCallBatch);
269 void updateWindowShadowDisabled(JsCallBatch &jsCallBatch);
270 void updateMainWindowRestored(JsCallBatch &jsCallBatch = JsCallBatch
::immediate());
272 void flushSystemPropertyUpdatesImmediate(JsCallBatch &jsCallBatch);
273 QOhosWindowProxy *windowProxyAfterPropertyUpdatesOrNull(JsCallBatch &jsCallBatch);
274 void updateWindowFullScreen(JsCallBatch &jsCallBatch);
275 void updateWindowMaximized(JsCallBatch &jsCallBatch);
276 void setOrResetWindowProxy(
std::shared_ptr<QOhosWindowProxy> windowProxy, QWindow *optLogicalParent);
277 const QOhosView *ancestorViewWithWindowOrNull()
const;
278 void updateNativeNodeVisibility(
bool visible, JsCallBatch &jsCallBatch);
279 void hideMainWindow(JsCallBatch &jsCallBatch);
280 void setWindowCornerRadius(
double radius, JsCallBatch &jsCallBatch = JsCallBatch
::immediate());
281 void setPrivacyMode(
bool privacyModeEnabled, JsCallBatch &jsCallBatch = JsCallBatch
::immediate());
282 void setBackgroundColor(
const QColor &color);
283 void setBrightness(
int brightness);
284 void setContrast(
int contrast);
285 void setSaturation(
int saturation);
286 void setWindowKeepScreenOn(
bool keepScreenOn, JsCallBatch &jsCallBatch = JsCallBatch
::immediate());
287 void setFixedSizeStateEnabled(
bool fixedSizeStateEnabled, JsCallBatch &jsCallBatch = JsCallBatch
::immediate());
288 void setWindowDragResizable(
bool dragResizable, JsCallBatch &jsCallBatch = JsCallBatch
::immediate());
289 void showWindow(JsCallBatch &jsCallBatch = JsCallBatch
::immediate());
290 void sendAsyncSyntheticWindowActiveEvent();
291 static bool canShiftSystemFocus(
const QOhosView *fromHostView,
const QOhosView *toHostView);
293 std::shared_ptr<QOhosWindowProxy> tryCreateWindowProxyIfNeeded(ViewType viewType, QWindow *optLogicalParent);
295 bool isWindowTransparencyRequested()
const;
297 bool isFixedSizeStateEnabled()
const;
298 bool isMaximizeRequestSupportedOrLogWarning()
const;
301 QPointer<QWindow> m_ownerWindow;
302 std::shared_ptr<QOhosWindowProxy> m_ohosWindowProxy;
303 QSharedPointer<QNativeNode> m_nativeNode;
304 SystemUpdateData m_updateData;
305 bool m_updatePending;
306 std::function<QOhosWindowProxy::AvoidArea(QOhosWindowProxy::AvoidAreaType)> m_avoidAreasProvider;
307 bool m_requireHandheldDeviceSupport;
308 QtOhos::InternalWindowId m_ownerWindowId;
309 bool m_windowDestroyed =
false;
310 std::optional<ViewType> m_viewType;
311 QPointer<QWindow> m_optLogicalParent;
312 QPointer<QOhosView> m_embeddedViewToActivateOnActive;
314 ViewGeometryPersistencePolicy m_geometryPersistencePolicy = ViewGeometryPersistencePolicy::Ignore;
315 std::shared_ptr<
void> m_windowPropertiesProviderCallbacksHandle;
316 std::function<
void()> m_optPostSurfaceDrawTask;
317 int m_pendingSelfMinimizeEchoes = 0;
318 std::atomic<
bool> m_surfaceHasContent =
false;
322void QOhosView::setSystemUpdateProperty(SystemUpdateDataProperty<T, SupportedModes> SystemUpdateData::*propertyMemberPtr,
const T &value)
324 QFlags<QOhosRuntimeDeviceTypeAndMode> supportedModes(SupportedModes);
326 if (m_requireHandheldDeviceSupport
327 && !supportedModes.testFlag(QOhosRuntimeDeviceTypeAndMode::HandheldDeviceWindowPcMode)
328 && !supportedModes.testFlag(QOhosRuntimeDeviceTypeAndMode::HandheldDeviceFullScreen)) {
332 bool windowModeOnly =
333 !supportedModes.testFlag(QOhosRuntimeDeviceTypeAndMode::HandheldDeviceFullScreen)
334 && (supportedModes.testFlag(QOhosRuntimeDeviceTypeAndMode::_2in1)
335 || supportedModes.testFlag(QOhosRuntimeDeviceTypeAndMode::HandheldDeviceWindowPcMode));
337 if (windowModeOnly && !QOhosSettings::instance().isWindowPcModeEnabled()
338 && viewType() == ViewType::MainWindow) {
342 auto &property = m_updateData.*propertyMemberPtr;
343 if (property.optPendingUpdateRequest != value) {
344 property.optPendingUpdateRequest = value;
345 scheduleSystemUpdateIfNeeded();
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)
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)
QList< QRect > displayCutoutRects() const
void setTransparentBackground(bool transparent)
void setModality(Qt::WindowModality modality)
bool isFullscreenImmersiveModeEnabled()
void setFramelessWindow(bool frameless)
QPixmap makeSnapshot() const
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
QHarmonyJsObjectRef abilityObjectRef() const
QOhosView(QWindow *ownerWindow, QSharedPointer< QNativeNode > nativeNode, QOhosPropertiesProvider propertiesProvider, QWindow *optLogicalParent)
void windowTouchOutside()
void nodeAreaChanged(QArkUi::QQtEmbeddedWindowNode::NodeAreaInfo areaChangeEvt)
void handlePaletteChange()
void windowResizeRejected(QSize rejectedSize)
void windowDisplayIdChanged(QOhosDisplayInfo::JsDisplayId)
static std::unique_ptr< QOhosView > createForWindow(QOhosPlatformWindow *window, QOhosPropertiesProvider windowPropertiesProvider)
void setOpacity(qreal opacity)
QHarmonyJsObjectRef jsWindowObjectRef() const
void windowMoveRejected(QPoint rejectedPosition)
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)
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
QtOhosQpa::enums::ohos::window::AvoidAreaType AvoidAreaType
bool sendEvent(WindowSystemEvent *event) override
static JsCallBatch & immediate()
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()
QOhosRuntimeDeviceTypeAndMode
@ HandheldDeviceFullScreen
@ HandheldDeviceWindowPcMode
void setQOhosPropertyOnQObject(QObject *qObject, T propertyValue)
std::optional< T > tryGetQOhosPropertyFromQObject(QObject *qObject)
bool disableWindowFocusableBeforeLoadContent
std::optional< QOhosDisplayInfo::JsDisplayId > displayId