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 <qohosplatformwindow.h>
20#include <qohosplugincore.h>
21#include <qohosruntimedevicetypeandmode.h>
22#include <qohossettings.h>
23#include <qohoswindowproperty.h>
24#include <render/qnativenode.h>
25#include <render/qohossurface.h>
26#include <render/qohoswindowproxy.h>
33enum class ViewGeometryPersistencePolicy
97 QWindow *ownerWindow, QSharedPointer<QNativeNode> nativeNode,
100 void setSizeLimits(
const QSize &minSize,
const QSize &maxSize);
103 void setSize(
const QSize &size);
110 void setTitle(
const QString &title);
133 const std::vector<QImage> &images,
const QPointF &hotspot,
134 const QMimeData &mimeData, QOhosConsumer<Qt::DropAction> dropActionConsumer);
137 Qt::WindowStates previousWindowState, Qt::WindowStates currentWindowState);
139 Qt::WindowFlags previousWindowFlags, Qt::WindowFlags currentWindowFlags);
179 struct SystemUpdateDataProperty
191 struct SystemUpdateData
193 WindowModeOnlySystemUpdateDataProperty<QSize> size;
194 WindowModeOnlySystemUpdateDataProperty<std::pair<QSize, QSize>> sizeLimits;
195 WindowModeOnlySystemUpdateDataProperty<std::pair<QPoint, QOhosOptional<QOhosDisplayInfo::JsDisplayId>>> position;
196 SystemUpdateDataProperty<
bool> visibility;
197 NoTabletSystemUpdateDataProperty<
bool> backgroundTransparent;
198 SystemUpdateDataProperty<QCursor> cursor;
199 NoTabletSystemUpdateDataProperty<
bool> focusable;
200 SystemUpdateDataProperty<QColor> backgroundColor;
201 SystemUpdateDataProperty<
int> brightness;
202 SystemUpdateDataProperty<
int> contrast;
203 SystemUpdateDataProperty<
int> saturation;
204 SystemUpdateDataProperty<
bool> windowTransparentForInput;
205 WindowModeOnlySystemUpdateDataProperty<Qt::WindowModality> modality;
206 WindowModeOnlySystemUpdateDataProperty<QString> title;
207 WindowModeOnlySystemUpdateDataProperty<WindowMinMaxCloseButtonsState> windowMinMaxCloseButtonsState;
208 NoTabletSystemUpdateDataProperty<
bool> windowStaysOnTop;
209 WindowModeOnlySystemUpdateDataProperty<
bool> frameless;
212 static constexpr auto makeSystemUpdateDataPropertyUpdateFuncPairsTuple()
214 return std::make_tuple(
215 std::make_pair(&SystemUpdateData::sizeLimits, &QOhosView::updateWindowSizeLimits),
216 std::make_pair(&SystemUpdateData::size, &QOhosView::updateWindowSize),
217 std::make_pair(&SystemUpdateData::position, &QOhosView::updateWindowPosition),
218 std::make_pair(&SystemUpdateData::backgroundTransparent, &QOhosView::updateWindowBackgroundTransparency),
219 std::make_pair(&SystemUpdateData::cursor, &QOhosView::updateWindowCursor),
220 std::make_pair(&SystemUpdateData::focusable, &QOhosView::updateWindowFocusable),
221 std::make_pair(&SystemUpdateData::backgroundColor, &QOhosView::updateWindowBackgroundColor),
222 std::make_pair(&SystemUpdateData::brightness, &QOhosView::updateWindowBrightness),
223 std::make_pair(&SystemUpdateData::contrast, &QOhosView::updateWindowContrast),
224 std::make_pair(&SystemUpdateData::saturation, &QOhosView::updateWindowSaturation),
225 std::make_pair(&SystemUpdateData::windowTransparentForInput, &QOhosView::updateWindowTransparentForInput),
226 std::make_pair(&SystemUpdateData::modality, &QOhosView::updateWindowModality),
227 std::make_pair(&SystemUpdateData::title, &QOhosView::updateWindowTitle),
228 std::make_pair(&SystemUpdateData::windowMinMaxCloseButtonsState, &QOhosView::updateWindowMinMaxCloseButtonsState),
229 std::make_pair(&SystemUpdateData::windowStaysOnTop, &QOhosView::updateWindowStaysOnTop),
230 std::make_pair(&SystemUpdateData::frameless, &QOhosView::updateWindowFrameless));
234 void setSystemUpdateProperty(SystemUpdateDataProperty<T, SupportedModes> SystemUpdateData::*property,
const T &value);
236 void scheduleSystemUpdateIfNeeded();
237 void updateWindowSize(
const QSize &size);
238 void updateWindowSizeLimits(
const std::pair<QSize, QSize> &sizeLimits);
239 void updateWindowPosition(
const std::pair<QPoint, QOhosOptional<QOhosDisplayInfo::JsDisplayId>> &position);
240 void updateWindowBackgroundTransparency(
bool transparent);
241 void updateWindowCursor(
const QCursor &cursor);
242 void updateWindowFocusable(
bool focusable);
243 void updateWindowBackgroundColor(
const QColor &color);
244 void updateWindowBrightness(
int brightness);
245 void updateWindowContrast(
int contast);
246 void updateWindowSaturation(
int saturation);
247 void updateWindowTransparentForInput(
bool transparentForInput);
248 void updateWindowModality(Qt::WindowModality modality);
249 void updateWindowTitle(
const QString &title);
251 void updateWindowStaysOnTop(
bool staysOnTop);
252 void updateWindowFrameless(
bool frameless);
254 void flushSystemPropertyUpdatesImmediate();
255 void setOrResetWindowProxy(
std::shared_ptr<QOhosWindowProxy> windowProxy, QWindow *optLogicalParent);
256 const QOhosView *ancestorViewWithWindowOrNull()
const;
257 void hideMainWindow();
258 void setWindowCornerRadius(
double radius);
259 void setPrivacyMode(
bool privacyModeEnabled);
260 void setBackgroundColor(
const QColor &color);
261 void setBrightness(
int brightness);
262 void setContrast(
int contrast);
263 void setSaturation(
int saturation);
264 void setWindowKeepScreenOn(
bool keepScreenOn);
265 void setFixedSizeStateEnabled(
bool fixedSizeStateEnabled);
267 void sendAsyncSyntheticWindowActiveEvent();
269 std::shared_ptr<QOhosWindowProxy> tryCreateWindowProxyIfNeeded(ViewType viewType, QWindow *optLogicalParent);
271 bool isWindowTransparencyRequested()
const;
274 QPointer<QWindow> m_ownerWindow;
275 std::shared_ptr<QOhosWindowProxy> m_ohosWindowProxy;
276 QSharedPointer<QNativeNode> m_nativeNode;
277 SystemUpdateData m_updateData;
278 bool m_updatePending;
279 std::function<QOhosWindowProxy::AvoidArea(QOhosWindowProxy::AvoidAreaType)> m_avoidAreasProvider;
280 bool m_requireHandheldDeviceSupport;
281 QtOhos::InternalWindowId m_ownerWindowId;
282 bool m_windowDestroyed =
false;
283 QPointer<QWindow> m_optLogicalParent;
285 ViewGeometryPersistencePolicy m_geometryPersistencePolicy = ViewGeometryPersistencePolicy::Ignore;
286 std::shared_ptr<
void> m_windowPropertiesProviderCallbacksHandle;
287 std::function<
void()> m_optPostSurfaceDrawTask;
291void QOhosView::setSystemUpdateProperty(SystemUpdateDataProperty<T, SupportedModes> SystemUpdateData::*propertyMemberPtr,
const T &value)
293 QFlags<QOhosRuntimeDeviceTypeAndMode> supportedModes(SupportedModes);
295 if (m_requireHandheldDeviceSupport
296 && !supportedModes.testFlag(QOhosRuntimeDeviceTypeAndMode::HandheldDeviceWindowPcMode)
297 && !supportedModes.testFlag(QOhosRuntimeDeviceTypeAndMode::HandheldDeviceFullScreen)) {
301 bool windowModeOnly =
302 !supportedModes.testFlag(QOhosRuntimeDeviceTypeAndMode::HandheldDeviceFullScreen)
303 && (supportedModes.testFlag(QOhosRuntimeDeviceTypeAndMode::_2in1)
304 || supportedModes.testFlag(QOhosRuntimeDeviceTypeAndMode::HandheldDeviceWindowPcMode));
306 if (windowModeOnly && !QOhosSettings::isWindowPcModeEnabled()
307 && viewType() == ViewType::MainWindow) {
311 auto &property = m_updateData.*propertyMemberPtr;
312 if (property.optPendingUpdateRequest != value) {
313 property.optPendingUpdateRequest = value;
314 scheduleSystemUpdateIfNeeded();
std::enable_if_t< qohosplugincore_h_detail::isQOhosOptional< QOhosInvokeResult< Func, T > >, QOhosInvokeResult< Func, T > > andThen(Func &&func) const
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)
EGLSurface tryGetOrCreateEGLWindowSurface(EGLDisplay display, EGLConfig config)
QOhosOptional< QSize > surfaceResolution() const
::OHNativeWindow * nativeWindow() const
void setNativeWindowSurface(::OHNativeWindow *nativeWindow)
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)
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)
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 forceGeometryUpdate()
void externalContentInteractionDetected()
void nodeAreaChanged(QArkUi::QQtEmbeddedWindowNode::AreaChangeEvent areaChangeEvt)
void setWindowMinMaxCloseButtonState(const WindowMinMaxCloseButtonsState &state)
void setWindowMask(const QOhosWindowProxy::WindowMask &windowMask)
void setSizeLimits(const QSize &minSize, const QSize &maxSize)
void windowTouchOutside()
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
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()
QOhosOptional< void > makeEmptyQOhosOptional()
QOhosRuntimeDeviceTypeAndMode
@ HandheldDeviceFullScreen
@ HandheldDeviceWindowPcMode
void setQOhosPropertyOnQObject(QObject *qObject, T propertyValue)
QOhosOptional< T > tryGetQOhosPropertyFromQObject(QObject *qObject)
bool disableWindowFocusableBeforeLoadContent
QOhosOptional< QOhosDisplayInfo::JsDisplayId > displayId