7#include <QtCore/qflags.h>
8#include <QtCore/qglobal.h>
9#include <QtCore/qmimedata.h>
10#include <QtCore/qobject.h>
11#include <QtCore/qpoint.h>
12#include <QtCore/qsize.h>
13#include <QtCore/qstring.h>
14#include <QtGui/qimage.h>
15#include <QtGui/qwindow.h>
17#include <qohosdisplayinfo.h>
18#include <qohosforeignwindow.h>
19#include <qohosplatformintegration.h>
20#include <qohosplatformwindow.h>
21#include <qohosplugincore.h>
22#include <qohosruntimedevicetypeandmode.h>
23#include <qohossettings.h>
24#include <qohoswindowproperty.h>
25#include <render/qnativenode.h>
26#include <render/qohossurface.h>
27#include <render/qohoswindowproxy.h>
34enum class ViewGeometryPersistencePolicy
98 QWindow *ownerWindow, QSharedPointer<QNativeNode> nativeNode,
101 void setSizeLimits(
const QSize &minSize,
const QSize &maxSize);
104 void setSize(
const QSize &size);
111 void setTitle(
const QString &title);
134 const std::vector<QImage> &images,
const QPointF &hotspot,
135 const QMimeData &mimeData, QOhosConsumer<Qt::DropAction> dropActionConsumer);
138 Qt::WindowStates previousWindowState, Qt::WindowStates currentWindowState);
140 Qt::WindowFlags previousWindowFlags, Qt::WindowFlags currentWindowFlags);
176 void applyPhoneWindowChrome();
184 struct SystemUpdateDataProperty
186 QOhosOptional<T> optPendingUpdateRequest;
196 struct SystemUpdateData
198 WindowModeOnlySystemUpdateDataProperty<QSize> size;
199 WindowModeOnlySystemUpdateDataProperty<std::pair<QSize, QSize>> sizeLimits;
200 WindowModeOnlySystemUpdateDataProperty<std::pair<QPoint, QOhosOptional<QOhosDisplayInfo::JsDisplayId>>> position;
201 SystemUpdateDataProperty<
bool> visibility;
202 NoTabletSystemUpdateDataProperty<
bool> backgroundTransparent;
203 SystemUpdateDataProperty<QCursor> cursor;
204 NoTabletSystemUpdateDataProperty<
bool> focusable;
205 SystemUpdateDataProperty<QColor> backgroundColor;
206 SystemUpdateDataProperty<
int> brightness;
207 SystemUpdateDataProperty<
int> contrast;
208 SystemUpdateDataProperty<
int> saturation;
209 SystemUpdateDataProperty<
bool> windowTransparentForInput;
210 WindowModeOnlySystemUpdateDataProperty<Qt::WindowModality> modality;
211 WindowModeOnlySystemUpdateDataProperty<QString> title;
212 WindowModeOnlySystemUpdateDataProperty<WindowMinMaxCloseButtonsState> windowMinMaxCloseButtonsState;
213 WindowModeOnlySystemUpdateDataProperty<
bool> windowStaysOnTop;
214 WindowModeOnlySystemUpdateDataProperty<
bool> frameless;
217 static constexpr auto makeSystemUpdateDataPropertyUpdateFuncPairsTuple()
219 return std::make_tuple(
220 std::make_pair(&SystemUpdateData::sizeLimits, &QOhosView::updateWindowSizeLimits),
221 std::make_pair(&SystemUpdateData::size, &QOhosView::updateWindowSize),
222 std::make_pair(&SystemUpdateData::position, &QOhosView::updateWindowPosition),
223 std::make_pair(&SystemUpdateData::backgroundTransparent, &QOhosView::updateWindowBackgroundTransparency),
224 std::make_pair(&SystemUpdateData::cursor, &QOhosView::updateWindowCursor),
225 std::make_pair(&SystemUpdateData::focusable, &QOhosView::updateWindowFocusable),
226 std::make_pair(&SystemUpdateData::backgroundColor, &QOhosView::updateWindowBackgroundColor),
227 std::make_pair(&SystemUpdateData::brightness, &QOhosView::updateWindowBrightness),
228 std::make_pair(&SystemUpdateData::contrast, &QOhosView::updateWindowContrast),
229 std::make_pair(&SystemUpdateData::saturation, &QOhosView::updateWindowSaturation),
230 std::make_pair(&SystemUpdateData::windowTransparentForInput, &QOhosView::updateWindowTransparentForInput),
231 std::make_pair(&SystemUpdateData::modality, &QOhosView::updateWindowModality),
232 std::make_pair(&SystemUpdateData::title, &QOhosView::updateWindowTitle),
233 std::make_pair(&SystemUpdateData::windowMinMaxCloseButtonsState, &QOhosView::updateWindowMinMaxCloseButtonsState),
234 std::make_pair(&SystemUpdateData::windowStaysOnTop, &QOhosView::updateWindowStaysOnTop),
235 std::make_pair(&SystemUpdateData::frameless, &QOhosView::updateWindowFrameless));
239 void setSystemUpdateProperty(SystemUpdateDataProperty<T, SupportedModes> SystemUpdateData::*property,
const T &value);
241 void scheduleSystemUpdateIfNeeded();
242 void updateWindowSize(
const QSize &size);
243 void updateWindowSizeLimits(
const std::pair<QSize, QSize> &sizeLimits);
244 void updateWindowPosition(
const std::pair<QPoint, QOhosOptional<QOhosDisplayInfo::JsDisplayId>> &position);
245 void updateWindowBackgroundTransparency(
bool transparent);
246 void updateWindowCursor(
const QCursor &cursor);
247 void updateWindowFocusable(
bool focusable);
248 void updateWindowBackgroundColor(
const QColor &color);
249 void updateWindowBrightness(
int brightness);
250 void updateWindowContrast(
int contast);
251 void updateWindowSaturation(
int saturation);
252 void updateWindowTransparentForInput(
bool transparentForInput);
253 void updateWindowModality(Qt::WindowModality modality);
254 void updateWindowTitle(
const QString &title);
256 void updateWindowStaysOnTop(
bool staysOnTop);
257 void updateWindowFrameless(
bool frameless);
259 void flushSystemPropertyUpdatesImmediate();
260 void setOrResetWindowProxy(
std::shared_ptr<QOhosWindowProxy> windowProxy, QWindow *optLogicalParent);
261 const QOhosView *ancestorViewWithWindowOrNull()
const;
262 void hideMainWindow();
263 void setWindowCornerRadius(
double radius);
264 void setPrivacyMode(
bool privacyModeEnabled);
265 void setBackgroundColor(
const QColor &color);
266 void setBrightness(
int brightness);
267 void setContrast(
int contrast);
268 void setSaturation(
int saturation);
269 void setWindowKeepScreenOn(
bool keepScreenOn);
270 void setFixedSizeStateEnabled(
bool fixedSizeStateEnabled);
271 void setWindowDragResizable(
bool dragResizable);
273 void sendAsyncSyntheticWindowActiveEvent();
275 std::shared_ptr<QOhosWindowProxy> tryCreateWindowProxyIfNeeded(ViewType viewType, QWindow *optLogicalParent);
277 bool isWindowTransparencyRequested()
const;
280 QPointer<QWindow> m_ownerWindow;
281 std::shared_ptr<QOhosWindowProxy> m_ohosWindowProxy;
282 QSharedPointer<QNativeNode> m_nativeNode;
283 SystemUpdateData m_updateData;
284 bool m_updatePending;
285 std::function<QOhosWindowProxy::AvoidArea(QOhosWindowProxy::AvoidAreaType)> m_avoidAreasProvider;
286 bool m_requireHandheldDeviceSupport;
287 QtOhos::InternalWindowId m_ownerWindowId;
288 bool m_windowDestroyed =
false;
289 QPointer<QWindow> m_optLogicalParent;
290 QOhosOptional<WindowHideMethod> m_lastMainWindowHideMethod;
291 ViewGeometryPersistencePolicy m_geometryPersistencePolicy = ViewGeometryPersistencePolicy::Ignore;
292 std::shared_ptr<
void> m_windowPropertiesProviderCallbacksHandle;
293 std::function<
void()> m_optPostSurfaceDrawTask;
297void QOhosView::setSystemUpdateProperty(SystemUpdateDataProperty<T, SupportedModes> SystemUpdateData::*propertyMemberPtr,
const T &value)
299 QFlags<QOhosRuntimeDeviceTypeAndMode> supportedModes(SupportedModes);
301 if (m_requireHandheldDeviceSupport
302 && !supportedModes.testFlag(QOhosRuntimeDeviceTypeAndMode::HandheldDeviceWindowPcMode)
303 && !supportedModes.testFlag(QOhosRuntimeDeviceTypeAndMode::HandheldDeviceFullScreen)) {
307 bool windowModeOnly =
308 !supportedModes.testFlag(QOhosRuntimeDeviceTypeAndMode::HandheldDeviceFullScreen)
309 && (supportedModes.testFlag(QOhosRuntimeDeviceTypeAndMode::_2in1)
310 || supportedModes.testFlag(QOhosRuntimeDeviceTypeAndMode::HandheldDeviceWindowPcMode));
312 if (windowModeOnly && !QOhosPlatformIntegration::instance()->settings()->isWindowPcModeEnabled()
313 && viewType() == ViewType::MainWindow) {
317 auto &property = m_updateData.*propertyMemberPtr;
318 if (property.optPendingUpdateRequest != value) {
319 property.optPendingUpdateRequest = value;
320 scheduleSystemUpdateIfNeeded();
QOhosPropertiesProvider(QOhosPropertiesStore &store)
QOhosOptional< T > tryGetProperty() const
std::shared_ptr< void > addPropertyWriteCallback(QOhosConsumer< T > propertyWriteCallback)
QOhosPropertiesStore(QObject *qObject)
std::shared_ptr< void > addPropertyWriteCallback(QOhosConsumer< T > propertyWriteCallback)
void notifyPropertyWrite(const QByteArray &propertyName)
QOhosOptional< T > tryGetProperty() const
void setExtraUsageBitsForNativeWindowBuffer(std::uint64_t usageSetBits)
void setNativeWindowSurface(::OHNativeWindow *nativeWindow, const QOhosOptional< QSize > &optSurfaceSize)
QOhosOptional< QSize > surfaceResolution() const
::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 QImage::Format mapNativeBufferFormatToQImageFormatOrFail(std::int32_t format)
static QOhosOptional< QSize > tryGetBufferGeometryForWindow(::OHNativeWindow *nativeWindow)
QOhosSurface(::OHNativeWindow *nativeWindow)
EGLSurface tryGetOrCreateEGLWindowSurface(EGLDisplay display, EGLConfig config, bool swappingBuffers)
void clearNativeWindowSurface()
void windowStatusChange(QOhosWindowProxy::WindowStatus windowStatus)
void setParentOrReparent(QOhosView &parentView)
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)
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)
QOhosOptional< QSize > surfaceResolution() const
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)
void windowTouchOutside()
void nodeAreaChanged(QArkUi::QQtEmbeddedWindowNode::NodeAreaInfo areaChangeEvt)
void handlePaletteChange()
void surfaceStatusChanged(const QOhosOptional< QSize > &optSurfaceSize)
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
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
QtOhos::enums::ohos::window::AvoidAreaType AvoidAreaType
bool sendEvent(WindowSystemEvent *event) override
Combined button and popup list for selecting options.
@ ForwardToGuiApplication
QOhosView * mapQWindowToViewOrNull(QWindow *window)
std::string makeQObjectOhosPropertyName()
QOhosOptional< T > tryMapFromQVariant(QVariant variant)
const char * qObjectOhosPropertyName()
std::shared_ptr< QWindowSystemEventHandler > makeApplicationStateTracker()
QT_END_NAMESPACE Q_DECLARE_METATYPE(QT_PREPEND_NAMESPACE(QtOhos::enums::kit::ShareKit::systemShare::SelectionMode))
std::nullopt_t makeEmptyQOhosOptional()
QOhosRuntimeDeviceTypeAndMode
@ HandheldDeviceFullScreen
@ HandheldDeviceWindowPcMode
void setQOhosPropertyOnQObject(QObject *qObject, T propertyValue)
QOhosOptional< T > tryGetQOhosPropertyFromQObject(QObject *qObject)
bool disableWindowFocusableBeforeLoadContent
QOhosOptional< QOhosDisplayInfo::JsDisplayId > displayId