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 ? makeQOhosOptional(ohosPlatformScreen->displayInfo().id)
367 : windowProxy.tryGetMainWindowJsDisplayId();
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 makeQOhosOptional(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
.windowTitle = qWindow->title().toStdString();
464 createInfo.windowId = window->internalWindowId();
469 createInfo.modal = qWindow->modality() != Qt::NonModal;
470 createInfo.windowRect = window->lastRequestedWindowFrameGeometry();
471 result = parentWindowProxy->createSubWindow(createInfo);
475 case ViewType::EmbeddedWindow:
480 case ViewType::FloatWindow:
483 .qWindowRef = QtOhos::QObjectThreadSafeRef(qWindow),
484 .internalWindowId = window->internalWindowId(),
490 qOhosReportFatalErrorAndAbort(
"Unsupported view type: %d", viewType);
494 if (result !=
nullptr) {
495 auto viewPtr = QPointer<
QOhosView>(
this);
496 std::weak_ptr<QOhosWindowProxy> weakWindowProxy = result;
497 auto shouldEmitSignalPredicate = [weakWindowProxy](
QOhosView &view) {
498 auto windowProxy = weakWindowProxy.lock();
499 return windowProxy !=
nullptr && windowProxy.get() == view.m_ohosWindowProxy.get();
502 result->setWindowCallbackReceiver(
505 .onWindowEvent = makeViewConditionalSignalEmitter(viewPtr, shouldEmitSignalPredicate, &QOhosView::windowEvent),
509 .onAvoidAreaChange = makeViewConditionalSignalEmitter(viewPtr, shouldEmitSignalPredicate, &QOhosView::avoidAreaChanged),
510 .onWindowRectChange = makeViewConditionalSignalEmitter(viewPtr, shouldEmitSignalPredicate, &QOhosView::windowRectChanged),
511 .onWindowRectChangeInGlobalDisplay = makeViewConditionalSignalEmitter(
512 viewPtr, shouldEmitSignalPredicate, &QOhosView::windowRectChangedInGlobalDisplay),
516 result->setNonClientAreaMouseWindowCallbackReceiver(
518 [viewPtr, shouldEmitSignalPredicate](std::vector<QOhosWindowProxy::NonClientAreaMouseEvent> &&batch) {
519 if (!viewPtr.isNull() && shouldEmitSignalPredicate(*viewPtr)) {
521 inputEventHandler->onNonClientAreaMouseEvents(viewPtr->m_ownerWindow,
std::move(batch));
525 result->setNonClientAreaTouchWindowCallbackReceiver(
527 [viewPtr, shouldEmitSignalPredicate](std::vector<QOhosWindowProxy::NonClientAreaTouchEvent> &&batch) {
528 if (!viewPtr.isNull() && shouldEmitSignalPredicate(*viewPtr)) {
530 inputEventHandler->onNonClientAreaTouchEvents(viewPtr->m_ownerWindow,
std::move(batch));
534 if (result->qtIsMainWindow() && result->isFocused().value_or(
false)) {
538 sendAsyncSyntheticWindowActiveEvent();
545bool QOhosView::isWindowTransparencyRequested()
const
547 return m_ownerWindow->requestedFormat().hasAlpha();
551 : m_windowPropertiesProvider(windowPropertyProvider)
556 , m_updatePending(
false)
563 return m_ohosWindowProxy !=
nullptr
564 ? m_ohosWindowProxy->getWindowAvoidArea(avoidAreaType)
565 : AvoidAreaCache::AvoidArea{};
569 this, &QOhosView::avoidAreaChanged,
571 [avoidAreasProvider](QOhosWindowProxy::
AvoidAreaType avoidAreaType,
const QOhosWindowProxy::AvoidArea &avoidArea) {
572 avoidAreasProvider->put(avoidAreaType, avoidArea);
575 m_avoidAreasProvider = [avoidAreasProvider](QOhosWindowProxy::AvoidAreaType type) {
576 return avoidAreasProvider->getStoredOrRetrieveFromWindowProxy(type);
580 m_nativeNode.get(), &QNativeNode::surfaceStatusChanged,
581 this, [
this](
const QOhosOptional<QSize> &optSurfaceSize) {
582 Q_EMIT surfaceStatusChanged(optSurfaceSize);
589 m_nativeNode->setNodeAreaChangeHandler(
590 [
this](
auto nodeAreaChangeEvent) {
591 Q_EMIT nodeAreaChanged(nodeAreaChangeEvent);
594 m_nativeNode->setNodeVisibilityChangeHandler(
595 [
this](
bool visible) {
596 if (viewType() == QOhosView::ViewType::EmbeddedWindow)
597 Q_EMIT windowVisibilityChange(visible);
600 std::vector<std::shared_ptr<
void>> writeCallbacks = {
601 m_windowPropertiesProvider.addPropertyWriteCallback<
double, &QOhosPlatformWindow::windowCornerRadiusProperty>(
602 [
this](
double windowCornerRadius) {
603 setWindowCornerRadius(windowCornerRadius);
605 m_windowPropertiesProvider.addPropertyWriteCallback<
bool, &QOhosPlatformWindow::windowPrivacyModeSettingProperty>(
606 [
this](
bool windowPrivacyModeSetting) {
607 setPrivacyMode(windowPrivacyModeSetting);
609 m_windowPropertiesProvider.addPropertyWriteCallback<QColor, &QOhosPlatformWindow::surfaceBackgroundColorProperty>(
610 [
this](QColor surfaceBackgroundColor) {
611 setBackgroundColor(surfaceBackgroundColor);
613 m_windowPropertiesProvider.addPropertyWriteCallback<
bool, &QOhosPlatformWindow::windowKeepScreenOnProperty>(
614 [
this](
bool keepScreenOn) {
615 setWindowKeepScreenOn(keepScreenOn);
617 m_windowPropertiesProvider.addPropertyWriteCallback<
bool, &QOhosPlatformWindow::windowFixedSizeStateProperty>(
618 [
this](
bool fixedSizeStateEnabled) {
619 setFixedSizeStateEnabled(fixedSizeStateEnabled);
621 m_windowPropertiesProvider.addPropertyWriteCallback<
int, &QOhosPlatformWindow::windowBrightnessProperty>(
622 [
this](
int brightness) {
623 setBrightness(brightness);
625 m_windowPropertiesProvider.addPropertyWriteCallback<
int, &QOhosPlatformWindow::windowContrastProperty>(
626 [
this](
int contrast) {
627 setContrast(contrast);
629 m_windowPropertiesProvider.addPropertyWriteCallback<
int, &QOhosPlatformWindow::windowSaturationProperty>(
630 [
this](
int saturation) {
631 setSaturation(saturation);
633 m_windowPropertiesProvider.addPropertyWriteCallback<
bool, &QOhosPlatformWindow::windowDragResizableProperty>(
634 [
this](
bool dragResizable) {
635 setWindowDragResizable(dragResizable);
639 m_windowPropertiesProviderCallbacksHandle = QtOhos::moveToSharedPtr(std::move(writeCallbacks));
648 m_nativeNode.reset();
653 setSystemUpdateProperty(&SystemUpdateData::position, {position, {}});
659 setSystemUpdateProperty(&SystemUpdateData::position, {position, makeQOhosOptional(jsDisplayId)});
660 flushSystemPropertyUpdatesImmediate();
665 setSystemUpdateProperty(&SystemUpdateData::size, size);
670 setSystemUpdateProperty(&SystemUpdateData::sizeLimits, std::make_pair(minSize, maxSize));
675 setSystemUpdateProperty(&SystemUpdateData::backgroundTransparent, transparent);
680 setSystemUpdateProperty(&SystemUpdateData::focusable, focusable);
683void QOhosView::setBackgroundColor(
const QColor &color)
685 setSystemUpdateProperty(&SystemUpdateData::backgroundColor, color);
688void QOhosView::setBrightness(
int brightness)
690 setSystemUpdateProperty(&SystemUpdateData::brightness, brightness);
695 setSystemUpdateProperty(&SystemUpdateData::contrast, contrast);
698void QOhosView::setSaturation(
int saturation)
700 setSystemUpdateProperty(&SystemUpdateData::saturation, saturation);
703void QOhosView::setWindowKeepScreenOn(
bool keepScreenOn)
705 if (m_ohosWindowProxy !=
nullptr)
706 m_ohosWindowProxy->setWindowKeepScreenOn(keepScreenOn);
709void QOhosView::setFixedSizeStateEnabled(
bool enabled)
711 if (viewType() != ViewType::MainWindow)
716 "%s: fixed size state is not supported while in HandheldDeviceFullScreen mode",
722 const auto supportedWindowModes = enabled
723 ? std::set<SupportWindowMode>({SupportWindowMode::FLOATING})
724 : std::set<SupportWindowMode>({SupportWindowMode::FULL_SCREEN, SupportWindowMode::FLOATING, SupportWindowMode::SPLIT});
726 m_ohosWindowProxy->setSupportedWindowModes(supportedWindowModes);
731 auto *ohosPlatformWindow =
static_cast<QOhosPlatformWindow *>(m_ownerWindow->handle());
732 m_ohosWindowProxy->showWindow(
733 QOhosWindowProxy::ShowWindowOptions{
734 .focusOnShow = ohosPlatformWindow->shouldShowWindowWithoutActivating()
735 ? makeQOhosOptional(
false)
736 : makeEmptyQOhosOptional(),
740void QOhosView::sendAsyncSyntheticWindowActiveEvent()
742 QMetaObject::invokeMethod(
745 QOhosWindowProxy::WindowEvent syntheticWindowActiveEvent = {
746 .type = QOhosWindowProxy::WindowEventType::WINDOW_ACTIVE,
748 Q_EMIT windowEvent(syntheticWindowActiveEvent);
750 Qt::QueuedConnection);
755 setSystemUpdateProperty(&SystemUpdateData::cursor, cursor);
760 setSystemUpdateProperty(&SystemUpdateData::modality, modality);
765 setSystemUpdateProperty(&SystemUpdateData::title, title);
770 switch (viewType()) {
771 case ViewType::MainWindow:
774 case ViewType::SubWindow:
775 m_ohosWindowProxy->raiseToAppTop();
777 case ViewType::FloatWindow:
779 case ViewType::EmbeddedWindow:
780 m_nativeNode->raise();
787 if (m_ohosWindowProxy !=
nullptr && m_ownerWindow->isVisible())
790 m_nativeNode->lower();
793void QOhosView::updateWindowSize(
const QSize &size)
795 if (m_ohosWindowProxy !=
nullptr)
796 m_ohosWindowProxy->setSize(size);
798 m_nativeNode->setSize(size);
801void QOhosView::updateWindowPosition(
const std::pair<QPoint, QOhosOptional<QOhosDisplayInfo::JsDisplayId>> &positionProp)
804 QOhosOptional<QOhosDisplayInfo::JsDisplayId> displayId;
805 std::tie(position, displayId) = positionProp;
807 if (m_ohosWindowProxy !=
nullptr) {
808 m_ohosWindowProxy->moveWindowToGlobalOrGlobalDisplay(position, displayId);
810 m_nativeNode->setPosition(position);
814void QOhosView::updateWindowBackgroundTransparency(
bool transparent)
816 if (m_ohosWindowProxy !=
nullptr) {
817 auto opaqueSystemBackgroundRgb = QGuiApplicationPrivate::platformTheme()
818 ->palette(QPlatformTheme::SystemPalette)
822 m_ohosWindowProxy->setWindowBackgroundColor(
824 ? QColor(Qt::transparent)
825 : tryGetBackgroundColorFromWindow(m_ownerWindow).value_or(
826 QColor(opaqueSystemBackgroundRgb)));
830void QOhosView::updateWindowCursor(
const QCursor &cursor)
832 if (m_ohosWindowProxy ==
nullptr)
835 if (cursor.shape() == Qt::BitmapCursor || cursor.shape() == Qt::BlankCursor) {
837 cursor.shape() == Qt::BlankCursor
838 ? makeTransparentBitmapCursor({1, 1})
841 QImage bitmapCursorImage = bitmapCursor.pixmap().isNull()
842 ? createImageFromBitmapAndMask(getCursorBitmap(bitmapCursor), getCursorMask(bitmapCursor))
843 : bitmapCursor.pixmap().toImage();
845 m_ohosWindowProxy->setCustomCursor(bitmapCursorImage, bitmapCursor.hotSpot());
847 m_ohosWindowProxy->setPointerStyleSync(cursor);
851void QOhosView::updateWindowFocusable(
bool focusable)
853 if (m_ohosWindowProxy !=
nullptr)
854 m_ohosWindowProxy->setWindowFocusable(focusable);
855 m_nativeNode->setFocusable(focusable);
858void QOhosView::updateWindowBackgroundColor(
const QColor &color)
860 m_nativeNode->setBackgroundColor(color);
863void QOhosView::updateWindowBrightness(
int brightness)
865 m_nativeNode->setBrightness(brightness);
868void QOhosView::updateWindowContrast(
int contrast)
870 m_nativeNode->setContrast(contrast);
873void QOhosView::updateWindowSaturation(
int saturation)
875 m_nativeNode->setSaturation(saturation);
878void QOhosView::updateWindowTransparentForInput(
bool transparentForInput)
880 if (m_ohosWindowProxy !=
nullptr)
881 m_ohosWindowProxy->setWindowTouchable(!transparentForInput);
882 m_nativeNode->setTransparentForInput(transparentForInput);
885void QOhosView::updateWindowSizeLimits(
const std::pair<QSize, QSize> &sizeLimits)
887 if (m_ohosWindowProxy !=
nullptr) {
888 auto windowMargins = QOhosPlatformWindow::fromQWindow(m_ownerWindow)->frameMargins();
889 m_ohosWindowProxy->setWindowLimits(
890 getQSizeGrownBy(sizeLimits.first, windowMargins),
891 getQSizeGrownBy(sizeLimits.second, windowMargins));
895void QOhosView::updateWindowModality(Qt::WindowModality modality)
897 if (m_ohosWindowProxy !=
nullptr) {
898 if (viewType() != ViewType::SubWindow) {
899 qCWarning(QtForOhos,
"%s: Modality is supported only for sub-windows.", Q_FUNC_INFO);
902 if (modality == Qt::WindowModality::ApplicationModal) {
905 "%s: Qt::ApplicationModal policy is unsupported by the platform. The window will behave like Qt::WindowModal.",
909 auto ohosModalityType = mapQtWindowModalityToOhosOrDefault(modality);
910 if (ohosModalityType.has_value())
911 m_ohosWindowProxy->setSubWindowModalEnabled(ohosModalityType.value());
913 m_ohosWindowProxy->setSubWindowModalDisabled();
917void QOhosView::updateWindowTitle(
const QString &title)
919 if (m_ohosWindowProxy !=
nullptr)
920 m_ohosWindowProxy->setTitle(title);
923void QOhosView::scheduleSystemUpdateIfNeeded()
927 m_updatePending = QMetaObject::invokeMethod(
930 flushSystemPropertyUpdatesImmediate();
932 Qt::QueuedConnection);
937 return m_ownerWindow;
942 auto *platformWindow = QOhosPlatformWindow::fromQWindow(m_ownerWindow);
944 auto currentViewTypeInfo = determineViewTypeAndLogicalParent(platformWindow);
945 bool viewTypeChanged = viewType() != currentViewTypeInfo.viewType;
947 if (viewTypeChanged) {
948 auto qOhosWindowProxy = tryCreateWindowProxyIfNeeded(currentViewTypeInfo.viewType, currentViewTypeInfo.optLogicalParent);
950 if (qOhosWindowProxy !=
nullptr
951 && currentViewTypeInfo.viewType == ViewType::SubWindow) {
952 constexpr bool preventSubWindowClose =
true;
953 qOhosWindowProxy->setSubWindowCloseHandler(
955 if (!m_ownerWindow.isNull()) {
956 qOhosPrintfDebug(
"onSubWindowCloseHandler: calling close()");
957 QOhosCloseEventContext::runWithCloseRootCauseSet(
958 QOhosCloseEventContext::CloseRootCause::SubWindowClose,
960 m_ownerWindow->close();
964 preventSubWindowClose);
967 if (qOhosWindowProxy !=
nullptr) {
968 m_nativeNode->setParent(qOhosWindowProxy->nodeXComponent());
969 m_nativeNode->fillToParent();
972 setOrResetWindowProxy(qOhosWindowProxy, currentViewTypeInfo.optLogicalParent);
974 syncWindowStateImmediate();
977 if (viewType() == ViewType::MainWindow) {
978 const auto windowStates = m_ownerWindow->windowStates();
979 if (windowStates.testFlag(Qt::WindowState::WindowFullScreen)) {
985 }
else if (windowStates.testFlag(Qt::WindowState::WindowMaximized)) {
987 }
else if (QOhosDeviceInfo::isPhone()
988 && m_ownerWindow->flags().testFlag(Qt::ExpandedClientAreaHint)) {
989 applyPhoneWindowChrome();
991 }
else if (viewType() == ViewType::SubWindow && m_ohosWindowProxy !=
nullptr) {
992 m_ohosWindowProxy->setFollowParentMultiScreenPolicy(
true);
995 if (m_ohosWindowProxy !=
nullptr) {
1001 if (surface !=
nullptr)
1004 m_nativeNode->setVisibility(
true);
1009 if (m_ohosWindowProxy ==
nullptr)
1014 const bool fullScreen = m_ownerWindow->windowStates().testFlag(Qt::WindowFullScreen);
1015 const bool expanded = m_ownerWindow->flags().testFlag(Qt::ExpandedClientAreaHint);
1016 m_ohosWindowProxy->setWindowLayoutFullScreen(fullScreen || expanded);
1017 m_ohosWindowProxy->setWindowSystemBarEnable(
1018 fullScreen ? QStringList{}
1019 : QStringList{ QStringLiteral(
"status"), QStringLiteral(
"navigation") });
1024 if (m_ohosWindowProxy ==
nullptr)
1028 m_ohosWindowProxy->maximize(QOhosWindowProxy::MaximizePresentation::ENTER_IMMERSIVE);
1030 applyPhoneWindowChrome();
1035 if (m_ohosWindowProxy ==
nullptr)
1039 m_ohosWindowProxy->recover();
1041 applyPhoneWindowChrome();
1046 if (m_ohosWindowProxy !=
nullptr)
1047 m_ohosWindowProxy->minimize();
1052 if (m_ohosWindowProxy !=
nullptr) {
1053 if (QGuiApplicationPrivate::focus_window) {
1054 const auto *focusPlatformWindow = QOhosPlatformWindow::fromQWindow(QGuiApplicationPrivate::focus_window);
1055 const auto *focusView = focusPlatformWindow->ownedViewOrNull();
1056 if (focusView && focusView !=
this) {
1057 if (focusView->m_ohosWindowProxy) {
1058 focusView->m_ohosWindowProxy->shiftAppWindowFocus(*m_ohosWindowProxy);
1061 sendAsyncSyntheticWindowActiveEvent();
1067 sendAsyncSyntheticWindowActiveEvent();
1073 if (m_ohosWindowProxy !=
nullptr)
1074 m_ohosWindowProxy->maximize(QOhosWindowProxy::MaximizePresentation::EXIT_IMMERSIVE);
1079 auto *qWindow = window->window();
1080 QNativeNode::CreateInfo createInfo;
1081 createInfo.geometry = window->geometry();
1082 createInfo.window = qWindow;
1083 createInfo.backgroundColor = windowPropertiesProvider.tryGetProperty<QColor, &QOhosPlatformWindow::surfaceBackgroundColorProperty>();
1084 createInfo.renderFitPolicyHint =
1087 QPlatformWindow *parentPlatformWindow = window->parent();
1089 if (parentPlatformWindow !=
nullptr) {
1091 auto *parentView = parentPlatformWindow->ownedViewOrNull();
1092 createInfo.optParent = parentView !=
nullptr
1093 ? makeQOhosOptional(parentView->m_nativeNode.get())
1097 auto nativeNode = QSharedPointer<QNativeNode>::create(createInfo);
1098 return std::make_unique<
QOhosView>(qWindow, nativeNode, windowPropertiesProvider);
1104 if (m_ohosWindowProxy !=
nullptr) {
1105 auto windowProperties = m_ohosWindowProxy->getWindowProperties();
1106 result.frameGeometry = windowProperties.windowRect;
1108 result.geometry = windowProperties.drawableRect.translated(windowProperties.windowRect.topLeft());
1113 result.geometry.setSize(
1114 evaluateGeometrySizeBasedOnFrameGeometry(result.geometry.topLeft(), result.frameGeometry));
1115 result.displayId = windowProperties.displayId;
1117 result.frameGeometry = m_nativeNode->geometry().toRect();
1118 result.geometry = result.frameGeometry;
1120 const auto *ancestorViewWithWindow = ancestorViewWithWindowOrNull();
1121 result.displayId = ancestorViewWithWindow !=
nullptr
1122 ? ancestorViewWithWindow->m_ohosWindowProxy->getWindowProperties().displayId
1131 auto avoidArea = m_avoidAreasProvider(type);
1133 tryUpdateMaximumMarginsFromAvoidArea(margins, avoidArea);
1139 if (!m_ohosWindowProxy)
1140 return ViewType::EmbeddedWindow;
1142 switch (m_ohosWindowProxy->windowProxyType()) {
1143 case WindowProxyType::FloatWindow:
1144 return ViewType::FloatWindow;
1145 case WindowProxyType::MainWindow:
1146 return ViewType::MainWindow;
1147 case WindowProxyType::SubWindow:
1148 return ViewType::SubWindow;
1151 qOhosReportFatalErrorAndAbort(
"Unrecognized WindowProxyType: %d",
static_cast<
int>(m_ohosWindowProxy->windowProxyType()));
1156 auto *platformWindow = QOhosPlatformWindow::fromQWindow(m_ownerWindow);
1157 auto targetWindowGeometry = platformWindow->geometry().marginsAdded(platformWindow->frameMargins());
1159 m_updateData.position.optPendingUpdateRequest = {targetWindowGeometry.topLeft(), {}};
1160 m_updateData.size.optPendingUpdateRequest = targetWindowGeometry.size();
1161 scheduleSystemUpdateIfNeeded();
1166 switch (viewType()) {
1167 case ViewType::MainWindow:
1170 case ViewType::FloatWindow:
1171 case ViewType::SubWindow:
1173 setOrResetWindowProxy(
nullptr,
nullptr);
1174 auto syntheticWindowHiddenEvent = QOhosWindowProxy::
WindowEvent {
1177 Q_EMIT windowEvent(syntheticWindowHiddenEvent);
1180 case ViewType::EmbeddedWindow:
1181 Q_EMIT windowVisibilityChange(
false);
1185 m_nativeNode->setVisibility(
false);
1195 if (m_ohosWindowProxy !=
nullptr)
1196 m_ohosWindowProxy->setWindowMask(mask);
1201 return m_nativeNode->surfaceOrNull();
1206 return m_nativeNode->windowId();
1211 qCDebug(QtForOhos) <<
"view:" <<
this <<
"setParentOrReparent parentView:" << &parentView;
1212 m_nativeNode->setParent(*parentView.m_nativeNode);
1213 setOrResetWindowProxy(
nullptr, parentView.ownerWindow());
1218 if (viewType() != ViewType::EmbeddedWindow) {
1219 qCDebug(QtForOhos) << Q_FUNC_INFO << m_ownerWindow;
1223 m_nativeNode->detachFromParentIfPresent();
1224 m_optLogicalParent =
nullptr;
1226 if (m_ownerWindow->isVisible() && !m_ohosWindowProxy)
1232 m_nativeNode->setVisibility(visible);
1233 m_lastMainWindowHideMethod = WindowHideMethod::NativeNodeVisibility;
1238 if (m_ohosWindowProxy->tryHideAbility()) {
1239 m_lastMainWindowHideMethod = WindowHideMethod::HideAbility;
1243 if (QOhosPlatformWindow::isWindowBeingClosedOrDestroyed(m_ownerWindow)) {
1248 m_ohosWindowProxy->minimize();
1249 m_lastMainWindowHideMethod = WindowHideMethod::Minimize;
1254 if (viewType() == ViewType::EmbeddedWindow && m_optLogicalParent ==
nullptr)
1257 std::vector<std::function<
void()>> postSurfaceDrawTasks;
1258 auto updatePostSurfaceDrawTask = qScopeGuard([&]() {
1259 if (!postSurfaceDrawTasks.empty()) {
1260 m_optPostSurfaceDrawTask = [postSurfaceDrawTasks = std::move(postSurfaceDrawTasks)]() {
1261 for (
const auto &task: postSurfaceDrawTasks)
1267 if (reason == WindowStateSyncReason::ViewTypeChanged && m_ohosWindowProxy
1268 && viewType() == ViewType::MainWindow) {
1269 postSurfaceDrawTasks.emplace_back(
1270 [weakWindowProxy = QtOhos::makeWeakPtr(m_ohosWindowProxy)]() {
1271 auto windowProxy = weakWindowProxy.lock();
1273 windowProxy->removeStartingWindow();
1277 auto *platformWindow = QOhosPlatformWindow::fromQWindow(m_ownerWindow);
1279 auto targetWindowLimitsToSet =
1280 viewType() == ViewType::EmbeddedWindow
1281 ? std::make_pair(m_ownerWindow->minimumSize(), m_ownerWindow->maximumSize())
1282 : std::make_pair(platformWindow->windowMinimumSize(), platformWindow->windowMaximumSize());
1284 auto windowFlags = QOhosPlatformWindow::platformWindowFlagsForQWindow(m_ownerWindow);
1285 bool focusable = !windowFlags.testFlag(Qt::WindowDoesNotAcceptFocus);
1287 auto submitSystemPropertyUpdate = [](
auto &targetProperty,
const auto &targetValue) {
1288 targetProperty.optPendingUpdateRequest = targetValue;
1291 auto submitOrResetSystemPropertyUpdate = [&submitSystemPropertyUpdate](
1292 auto &targetProperty,
1293 const auto &targetValue,
1296 targetProperty.optPendingUpdateRequest.reset();
1298 submitSystemPropertyUpdate(targetProperty, targetValue);
1301 submitSystemPropertyUpdate(m_updateData.title, m_ownerWindow->title());
1303 auto windowGeometryPersistenceState =
1304 viewType() == ViewType::MainWindow
1305 && m_geometryPersistencePolicy != ViewGeometryPersistencePolicy::Ignore
1306 ? syncWindowGeometryPersistenceState(m_ohosWindowProxy.get())
1307 : WindowGeometryPersistenceState::Disabled;
1310 bool windowGeometrySyncEnabled =
false;
1311 switch (currentRuntimeDeviceTypeAndMode) {
1314 windowGeometrySyncEnabled =
true;
1316 case QOhosRuntimeDeviceTypeAndMode::HandheldDeviceFullScreen:
1317 windowGeometrySyncEnabled = viewType() != ViewType::MainWindow;
1321 QOhosOptional<QOhosDisplayInfo::JsDisplayId> targetDisplayId;
1322 switch (viewType()) {
1323 case ViewType::SubWindow:
1324 if (m_optLogicalParent ==
nullptr)
1325 qOhosReportFatalErrorAndAbort(
"%s: logical parent for a subwindow is null", Q_FUNC_INFO);
1326 targetDisplayId = tryGetSubWindowJsDisplayId(m_optLogicalParent, *m_ohosWindowProxy);
1328 case ViewType::MainWindow:
1330 targetDisplayId = m_ohosWindowProxy->tryGetMainWindowJsDisplayId();
1333 case ViewType::FloatWindow:
1334 case ViewType::EmbeddedWindow:
1338 auto targetGeometryToSet = platformWindow->lastRequestedWindowFrameGeometry();
1340 if (windowGeometrySyncEnabled) {
1341 submitSystemPropertyUpdate(m_updateData.sizeLimits, targetWindowLimitsToSet);
1342 submitOrResetSystemPropertyUpdate(
1343 m_updateData.size, targetGeometryToSet.size(), windowGeometryPersistenceState);
1345 if (!qt_window_private(m_ownerWindow)->positionAutomatic) {
1346 submitOrResetSystemPropertyUpdate(
1347 m_updateData.position,
1348 std::make_pair(targetGeometryToSet.topLeft(), targetDisplayId),
1349 windowGeometryPersistenceState);
1353 submitSystemPropertyUpdate(m_updateData.backgroundTransparent, isWindowTransparencyRequested());
1356 submitSystemPropertyUpdate(m_updateData.focusable, focusable);
1358 if (viewType() == ViewType::SubWindow)
1359 submitSystemPropertyUpdate(m_updateData.modality, m_ownerWindow->modality());
1361 submitSystemPropertyUpdate(
1362 m_updateData.windowMinMaxCloseButtonsState,
1364 .maxButtonShown = windowFlags.testFlag(Qt::WindowMaximizeButtonHint),
1365 .minButtonShown = windowFlags.testFlag(Qt::WindowMinimizeButtonHint),
1366 .closeButtonShown = windowFlags.testFlag(Qt::WindowCloseButtonHint),
1369 submitSystemPropertyUpdate(
1370 m_updateData.windowStaysOnTop, windowFlags.testFlag(Qt::WindowStaysOnTopHint));
1372 submitSystemPropertyUpdate(m_updateData.frameless, windowFlags.testFlag(Qt::FramelessWindowHint));
1374 submitSystemPropertyUpdate(
1375 m_updateData.windowTransparentForInput, windowFlags.testFlag(Qt::WindowTransparentForInput));
1377 flushSystemPropertyUpdatesImmediate();
1379 bool disableWindowShadow = windowFlags.testFlag(Qt::WindowType::NoDropShadowWindowHint);
1380 if (disableWindowShadow)
1383 if (!m_ownerWindow->mask().isNull() && m_ohosWindowProxy !=
nullptr) {
1384 m_ohosWindowProxy->setWindowMask(
1385 QOhosWindowProxy::WindowMask {
1386 .windowMaskRegion = m_ownerWindow->mask(),
1388 makeQOhosOptional(targetGeometryToSet.size()));
1390 const auto privacyModeSetting = m_windowPropertiesProvider
1391 .tryGetProperty<
bool, &QOhosPlatformWindow::windowPrivacyModeSettingProperty>();
1392 if (privacyModeSetting.has_value())
1393 setPrivacyMode(privacyModeSetting.value());
1395 const auto windowCornerRadius = m_windowPropertiesProvider
1396 .tryGetProperty<
double, &QOhosPlatformWindow::windowCornerRadiusProperty>();
1397 if (windowCornerRadius.has_value())
1398 setWindowCornerRadius(windowCornerRadius.value());
1400 const auto keepScreenOn = m_windowPropertiesProvider
1401 .tryGetProperty<
bool, &QOhosPlatformWindow::windowKeepScreenOnProperty>();
1402 if (keepScreenOn.has_value())
1403 setWindowKeepScreenOn(keepScreenOn.value());
1405 auto fixedSizeStateEnabled = m_windowPropertiesProvider
1406 .tryGetProperty<
bool, &QOhosPlatformWindow::windowFixedSizeStateProperty>();
1407 if (fixedSizeStateEnabled.has_value())
1408 setFixedSizeStateEnabled(fixedSizeStateEnabled.value());
1410 auto windowDragResizable = m_windowPropertiesProvider
1411 .tryGetProperty<
bool, &QOhosPlatformWindow::windowDragResizableProperty>();
1412 if (windowDragResizable.has_value())
1413 setWindowDragResizable(windowDragResizable.value());
1418 bool shouldSynchronizeTargetDisplayIdWithQpa =
1419 qt_window_private(m_ownerWindow)->positionAutomatic
1420 && reason == WindowStateSyncReason::ViewTypeChanged
1421 && m_ohosWindowProxy !=
nullptr;
1423 if (shouldSynchronizeTargetDisplayIdWithQpa) {
1424 auto optTargetDisplayId = m_ohosWindowProxy->getWindowProperties().displayId;
1425 if (optTargetDisplayId.has_value()) {
1426 QOhosDisplayInfo::JsDisplayId syntheticDisplayIdChangeEvent = optTargetDisplayId.value();
1427 Q_EMIT windowDisplayIdChanged(syntheticDisplayIdChangeEvent);
1432void QOhosView::flushSystemPropertyUpdatesImmediate()
1434 static const auto systemDataPropertyUpdateFuncPairsTuple = makeSystemUpdateDataPropertyUpdateFuncPairsTuple();
1437 systemDataPropertyUpdateFuncPairsTuple,
1438 [&](
const auto &updateDataMemberPtrUpdateFuncPair) {
1439 auto memberPtr = updateDataMemberPtrUpdateFuncPair.first;
1440 auto updateFuncPtr = updateDataMemberPtrUpdateFuncPair.second;
1441 auto &property = m_updateData.*memberPtr;
1442 auto optUpdateRequest =
std::exchange(property.optPendingUpdateRequest, {});
1443 if (optUpdateRequest.has_value())
1444 (
this->*updateFuncPtr)(optUpdateRequest.value());
1446 m_updatePending =
false;
1451 m_nativeNode->addForeignWindowChild(foreignWindow);
1456 auto *surface = m_nativeNode->surfaceOrNull();
1457 return surface !=
nullptr
1458 ? surface->surfaceResolution()
1464 return m_ohosWindowProxy !=
nullptr
1465 ? m_ohosWindowProxy->getImmersiveModeEnabledState()
1471 if (viewType() == ViewType::SubWindow) {
1472 auto *screen = m_ownerWindow->screen();
1473 return screen !=
nullptr && m_ownerWindow->geometry().size() == screen->geometry().size();
1481 if (m_ohosWindowProxy !=
nullptr) {
1482 m_ohosWindowProxy->setWindowTitleButtonVisible(
1483 state.maxButtonShown, state.minButtonShown, state.closeButtonShown);
1487void QOhosView::updateWindowStaysOnTop(
bool staysOnTop)
1489 if (m_ohosWindowProxy !=
nullptr)
1490 m_ohosWindowProxy->setWindowTopmost(staysOnTop);
1493void QOhosView::updateWindowFrameless(
bool frameless)
1495 bool supportsFramelessWindow = viewType() == ViewType::MainWindow || viewType() == ViewType::SubWindow;
1496 if (m_ohosWindowProxy !=
nullptr && supportsFramelessWindow) {
1497 m_ohosWindowProxy->setWindowDecorVisible(!frameless);
1498 m_ohosWindowProxy->setWindowTitleMoveEnabled(!frameless);
1502void QOhosView::setWindowDragResizable(
bool dragResizable)
1504 if (m_ohosWindowProxy !=
nullptr)
1505 m_ohosWindowProxy->enableDrag(dragResizable);
1510 setSystemUpdateProperty(&SystemUpdateData::windowMinMaxCloseButtonsState, state);
1515 setSystemUpdateProperty(&SystemUpdateData::windowStaysOnTop, staysOnTop);
1520 setSystemUpdateProperty(&SystemUpdateData::frameless, frameless);
1525 if (m_ohosWindowProxy !=
nullptr) {
1526 constexpr double windowShadowDisabledRadius = 0.0;
1527 m_ohosWindowProxy->setWindowShadowRadius(windowShadowDisabledRadius);
1531void QOhosView::setWindowCornerRadius(
double radius)
1533 if (m_ohosWindowProxy !=
nullptr)
1534 m_ohosWindowProxy->setWindowCornerRadius(radius);
1539 setSystemUpdateProperty(&SystemUpdateData::windowTransparentForInput, transparentForInput);
1544 if (m_ohosWindowProxy !=
nullptr)
1545 return m_ohosWindowProxy->startMoving();
1549void QOhosView::setPrivacyMode(
bool privacyModeEnabled)
1551 if (m_ohosWindowProxy !=
nullptr)
1552 m_ohosWindowProxy->setWindowPrivacyMode(privacyModeEnabled);
1556 const std::vector<QImage> &images,
const QPointF &hotspot,
1557 const QMimeData &mimeData, QOhosConsumer<Qt::DropAction> dropActionConsumer)
1559 m_nativeNode->startDrag(images, hotspot, mimeData, std::move(dropActionConsumer));
1565 if (m_ohosWindowProxy ==
nullptr || !m_ohosWindowProxy->qtIsMainWindow())
1568 if (!lastMainWindowHideMethod.has_value()) {
1569 m_ohosWindowProxy->restore();
1573 switch (lastMainWindowHideMethod.value()) {
1574 case WindowHideMethod::NativeNodeVisibility:
1575 case WindowHideMethod::Minimize:
1576 m_ohosWindowProxy->restore();
1578 case WindowHideMethod::HideAbility:
1579 m_ohosWindowProxy->showAbility();
1585 Qt::WindowStates previousWindowState, Qt::WindowStates currentWindowState)
1587 auto stateChange = previousWindowState ^ currentWindowState;
1588 if (stateChange.testFlag(Qt::WindowState::WindowMinimized) && !currentWindowState.testFlag(Qt::WindowState::WindowMinimized))
1591 if (stateChange.testFlag(Qt::WindowState::WindowMaximized) && currentWindowState.testFlag(Qt::WindowState::WindowMaximized)) {
1596 if (stateChange.testFlag(Qt::WindowState::WindowFullScreen) && currentWindowState.testFlag(Qt::WindowState::WindowFullScreen)) {
1601 if (stateChange.testFlag(Qt::WindowState::WindowMinimized) && currentWindowState.testFlag(Qt::WindowState::WindowMinimized)) {
1606 if (!currentWindowState) {
1613 Qt::WindowFlags previousWindowFlags, Qt::WindowFlags currentWindowFlags)
1615 const auto flagsChange = previousWindowFlags ^ currentWindowFlags;
1617 bool minMaxCloseButtonStateChanged = (flagsChange & (Qt::WindowMinMaxButtonsHint | Qt::WindowCloseButtonHint)) != 0;
1618 bool framelessChanged = (flagsChange & Qt::FramelessWindowHint) != 0;
1620 if (minMaxCloseButtonStateChanged || framelessChanged) {
1622 .maxButtonShown = currentWindowFlags.testFlag(Qt::WindowMaximizeButtonHint),
1623 .minButtonShown = currentWindowFlags.testFlag(Qt::WindowMinimizeButtonHint),
1624 .closeButtonShown = currentWindowFlags.testFlag(Qt::WindowCloseButtonHint),
1628 bool windowStaysOnTopChanged = (flagsChange & Qt::WindowStaysOnTopHint) != 0;
1629 if (windowStaysOnTopChanged)
1632 bool transparentForInputChanged = (flagsChange & Qt::WindowTransparentForInput) != 0;
1633 if (transparentForInputChanged)
1636 if (framelessChanged)
1639 bool focusableChanged = (flagsChange & Qt::WindowDoesNotAcceptFocus) != 0;
1640 if (focusableChanged) {
1641 bool windowAcceptsFocus = !currentWindowFlags.testFlag(Qt::WindowDoesNotAcceptFocus);
1645 bool disableWindowShadowChanged = (flagsChange & Qt::NoDropShadowWindowHint) != 0;
1646 if (disableWindowShadowChanged && currentWindowFlags.testFlag(Qt::NoDropShadowWindowHint))
1649 bool expandedClientAreaChanged = (flagsChange & Qt::ExpandedClientAreaHint) != 0;
1651 applyPhoneWindowChrome();
1656 return m_nativeNode->nodeAreaInfo();
1668 return !(*
this == other);
1671void QOhosView::setOrResetWindowProxy(
std::shared_ptr<QOhosWindowProxy> windowProxy, QWindow *optLogicalParent)
1673 m_ohosWindowProxy.reset();
1674 m_ohosWindowProxy = windowProxy
1675 ? QtOhos::makeSharedPtrWithAttachedExtraData<QOhosWindowProxy>(
1677 QWindowProxyRegistry::instance().registerQWindowWithWindowProxy(ownerWindow(), *windowProxy))
1679 m_optLogicalParent = optLogicalParent;
1685 auto *platformWindow = m_optLogicalParent !=
nullptr
1686 ? QOhosPlatformWindow::fromQWindowOrNull(m_optLogicalParent)
1689 return platformWindow !=
nullptr
1690 ? platformWindow->ownedViewOrNull()
1697 while (parent !=
nullptr && !parent->m_ohosWindowProxy)
1700 return parent !=
nullptr && parent->m_ohosWindowProxy
1707 return m_ohosWindowProxy ? m_ohosWindowProxy->snapshot() : QPixmap();
1712 return m_nativeNode->nodeScreenGeometryPixels();
1717 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()
QOhosOptional< QSize > surfaceResolution() const
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 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)
void startDrag(const std::vector< QImage > &images, const QPointF &hotspot, const QMimeData &mimeData, QOhosConsumer< Qt::DropAction > dropActionConsumer)
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
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.
QOhosOptional< QOhosWindowProxy::ModalityType > mapQtWindowModalityToOhosOrDefault(Qt::WindowModality windowModality)
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 ...))
QOhosOptional< QColor > tryGetBackgroundColorFromWindow(QWindow *window)
QCursor makeTransparentBitmapCursor(QSize cursorSize)
QWindow * syntheticParentForQWindowOrNull(QWindow *qWindow)
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()
QOhosOptional< QOhosDisplayInfo::JsDisplayId > tryGetSubWindowJsDisplayId(QWindow *logicalParent, QOhosWindowProxy &windowProxy)
QBitmap getCursorBitmap(const QCursor &cursor)
ViewGeometryPersistencePolicy determineViewGeometryPersistencePolicy()
ViewTypeInfo determineViewTypeAndLogicalParent(const QOhosPlatformWindow *platformWindow)
WindowGeometryPersistenceState syncWindowGeometryPersistenceState(QOhosWindowProxy *windowProxy)
QImage createImageFromBitmapAndMask(const QBitmap &bitmap, const QBitmap &mask)
bool acquireAndCleanPendingAutoStartedInstanceWindowFlag()
std::nullopt_t makeEmptyQOhosOptional()
bool isHandheldDeviceType()
QOhosRuntimeDeviceTypeAndMode
@ HandheldDeviceFullScreen
@ HandheldDeviceWindowPcMode
QOhosRuntimeDeviceTypeAndMode queryQOhosRuntimeDeviceAndMode()
std::string qAbilityInstanceId
bool disableWindowFocusableBeforeLoadContentHack
std::string qAbilityInstanceId
QWindow * optLogicalParent
QOhosView::ViewType viewType