7#include <QtCore/private/qohoscommon_p.h>
8#include <QtCore/qflags.h>
9#include <QtCore/qglobal.h>
10#include <QtCore/qmimedata.h>
11#include <QtCore/qobject.h>
12#include <QtCore/qpoint.h>
13#include <QtCore/qpointer.h>
14#include <QtCore/qsharedpointer.h>
15#include <QtCore/qsize.h>
16#include <QtCore/qstring.h>
17#include <QtGui/qimage.h>
18#include <QtGui/qwindow.h>
21#include <qohosdisplayinfo.h>
22#include <qohosforeignwindow.h>
23#include <qohosplatformwindow.h>
24#include <qohosruntimedevicetypeandmode.h>
25#include <qohossettings.h>
26#include <qohoswindowproperty.h>
27#include <render/qnativenode.h>
28#include <render/qohossurface.h>
29#include <render/qohoswindowproxy.h>
35enum class ViewGeometryPersistencePolicy
99 QWindow *ownerWindow, QSharedPointer<QNativeNode> nativeNode,
102 void setSizeLimits(
const QSize &minSize,
const QSize &maxSize);
105 void setSize(
const QSize &size);
112 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);
179 void applyPhoneWindowChrome();
187 struct SystemUpdateDataProperty
189 std::optional<T> optPendingUpdateRequest;
199 struct SystemUpdateData
201 WindowModeOnlySystemUpdateDataProperty<QSize> size;
202 WindowModeOnlySystemUpdateDataProperty<std::pair<QSize, QSize>> sizeLimits;
203 WindowModeOnlySystemUpdateDataProperty<std::pair<QPoint, std::optional<QOhosDisplayInfo::JsDisplayId>>> position;
204 SystemUpdateDataProperty<
bool> visibility;
205 NoTabletSystemUpdateDataProperty<
bool> backgroundTransparent;
206 SystemUpdateDataProperty<QCursor> cursor;
207 NoTabletSystemUpdateDataProperty<
bool> focusable;
208 SystemUpdateDataProperty<QColor> backgroundColor;
209 SystemUpdateDataProperty<
int> brightness;
210 SystemUpdateDataProperty<
int> contrast;
211 SystemUpdateDataProperty<
int> saturation;
212 SystemUpdateDataProperty<
bool> windowTransparentForInput;
213 WindowModeOnlySystemUpdateDataProperty<Qt::WindowModality> modality;
214 WindowModeOnlySystemUpdateDataProperty<QString> title;
215 WindowModeOnlySystemUpdateDataProperty<WindowMinMaxCloseButtonsState> windowMinMaxCloseButtonsState;
216 WindowModeOnlySystemUpdateDataProperty<
bool> windowStaysOnTop;
217 WindowModeOnlySystemUpdateDataProperty<
bool> frameless;
220 static constexpr auto makeSystemUpdateDataPropertyUpdateFuncPairsTuple()
222 return std::make_tuple(
223 std::make_pair(&SystemUpdateData::sizeLimits, &QOhosView::updateWindowSizeLimits),
224 std::make_pair(&SystemUpdateData::size, &QOhosView::updateWindowSize),
225 std::make_pair(&SystemUpdateData::position, &QOhosView::updateWindowPosition),
226 std::make_pair(&SystemUpdateData::backgroundTransparent, &QOhosView::updateWindowBackgroundTransparency),
227 std::make_pair(&SystemUpdateData::cursor, &QOhosView::updateWindowCursor),
228 std::make_pair(&SystemUpdateData::focusable, &QOhosView::updateWindowFocusable),
229 std::make_pair(&SystemUpdateData::backgroundColor, &QOhosView::updateWindowBackgroundColor),
230 std::make_pair(&SystemUpdateData::brightness, &QOhosView::updateWindowBrightness),
231 std::make_pair(&SystemUpdateData::contrast, &QOhosView::updateWindowContrast),
232 std::make_pair(&SystemUpdateData::saturation, &QOhosView::updateWindowSaturation),
233 std::make_pair(&SystemUpdateData::windowTransparentForInput, &QOhosView::updateWindowTransparentForInput),
234 std::make_pair(&SystemUpdateData::modality, &QOhosView::updateWindowModality),
235 std::make_pair(&SystemUpdateData::title, &QOhosView::updateWindowTitle),
236 std::make_pair(&SystemUpdateData::windowMinMaxCloseButtonsState, &QOhosView::updateWindowMinMaxCloseButtonsState),
237 std::make_pair(&SystemUpdateData::windowStaysOnTop, &QOhosView::updateWindowStaysOnTop),
238 std::make_pair(&SystemUpdateData::frameless, &QOhosView::updateWindowFrameless));
242 void setSystemUpdateProperty(SystemUpdateDataProperty<T, SupportedModes> SystemUpdateData::*property,
const T &value);
244 void scheduleSystemUpdateIfNeeded();
245 void updateWindowSize(
const QSize &size);
246 void updateWindowSizeLimits(
const std::pair<QSize, QSize> &sizeLimits);
247 void updateWindowPosition(
const std::pair<QPoint, std::optional<QOhosDisplayInfo::JsDisplayId>> &position);
248 void updateWindowBackgroundTransparency(
bool transparent);
249 void updateWindowCursor(
const QCursor &cursor);
250 void updateWindowFocusable(
bool focusable);
251 void updateWindowBackgroundColor(
const QColor &color);
252 void updateWindowBrightness(
int brightness);
253 void updateWindowContrast(
int contast);
254 void updateWindowSaturation(
int saturation);
255 void updateWindowTransparentForInput(
bool transparentForInput);
256 void updateWindowModality(Qt::WindowModality modality);
257 void updateWindowTitle(
const QString &title);
259 void updateWindowStaysOnTop(
bool staysOnTop);
260 void updateWindowFrameless(
bool frameless);
262 void flushSystemPropertyUpdatesImmediate();
263 QOhosWindowProxy *flushedWindowProxyOrNull();
264 void setOrResetWindowProxy(
std::shared_ptr<QOhosWindowProxy> windowProxy, QWindow *optLogicalParent);
265 const QOhosView *ancestorViewWithWindowOrNull()
const;
266 void hideMainWindow();
267 void setWindowCornerRadius(
double radius);
268 void setPrivacyMode(
bool privacyModeEnabled);
269 void setBackgroundColor(
const QColor &color);
270 void setBrightness(
int brightness);
271 void setContrast(
int contrast);
272 void setSaturation(
int saturation);
273 void setWindowKeepScreenOn(
bool keepScreenOn);
274 void setFixedSizeStateEnabled(
bool fixedSizeStateEnabled);
275 void setWindowDragResizable(
bool dragResizable);
277 void sendAsyncSyntheticWindowActiveEvent();
279 std::shared_ptr<QOhosWindowProxy> tryCreateWindowProxyIfNeeded(ViewType viewType, QWindow *optLogicalParent);
281 bool isWindowTransparencyRequested()
const;
284 QPointer<QWindow> m_ownerWindow;
285 std::shared_ptr<QOhosWindowProxy> m_ohosWindowProxy;
286 QSharedPointer<QNativeNode> m_nativeNode;
287 SystemUpdateData m_updateData;
288 bool m_updatePending;
289 std::function<QOhosWindowProxy::AvoidArea(QOhosWindowProxy::AvoidAreaType)> m_avoidAreasProvider;
290 bool m_requireHandheldDeviceSupport;
291 QtOhos::InternalWindowId m_ownerWindowId;
292 bool m_windowDestroyed =
false;
293 std::optional<ViewType> m_viewType;
294 QPointer<QWindow> m_optLogicalParent;
296 ViewGeometryPersistencePolicy m_geometryPersistencePolicy = ViewGeometryPersistencePolicy::Ignore;
297 std::shared_ptr<
void> m_windowPropertiesProviderCallbacksHandle;
298 std::function<
void()> m_optPostSurfaceDrawTask;
299 int m_pendingSelfMinimizeEchoes = 0;
303void QOhosView::setSystemUpdateProperty(SystemUpdateDataProperty<T, SupportedModes> SystemUpdateData::*propertyMemberPtr,
const T &value)
305 QFlags<QOhosRuntimeDeviceTypeAndMode> supportedModes(SupportedModes);
307 if (m_requireHandheldDeviceSupport
308 && !supportedModes.testFlag(QOhosRuntimeDeviceTypeAndMode::HandheldDeviceWindowPcMode)
309 && !supportedModes.testFlag(QOhosRuntimeDeviceTypeAndMode::HandheldDeviceFullScreen)) {
313 bool windowModeOnly =
314 !supportedModes.testFlag(QOhosRuntimeDeviceTypeAndMode::HandheldDeviceFullScreen)
315 && (supportedModes.testFlag(QOhosRuntimeDeviceTypeAndMode::_2in1)
316 || supportedModes.testFlag(QOhosRuntimeDeviceTypeAndMode::HandheldDeviceWindowPcMode));
318 if (windowModeOnly && !QOhosSettings::instance().isWindowPcModeEnabled()
319 && viewType() == ViewType::MainWindow) {
323 auto &property = m_updateData.*propertyMemberPtr;
324 if (property.optPendingUpdateRequest != value) {
325 property.optPendingUpdateRequest = value;
326 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)
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
QtOhosQpa::enums::ohos::window::AvoidAreaType AvoidAreaType
bool sendEvent(WindowSystemEvent *event) override
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