4#include <render/qohosview.h>
6#include <QtCore/private/qnapi_p.h>
7#include <QtCore/private/qohoscommon_p.h>
8#include <QtCore/qscopeguard.h>
9#include <QtGui/private/qguiapplication_p.h>
10#include <QtGui/private/qhighdpiscaling_p.h>
11#include <QtGui/private/qwindow_p.h>
12#include <QtGui/qbitmap.h>
13#include <QtGui/qpalette.h>
14#include <ace/xcomponent/native_interface_xcomponent.h>
15#include <arkui/native_type.h>
18#include <qarkui/window.h>
19#include <qohosdeviceinfo_p.h>
20#include <qohosinputmethodeventhandler.h>
21#include <qohosjsmain.h>
22#include <qohosplatformbackingstore.h>
23#include <qohosplatformintegration.h>
24#include <qohosplatformscreen.h>
25#include <qohosplatformwindow.h>
26#include <qohosutils.h>
27#include <qpa/qplatformscreen.h>
28#include <qpa/qplatformtheme.h>
29#include <qpa/qwindowsysteminterface.h>
30#include <render/qnativenode.h>
31#include <render/qohoswindowproxy.h>
32#include <render/qwindowproxyregistry.h>
58 Qt::WindowModality windowModality)
62 switch (windowModality) {
63 case Qt::WindowModality::NonModal:
65 case Qt::WindowModality::WindowModal:
67 case Qt::WindowModality::ApplicationModal:
72 "%s: got illegal Qt::WindowModality value (%d), using the default instead",
73 Q_FUNC_INFO,
static_cast<
int>(windowModality));
78template<
typename ...SignalParams>
80 QPointer<QOhosView> viewPtr,
std::function<
bool(
QOhosView &)> predicate,
void (QOhosView::*signalFuncPtr)(SignalParams ...))
82 return [signalFuncPtr, viewPtr, predicate = std::move(predicate)](SignalParams ...args) {
83 if (viewPtr && predicate(*viewPtr))
84 Q_EMIT (*viewPtr.*signalFuncPtr)(args...);
94 explicit AvoidAreaCache(std::function<AvoidArea(AvoidAreaType)> avoidAreasProvider);
98 const AvoidArea &avoidArea);
103 std::function<AvoidArea(AvoidAreaType)> m_avoidAreasProvider;
104 QMap<AvoidAreaType, AvoidArea> m_store;
114 QOhosWindowProxy::
AvoidAreaType avoidAreaType,
const QOhosWindowProxy::AvoidArea &avoidArea)
116 m_store[avoidAreaType] = avoidArea;
122 if (m_store.contains(avoidAreaType))
123 return m_store.value(avoidAreaType);
125 auto result = m_avoidAreasProvider(avoidAreaType);
126 m_store[avoidAreaType] = result;
132 if (!avoidArea.visible)
135 marginsToUpdate.setTop(qMax(marginsToUpdate.top(), avoidArea.topRect.height()));
136 marginsToUpdate.setLeft(qMax(marginsToUpdate.left(), avoidArea.leftRect.width()));
137 marginsToUpdate.setRight(qMax(marginsToUpdate.right(), avoidArea.rightRect.width()));
138 marginsToUpdate.setBottom(qMax(marginsToUpdate.bottom(), avoidArea.bottomRect.height()));
142 const QPoint &geometryOrigin,
const QRect &frameGeometry)
144 int topFrameMargin = qAbs(frameGeometry.top() - geometryOrigin.y());
145 int sideAndBottomFrameMargin = qAbs(frameGeometry.left() - geometryOrigin.x());
148 frameGeometry.width() - 2 * sideAndBottomFrameMargin,
149 frameGeometry.height() - topFrameMargin - sideAndBottomFrameMargin
161 qMax(1, size.width() + margins.left() + margins.right()),
162 qMax(1, size.height() + margins.top() + margins.bottom())};
168 return !visibleWindows.empty()
169 ? visibleWindows.front()
176 return !focusedWindows.empty()
177 ? focusedWindows.front()
183 auto *focusWindow = getFirstTopLevelWindowWithSystemFocusOrNull();
184 auto *firstTopLevelWindow = getFirstTopLevelWindowOrNull();
186 auto isValidSyntheticParent = [&](QWindow *w) {
187 return w !=
nullptr && w != qWindow && w->isVisible();
190 return isValidSyntheticParent(focusWindow)
192 : isValidSyntheticParent(firstTopLevelWindow)
193 ? firstTopLevelWindow
199 using ViewType = QOhosView::ViewType;
201 auto *qWindow = platformWindow->window();
202 auto *parent = qWindow->parent();
203 auto *transientParent = qWindow->transientParent();
205 auto windowType = qWindow->type();
207 QWindow *subWindowTagValue = platformWindow->validSubWindowOfTagValueOrNull();
209 static QSet<Qt::WindowType> fallbackToSubWindowWindowTypes{
217 if (taggedAsMainWindow) {
218 return ViewTypeInfo {
219 .viewType = ViewType::MainWindow,
220 .optLogicalParent =
nullptr,
225 if (taggedAsFloatWindow) {
226 return ViewTypeInfo {
227 .viewType = ViewType::FloatWindow,
228 .optLogicalParent =
nullptr,
232 bool overrideAsSubWindow = subWindowTagValue !=
nullptr;
233 if (overrideAsSubWindow) {
234 return ViewTypeInfo {
235 .viewType = ViewType::SubWindow,
236 .optLogicalParent = subWindowTagValue,
240 if (parent !=
nullptr) {
241 return ViewTypeInfo {
242 .viewType = ViewType::EmbeddedWindow,
243 .optLogicalParent = parent,
247 if (transientParent !=
nullptr) {
248 return ViewTypeInfo {
249 .viewType = ViewType::SubWindow,
250 .optLogicalParent = transientParent,
254 auto *syntheticParent = syntheticParentForQWindowOrNull(platformWindow->window());
256 bool automaticOverrideActive =
257 fallbackToSubWindowWindowTypes.contains(windowType)
258 && syntheticParent !=
nullptr;
259 if (automaticOverrideActive) {
260 return ViewTypeInfo {
261 .viewType = ViewType::SubWindow,
262 .optLogicalParent = syntheticParent,
266 return ViewTypeInfo {
267 .viewType = ViewType::MainWindow,
268 .optLogicalParent =
nullptr,
274 return cursor.bitmap();
279 return cursor.mask();
284 const auto maskTransparentColor = QColor(Qt::color0).rgba();
285 const auto transparentColor = QColor(Qt::transparent).rgba();
287 QImage image = bitmap.toImage().convertToFormat(QImage::Format_RGBA8888);
288 QImage maskImage = mask.toImage().convertToFormat(QImage::Format_RGB32);
290 for (
int row = 0; row < image.height(); ++row) {
291 auto *imageData =
reinterpret_cast<QRgb *>(image.scanLine(row));
292 auto *maskData =
reinterpret_cast<QRgb *>(maskImage.scanLine(row));
293 for (
int col = 0; col < image.width(); ++col) {
294 if (maskData[col] == maskTransparentColor)
295 imageData[col] = transparentColor;
304 QBitmap cursorPixels(cursorSize);
305 cursorPixels.fill(Qt::transparent);
306 QBitmap cursorMask(cursorSize);
307 cursorMask.fill(Qt::color0);
308 return QCursor(cursorPixels, cursorMask);
315 auto viewGeometryPersistencePolicy = ViewGeometryPersistencePolicy::Ignore;
319 case WindowGeometryPersistencePolicy
::Disabled:
320 viewGeometryPersistencePolicy = ViewGeometryPersistencePolicy::Disabled;
322 case WindowGeometryPersistencePolicy
::Enabled:
323 viewGeometryPersistencePolicy = ViewGeometryPersistencePolicy::Enabled;
326 viewGeometryPersistencePolicy = ViewGeometryPersistencePolicy::FollowSystemSetting;
330 return viewGeometryPersistencePolicy;
337 bool geometryPersistenceEnabled =
false;
340 case WindowGeometryPersistencePolicy
::Disabled:
343 case WindowGeometryPersistencePolicy
::Enabled:
352 return geometryPersistenceEnabled
358 QWindow *logicalParent, QOhosWindowProxy &windowProxy)
360 auto *screen = logicalParent->screen();
361 auto *ohosPlatformScreen = screen !=
nullptr
365 return ohosPlatformScreen !=
nullptr
366 ?
std::optional(ohosPlatformScreen->displayInfo().id)
372 if (window !=
nullptr) {
373 QWindowPrivate *windowPrivate = qt_window_private(window);
374 QPalette palette = windowPrivate->windowPalette();
375 QColor backgroundColor = palette.color(QPalette::Window);
376 return backgroundColor;
385 auto optPostSurfaceDrawTask =
std::exchange(m_optPostSurfaceDrawTask, {});
386 if (optPostSurfaceDrawTask)
387 optPostSurfaceDrawTask();
390std::shared_ptr<QOhosWindowProxy>
QOhosView::tryCreateWindowProxyIfNeeded(ViewType viewType, QWindow *optLogicalParent)
392 QWindow *qWindow = m_ownerWindow;
395 std::shared_ptr<QOhosWindowProxy> result;
398 case ViewType::MainWindow:
402 if (useAutoStartedMainWindow) {
404 createInfo.qWindowRef = QtOhos::QObjectThreadSafeRef(qWindow);
406 return jsState.defaultQAbilityPeer()->instanceId();
413 createInfo.qWindowRef = QtOhos::QObjectThreadSafeRef(qWindow);
414 createInfo.windowId = window->internalWindowId();
415 createInfo
.windowTitle = qWindow->title().toStdString();
416 createInfo.frameGeometry = window->lastRequestedWindowFrameGeometry();
417 createInfo.fullscreen = qWindow->windowState() == Qt::WindowFullScreen;
423 case ViewType::SubWindow:
425 auto *targetWindowToBeSubWindowOf = optLogicalParent;
427 if (Q_UNLIKELY(targetWindowToBeSubWindowOf ==
nullptr))
428 qOhosReportFatalErrorAndAbort(
"Failed to determine valid parent of a SubWindow");
430 if (!targetWindowToBeSubWindowOf->isVisible()) {
431 auto *targetParentPlatformWindow = QOhosPlatformWindow::fromQWindowOrNull(targetWindowToBeSubWindowOf);
432 if (targetParentPlatformWindow !=
nullptr)
433 targetParentPlatformWindow->setVisible(
true);
435 targetWindowToBeSubWindowOf->show();
438 auto *targetWindowToBeSubWindowOfView =
439 QOhosPlatformWindow::fromQWindow(targetWindowToBeSubWindowOf)->ownedViewOrNull();
441 const QOhosView *firstViewWithWindow =
nullptr;
442 switch (targetWindowToBeSubWindowOfView->viewType()) {
443 case ViewType::MainWindow:
444 case ViewType::SubWindow:
445 case ViewType::FloatWindow:
446 firstViewWithWindow = targetWindowToBeSubWindowOfView;
448 case ViewType::EmbeddedWindow:
449 firstViewWithWindow = ancestorViewWithWindowOrNull();
453 if (firstViewWithWindow ==
nullptr)
454 qOhosReportFatalErrorAndAbort(
"Failed to determine valid parent for this window.");
456 auto parentWindowProxy = firstViewWithWindow->m_ohosWindowProxy;
457 if (Q_UNLIKELY(!parentWindowProxy)) {
458 qOhosReportFatalErrorAndAbort(
459 "parentWindowProxy is null but should not be. This is most likely a programming error");
463 createInfo.window = QtOhos::QObjectThreadSafeRef(qWindow);
464 createInfo
.windowTitle = qWindow->title().toStdString();
465 createInfo.windowId = window->internalWindowId();
470 createInfo.modal = qWindow->modality() != Qt::NonModal;
471 createInfo.windowRect = window->lastRequestedWindowFrameGeometry();
472 result = parentWindowProxy->createSubWindow(createInfo);
476 case ViewType::EmbeddedWindow:
481 case ViewType::FloatWindow:
484 .qWindowRef = QtOhos::QObjectThreadSafeRef(qWindow),
485 .internalWindowId = window->internalWindowId(),
491 qOhosReportFatalErrorAndAbort(
"Unsupported view type: %d", viewType);
495 if (result !=
nullptr) {
496 auto viewPtr = QPointer<
QOhosView>(
this);
497 std::weak_ptr<QOhosWindowProxy> weakWindowProxy = result;
498 auto shouldEmitSignalPredicate = [weakWindowProxy](
QOhosView &view) {
499 auto windowProxy = weakWindowProxy.lock();
500 return windowProxy !=
nullptr && windowProxy.get() == view.m_ohosWindowProxy.get();
503 result->setWindowCallbackReceiver(
506 .onWindowEvent = makeViewConditionalSignalEmitter(viewPtr, shouldEmitSignalPredicate, &QOhosView::windowEvent),
510 .onAvoidAreaChange = makeViewConditionalSignalEmitter(viewPtr, shouldEmitSignalPredicate, &QOhosView::avoidAreaChanged),
511 .onWindowRectChange = makeViewConditionalSignalEmitter(viewPtr, shouldEmitSignalPredicate, &QOhosView::windowRectChanged),
512 .onWindowRectChangeInGlobalDisplay = makeViewConditionalSignalEmitter(
513 viewPtr, shouldEmitSignalPredicate, &QOhosView::windowRectChangedInGlobalDisplay),
517 result->setNonClientAreaMouseWindowCallbackReceiver(
519 [viewPtr, shouldEmitSignalPredicate](std::vector<QOhosWindowProxy::NonClientAreaMouseEvent> &&batch) {
520 if (!viewPtr.isNull() && shouldEmitSignalPredicate(*viewPtr)) {
522 inputEventHandler->onNonClientAreaMouseEvents(viewPtr->m_ownerWindow,
std::move(batch));
526 result->setNonClientAreaTouchWindowCallbackReceiver(
528 [viewPtr, shouldEmitSignalPredicate](std::vector<QOhosWindowProxy::NonClientAreaTouchEvent> &&batch) {
529 if (!viewPtr.isNull() && shouldEmitSignalPredicate(*viewPtr)) {
531 inputEventHandler->onNonClientAreaTouchEvents(viewPtr->m_ownerWindow,
std::move(batch));
535 if (result->qtIsMainWindow() && result->isFocused().value_or(
false)) {
539 sendAsyncSyntheticWindowActiveEvent();
546bool QOhosView::isWindowTransparencyRequested()
const
548 return m_ownerWindow->requestedFormat().hasAlpha();
552 : m_windowPropertiesProvider(windowPropertyProvider)
557 , m_updatePending(
false)
564 return m_ohosWindowProxy !=
nullptr
565 ? m_ohosWindowProxy->getWindowAvoidArea(avoidAreaType)
566 : AvoidAreaCache::AvoidArea{};
570 this, &QOhosView::avoidAreaChanged,
572 [avoidAreasProvider](QOhosWindowProxy::
AvoidAreaType avoidAreaType,
const QOhosWindowProxy::AvoidArea &avoidArea) {
573 avoidAreasProvider->put(avoidAreaType, avoidArea);
576 m_avoidAreasProvider = [avoidAreasProvider](QOhosWindowProxy::AvoidAreaType type) {
577 return avoidAreasProvider->getStoredOrRetrieveFromWindowProxy(type);
581 m_nativeNode.get(), &QNativeNode::surfaceStatusChanged,
582 this, [
this](
const std::optional<QSize> &optSurfaceSize) {
583 Q_EMIT surfaceStatusChanged(optSurfaceSize);
590 m_nativeNode->setNodeAreaChangeHandler(
591 [
this](
auto nodeAreaChangeEvent) {
592 Q_EMIT nodeAreaChanged(nodeAreaChangeEvent);
595 m_nativeNode->setNodeVisibilityChangeHandler(
596 [
this](
bool visible) {
597 if (viewType() == QOhosView::ViewType::EmbeddedWindow)
598 Q_EMIT windowVisibilityChange(visible);
601 std::vector<std::shared_ptr<
void>> writeCallbacks = {
602 m_windowPropertiesProvider.addPropertyWriteCallback<
double, &QOhosPlatformWindow::windowCornerRadiusProperty>(
603 [
this](
double windowCornerRadius) {
604 setWindowCornerRadius(windowCornerRadius);
606 m_windowPropertiesProvider.addPropertyWriteCallback<
bool, &QOhosPlatformWindow::windowPrivacyModeSettingProperty>(
607 [
this](
bool windowPrivacyModeSetting) {
608 setPrivacyMode(windowPrivacyModeSetting);
610 m_windowPropertiesProvider.addPropertyWriteCallback<QColor, &QOhosPlatformWindow::surfaceBackgroundColorProperty>(
611 [
this](QColor surfaceBackgroundColor) {
612 setBackgroundColor(surfaceBackgroundColor);
614 m_windowPropertiesProvider.addPropertyWriteCallback<
bool, &QOhosPlatformWindow::windowKeepScreenOnProperty>(
615 [
this](
bool keepScreenOn) {
616 setWindowKeepScreenOn(keepScreenOn);
618 m_windowPropertiesProvider.addPropertyWriteCallback<
bool, &QOhosPlatformWindow::windowFixedSizeStateProperty>(
619 [
this](
bool fixedSizeStateEnabled) {
620 setFixedSizeStateEnabled(fixedSizeStateEnabled);
622 m_windowPropertiesProvider.addPropertyWriteCallback<
int, &QOhosPlatformWindow::windowBrightnessProperty>(
623 [
this](
int brightness) {
624 setBrightness(brightness);
626 m_windowPropertiesProvider.addPropertyWriteCallback<
int, &QOhosPlatformWindow::windowContrastProperty>(
627 [
this](
int contrast) {
628 setContrast(contrast);
630 m_windowPropertiesProvider.addPropertyWriteCallback<
int, &QOhosPlatformWindow::windowSaturationProperty>(
631 [
this](
int saturation) {
632 setSaturation(saturation);
634 m_windowPropertiesProvider.addPropertyWriteCallback<
bool, &QOhosPlatformWindow::windowDragResizableProperty>(
635 [
this](
bool dragResizable) {
636 setWindowDragResizable(dragResizable);
640 m_windowPropertiesProviderCallbacksHandle = QtOhos::moveToSharedPtr(std::move(writeCallbacks));
649 m_nativeNode.reset();
654 setSystemUpdateProperty(&SystemUpdateData::position, {position, {}});
660 setSystemUpdateProperty(&SystemUpdateData::position, {position, jsDisplayId});
661 flushSystemPropertyUpdatesImmediate();
666 setSystemUpdateProperty(&SystemUpdateData::size, size);
671 setSystemUpdateProperty(&SystemUpdateData::sizeLimits, std::make_pair(minSize, maxSize));
676 setSystemUpdateProperty(&SystemUpdateData::backgroundTransparent, transparent);
681 setSystemUpdateProperty(&SystemUpdateData::focusable, focusable);
684void QOhosView::setBackgroundColor(
const QColor &color)
686 setSystemUpdateProperty(&SystemUpdateData::backgroundColor, color);
689void QOhosView::setBrightness(
int brightness)
691 setSystemUpdateProperty(&SystemUpdateData::brightness, brightness);
696 setSystemUpdateProperty(&SystemUpdateData::contrast, contrast);
699void QOhosView::setSaturation(
int saturation)
701 setSystemUpdateProperty(&SystemUpdateData::saturation, saturation);
704void QOhosView::setWindowKeepScreenOn(
bool keepScreenOn)
706 if (m_ohosWindowProxy !=
nullptr)
707 m_ohosWindowProxy->setWindowKeepScreenOn(keepScreenOn);
710void QOhosView::setFixedSizeStateEnabled(
bool enabled)
712 if (viewType() != ViewType::MainWindow)
717 "%s: fixed size state is not supported while in HandheldDeviceFullScreen mode",
723 const auto supportedWindowModes = enabled
724 ? std::set<SupportWindowMode>({SupportWindowMode::FLOATING})
725 : std::set<SupportWindowMode>({SupportWindowMode::FULL_SCREEN, SupportWindowMode::FLOATING, SupportWindowMode::SPLIT});
727 m_ohosWindowProxy->setSupportedWindowModes(supportedWindowModes);
732 auto *ohosPlatformWindow =
static_cast<QOhosPlatformWindow *>(m_ownerWindow->handle());
733 m_ohosWindowProxy->showWindow(
734 QOhosWindowProxy::ShowWindowOptions{
735 .focusOnShow = ohosPlatformWindow->shouldShowWindowWithoutActivating()
736 ? std::optional(
false)
741void QOhosView::sendAsyncSyntheticWindowActiveEvent()
743 QMetaObject::invokeMethod(
746 QOhosWindowProxy::WindowEvent syntheticWindowActiveEvent = {
747 .type = QOhosWindowProxy::WindowEventType::WINDOW_ACTIVE,
749 Q_EMIT windowEvent(syntheticWindowActiveEvent);
751 Qt::QueuedConnection);
756 setSystemUpdateProperty(&SystemUpdateData::cursor, cursor);
761 setSystemUpdateProperty(&SystemUpdateData::modality, modality);
766 setSystemUpdateProperty(&SystemUpdateData::title, title);
771 switch (viewType()) {
772 case ViewType::MainWindow:
775 case ViewType::SubWindow:
776 m_ohosWindowProxy->raiseToAppTop();
778 case ViewType::FloatWindow:
780 case ViewType::EmbeddedWindow:
781 m_nativeNode->raise();
788 if (m_ohosWindowProxy !=
nullptr && m_ownerWindow->isVisible())
791 m_nativeNode->lower();
794void QOhosView::updateWindowSize(
const QSize &size)
796 if (m_ohosWindowProxy !=
nullptr)
797 m_ohosWindowProxy->setSize(size);
799 m_nativeNode->setSize(size);
802void QOhosView::updateWindowPosition(
const std::pair<QPoint, std::optional<QOhosDisplayInfo::JsDisplayId>> &positionProp)
806 std::tie(position, displayId) = positionProp;
808 if (m_ohosWindowProxy !=
nullptr) {
809 m_ohosWindowProxy->moveWindowToGlobalOrGlobalDisplay(position, displayId);
811 m_nativeNode->setPosition(position);
815void QOhosView::updateWindowBackgroundTransparency(
bool transparent)
817 if (m_ohosWindowProxy !=
nullptr) {
818 auto opaqueSystemBackgroundRgb = QGuiApplicationPrivate::platformTheme()
819 ->palette(QPlatformTheme::SystemPalette)
823 m_ohosWindowProxy->setWindowBackgroundColor(
825 ? QColor(Qt::transparent)
826 : tryGetBackgroundColorFromWindow(m_ownerWindow).value_or(
827 QColor(opaqueSystemBackgroundRgb)));
831void QOhosView::updateWindowCursor(
const QCursor &cursor)
833 if (m_ohosWindowProxy ==
nullptr)
836 if (cursor.shape() == Qt::BitmapCursor || cursor.shape() == Qt::BlankCursor) {
838 cursor.shape() == Qt::BlankCursor
839 ? makeTransparentBitmapCursor({1, 1})
842 QImage bitmapCursorImage = bitmapCursor.pixmap().isNull()
843 ? createImageFromBitmapAndMask(getCursorBitmap(bitmapCursor), getCursorMask(bitmapCursor))
844 : bitmapCursor.pixmap().toImage();
846 m_ohosWindowProxy->setCustomCursor(bitmapCursorImage, bitmapCursor.hotSpot());
848 m_ohosWindowProxy->setPointerStyleSync(cursor);
852void QOhosView::updateWindowFocusable(
bool focusable)
854 if (m_ohosWindowProxy !=
nullptr)
855 m_ohosWindowProxy->setWindowFocusable(focusable);
856 m_nativeNode->setFocusable(focusable);
859void QOhosView::updateWindowBackgroundColor(
const QColor &color)
861 m_nativeNode->setBackgroundColor(color);
864void QOhosView::updateWindowBrightness(
int brightness)
866 m_nativeNode->setBrightness(brightness);
869void QOhosView::updateWindowContrast(
int contrast)
871 m_nativeNode->setContrast(contrast);
874void QOhosView::updateWindowSaturation(
int saturation)
876 m_nativeNode->setSaturation(saturation);
879void QOhosView::updateWindowTransparentForInput(
bool transparentForInput)
881 if (m_ohosWindowProxy !=
nullptr)
882 m_ohosWindowProxy->setWindowTouchable(!transparentForInput);
883 m_nativeNode->setTransparentForInput(transparentForInput);
886void QOhosView::updateWindowSizeLimits(
const std::pair<QSize, QSize> &sizeLimits)
888 if (m_ohosWindowProxy !=
nullptr) {
889 auto windowMargins = QOhosPlatformWindow::fromQWindow(m_ownerWindow)->frameMargins();
890 m_ohosWindowProxy->setWindowLimits(
891 getQSizeGrownBy(sizeLimits.first, windowMargins),
892 getQSizeGrownBy(sizeLimits.second, windowMargins));
896void QOhosView::updateWindowModality(Qt::WindowModality modality)
898 if (m_ohosWindowProxy !=
nullptr) {
899 if (viewType() != ViewType::SubWindow) {
900 qCWarning(QtForOhos,
"%s: Modality is supported only for sub-windows.", Q_FUNC_INFO);
903 if (modality == Qt::WindowModality::ApplicationModal) {
906 "%s: Qt::ApplicationModal policy is unsupported by the platform. The window will behave like Qt::WindowModal.",
910 auto ohosModalityType = mapQtWindowModalityToOhosOrDefault(modality);
911 if (ohosModalityType.has_value())
912 m_ohosWindowProxy->setSubWindowModalEnabled(ohosModalityType.value());
914 m_ohosWindowProxy->setSubWindowModalDisabled();
918void QOhosView::updateWindowTitle(
const QString &title)
920 if (m_ohosWindowProxy !=
nullptr)
921 m_ohosWindowProxy->setTitle(title);
924void QOhosView::scheduleSystemUpdateIfNeeded()
928 m_updatePending = QMetaObject::invokeMethod(
931 flushSystemPropertyUpdatesImmediate();
933 Qt::QueuedConnection);
938 return m_ownerWindow;
943 auto *platformWindow = QOhosPlatformWindow::fromQWindow(m_ownerWindow);
945 auto currentViewTypeInfo = determineViewTypeAndLogicalParent(platformWindow);
946 bool viewTypeChanged = viewType() != currentViewTypeInfo.viewType;
948 if (viewTypeChanged) {
949 auto qOhosWindowProxy = tryCreateWindowProxyIfNeeded(currentViewTypeInfo.viewType, currentViewTypeInfo.optLogicalParent);
951 if (qOhosWindowProxy !=
nullptr
952 && currentViewTypeInfo.viewType == ViewType::SubWindow) {
953 constexpr bool preventSubWindowClose =
true;
954 qOhosWindowProxy->setSubWindowCloseHandler(
956 if (!m_ownerWindow.isNull()) {
957 qOhosPrintfDebug(
"onSubWindowCloseHandler: calling close()");
958 QOhosCloseEventContext::runWithCloseRootCauseSet(
959 QOhosCloseEventContext::CloseRootCause::SubWindowClose,
961 m_ownerWindow->close();
965 preventSubWindowClose);
968 if (qOhosWindowProxy !=
nullptr) {
969 m_nativeNode->setParent(qOhosWindowProxy->nodeXComponent());
970 m_nativeNode->fillToParent();
973 setOrResetWindowProxy(qOhosWindowProxy, currentViewTypeInfo.optLogicalParent);
975 syncWindowStateImmediate();
978 if (viewType() == ViewType::MainWindow) {
979 const auto windowStates = m_ownerWindow->windowStates();
980 if (windowStates.testFlag(Qt::WindowState::WindowFullScreen)) {
986 }
else if (windowStates.testFlag(Qt::WindowState::WindowMaximized)) {
988 }
else if (QOhosDeviceInfo::isPhone()
989 && m_ownerWindow->flags().testFlag(Qt::ExpandedClientAreaHint)) {
990 applyPhoneWindowChrome();
992 }
else if (viewType() == ViewType::SubWindow && m_ohosWindowProxy !=
nullptr) {
993 m_ohosWindowProxy->setFollowParentMultiScreenPolicy(
true);
996 if (m_ohosWindowProxy !=
nullptr) {
1002 if (surface !=
nullptr)
1005 m_nativeNode->setVisibility(
true);
1010 if (m_ohosWindowProxy ==
nullptr)
1015 const bool fullScreen = m_ownerWindow->windowStates().testFlag(Qt::WindowFullScreen);
1016 const bool expanded = m_ownerWindow->flags().testFlag(Qt::ExpandedClientAreaHint);
1017 m_ohosWindowProxy->setWindowLayoutFullScreen(fullScreen || expanded);
1018 m_ohosWindowProxy->setWindowSystemBarEnable(
1019 fullScreen ? QStringList{}
1020 : QStringList{ QStringLiteral(
"status"), QStringLiteral(
"navigation") });
1025 if (m_ohosWindowProxy ==
nullptr)
1029 flushSystemPropertyUpdatesImmediate();
1030 m_ohosWindowProxy->maximize(QOhosWindowProxy::MaximizePresentation::ENTER_IMMERSIVE);
1032 applyPhoneWindowChrome();
1038 if (m_ohosWindowProxy ==
nullptr)
1042 m_ohosWindowProxy->recover();
1044 applyPhoneWindowChrome();
1049 if (m_ohosWindowProxy !=
nullptr)
1050 m_ohosWindowProxy->minimize();
1055 if (m_ohosWindowProxy !=
nullptr) {
1056 if (QGuiApplicationPrivate::focus_window) {
1057 const auto *focusPlatformWindow = QOhosPlatformWindow::fromQWindow(QGuiApplicationPrivate::focus_window);
1058 const auto *focusView = focusPlatformWindow->ownedViewOrNull();
1059 if (focusView && focusView !=
this) {
1060 if (focusView->m_ohosWindowProxy) {
1061 focusView->m_ohosWindowProxy->shiftAppWindowFocus(*m_ohosWindowProxy);
1064 sendAsyncSyntheticWindowActiveEvent();
1070 sendAsyncSyntheticWindowActiveEvent();
1076 if (m_ohosWindowProxy !=
nullptr)
1077 m_ohosWindowProxy->maximize(QOhosWindowProxy::MaximizePresentation::EXIT_IMMERSIVE);
1082 auto *qWindow = window->window();
1083 QNativeNode::CreateInfo createInfo;
1084 createInfo.geometry = window->geometry();
1085 createInfo.window = qWindow;
1086 createInfo.backgroundColor = windowPropertiesProvider.tryGetProperty<QColor, &QOhosPlatformWindow::surfaceBackgroundColorProperty>();
1087 createInfo.renderFitPolicyHint = qTransform(
1088 windowPropertiesProvider.tryGetProperty<
int, &QOhosPlatformWindow::nativeNodeRenderFitPolicyHintProperty>(),
1090 return static_cast<::ArkUI_RenderFit>(renderFit);
1093 QPlatformWindow *parentPlatformWindow = window->parent();
1095 if (parentPlatformWindow !=
nullptr) {
1097 auto *parentView = parentPlatformWindow->ownedViewOrNull();
1098 createInfo.optParent = parentView !=
nullptr
1099 ?
std::optional(parentView->m_nativeNode.get())
1103 auto nativeNode = QSharedPointer<QNativeNode>::create(createInfo);
1104 return std::make_unique<
QOhosView>(qWindow, nativeNode, windowPropertiesProvider);
1110 if (m_ohosWindowProxy !=
nullptr) {
1111 auto windowProperties = m_ohosWindowProxy->getWindowProperties();
1112 result.frameGeometry = windowProperties.windowRect;
1114 result.geometry = windowProperties.drawableRect.translated(windowProperties.windowRect.topLeft());
1119 result.geometry.setSize(
1120 evaluateGeometrySizeBasedOnFrameGeometry(result.geometry.topLeft(), result.frameGeometry));
1121 result.displayId = windowProperties.displayId;
1123 result.frameGeometry = m_nativeNode->geometry().toRect();
1124 result.geometry = result.frameGeometry;
1126 const auto *ancestorViewWithWindow = ancestorViewWithWindowOrNull();
1127 result.displayId = ancestorViewWithWindow !=
nullptr
1128 ? ancestorViewWithWindow->m_ohosWindowProxy->getWindowProperties().displayId
1137 auto avoidArea = m_avoidAreasProvider(type);
1139 tryUpdateMaximumMarginsFromAvoidArea(margins, avoidArea);
1145 if (!m_ohosWindowProxy)
1146 return ViewType::EmbeddedWindow;
1148 switch (m_ohosWindowProxy->windowProxyType()) {
1149 case WindowProxyType::FloatWindow:
1150 return ViewType::FloatWindow;
1151 case WindowProxyType::MainWindow:
1152 return ViewType::MainWindow;
1153 case WindowProxyType::SubWindow:
1154 return ViewType::SubWindow;
1157 qOhosReportFatalErrorAndAbort(
"Unrecognized WindowProxyType: %d",
static_cast<
int>(m_ohosWindowProxy->windowProxyType()));
1162 auto *platformWindow = QOhosPlatformWindow::fromQWindow(m_ownerWindow);
1163 auto targetWindowGeometry = platformWindow->geometry().marginsAdded(platformWindow->frameMargins());
1165 m_updateData.position.optPendingUpdateRequest = {targetWindowGeometry.topLeft(), {}};
1166 m_updateData.size.optPendingUpdateRequest = targetWindowGeometry.size();
1167 scheduleSystemUpdateIfNeeded();
1172 switch (viewType()) {
1173 case ViewType::MainWindow:
1176 case ViewType::FloatWindow:
1177 case ViewType::SubWindow:
1179 setOrResetWindowProxy(
nullptr,
nullptr);
1180 auto syntheticWindowHiddenEvent = QOhosWindowProxy::
WindowEvent {
1183 Q_EMIT windowEvent(syntheticWindowHiddenEvent);
1186 case ViewType::EmbeddedWindow:
1187 Q_EMIT windowVisibilityChange(
false);
1191 m_nativeNode->setVisibility(
false);
1201 if (m_ohosWindowProxy !=
nullptr)
1202 m_ohosWindowProxy->setWindowMask(mask);
1207 return m_nativeNode->surfaceOrNull();
1212 return m_nativeNode->windowId();
1217 qCDebug(QtForOhos) <<
"view:" <<
this <<
"setParentOrReparent parentView:" << &parentView;
1218 m_nativeNode->setParent(*parentView.m_nativeNode);
1219 setOrResetWindowProxy(
nullptr, parentView.ownerWindow());
1224 if (viewType() != ViewType::EmbeddedWindow) {
1225 qCDebug(QtForOhos) << Q_FUNC_INFO << m_ownerWindow;
1229 m_nativeNode->detachFromParentIfPresent();
1230 m_optLogicalParent =
nullptr;
1232 if (m_ownerWindow->isVisible() && !m_ohosWindowProxy)
1238 m_nativeNode->setVisibility(visible);
1239 m_lastMainWindowHideMethod = WindowHideMethod::NativeNodeVisibility;
1244 if (m_ohosWindowProxy->tryHideAbility()) {
1245 m_lastMainWindowHideMethod = WindowHideMethod::HideAbility;
1249 if (QOhosPlatformWindow::isWindowBeingClosedOrDestroyed(m_ownerWindow)) {
1254 m_ohosWindowProxy->minimize();
1255 m_lastMainWindowHideMethod = WindowHideMethod::Minimize;
1260 if (viewType() == ViewType::EmbeddedWindow && m_optLogicalParent ==
nullptr)
1263 std::vector<std::function<
void()>> postSurfaceDrawTasks;
1264 auto updatePostSurfaceDrawTask = qScopeGuard([&]() {
1265 if (!postSurfaceDrawTasks.empty()) {
1266 m_optPostSurfaceDrawTask = [postSurfaceDrawTasks = std::move(postSurfaceDrawTasks)]() {
1267 for (
const auto &task: postSurfaceDrawTasks)
1273 if (reason == WindowStateSyncReason::ViewTypeChanged && m_ohosWindowProxy
1274 && viewType() == ViewType::MainWindow) {
1275 postSurfaceDrawTasks.emplace_back(
1276 [weakWindowProxy = QtOhos::makeWeakPtr(m_ohosWindowProxy)]() {
1277 auto windowProxy = weakWindowProxy.lock();
1279 windowProxy->removeStartingWindow();
1283 auto *platformWindow = QOhosPlatformWindow::fromQWindow(m_ownerWindow);
1285 auto targetWindowLimitsToSet =
1286 viewType() == ViewType::EmbeddedWindow
1287 ? std::make_pair(m_ownerWindow->minimumSize(), m_ownerWindow->maximumSize())
1288 : std::make_pair(platformWindow->windowMinimumSize(), platformWindow->windowMaximumSize());
1290 auto windowFlags = QOhosPlatformWindow::platformWindowFlagsForQWindow(m_ownerWindow);
1291 bool focusable = !windowFlags.testFlag(Qt::WindowDoesNotAcceptFocus);
1293 auto submitSystemPropertyUpdate = [](
auto &targetProperty,
const auto &targetValue) {
1294 targetProperty.optPendingUpdateRequest = targetValue;
1297 auto submitOrResetSystemPropertyUpdate = [&submitSystemPropertyUpdate](
1298 auto &targetProperty,
1299 const auto &targetValue,
1302 targetProperty.optPendingUpdateRequest.reset();
1304 submitSystemPropertyUpdate(targetProperty, targetValue);
1307 submitSystemPropertyUpdate(m_updateData.title, m_ownerWindow->title());
1309 auto windowGeometryPersistenceState =
1310 viewType() == ViewType::MainWindow
1311 && m_geometryPersistencePolicy != ViewGeometryPersistencePolicy::Ignore
1312 ? syncWindowGeometryPersistenceState(m_ohosWindowProxy.get())
1313 : WindowGeometryPersistenceState::Disabled;
1316 bool windowGeometrySyncEnabled =
false;
1317 switch (currentRuntimeDeviceTypeAndMode) {
1320 windowGeometrySyncEnabled =
true;
1322 case QOhosRuntimeDeviceTypeAndMode::HandheldDeviceFullScreen:
1323 windowGeometrySyncEnabled = viewType() != ViewType::MainWindow;
1328 switch (viewType()) {
1329 case ViewType::SubWindow:
1330 if (m_optLogicalParent ==
nullptr)
1331 qOhosReportFatalErrorAndAbort(
"%s: logical parent for a subwindow is null", Q_FUNC_INFO);
1332 targetDisplayId = tryGetSubWindowJsDisplayId(m_optLogicalParent, *m_ohosWindowProxy);
1334 case ViewType::MainWindow:
1336 targetDisplayId = m_ohosWindowProxy->tryGetMainWindowJsDisplayId();
1339 case ViewType::FloatWindow:
1340 case ViewType::EmbeddedWindow:
1344 auto targetGeometryToSet = platformWindow->lastRequestedWindowFrameGeometry();
1346 if (windowGeometrySyncEnabled) {
1347 submitSystemPropertyUpdate(m_updateData.sizeLimits, targetWindowLimitsToSet);
1348 submitOrResetSystemPropertyUpdate(
1349 m_updateData.size, targetGeometryToSet.size(), windowGeometryPersistenceState);
1351 if (!qt_window_private(m_ownerWindow)->positionAutomatic) {
1352 submitOrResetSystemPropertyUpdate(
1353 m_updateData.position,
1354 std::make_pair(targetGeometryToSet.topLeft(), targetDisplayId),
1355 windowGeometryPersistenceState);
1359 submitSystemPropertyUpdate(m_updateData.backgroundTransparent, isWindowTransparencyRequested());
1362 submitSystemPropertyUpdate(m_updateData.focusable, focusable);
1364 if (viewType() == ViewType::SubWindow)
1365 submitSystemPropertyUpdate(m_updateData.modality, m_ownerWindow->modality());
1367 submitSystemPropertyUpdate(
1368 m_updateData.windowMinMaxCloseButtonsState,
1370 .maxButtonShown = windowFlags.testFlag(Qt::WindowMaximizeButtonHint),
1371 .minButtonShown = windowFlags.testFlag(Qt::WindowMinimizeButtonHint),
1372 .closeButtonShown = windowFlags.testFlag(Qt::WindowCloseButtonHint),
1375 submitSystemPropertyUpdate(
1376 m_updateData.windowStaysOnTop, windowFlags.testFlag(Qt::WindowStaysOnTopHint));
1378 submitSystemPropertyUpdate(m_updateData.frameless, windowFlags.testFlag(Qt::FramelessWindowHint));
1380 submitSystemPropertyUpdate(
1381 m_updateData.windowTransparentForInput, windowFlags.testFlag(Qt::WindowTransparentForInput));
1383 flushSystemPropertyUpdatesImmediate();
1385 bool disableWindowShadow = windowFlags.testFlag(Qt::WindowType::NoDropShadowWindowHint);
1386 if (disableWindowShadow)
1389 if (!m_ownerWindow->mask().isNull() && m_ohosWindowProxy !=
nullptr) {
1390 m_ohosWindowProxy->setWindowMask(
1391 QOhosWindowProxy::WindowMask {
1392 .windowMaskRegion = m_ownerWindow->mask(),
1394 targetGeometryToSet.size());
1396 const auto privacyModeSetting = m_windowPropertiesProvider
1397 .tryGetProperty<
bool, &QOhosPlatformWindow::windowPrivacyModeSettingProperty>();
1398 if (privacyModeSetting.has_value())
1399 setPrivacyMode(privacyModeSetting.value());
1401 const auto windowCornerRadius = m_windowPropertiesProvider
1402 .tryGetProperty<
double, &QOhosPlatformWindow::windowCornerRadiusProperty>();
1403 if (windowCornerRadius.has_value())
1404 setWindowCornerRadius(windowCornerRadius.value());
1406 const auto keepScreenOn = m_windowPropertiesProvider
1407 .tryGetProperty<
bool, &QOhosPlatformWindow::windowKeepScreenOnProperty>();
1408 if (keepScreenOn.has_value())
1409 setWindowKeepScreenOn(keepScreenOn.value());
1411 auto fixedSizeStateEnabled = m_windowPropertiesProvider
1412 .tryGetProperty<
bool, &QOhosPlatformWindow::windowFixedSizeStateProperty>();
1413 if (fixedSizeStateEnabled.has_value())
1414 setFixedSizeStateEnabled(fixedSizeStateEnabled.value());
1416 auto windowDragResizable = m_windowPropertiesProvider
1417 .tryGetProperty<
bool, &QOhosPlatformWindow::windowDragResizableProperty>();
1418 if (windowDragResizable.has_value())
1419 setWindowDragResizable(windowDragResizable.value());
1424 bool shouldSynchronizeTargetDisplayIdWithQpa =
1425 qt_window_private(m_ownerWindow)->positionAutomatic
1426 && reason == WindowStateSyncReason::ViewTypeChanged
1427 && m_ohosWindowProxy !=
nullptr;
1429 if (shouldSynchronizeTargetDisplayIdWithQpa) {
1430 auto optTargetDisplayId = m_ohosWindowProxy->getWindowProperties().displayId;
1431 if (optTargetDisplayId.has_value()) {
1432 QOhosDisplayInfo::JsDisplayId syntheticDisplayIdChangeEvent = optTargetDisplayId.value();
1433 Q_EMIT windowDisplayIdChanged(syntheticDisplayIdChangeEvent);
1438void QOhosView::flushSystemPropertyUpdatesImmediate()
1440 static const auto systemDataPropertyUpdateFuncPairsTuple = makeSystemUpdateDataPropertyUpdateFuncPairsTuple();
1443 systemDataPropertyUpdateFuncPairsTuple,
1444 [&](
const auto &updateDataMemberPtrUpdateFuncPair) {
1445 auto memberPtr = updateDataMemberPtrUpdateFuncPair.first;
1446 auto updateFuncPtr = updateDataMemberPtrUpdateFuncPair.second;
1447 auto &property = m_updateData.*memberPtr;
1448 auto optUpdateRequest =
std::exchange(property.optPendingUpdateRequest, {});
1449 if (optUpdateRequest.has_value())
1450 (
this->*updateFuncPtr)(optUpdateRequest.value());
1452 m_updatePending =
false;
1457 m_nativeNode->addForeignWindowChild(foreignWindow);
1462 auto *surface = m_nativeNode->surfaceOrNull();
1463 return surface !=
nullptr
1464 ? surface->surfaceResolution()
1470 return m_ohosWindowProxy !=
nullptr
1471 ? m_ohosWindowProxy->getImmersiveModeEnabledState()
1477 if (viewType() == ViewType::SubWindow) {
1478 auto *screen = m_ownerWindow->screen();
1479 return screen !=
nullptr && m_ownerWindow->geometry().size() == screen->geometry().size();
1487 if (m_ohosWindowProxy !=
nullptr) {
1488 m_ohosWindowProxy->setWindowTitleButtonVisible(
1489 state.maxButtonShown, state.minButtonShown, state.closeButtonShown);
1493void QOhosView::updateWindowStaysOnTop(
bool staysOnTop)
1495 if (m_ohosWindowProxy !=
nullptr)
1496 m_ohosWindowProxy->setWindowTopmost(staysOnTop);
1499void QOhosView::updateWindowFrameless(
bool frameless)
1501 bool supportsFramelessWindow = viewType() == ViewType::MainWindow || viewType() == ViewType::SubWindow;
1502 if (m_ohosWindowProxy !=
nullptr && supportsFramelessWindow) {
1503 m_ohosWindowProxy->setWindowDecorVisible(!frameless);
1504 m_ohosWindowProxy->setWindowTitleMoveEnabled(!frameless);
1508void QOhosView::setWindowDragResizable(
bool dragResizable)
1510 if (m_ohosWindowProxy !=
nullptr)
1511 m_ohosWindowProxy->enableDrag(dragResizable);
1516 setSystemUpdateProperty(&SystemUpdateData::windowMinMaxCloseButtonsState, state);
1521 setSystemUpdateProperty(&SystemUpdateData::windowStaysOnTop, staysOnTop);
1526 setSystemUpdateProperty(&SystemUpdateData::frameless, frameless);
1531 if (m_ohosWindowProxy !=
nullptr) {
1532 constexpr double windowShadowDisabledRadius = 0.0;
1533 m_ohosWindowProxy->setWindowShadowRadius(windowShadowDisabledRadius);
1537void QOhosView::setWindowCornerRadius(
double radius)
1539 if (m_ohosWindowProxy !=
nullptr)
1540 m_ohosWindowProxy->setWindowCornerRadius(radius);
1545 setSystemUpdateProperty(&SystemUpdateData::windowTransparentForInput, transparentForInput);
1550 if (m_ohosWindowProxy !=
nullptr)
1551 return m_ohosWindowProxy->startMoving();
1555void QOhosView::setPrivacyMode(
bool privacyModeEnabled)
1557 if (m_ohosWindowProxy !=
nullptr)
1558 m_ohosWindowProxy->setWindowPrivacyMode(privacyModeEnabled);
1562 const std::vector<QImage> &images,
const QPointF &hotspot,
1563 const QMimeData &mimeData, QOhosConsumer<Qt::DropAction> dropActionConsumer)
1565 m_nativeNode->startDrag(images, hotspot, mimeData, std::move(dropActionConsumer));
1570 const auto lastMainWindowHideMethod =
std::exchange(m_lastMainWindowHideMethod, {});
1571 if (m_ohosWindowProxy ==
nullptr || !m_ohosWindowProxy->qtIsMainWindow())
1574 if (!lastMainWindowHideMethod.has_value()) {
1575 m_ohosWindowProxy->restore();
1579 switch (lastMainWindowHideMethod.value()) {
1580 case WindowHideMethod::NativeNodeVisibility:
1581 case WindowHideMethod::Minimize:
1582 m_ohosWindowProxy->restore();
1584 case WindowHideMethod::HideAbility:
1585 m_ohosWindowProxy->showAbility();
1591 Qt::WindowStates previousWindowState, Qt::WindowStates currentWindowState)
1593 auto stateChange = previousWindowState ^ currentWindowState;
1594 if (stateChange.testFlag(Qt::WindowState::WindowMinimized) && !currentWindowState.testFlag(Qt::WindowState::WindowMinimized))
1597 if (stateChange.testFlag(Qt::WindowState::WindowMaximized) && currentWindowState.testFlag(Qt::WindowState::WindowMaximized)) {
1602 if (stateChange.testFlag(Qt::WindowState::WindowFullScreen) && currentWindowState.testFlag(Qt::WindowState::WindowFullScreen)) {
1607 if (stateChange.testFlag(Qt::WindowState::WindowMinimized) && currentWindowState.testFlag(Qt::WindowState::WindowMinimized)) {
1612 if (!currentWindowState) {
1619 Qt::WindowFlags previousWindowFlags, Qt::WindowFlags currentWindowFlags)
1621 const auto flagsChange = previousWindowFlags ^ currentWindowFlags;
1623 bool minMaxCloseButtonStateChanged = (flagsChange & (Qt::WindowMinMaxButtonsHint | Qt::WindowCloseButtonHint)) != 0;
1624 bool framelessChanged = (flagsChange & Qt::FramelessWindowHint) != 0;
1626 if (minMaxCloseButtonStateChanged || framelessChanged) {
1628 .maxButtonShown = currentWindowFlags.testFlag(Qt::WindowMaximizeButtonHint),
1629 .minButtonShown = currentWindowFlags.testFlag(Qt::WindowMinimizeButtonHint),
1630 .closeButtonShown = currentWindowFlags.testFlag(Qt::WindowCloseButtonHint),
1634 bool windowStaysOnTopChanged = (flagsChange & Qt::WindowStaysOnTopHint) != 0;
1635 if (windowStaysOnTopChanged)
1638 bool transparentForInputChanged = (flagsChange & Qt::WindowTransparentForInput) != 0;
1639 if (transparentForInputChanged)
1642 if (framelessChanged)
1645 bool focusableChanged = (flagsChange & Qt::WindowDoesNotAcceptFocus) != 0;
1646 if (focusableChanged) {
1647 bool windowAcceptsFocus = !currentWindowFlags.testFlag(Qt::WindowDoesNotAcceptFocus);
1651 bool disableWindowShadowChanged = (flagsChange & Qt::NoDropShadowWindowHint) != 0;
1652 if (disableWindowShadowChanged && currentWindowFlags.testFlag(Qt::NoDropShadowWindowHint))
1655 bool expandedClientAreaChanged = (flagsChange & Qt::ExpandedClientAreaHint) != 0;
1657 applyPhoneWindowChrome();
1662 return m_nativeNode->nodeAreaInfo();
1674 return !(*
this == other);
1677void QOhosView::setOrResetWindowProxy(
std::shared_ptr<QOhosWindowProxy> windowProxy, QWindow *optLogicalParent)
1679 m_ohosWindowProxy.reset();
1680 m_ohosWindowProxy = windowProxy
1681 ? QtOhos::makeSharedPtrWithAttachedExtraData<QOhosWindowProxy>(
1683 QWindowProxyRegistry::instance().registerQWindowWithWindowProxy(ownerWindow(), *windowProxy))
1685 m_optLogicalParent = optLogicalParent;
1691 auto *platformWindow = m_optLogicalParent !=
nullptr
1692 ? QOhosPlatformWindow::fromQWindowOrNull(m_optLogicalParent)
1695 return platformWindow !=
nullptr
1696 ? platformWindow->ownedViewOrNull()
1703 while (parent !=
nullptr && !parent->m_ohosWindowProxy)
1706 return parent !=
nullptr && parent->m_ohosWindowProxy
1713 return m_ohosWindowProxy ? m_ohosWindowProxy->snapshot() : QPixmap();
1718 return m_nativeNode->nodeScreenGeometryPixels();
1723 return m_nativeNode->nodeParentRelativeGeometryPixels();
void externalContentClickDetected()
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 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 handlePaletteChange()
void windowDisplayIdChanged(QOhosDisplayInfo::JsDisplayId)
void setNativeNodeVisibility(bool visible)
void setWindowStaysOnTop(bool staysOnTop)
ViewGeometry viewGeometry() const
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)
const QOhosView * viewParentOrNull() const
QRect nodeScreenGeometryPixels() const
void setWindowRectAutoSave(bool enabed)
static std::shared_ptr< QOhosWindowProxy > createFloatWindow(const FloatWindowCreateInfo &createInfo)
QtOhos::enums::ohos::window::ModalityType ModalityType
std::optional< QOhosDisplayInfo::JsDisplayId > tryGetMainWindowJsDisplayId() const
QtOhos::enums::ohos::window::AvoidAreaType AvoidAreaType
QOhosWindowProxyExistingMainWindowCreateInfo ExistingMainWindowCreateInfo
static std::shared_ptr< QOhosWindowProxy > createForExistingMainWindow(const ExistingMainWindowCreateInfo &createInfo)
bool isWindowRectAutoSave() const
QOhosWindowProxySubWindowCreateInfo SubWindowCreateInfo
QtOhos::enums::ohos::window::WindowEventType WindowEventType
QOhosWindowProxyMainWindowCreateInfo MainWindowCreateInfo
QOhosWindowProxyFloatWindowCreateInfo FloatWindowCreateInfo
QtOhos::enums::ohos::bundle::bundleManager::SupportWindowMode SupportWindowMode
static std::shared_ptr< QOhosWindowProxy > createMainWindow(const MainWindowCreateInfo &createInfo)
QOhosWindowProxy::AvoidAreaType AvoidAreaType
AvoidAreaCache(std::function< AvoidArea(AvoidAreaType)> avoidAreasProvider)
AvoidArea getStoredOrRetrieveFromWindowProxy(AvoidAreaType avoidAreaType)
void put(AvoidAreaType avoidAreaType, const AvoidArea &avoidArea)
static QWindowProxyRegistry & instance()
Combined button and popup list for selecting options.
QSize evaluateGeometrySizeBasedOnFrameGeometry(const QPoint &geometryOrigin, const QRect &frameGeometry)
std::function< void(SignalParams...)> makeViewConditionalSignalEmitter(QPointer< QOhosView > viewPtr, std::function< bool(QOhosView &)> predicate, void(QOhosView::*signalFuncPtr)(SignalParams ...))
std::optional< QColor > tryGetBackgroundColorFromWindow(QWindow *window)
QCursor makeTransparentBitmapCursor(QSize cursorSize)
QWindow * syntheticParentForQWindowOrNull(QWindow *qWindow)
std::optional< QOhosWindowProxy::ModalityType > mapQtWindowModalityToOhosOrDefault(Qt::WindowModality windowModality)
QBitmap getCursorMask(const QCursor &cursor)
WindowGeometryPersistenceState
QSize getQSizeGrownBy(const QSize &size, const QMargins &margins)
void tryUpdateMaximumMarginsFromAvoidArea(QMargins &marginsToUpdate, const QOhosWindowProxy::AvoidArea &avoidArea)
QWindow * getFirstTopLevelWindowWithSystemFocusOrNull()
QWindow * getFirstTopLevelWindowOrNull()
QBitmap getCursorBitmap(const QCursor &cursor)
ViewGeometryPersistencePolicy determineViewGeometryPersistencePolicy()
std::optional< QOhosDisplayInfo::JsDisplayId > tryGetSubWindowJsDisplayId(QWindow *logicalParent, QOhosWindowProxy &windowProxy)
ViewTypeInfo determineViewTypeAndLogicalParent(const QOhosPlatformWindow *platformWindow)
WindowGeometryPersistenceState syncWindowGeometryPersistenceState(QOhosWindowProxy *windowProxy)
QImage createImageFromBitmapAndMask(const QBitmap &bitmap, const QBitmap &mask)
bool acquireAndCleanPendingAutoStartedInstanceWindowFlag()
bool isHandheldDeviceType()
QOhosRuntimeDeviceTypeAndMode
@ HandheldDeviceFullScreen
@ HandheldDeviceWindowPcMode
QOhosRuntimeDeviceTypeAndMode queryQOhosRuntimeDeviceAndMode()
std::string qAbilityInstanceId
bool disableWindowFocusableBeforeLoadContentHack
std::string qAbilityInstanceId
QWindow * optLogicalParent
QOhosView::ViewType viewType