Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qohosview.cpp
Go to the documentation of this file.
1// Copyright (C) 2025 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#include <render/qohosview.h>
5
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>
16#include <functional>
17#include <memory>
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>
33#include <string>
34#include <tuple>
35#include <vector>
36
38
40
41namespace
42{
43
49
55
57 Qt::WindowModality windowModality)
58{
59 using ModalityType = QOhosWindowProxy::ModalityType;
60
61 switch (windowModality) {
62 case Qt::WindowModality::NonModal:
63 return std::nullopt;
64 case Qt::WindowModality::WindowModal:
65 return ModalityType::WINDOW_MODALITY;
66 case Qt::WindowModality::ApplicationModal:
67 return ModalityType::APPLICATION_MODALITY;
68 }
69
70 qOhosPrintfWarning(
71 "%s: got illegal Qt::WindowModality value (%d), using the default instead",
72 Q_FUNC_INFO, static_cast<int>(windowModality));
73
74 return std::nullopt;
75}
76
77template<typename ...SignalParams>
78std::function<void(SignalParams...)> makeViewConditionalSignalEmitter(
79 QPointer<QOhosView> viewPtr, std::function<bool(QOhosView &)> predicate, void (QOhosView::*signalFuncPtr)(SignalParams ...))
80{
81 return [signalFuncPtr, viewPtr, predicate = std::move(predicate)](SignalParams ...args) {
82 if (viewPtr && predicate(*viewPtr))
83 Q_EMIT (*viewPtr.*signalFuncPtr)(args...);
84 };
85}
86
88{
89public:
91 using AvoidAreaType = QOhosWindowProxy::AvoidAreaType;
92
93 explicit AvoidAreaCache(std::function<AvoidArea(AvoidAreaType)> avoidAreasProvider);
94
95 void put(
96 AvoidAreaType avoidAreaType,
97 const AvoidArea &avoidArea);
98
100
101private:
102 std::function<AvoidArea(AvoidAreaType)> m_avoidAreasProvider;
103 QMap<AvoidAreaType, AvoidArea> m_store;
104};
105
106AvoidAreaCache::AvoidAreaCache(std::function<AvoidArea(AvoidAreaType)> avoidAreasProvider)
108 , m_store()
109{
110}
111
113 QOhosWindowProxy::AvoidAreaType avoidAreaType, const QOhosWindowProxy::AvoidArea &avoidArea)
114{
115 m_store[avoidAreaType] = avoidArea;
116}
117
119 QOhosWindowProxy::AvoidAreaType avoidAreaType)
120{
121 if (m_store.contains(avoidAreaType))
122 return m_store.value(avoidAreaType);
123
124 auto result = m_avoidAreasProvider(avoidAreaType);
125 m_store[avoidAreaType] = result;
126 return result;
127}
128
129void tryUpdateMaximumMarginsFromAvoidArea(QMargins &marginsToUpdate, const QOhosWindowProxy::AvoidArea &avoidArea)
130{
131 if (!avoidArea.visible)
132 return;
133
134 marginsToUpdate.setTop(qMax(marginsToUpdate.top(), avoidArea.topRect.height()));
135 marginsToUpdate.setLeft(qMax(marginsToUpdate.left(), avoidArea.leftRect.width()));
136 marginsToUpdate.setRight(qMax(marginsToUpdate.right(), avoidArea.rightRect.width()));
137 marginsToUpdate.setBottom(qMax(marginsToUpdate.bottom(), avoidArea.bottomRect.height()));
138}
139
141 const QPoint &geometryOrigin, const QRect &frameGeometry)
142{
143 int topFrameMargin = qAbs(frameGeometry.top() - geometryOrigin.y());
144 int sideAndBottomFrameMargin = qAbs(frameGeometry.left() - geometryOrigin.x());
145
146 return {
147 frameGeometry.width() - 2 * sideAndBottomFrameMargin,
148 frameGeometry.height() - topFrameMargin - sideAndBottomFrameMargin
149 };
150}
151
152QSize getQSizeGrownBy(const QSize &size, const QMargins &margins)
153{
154 // HACK
155 // when the minimum window size is set to 0, the system seems to treat it as “not set” and
156 // applies its own default values instead (width: 320vp, height: 72vp).
157 // Therefore, when the intention is to set the minimum size to 0,
158 // we set it to 1 instead to avoid the system default being applied.
159 return {
160 qMax(1, size.width() + margins.left() + margins.right()),
161 qMax(1, size.height() + margins.top() + margins.bottom())};
162}
163
165{
166 auto visibleWindows = QWindowProxyRegistry::instance().queryWindowsWithVisibleSystemWindow();
167 return !visibleWindows.empty()
168 ? visibleWindows.front()
169 : nullptr;
170}
171
173{
174 auto focusedWindows = QWindowProxyRegistry::instance().queryWindowsWithSystemWindowAndFocus();
175 return !focusedWindows.empty()
176 ? focusedWindows.front()
177 : nullptr;
178}
179
181{
182 auto *focusWindow = getFirstTopLevelWindowWithSystemFocusOrNull();
183 auto *firstTopLevelWindow = getFirstTopLevelWindowOrNull();
184
185 auto isValidSyntheticParent = [&](QWindow *w) {
186 return w != nullptr && w != qWindow && w->isVisible();
187 };
188
189 return isValidSyntheticParent(focusWindow)
190 ? focusWindow
191 : isValidSyntheticParent(firstTopLevelWindow)
192 ? firstTopLevelWindow
193 : nullptr;
194}
195
197{
198 using ViewType = QOhosView::ViewType;
199
200 auto *qWindow = platformWindow->window();
201 auto *parent = qWindow->parent();
202 auto *transientParent = qWindow->transientParent();
203
204 auto windowType = qWindow->type();
205
206 QWindow *subWindowTagValue = platformWindow->validSubWindowOfTagValueOrNull();
207
208 static QSet<Qt::WindowType> fallbackToSubWindowWindowTypes{
209 Qt::Popup,
210 Qt::ToolTip,
211 Qt::Dialog,
212 Qt::Tool,
213 };
214
215 bool taggedAsMainWindow = platformWindow->mainWindowTagValueOrFalse();
216 if (taggedAsMainWindow) {
217 return ViewTypeInfo {
218 .viewType = ViewType::MainWindow,
219 .optLogicalParent = nullptr,
220 };
221 }
222
223 bool taggedAsFloatWindow = platformWindow->floatWindowTagValueOrFalse();
224 if (taggedAsFloatWindow) {
225 return ViewTypeInfo {
226 .viewType = ViewType::FloatWindow,
227 .optLogicalParent = nullptr,
228 };
229 }
230
231 bool overrideAsSubWindow = subWindowTagValue != nullptr;
232 if (overrideAsSubWindow) {
233 return ViewTypeInfo {
234 .viewType = ViewType::SubWindow,
235 .optLogicalParent = subWindowTagValue,
236 };
237 }
238
239 if (parent != nullptr) {
240 return ViewTypeInfo {
241 .viewType = ViewType::EmbeddedWindow,
242 .optLogicalParent = parent,
243 };
244 }
245
246 if (transientParent != nullptr) {
247 return ViewTypeInfo {
248 .viewType = ViewType::SubWindow,
249 .optLogicalParent = transientParent,
250 };
251 }
252
253 auto *syntheticParent = syntheticParentForQWindowOrNull(platformWindow->window());
254
255 bool automaticOverrideActive =
256 fallbackToSubWindowWindowTypes.contains(windowType)
257 && syntheticParent != nullptr;
258 if (automaticOverrideActive) {
259 return ViewTypeInfo {
260 .viewType = ViewType::SubWindow,
261 .optLogicalParent = syntheticParent,
262 };
263 }
264
265 return ViewTypeInfo {
266 .viewType = ViewType::MainWindow,
267 .optLogicalParent = nullptr,
268 };
269}
270
271QBitmap getCursorBitmap(const QCursor &cursor)
272{
273 return cursor.bitmap();
274}
275
276QBitmap getCursorMask(const QCursor &cursor)
277{
278 return cursor.mask();
279}
280
281QImage createImageFromBitmapAndMask(const QBitmap &bitmap, const QBitmap &mask)
282{
283 const auto maskTransparentColor = QColor(Qt::color0).rgba();
284 const auto transparentColor = QColor(Qt::transparent).rgba();
285
286 QImage image = bitmap.toImage().convertToFormat(QImage::Format_RGBA8888);
287 QImage maskImage = mask.toImage().convertToFormat(QImage::Format_RGB32);
288
289 for (int row = 0; row < image.height(); ++row) {
290 auto *imageData = reinterpret_cast<QRgb *>(image.scanLine(row));
291 auto *maskData = reinterpret_cast<QRgb *>(maskImage.scanLine(row));
292 for (int col = 0; col < image.width(); ++col) {
293 if (maskData[col] == maskTransparentColor)
294 imageData[col] = transparentColor;
295 }
296 }
297
298 return image;
299}
300
302{
303 QBitmap cursorPixels(cursorSize);
304 cursorPixels.fill(Qt::transparent);
305 QBitmap cursorMask(cursorSize);
306 cursorMask.fill(Qt::color0);
307 return QCursor(cursorPixels, cursorMask);
308}
309
310ViewGeometryPersistencePolicy determineViewGeometryPersistencePolicy()
311{
312 using WindowGeometryPersistencePolicy = QOhosPlatformIntegration::WindowGeometryPersistencePolicy;
313
314 auto viewGeometryPersistencePolicy = ViewGeometryPersistencePolicy::Ignore;
315
317 switch (policy) {
318 case WindowGeometryPersistencePolicy::Disabled:
319 viewGeometryPersistencePolicy = ViewGeometryPersistencePolicy::Disabled;
320 break;
321 case WindowGeometryPersistencePolicy::Enabled:
322 viewGeometryPersistencePolicy = ViewGeometryPersistencePolicy::Enabled;
323 break;
324 case WindowGeometryPersistencePolicy::FollowSystemSetting:
325 viewGeometryPersistencePolicy = ViewGeometryPersistencePolicy::FollowSystemSetting;
326 break;
327 }
328
329 return viewGeometryPersistencePolicy;
330}
331
333{
334 using WindowGeometryPersistencePolicy = QOhosPlatformIntegration::WindowGeometryPersistencePolicy;
335
336 bool geometryPersistenceEnabled = false;
338 switch (policy) {
339 case WindowGeometryPersistencePolicy::Disabled:
340 windowProxy->setWindowRectAutoSave(false);
341 break;
342 case WindowGeometryPersistencePolicy::Enabled:
343 windowProxy->setWindowRectAutoSave(true);
344 geometryPersistenceEnabled = windowProxy->isWindowRectAutoSave();
345 break;
346 case WindowGeometryPersistencePolicy::FollowSystemSetting:
347 geometryPersistenceEnabled = windowProxy->isWindowRectAutoSave();
348 break;
349 }
350
351 return geometryPersistenceEnabled
354}
355
357 QWindow *logicalParent, QOhosWindowProxy &windowProxy)
358{
359 auto *screen = logicalParent->screen();
360 auto *ohosPlatformScreen = screen != nullptr
361 ? static_cast<QOhosPlatformScreen *>(screen->handle())
362 : nullptr;
363
364 return ohosPlatformScreen != nullptr
365 ? std::optional(ohosPlatformScreen->displayInfo().id)
366 : windowProxy.tryGetMainWindowJsDisplayId();
367}
368
370{
371 if (window != nullptr) {
372 QWindowPrivate *windowPrivate = qt_window_private(window);
373 QPalette palette = windowPrivate->windowPalette();
374 QColor backgroundColor = palette.color(QPalette::Window);
375 return backgroundColor;
376 }
377 return std::nullopt;
378}
379
380}
381
383{
384 auto optPostSurfaceDrawTask = std::exchange(m_optPostSurfaceDrawTask, {});
385 if (optPostSurfaceDrawTask)
386 optPostSurfaceDrawTask();
387}
388
389std::shared_ptr<QOhosWindowProxy> QOhosView::tryCreateWindowProxyIfNeeded(ViewType viewType, QWindow *optLogicalParent)
390{
391 QWindow *qWindow = m_ownerWindow;
392 QOhosPlatformWindow *window = QOhosPlatformWindow::fromQWindow(qWindow);
393
394 std::shared_ptr<QOhosWindowProxy> result;
395
396 switch (viewType) {
397 case ViewType::MainWindow:
398 {
399 // NOTE: treat windows automatically-created by the platform in a special way
401 if (useAutoStartedMainWindow) {
402 QOhosWindowProxy::ExistingMainWindowCreateInfo createInfo;
403 createInfo.qWindowRef = QtOhos::QObjectThreadSafeRef(qWindow);
404 createInfo.qAbilityInstanceId = QtOhos::evalInJsThread([](QtOhos::JsState &jsState) {
405 return jsState.defaultQAbilityPeer()->instanceId();
406 },
407 Q_FUNC_INFO);
408 result = QOhosWindowProxy::createForExistingMainWindow(createInfo);
409 m_geometryPersistencePolicy = determineViewGeometryPersistencePolicy();
410 } else {
411 QOhosWindowProxy::MainWindowCreateInfo createInfo;
412 createInfo.qWindowRef = QtOhos::QObjectThreadSafeRef(qWindow);
413 createInfo.windowId = window->internalWindowId();
414 createInfo.windowTitle = qWindow->title().toStdString();
415 createInfo.frameGeometry = window->lastRequestedWindowFrameGeometry();
416 createInfo.fullscreen = qWindow->windowState() == Qt::WindowFullScreen;
417 result = QOhosWindowProxy::createMainWindow(createInfo);
418 }
419
420 break;
421 }
422 case ViewType::SubWindow:
423 {
424 auto *targetWindowToBeSubWindowOf = optLogicalParent;
425
426 if (Q_UNLIKELY(targetWindowToBeSubWindowOf == nullptr))
427 qOhosReportFatalErrorAndAbort("Failed to determine valid parent of a SubWindow");
428
429 if (!targetWindowToBeSubWindowOf->isVisible()) {
430 auto *targetParentPlatformWindow = QOhosPlatformWindow::fromQWindowOrNull(targetWindowToBeSubWindowOf);
431 if (targetParentPlatformWindow != nullptr)
432 targetParentPlatformWindow->setVisible(true);
433 else
434 targetWindowToBeSubWindowOf->show();
435 }
436
437 auto *targetWindowToBeSubWindowOfView =
438 QOhosPlatformWindow::fromQWindow(targetWindowToBeSubWindowOf)->ownedViewOrNull();
439
440 const QOhosView *firstViewWithWindow = nullptr;
441 switch (targetWindowToBeSubWindowOfView->viewType()) {
442 case ViewType::MainWindow:
443 case ViewType::SubWindow:
444 case ViewType::FloatWindow:
445 firstViewWithWindow = targetWindowToBeSubWindowOfView;
446 break;
447 case ViewType::EmbeddedWindow:
448 firstViewWithWindow = ancestorViewWithWindowOrNull();
449 break;
450 }
451
452 if (firstViewWithWindow == nullptr)
453 qOhosReportFatalErrorAndAbort("Failed to determine valid parent for this window.");
454
455 auto parentWindowProxy = firstViewWithWindow->m_ohosWindowProxy;
456 if (Q_UNLIKELY(!parentWindowProxy)) {
457 qOhosReportFatalErrorAndAbort(
458 "parentWindowProxy is null but should not be. This is most likely a programming error");
459 }
460
461 QOhosWindowProxy::SubWindowCreateInfo createInfo;
462 createInfo.window = QtOhos::QObjectThreadSafeRef(qWindow);
463 createInfo.windowTitle = qWindow->title().toStdString();
464 createInfo.windowId = window->internalWindowId();
465 createInfo.qAbilityInstanceId = parentWindowProxy->qAbilityInstanceId();
466
468 createInfo.disableWindowFocusableBeforeLoadContentHack = window->windowFlags().testFlag(Qt::WindowDoesNotAcceptFocus);
469 createInfo.modal = qWindow->modality() != Qt::NonModal;
470 createInfo.windowRect = window->lastRequestedWindowFrameGeometry();
471 result = parentWindowProxy->createSubWindow(createInfo);
472
473 break;
474 }
475 case ViewType::EmbeddedWindow:
476 {
477 // NOTE - NativeNode is now always created during view instantiation
478 break;
479 }
480 case ViewType::FloatWindow:
481 {
482 QOhosWindowProxy::FloatWindowCreateInfo createInfo = {
483 .qWindowRef = QtOhos::QObjectThreadSafeRef(qWindow),
484 .internalWindowId = window->internalWindowId(),
485 };
486 result = QOhosWindowProxy::createFloatWindow(createInfo);
487 break;
488 }
489 default:
490 qOhosReportFatalErrorAndAbort("Unsupported view type: %d", viewType);
491
492 }
493
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();
500 };
501
502 result->setWindowCallbackReceiver(
503 std::make_unique<QOhosWindowProxy::WindowCallbacks>(
504 QOhosWindowProxy::WindowCallbacks {
505 .onWindowEvent = makeViewConditionalSignalEmitter(viewPtr, shouldEmitSignalPredicate, &QOhosView::windowEvent),
506 .onWindowStatusChange = makeViewConditionalSignalEmitter(viewPtr, shouldEmitSignalPredicate, &QOhosView::windowStatusChange),
507 .onWindowVisibilityChange = makeViewConditionalSignalEmitter(viewPtr, shouldEmitSignalPredicate, &QOhosView::windowVisibilityChange),
508 .onTouchOutside = makeViewConditionalSignalEmitter(viewPtr, shouldEmitSignalPredicate, &QOhosView::windowTouchOutside),
509 .onAvoidAreaChange = makeViewConditionalSignalEmitter(viewPtr, shouldEmitSignalPredicate, &QOhosView::avoidAreaChanged),
510 .onWindowRectChange = makeViewConditionalSignalEmitter(viewPtr, shouldEmitSignalPredicate, &QOhosView::windowRectChanged),
511 .onWindowRectChangeInGlobalDisplay = makeViewConditionalSignalEmitter(
512 viewPtr, shouldEmitSignalPredicate, &QOhosView::windowRectChangedInGlobalDisplay),
513 .onWindowDisplayIdChange = makeViewConditionalSignalEmitter(viewPtr, shouldEmitSignalPredicate, &QOhosView::windowDisplayIdChanged),
514 }));
515
516 result->setNonClientAreaMouseWindowCallbackReceiver(
517 this,
518 [viewPtr, shouldEmitSignalPredicate](std::vector<QOhosWindowProxy::NonClientAreaMouseEvent> &&batch) {
519 if (!viewPtr.isNull() && shouldEmitSignalPredicate(*viewPtr)) {
521 inputEventHandler->onNonClientAreaMouseEvents(viewPtr->m_ownerWindow, std::move(batch));
522 }
523 });
524
525 result->setNonClientAreaTouchWindowCallbackReceiver(
526 this,
527 [viewPtr, shouldEmitSignalPredicate](std::vector<QOhosWindowProxy::NonClientAreaTouchEvent> &&batch) {
528 if (!viewPtr.isNull() && shouldEmitSignalPredicate(*viewPtr)) {
530 inputEventHandler->onNonClientAreaTouchEvents(viewPtr->m_ownerWindow, std::move(batch));
531 }
532 });
533
534 if (result->qtIsMainWindow() && result->isFocused().value_or(false)) {
535 // HACK
536 // WINDOW_ACTIVE event should be handled by QOhosFloatingWindow after OHOS system event received.
537 // Until we cannot register this event properly, keep sending it manually here.
538 sendAsyncSyntheticWindowActiveEvent();
539 }
540 }
541
542 return result;
543}
544
545bool QOhosView::isWindowTransparencyRequested() const
546{
547 return m_ownerWindow->requestedFormat().hasAlpha();
548}
549
550QOhosView::QOhosView(QWindow *ownerWindow, QSharedPointer<QNativeNode> nativeNode, QOhosPropertiesProvider windowPropertyProvider)
551 : m_windowPropertiesProvider(windowPropertyProvider)
555 , m_updateData()
556 , m_updatePending(false)
558 , m_requireHandheldDeviceSupport(isHandheldDeviceType())
561{
562 auto avoidAreasProvider = std::make_shared<AvoidAreaCache>([this](AvoidAreaCache::AvoidAreaType avoidAreaType) {
563 return m_ohosWindowProxy != nullptr
564 ? m_ohosWindowProxy->getWindowAvoidArea(avoidAreaType)
565 : AvoidAreaCache::AvoidArea{};
566 });
567
568 connect(
569 this, &QOhosView::avoidAreaChanged,
570 this,
571 [avoidAreasProvider](QOhosWindowProxy::AvoidAreaType avoidAreaType, const QOhosWindowProxy::AvoidArea &avoidArea) {
572 avoidAreasProvider->put(avoidAreaType, avoidArea);
573 });
574
575 m_avoidAreasProvider = [avoidAreasProvider](QOhosWindowProxy::AvoidAreaType type) {
576 return avoidAreasProvider->getStoredOrRetrieveFromWindowProxy(type);
577 };
578
579 connect(
580 m_nativeNode.get(), &QNativeNode::surfaceStatusChanged,
581 this, [this](const std::optional<QSize> &optSurfaceSize) {
582 Q_EMIT surfaceStatusChanged(optSurfaceSize);
583 });
584
585 connect(
588
589 m_nativeNode->setNodeAreaChangeHandler(
590 [this](auto nodeAreaChangeEvent) {
591 m_nodeLaidOut = true;
592 Q_EMIT nodeAreaChanged(nodeAreaChangeEvent);
593 });
594
595 m_nativeNode->setNodeVisibilityChangeHandler(
596 [this](bool visible) {
597 if (m_ohosWindowProxy == nullptr)
598 Q_EMIT windowVisibilityChange(visible);
599 });
600
601 std::vector<std::shared_ptr<void>> writeCallbacks = {
602 m_windowPropertiesProvider.addPropertyWriteCallback<double, &QOhosPlatformWindow::windowCornerRadiusProperty>(
603 [this](double windowCornerRadius) {
604 setWindowCornerRadius(windowCornerRadius);
605 }),
606 m_windowPropertiesProvider.addPropertyWriteCallback<bool, &QOhosPlatformWindow::windowPrivacyModeSettingProperty>(
607 [this](bool windowPrivacyModeSetting) {
608 setPrivacyMode(windowPrivacyModeSetting);
609 }),
610 m_windowPropertiesProvider.addPropertyWriteCallback<QColor, &QOhosPlatformWindow::surfaceBackgroundColorProperty>(
611 [this](QColor surfaceBackgroundColor) {
612 setBackgroundColor(surfaceBackgroundColor);
613 }),
614 m_windowPropertiesProvider.addPropertyWriteCallback<bool, &QOhosPlatformWindow::windowKeepScreenOnProperty>(
615 [this](bool keepScreenOn) {
616 setWindowKeepScreenOn(keepScreenOn);
617 }),
618 m_windowPropertiesProvider.addPropertyWriteCallback<bool, &QOhosPlatformWindow::windowFixedSizeStateProperty>(
619 [this](bool fixedSizeStateEnabled) {
620 setFixedSizeStateEnabled(fixedSizeStateEnabled);
621 }),
622 m_windowPropertiesProvider.addPropertyWriteCallback<int, &QOhosPlatformWindow::windowBrightnessProperty>(
623 [this](int brightness) {
624 setBrightness(brightness);
625 }),
626 m_windowPropertiesProvider.addPropertyWriteCallback<int, &QOhosPlatformWindow::windowContrastProperty>(
627 [this](int contrast) {
628 setContrast(contrast);
629 }),
630 m_windowPropertiesProvider.addPropertyWriteCallback<int, &QOhosPlatformWindow::windowSaturationProperty>(
631 [this](int saturation) {
632 setSaturation(saturation);
633 }),
634 m_windowPropertiesProvider.addPropertyWriteCallback<bool, &QOhosPlatformWindow::windowDragResizableProperty>(
635 [this](bool dragResizable) {
636 setWindowDragResizable(dragResizable);
637 }),
638 };
639
640 m_windowPropertiesProviderCallbacksHandle = QtOhos::moveToSharedPtr(std::move(writeCallbacks));
641}
642
644{
645 // This call is necessary in order to avoid receiving callbacks
646 // from the underlying XComponent after we terminate the window.
647 // Not having this resulted in exceptions thrown from the system
648 // because QOhosNativeXComponent reffered to the window object that is null.
649 m_nativeNode.reset();
650}
651
652void QOhosView::setPosition(const QPoint &position)
653{
654 setSystemUpdateProperty(&SystemUpdateData::position, {position, {}});
655}
656
658 const QPoint &position, QOhosDisplayInfo::JsDisplayId jsDisplayId)
659{
660 setSystemUpdateProperty(&SystemUpdateData::position, {position, jsDisplayId});
661 flushSystemPropertyUpdatesImmediate();
662}
663
664void QOhosView::setSize(const QSize &size)
665{
666 setSystemUpdateProperty(&SystemUpdateData::size, size);
667}
668
669void QOhosView::setSizeLimits(const QSize &minSize, const QSize &maxSize)
670{
671 setSystemUpdateProperty(&SystemUpdateData::sizeLimits, std::make_pair(minSize, maxSize));
672}
673
674void QOhosView::setTransparentBackground(bool transparent)
675{
676 setSystemUpdateProperty(&SystemUpdateData::backgroundTransparent, transparent);
677}
678
679void QOhosView::setFocusable(bool focusable)
680{
681 setSystemUpdateProperty(&SystemUpdateData::focusable, focusable);
682}
683
684void QOhosView::setBackgroundColor(const QColor &color)
685{
686 setSystemUpdateProperty(&SystemUpdateData::backgroundColor, color);
687}
688
689void QOhosView::setBrightness(int brightness)
690{
691 setSystemUpdateProperty(&SystemUpdateData::brightness, brightness);
692}
693
694void QOhosView::setContrast(int contrast)
695{
696 setSystemUpdateProperty(&SystemUpdateData::contrast, contrast);
697}
698
699void QOhosView::setSaturation(int saturation)
700{
701 setSystemUpdateProperty(&SystemUpdateData::saturation, saturation);
702}
703
704void QOhosView::setWindowKeepScreenOn(bool keepScreenOn)
705{
706 if (m_ohosWindowProxy != nullptr)
707 m_ohosWindowProxy->setWindowKeepScreenOn(keepScreenOn);
708}
709
710void QOhosView::setFixedSizeStateEnabled(bool enabled)
711{
712 if (m_ohosWindowProxy == nullptr || viewType() != ViewType::MainWindow)
713 return;
714
716 qOhosPrintfWarning(
717 "%s: fixed size state is not supported while in HandheldDeviceFullScreen mode",
718 Q_FUNC_INFO);
719 return;
720 }
721
722 using SupportWindowMode = QOhosWindowProxy::SupportWindowMode;
723 const auto supportedWindowModes = enabled
724 ? std::set<SupportWindowMode>({SupportWindowMode::FLOATING})
725 : std::set<SupportWindowMode>({SupportWindowMode::FULL_SCREEN, SupportWindowMode::FLOATING, SupportWindowMode::SPLIT});
726
727 m_ohosWindowProxy->setSupportedWindowModes(supportedWindowModes);
728}
729
730void QOhosView::showWindow()
731{
732 auto *ohosPlatformWindow = static_cast<QOhosPlatformWindow *>(m_ownerWindow->handle());
733 m_ohosWindowProxy->showWindow(
734 QOhosWindowProxy::ShowWindowOptions{
735 .focusOnShow = ohosPlatformWindow->shouldShowWindowWithoutActivating()
736 ? std::optional(false)
737 : std::nullopt,
738 });
739}
740
741void QOhosView::sendAsyncSyntheticWindowActiveEvent()
742{
743 QMetaObject::invokeMethod(
744 this,
745 [this]() {
746 QOhosWindowProxy::WindowEvent syntheticWindowActiveEvent = {
747 .type = QOhosWindowProxy::WindowEventType::WINDOW_ACTIVE,
748 };
749 Q_EMIT windowEvent(syntheticWindowActiveEvent);
750 },
751 Qt::QueuedConnection);
752}
753
754void QOhosView::setCursor(const QCursor &cursor)
755{
756 setSystemUpdateProperty(&SystemUpdateData::cursor, cursor);
757}
758
759void QOhosView::setModality(Qt::WindowModality modality)
760{
761 setSystemUpdateProperty(&SystemUpdateData::modality, modality);
762}
763
764void QOhosView::setTitle(const QString &title)
765{
766 setSystemUpdateProperty(&SystemUpdateData::title, title);
767}
768
770{
771 if (m_ohosWindowProxy == nullptr) {
772 m_nativeNode->raise();
773 return;
774 }
775
776 switch (viewType()) {
777 case ViewType::MainWindow:
778 showWindow();
779 break;
780 case ViewType::SubWindow:
781 m_ohosWindowProxy->raiseToAppTop();
782 break;
783 case ViewType::FloatWindow:
784 case ViewType::EmbeddedWindow:
785 break;
786 }
787}
788
790{
791 if (m_ohosWindowProxy != nullptr && m_ownerWindow->isVisible())
792 showWindow();
793 else
794 m_nativeNode->lower();
795}
796
797void QOhosView::updateWindowSize(const QSize &size)
798{
799 if (m_ohosWindowProxy != nullptr)
800 m_ohosWindowProxy->setSize(size);
801 else
802 m_nativeNode->setSize(size);
803}
804
805void QOhosView::updateWindowPosition(const std::pair<QPoint, std::optional<QOhosDisplayInfo::JsDisplayId>> &positionProp)
806{
807 QPoint position;
808 std::optional<QOhosDisplayInfo::JsDisplayId> displayId;
809 std::tie(position, displayId) = positionProp;
810
811 if (m_ohosWindowProxy != nullptr) {
812 m_ohosWindowProxy->moveWindowToGlobalOrGlobalDisplay(position, displayId);
813 } else {
814 m_nativeNode->setPosition(position);
815 }
816}
817
818void QOhosView::updateWindowBackgroundTransparency(bool transparent)
819{
820 if (m_ohosWindowProxy != nullptr) {
821 auto opaqueSystemBackgroundRgb = QGuiApplicationPrivate::platformTheme()
822 ->palette(QPlatformTheme::SystemPalette)
823 ->window()
824 .color()
825 .rgb();
826 m_ohosWindowProxy->setWindowBackgroundColor(
827 transparent
828 ? QColor(Qt::transparent)
829 : tryGetBackgroundColorFromWindow(m_ownerWindow).value_or(
830 QColor(opaqueSystemBackgroundRgb)));
831 }
832}
833
834void QOhosView::updateWindowCursor(const QCursor &cursor)
835{
836 if (m_ohosWindowProxy == nullptr)
837 return;
838
839 if (cursor.shape() == Qt::BitmapCursor || cursor.shape() == Qt::BlankCursor) {
840 auto bitmapCursor =
841 cursor.shape() == Qt::BlankCursor
842 ? makeTransparentBitmapCursor({1, 1})
843 : cursor;
844
845 QImage bitmapCursorImage = bitmapCursor.pixmap().isNull()
846 ? createImageFromBitmapAndMask(getCursorBitmap(bitmapCursor), getCursorMask(bitmapCursor))
847 : bitmapCursor.pixmap().toImage();
848
849 m_ohosWindowProxy->setCustomCursor(bitmapCursorImage, bitmapCursor.hotSpot());
850 } else {
851 m_ohosWindowProxy->setPointerStyleSync(cursor);
852 }
853}
854
855void QOhosView::updateWindowFocusable(bool focusable)
856{
857 if (m_ohosWindowProxy != nullptr)
858 m_ohosWindowProxy->setWindowFocusable(focusable);
859 m_nativeNode->setFocusable(focusable);
860}
861
862void QOhosView::updateWindowBackgroundColor(const QColor &color)
863{
864 m_nativeNode->setBackgroundColor(color);
865}
866
867void QOhosView::updateWindowBrightness(int brightness)
868{
869 m_nativeNode->setBrightness(brightness);
870}
871
872void QOhosView::updateWindowContrast(int contrast)
873{
874 m_nativeNode->setContrast(contrast);
875}
876
877void QOhosView::updateWindowSaturation(int saturation)
878{
879 m_nativeNode->setSaturation(saturation);
880}
881
882void QOhosView::updateWindowTransparentForInput(bool transparentForInput)
883{
884 if (m_ohosWindowProxy != nullptr)
885 m_ohosWindowProxy->setWindowTouchable(!transparentForInput);
886 m_nativeNode->setTransparentForInput(transparentForInput);
887}
888
889void QOhosView::updateWindowSizeLimits(const std::pair<QSize, QSize> &sizeLimits)
890{
891 if (m_ohosWindowProxy != nullptr) {
892 auto windowMargins = QOhosPlatformWindow::fromQWindow(m_ownerWindow)->frameMargins();
893 m_ohosWindowProxy->setWindowLimits(
894 getQSizeGrownBy(sizeLimits.first, windowMargins),
895 getQSizeGrownBy(sizeLimits.second, windowMargins));
896 }
897}
898
899void QOhosView::updateWindowModality(Qt::WindowModality modality)
900{
901 if (m_ohosWindowProxy != nullptr) {
902 if (viewType() != ViewType::SubWindow) {
903 qCWarning(QtForOhos, "%s: Modality is supported only for sub-windows.", Q_FUNC_INFO);
904 return;
905 }
906 if (modality == Qt::WindowModality::ApplicationModal) {
907 qCWarning(
908 QtForOhos,
909 "%s: Qt::ApplicationModal policy is unsupported by the platform. The window will behave like Qt::WindowModal.",
910 Q_FUNC_INFO);
911 }
912
913 auto ohosModalityType = mapQtWindowModalityToOhosOrDefault(modality);
914 if (ohosModalityType.has_value())
915 m_ohosWindowProxy->setSubWindowModalEnabled(ohosModalityType.value());
916 else
917 m_ohosWindowProxy->setSubWindowModalDisabled();
918 }
919}
920
921void QOhosView::updateWindowTitle(const QString &title)
922{
923 if (m_ohosWindowProxy != nullptr)
924 m_ohosWindowProxy->setTitle(title);
925}
926
927void QOhosView::scheduleSystemUpdateIfNeeded()
928{
929 if (m_updatePending)
930 return;
931 m_updatePending = QMetaObject::invokeMethod(
932 this,
933 [this]() {
934 flushSystemPropertyUpdatesImmediate();
935 },
936 Qt::QueuedConnection);
937}
938
940{
941 return m_ownerWindow;
942}
943
945{
946 auto *platformWindow = QOhosPlatformWindow::fromQWindow(m_ownerWindow);
947
948 auto currentViewTypeInfo = determineViewTypeAndLogicalParent(platformWindow);
949 const bool hadWindowProxy = m_ohosWindowProxy != nullptr;
950 const bool needsWindowProxy = !hadWindowProxy
951 && currentViewTypeInfo.viewType != ViewType::EmbeddedWindow;
952 const bool windowProxyRoleChanged = hadWindowProxy
953 && viewType() != currentViewTypeInfo.viewType;
954
955 if (needsWindowProxy || windowProxyRoleChanged) {
956 auto qOhosWindowProxy = tryCreateWindowProxyIfNeeded(currentViewTypeInfo.viewType, currentViewTypeInfo.optLogicalParent);
957
958 if (qOhosWindowProxy != nullptr
959 && currentViewTypeInfo.viewType == ViewType::SubWindow) {
960 constexpr bool preventSubWindowClose = true;
961 qOhosWindowProxy->setSubWindowCloseHandler(
962 [this]() {
963 if (!m_ownerWindow.isNull()) {
964 qOhosPrintfDebug("onSubWindowCloseHandler: calling close()");
965 QOhosCloseEventContext::runWithCloseRootCauseSet(
966 QOhosCloseEventContext::CloseRootCause::SubWindowClose,
967 [&]() {
968 m_ownerWindow->close();
969 });
970 }
971 },
972 preventSubWindowClose);
973 }
974
975 m_viewType = currentViewTypeInfo.viewType;
976 setOrResetWindowProxy(qOhosWindowProxy, currentViewTypeInfo.optLogicalParent);
977
978 if (qOhosWindowProxy != nullptr) {
979 m_nativeNode->setParent(qOhosWindowProxy->nodeXComponent());
980 m_nativeNode->fillToParent();
981 }
982#if QT_CONFIG(draganddrop)
983 m_nativeNode->enableDropDisallowedBadge();
984#endif
985 } else {
986 syncWindowStateImmediate();
987 }
988
989 if (viewType() == ViewType::MainWindow) {
990 const auto windowStates = m_ownerWindow->windowStates();
991 if (windowStates.testFlag(Qt::WindowState::WindowFullScreen)) {
992 // A phone window created fullscreen still shows the system bars, so
993 // hide them explicitly. On 2-in-1/tablet the window is already
994 // immersive at creation; re-applying would only make it twitch.
995 if (hadWindowProxy || QOhosDeviceInfo::isPhone())
997 } else if (windowStates.testFlag(Qt::WindowState::WindowMaximized)) {
999 } else if (QOhosDeviceInfo::isPhone()
1000 && m_ownerWindow->flags().testFlag(Qt::ExpandedClientAreaHint)) {
1001 applyPhoneWindowChrome();
1002 }
1003 } else if (viewType() == ViewType::SubWindow && m_ohosWindowProxy != nullptr) {
1004 m_ohosWindowProxy->setFollowParentMultiScreenPolicy(true);
1005 }
1006
1007 if (m_ohosWindowProxy != nullptr) {
1009 showWindow();
1010 }
1011
1012 auto *surface = surfaceOrNull();
1013 if (surface != nullptr)
1015
1016 m_nativeNode->setVisibility(true);
1017
1018 // Mirrors hide(): ArkUI does not report the node visibility change for an
1019 // embedded window, so the view has to.
1020 if (viewType() == ViewType::EmbeddedWindow)
1021 Q_EMIT windowVisibilityChange(true);
1022}
1023
1024void QOhosView::applyPhoneWindowChrome()
1025{
1026 if (m_ohosWindowProxy == nullptr)
1027 return;
1028
1029 // Lay the window out under the system bars when fullscreen or when the
1030 // client area is expanded; only fullscreen also hides the bars.
1031 const bool fullScreen = m_ownerWindow->windowStates().testFlag(Qt::WindowFullScreen);
1032 const bool expanded = m_ownerWindow->flags().testFlag(Qt::ExpandedClientAreaHint);
1033 m_ohosWindowProxy->setWindowLayoutFullScreen(fullScreen || expanded);
1034 m_ohosWindowProxy->setWindowSystemBarEnable(
1035 fullScreen ? QStringList{}
1036 : QStringList{ QStringLiteral("status"), QStringLiteral("navigation") });
1037}
1038
1040{
1041 auto *windowProxy = flushedWindowProxyOrNull();
1042 if (windowProxy == nullptr)
1043 return;
1044
1046 windowProxy->maximize(QOhosWindowProxy::MaximizePresentation::ENTER_IMMERSIVE);
1047 else
1048 applyPhoneWindowChrome();
1049}
1050
1052{
1053 auto *windowProxy = flushedWindowProxyOrNull();
1054 if (windowProxy == nullptr)
1055 return;
1056
1058 windowProxy->recover();
1059 else
1060 applyPhoneWindowChrome();
1061}
1062
1064{
1065 auto *windowProxy = flushedWindowProxyOrNull();
1066 if (windowProxy != nullptr)
1067 windowProxy->minimize();
1068}
1069
1071{
1072 if (m_ohosWindowProxy != nullptr) {
1073 if (QGuiApplicationPrivate::focus_window) {
1074 const auto *focusPlatformWindow = QOhosPlatformWindow::fromQWindow(QGuiApplicationPrivate::focus_window);
1075 const auto *focusView = focusPlatformWindow->ownedViewOrNull();
1076 if (focusView && focusView != this) {
1077 if (focusView->m_ohosWindowProxy) {
1078 focusView->m_ohosWindowProxy->shiftAppWindowFocus(*m_ohosWindowProxy);
1079 } else {
1080 // If the previously focused window is an EmbeddedWindow.
1081 sendAsyncSyntheticWindowActiveEvent();
1082 }
1083 }
1084 }
1085 } else {
1086 // for EmbeddedWindow
1087 sendAsyncSyntheticWindowActiveEvent();
1088 }
1089}
1090
1092{
1093 auto *windowProxy = flushedWindowProxyOrNull();
1094 if (windowProxy != nullptr)
1095 windowProxy->maximize(QOhosWindowProxy::MaximizePresentation::EXIT_IMMERSIVE);
1096}
1097
1098std::unique_ptr<QOhosView> QOhosView::createForWindow(QOhosPlatformWindow *window, QOhosPropertiesProvider windowPropertiesProvider)
1099{
1100 auto *qWindow = window->window();
1101 QNativeNode::CreateInfo createInfo;
1102 createInfo.geometry = window->geometry();
1103 createInfo.window = qWindow;
1104 createInfo.backgroundColor = windowPropertiesProvider.tryGetProperty<QColor, &QOhosPlatformWindow::surfaceBackgroundColorProperty>();
1105 createInfo.renderFitPolicyHint = qTransform(
1106 windowPropertiesProvider.tryGetProperty<int, &QOhosPlatformWindow::nativeNodeRenderFitPolicyHintProperty>(),
1107 [](int renderFit) {
1108 return static_cast<::ArkUI_RenderFit>(renderFit);
1109 });
1110
1111 QPlatformWindow *parentPlatformWindow = window->parent();
1112
1113 if (parentPlatformWindow != nullptr) {
1114 auto *parentPlatformWindow = static_cast<QOhosPlatformWindow *>(window->parent());
1115 auto *parentView = parentPlatformWindow->ownedViewOrNull();
1116 createInfo.optParent = parentView != nullptr
1117 ? std::optional(parentView->m_nativeNode.get())
1118 : std::nullopt;
1119 }
1120
1121 auto nativeNode = QSharedPointer<QNativeNode>::create(createInfo);
1122 return std::make_unique<QOhosView>(qWindow, nativeNode, windowPropertiesProvider);
1123}
1124
1126{
1127 QOhosView::ViewGeometry result;
1128 if (m_ohosWindowProxy != nullptr) {
1129 auto windowProperties = m_ohosWindowProxy->getWindowProperties();
1130 result.frameGeometry = windowProperties.windowRect;
1131 // Translate relative coordinates of the window to absolute screen values
1132 result.geometry = windowProperties.drawableRect.translated(windowProperties.windowRect.topLeft());
1133 // HACK:
1134 // "result.geometry" might contain invalid size but (1) it will likely contain proper
1135 // top-left corner coords and (2) "result.frameGeometry" is also valid, so adjust the
1136 // invalidated size based on these two.
1137 result.geometry.setSize(
1138 evaluateGeometrySizeBasedOnFrameGeometry(result.geometry.topLeft(), result.frameGeometry));
1139 result.displayId = windowProperties.displayId;
1140 } else {
1141 result.frameGeometry = m_nativeNode->geometry().toRect();
1142 result.geometry = result.frameGeometry;
1143
1144 const auto *ancestorViewWithWindow = ancestorViewWithWindowOrNull();
1145 result.displayId = ancestorViewWithWindow != nullptr
1146 ? ancestorViewWithWindow->m_ohosWindowProxy->getWindowProperties().displayId
1147 : std::nullopt;
1148 }
1149
1150 return result;
1151}
1152
1153QMargins QOhosView::avoidAreaMargins(QOhosWindowProxy::AvoidAreaType type) const
1154{
1155 auto avoidArea = m_avoidAreasProvider(type);
1156 QMargins margins;
1157 tryUpdateMaximumMarginsFromAvoidArea(margins, avoidArea);
1158 return margins;
1159}
1160
1162{
1163 return m_ohosWindowProxy != nullptr ? m_ohosWindowProxy->getDisplayCutoutRects()
1164 : QList<QRect>();
1165}
1166
1168{
1169 return m_viewType.value_or(ViewType::EmbeddedWindow);
1170}
1171
1173{
1174 auto *platformWindow = QOhosPlatformWindow::fromQWindow(m_ownerWindow);
1175 auto targetWindowGeometry = platformWindow->geometry().marginsAdded(platformWindow->frameMargins());
1176
1177 m_updateData.position.optPendingUpdateRequest = {targetWindowGeometry.topLeft(), {}};
1178 m_updateData.size.optPendingUpdateRequest = targetWindowGeometry.size();
1179 scheduleSystemUpdateIfNeeded();
1180}
1181
1183{
1184 switch (viewType()) {
1185 case ViewType::MainWindow:
1186 hideMainWindow();
1187 break;
1188 case ViewType::FloatWindow:
1189 case ViewType::SubWindow:
1190 {
1191 setOrResetWindowProxy(nullptr, nullptr);
1192 auto syntheticWindowHiddenEvent = QOhosWindowProxy::WindowEvent {
1193 .type = QOhosWindowProxy::WindowEventType::WINDOW_HIDDEN,
1194 };
1195 Q_EMIT windowEvent(syntheticWindowHiddenEvent);
1196 break;
1197 }
1198 case ViewType::EmbeddedWindow:
1199 Q_EMIT windowVisibilityChange(false);
1200 break;
1201 }
1202
1203 m_nativeNode->setVisibility(false);
1204}
1205
1207{
1208 setTransparentBackground(isWindowTransparencyRequested());
1209}
1210
1211void QOhosView::setWindowMask(const QOhosWindowProxy::WindowMask &mask)
1212{
1213 if (m_ohosWindowProxy != nullptr)
1214 m_ohosWindowProxy->setWindowMask(mask);
1215}
1216
1217QOhosSurface *QOhosView::surfaceOrNull() const
1218{
1219 return m_nativeNode->surfaceOrNull();
1220}
1221
1223{
1224 return m_nativeNode->windowId();
1225}
1226
1228{
1229 qCDebug(QtForOhos) << "view:" << this << "setParentOrReparent parentView:" << &parentView;
1230 m_nativeNode->setParent(*parentView.m_nativeNode);
1231 m_viewType.reset();
1232 setOrResetWindowProxy(nullptr, parentView.ownerWindow());
1233}
1234
1236{
1237 if (viewType() != ViewType::EmbeddedWindow) {
1238 qCDebug(QtForOhos) << Q_FUNC_INFO << m_ownerWindow;
1239 return;
1240 }
1241
1242 m_nativeNode->detachFromParentIfPresent();
1243 m_optLogicalParent = nullptr;
1244
1245 if (m_ownerWindow->isVisible() && !m_ohosWindowProxy)
1247}
1248
1250{
1251 m_nativeNode->setVisibility(visible);
1252 m_lastMainWindowHideMethod = WindowHideMethod::NativeNodeVisibility;
1253}
1254
1255void QOhosView::hideMainWindow()
1256{
1257 if (m_ohosWindowProxy->tryHideAbility()) {
1258 m_lastMainWindowHideMethod = WindowHideMethod::HideAbility;
1259 return;
1260 }
1261
1262 if (QOhosPlatformWindow::isWindowBeingClosedOrDestroyed(m_ownerWindow)) {
1264 return;
1265 }
1266
1267 m_ohosWindowProxy->minimize();
1268 m_lastMainWindowHideMethod = WindowHideMethod::Minimize;
1269
1270 auto *platformWindow = QOhosPlatformWindow::fromQWindow(m_ownerWindow);
1271 if (!platformWindow->windowStates().testFlag(Qt::WindowMinimized))
1272 ++m_pendingSelfMinimizeEchoes;
1273}
1274
1275void QOhosView::syncWindowStateImmediate(WindowStateSyncReason reason)
1276{
1277 if (m_ohosWindowProxy == nullptr && m_optLogicalParent == nullptr)
1278 return;
1279
1280 std::vector<std::function<void()>> postSurfaceDrawTasks;
1281 auto updatePostSurfaceDrawTask = qScopeGuard([&]() {
1282 if (!postSurfaceDrawTasks.empty()) {
1283 m_optPostSurfaceDrawTask = [postSurfaceDrawTasks = std::move(postSurfaceDrawTasks)]() {
1284 for (const auto &task: postSurfaceDrawTasks)
1285 task();
1286 };
1287 }
1288 });
1289
1290 if (reason == WindowStateSyncReason::ViewTypeChanged && m_ohosWindowProxy
1291 && viewType() == ViewType::MainWindow) {
1292 postSurfaceDrawTasks.emplace_back(
1293 [weakWindowProxy = QtOhos::makeWeakPtr(m_ohosWindowProxy)]() {
1294 auto windowProxy = weakWindowProxy.lock();
1295 if (windowProxy)
1296 windowProxy->removeStartingWindow();
1297 });
1298 }
1299
1300 auto *platformWindow = QOhosPlatformWindow::fromQWindow(m_ownerWindow);
1301
1302 auto targetWindowLimitsToSet =
1303 viewType() == ViewType::EmbeddedWindow
1304 ? std::make_pair(m_ownerWindow->minimumSize(), m_ownerWindow->maximumSize())
1305 : std::make_pair(platformWindow->windowMinimumSize(), platformWindow->windowMaximumSize());
1306
1307 auto windowFlags = QOhosPlatformWindow::platformWindowFlagsForQWindow(m_ownerWindow);
1308 bool focusable = !windowFlags.testFlag(Qt::WindowDoesNotAcceptFocus);
1309
1310 auto submitSystemPropertyUpdate = [](auto &targetProperty, const auto &targetValue) {
1311 targetProperty.optPendingUpdateRequest = targetValue;
1312 };
1313
1314 auto submitOrResetSystemPropertyUpdate = [&submitSystemPropertyUpdate](
1315 auto &targetProperty,
1316 const auto &targetValue,
1317 WindowGeometryPersistenceState windowGeometryPersistenceState) {
1318 if (windowGeometryPersistenceState == WindowGeometryPersistenceState::Enabled)
1319 targetProperty.optPendingUpdateRequest.reset();
1320 else
1321 submitSystemPropertyUpdate(targetProperty, targetValue);
1322 };
1323
1324 submitSystemPropertyUpdate(m_updateData.title, m_ownerWindow->title());
1325
1326 auto windowGeometryPersistenceState =
1327 viewType() == ViewType::MainWindow
1328 && m_geometryPersistencePolicy != ViewGeometryPersistencePolicy::Ignore
1329 ? syncWindowGeometryPersistenceState(m_ohosWindowProxy.get())
1330 : WindowGeometryPersistenceState::Disabled;
1331
1332 auto currentRuntimeDeviceTypeAndMode = queryQOhosRuntimeDeviceAndMode();
1333 bool windowGeometrySyncEnabled = false;
1334 switch (currentRuntimeDeviceTypeAndMode) {
1337 windowGeometrySyncEnabled = true;
1338 break;
1339 case QOhosRuntimeDeviceTypeAndMode::HandheldDeviceFullScreen:
1340 windowGeometrySyncEnabled = viewType() != ViewType::MainWindow;
1341 break;
1342 }
1343
1344 std::optional<QOhosDisplayInfo::JsDisplayId> targetDisplayId;
1345 switch (viewType()) {
1346 case ViewType::SubWindow:
1347 if (m_optLogicalParent == nullptr)
1348 qOhosReportFatalErrorAndAbort("%s: logical parent for a subwindow is null", Q_FUNC_INFO);
1349 targetDisplayId = tryGetSubWindowJsDisplayId(m_optLogicalParent, *m_ohosWindowProxy);
1350 break;
1351 case ViewType::MainWindow:
1352 {
1353 targetDisplayId = m_ohosWindowProxy->tryGetMainWindowJsDisplayId();
1354 break;
1355 }
1356 case ViewType::FloatWindow:
1357 case ViewType::EmbeddedWindow:
1358 break;
1359 }
1360
1361 auto targetGeometryToSet = platformWindow->lastRequestedWindowFrameGeometry();
1362
1363 if (windowGeometrySyncEnabled) {
1364 submitSystemPropertyUpdate(m_updateData.sizeLimits, targetWindowLimitsToSet);
1365 submitOrResetSystemPropertyUpdate(
1366 m_updateData.size, targetGeometryToSet.size(), windowGeometryPersistenceState);
1367
1368 if (!qt_window_private(m_ownerWindow)->positionAutomatic) {
1369 submitOrResetSystemPropertyUpdate(
1370 m_updateData.position,
1371 std::make_pair(targetGeometryToSet.topLeft(), targetDisplayId),
1372 windowGeometryPersistenceState);
1373 }
1374 }
1375
1376 submitSystemPropertyUpdate(m_updateData.backgroundTransparent, isWindowTransparencyRequested());
1377
1378 if (currentRuntimeDeviceTypeAndMode == QOhosRuntimeDeviceTypeAndMode::_2in1)
1379 submitSystemPropertyUpdate(m_updateData.focusable, focusable);
1380
1381 if (viewType() == ViewType::SubWindow)
1382 submitSystemPropertyUpdate(m_updateData.modality, m_ownerWindow->modality());
1383
1384 submitSystemPropertyUpdate(
1385 m_updateData.windowMinMaxCloseButtonsState,
1387 .maxButtonShown = windowFlags.testFlag(Qt::WindowMaximizeButtonHint),
1388 .minButtonShown = windowFlags.testFlag(Qt::WindowMinimizeButtonHint),
1389 .closeButtonShown = windowFlags.testFlag(Qt::WindowCloseButtonHint),
1390 });
1391
1392 submitSystemPropertyUpdate(
1393 m_updateData.windowStaysOnTop, windowFlags.testFlag(Qt::WindowStaysOnTopHint));
1394
1395 submitSystemPropertyUpdate(m_updateData.frameless, windowFlags.testFlag(Qt::FramelessWindowHint));
1396
1397 submitSystemPropertyUpdate(
1398 m_updateData.windowTransparentForInput, windowFlags.testFlag(Qt::WindowTransparentForInput));
1399
1400 flushSystemPropertyUpdatesImmediate();
1401
1402 bool disableWindowShadow = windowFlags.testFlag(Qt::WindowType::NoDropShadowWindowHint);
1403 if (disableWindowShadow)
1405
1406 if (!m_ownerWindow->mask().isNull() && m_ohosWindowProxy != nullptr) {
1407 m_ohosWindowProxy->setWindowMask(
1408 QOhosWindowProxy::WindowMask {
1409 .windowMaskRegion = m_ownerWindow->mask(),
1410 },
1411 targetGeometryToSet.size());
1412 }
1413 const auto privacyModeSetting = m_windowPropertiesProvider
1414 .tryGetProperty<bool, &QOhosPlatformWindow::windowPrivacyModeSettingProperty>();
1415 if (privacyModeSetting.has_value())
1416 setPrivacyMode(privacyModeSetting.value());
1417
1418 const auto windowCornerRadius = m_windowPropertiesProvider
1419 .tryGetProperty<double, &QOhosPlatformWindow::windowCornerRadiusProperty>();
1420 if (windowCornerRadius.has_value())
1421 setWindowCornerRadius(windowCornerRadius.value());
1422
1423 const auto keepScreenOn = m_windowPropertiesProvider
1424 .tryGetProperty<bool, &QOhosPlatformWindow::windowKeepScreenOnProperty>();
1425 if (keepScreenOn.has_value())
1426 setWindowKeepScreenOn(keepScreenOn.value());
1427
1428 auto fixedSizeStateEnabled = m_windowPropertiesProvider
1429 .tryGetProperty<bool, &QOhosPlatformWindow::windowFixedSizeStateProperty>();
1430 if (fixedSizeStateEnabled.has_value())
1431 setFixedSizeStateEnabled(fixedSizeStateEnabled.value());
1432
1433 auto windowDragResizable = m_windowPropertiesProvider
1434 .tryGetProperty<bool, &QOhosPlatformWindow::windowDragResizableProperty>();
1435 if (windowDragResizable.has_value())
1436 setWindowDragResizable(windowDragResizable.value());
1437
1438 // NOTE - when position automatic is set we do not control window position
1439 // therefore no window callback about window position change will be sent
1440 // and the screen that given window belongs to needs to be synchronized
1441 bool shouldSynchronizeTargetDisplayIdWithQpa =
1442 qt_window_private(m_ownerWindow)->positionAutomatic
1443 && reason == WindowStateSyncReason::ViewTypeChanged
1444 && m_ohosWindowProxy != nullptr;
1445
1446 if (shouldSynchronizeTargetDisplayIdWithQpa) {
1447 auto optTargetDisplayId = m_ohosWindowProxy->getWindowProperties().displayId;
1448 if (optTargetDisplayId.has_value()) {
1449 QOhosDisplayInfo::JsDisplayId syntheticDisplayIdChangeEvent = optTargetDisplayId.value();
1450 Q_EMIT windowDisplayIdChanged(syntheticDisplayIdChangeEvent);
1451 }
1452 }
1453}
1454
1455void QOhosView::flushSystemPropertyUpdatesImmediate()
1456{
1457 static const auto systemDataPropertyUpdateFuncPairsTuple = makeSystemUpdateDataPropertyUpdateFuncPairsTuple();
1458
1459 QtOhos::tupleForEach(
1460 systemDataPropertyUpdateFuncPairsTuple,
1461 [&](const auto &updateDataMemberPtrUpdateFuncPair) {
1462 auto memberPtr = updateDataMemberPtrUpdateFuncPair.first;
1463 auto updateFuncPtr = updateDataMemberPtrUpdateFuncPair.second;
1464 auto &property = m_updateData.*memberPtr;
1465 auto optUpdateRequest = std::exchange(property.optPendingUpdateRequest, {});
1466 if (optUpdateRequest.has_value())
1467 (this->*updateFuncPtr)(optUpdateRequest.value());
1468 });
1469 m_updatePending = false;
1470}
1471
1472QOhosWindowProxy *QOhosView::flushedWindowProxyOrNull()
1473{
1474 if (m_ohosWindowProxy == nullptr)
1475 return nullptr;
1476
1477 flushSystemPropertyUpdatesImmediate();
1478 return m_ohosWindowProxy.get();
1479}
1480
1481void QOhosView::addForeignWindowChild(QOhosForeignWindow *foreignWindow)
1482{
1483 m_nativeNode->addForeignWindowChild(foreignWindow);
1484}
1485
1487{
1488 auto *surface = m_nativeNode->surfaceOrNull();
1489 return surface != nullptr
1490 ? surface->surfaceResolution()
1491 : std::nullopt;
1492}
1493
1495{
1496 return m_ohosWindowProxy != nullptr
1497 ? m_ohosWindowProxy->getImmersiveModeEnabledState()
1498 : false;
1499}
1500
1502{
1503 if (viewType() == ViewType::SubWindow) {
1504 auto *screen = m_ownerWindow->screen();
1505 return screen != nullptr && m_ownerWindow->geometry().size() == screen->geometry().size();
1506 }
1507
1508 return false;
1509}
1510
1511void QOhosView::updateWindowMinMaxCloseButtonsState(const WindowMinMaxCloseButtonsState &state)
1512{
1513 if (m_ohosWindowProxy != nullptr) {
1514 m_ohosWindowProxy->setWindowTitleButtonVisible(
1515 state.maxButtonShown, state.minButtonShown, state.closeButtonShown);
1516 }
1517}
1518
1519void QOhosView::updateWindowStaysOnTop(bool staysOnTop)
1520{
1521 if (m_ohosWindowProxy != nullptr)
1522 m_ohosWindowProxy->setWindowTopmost(staysOnTop);
1523}
1524
1525void QOhosView::updateWindowFrameless(bool frameless)
1526{
1527 bool supportsFramelessWindow = viewType() == ViewType::MainWindow || viewType() == ViewType::SubWindow;
1528 if (m_ohosWindowProxy != nullptr && supportsFramelessWindow) {
1529 m_ohosWindowProxy->setWindowDecorVisible(!frameless);
1530 m_ohosWindowProxy->setWindowTitleMoveEnabled(!frameless);
1531 }
1532}
1533
1534void QOhosView::setWindowDragResizable(bool dragResizable)
1535{
1536 if (m_ohosWindowProxy != nullptr)
1537 m_ohosWindowProxy->enableDrag(dragResizable);
1538}
1539
1541{
1542 setSystemUpdateProperty(&SystemUpdateData::windowMinMaxCloseButtonsState, state);
1543}
1544
1545void QOhosView::setWindowStaysOnTop(bool staysOnTop)
1546{
1547 setSystemUpdateProperty(&SystemUpdateData::windowStaysOnTop, staysOnTop);
1548}
1549
1550void QOhosView::setFramelessWindow(bool frameless)
1551{
1552 setSystemUpdateProperty(&SystemUpdateData::frameless, frameless);
1553}
1554
1556{
1557 if (m_ohosWindowProxy != nullptr) {
1558 constexpr double windowShadowDisabledRadius = 0.0;
1559 m_ohosWindowProxy->setWindowShadowRadius(windowShadowDisabledRadius);
1560 }
1561}
1562
1563void QOhosView::setWindowCornerRadius(double radius)
1564{
1565 if (m_ohosWindowProxy != nullptr)
1566 m_ohosWindowProxy->setWindowCornerRadius(radius);
1567}
1568
1569void QOhosView::setWindowTransparentForInput(bool transparentForInput)
1570{
1571 setSystemUpdateProperty(&SystemUpdateData::windowTransparentForInput, transparentForInput);
1572}
1573
1575{
1576 if (m_ohosWindowProxy != nullptr)
1577 return m_ohosWindowProxy->startMoving();
1578 return false;
1579}
1580
1581void QOhosView::setPrivacyMode(bool privacyModeEnabled)
1582{
1583 if (m_ohosWindowProxy != nullptr)
1584 m_ohosWindowProxy->setWindowPrivacyMode(privacyModeEnabled);
1585}
1586
1587void QOhosView::startDrag(
1588 const std::vector<QImage> &images, const QPointF &hotspot,
1589 const QMimeData &mimeData, QOhosConsumer<Qt::DropAction> dropActionConsumer)
1590{
1591 m_nativeNode->startDrag(images, hotspot, mimeData, std::move(dropActionConsumer));
1592}
1593
1595{
1596 const auto lastMainWindowHideMethod = std::exchange(m_lastMainWindowHideMethod, {});
1597 if (m_ohosWindowProxy == nullptr || !m_ohosWindowProxy->qtIsMainWindow())
1598 return;
1599
1600 if (!lastMainWindowHideMethod.has_value()) {
1601 m_ohosWindowProxy->restore();
1602 return;
1603 }
1604
1605 switch (lastMainWindowHideMethod.value()) {
1606 case WindowHideMethod::NativeNodeVisibility:
1607 case WindowHideMethod::Minimize:
1608 m_ohosWindowProxy->restore();
1609 break;
1610 case WindowHideMethod::HideAbility:
1611 m_ohosWindowProxy->showAbility();
1612 break;
1613 }
1614}
1615
1617 Qt::WindowStates previousWindowState, Qt::WindowStates currentWindowState)
1618{
1619 auto stateChange = previousWindowState ^ currentWindowState;
1620 if (stateChange.testFlag(Qt::WindowState::WindowMinimized) && !currentWindowState.testFlag(Qt::WindowState::WindowMinimized)) {
1621 if (viewType() == ViewType::MainWindow)
1623 else if (m_ohosWindowProxy)
1624 showWindow();
1625 }
1626
1627 if (stateChange.testFlag(Qt::WindowState::WindowMaximized) && currentWindowState.testFlag(Qt::WindowState::WindowMaximized)) {
1628 maximize();
1629 return;
1630 }
1631
1632 if (stateChange.testFlag(Qt::WindowState::WindowFullScreen) && currentWindowState.testFlag(Qt::WindowState::WindowFullScreen)) {
1634 return;
1635 }
1636
1637 if (stateChange.testFlag(Qt::WindowState::WindowMinimized) && currentWindowState.testFlag(Qt::WindowState::WindowMinimized)) {
1638 minimize();
1639 return;
1640 }
1641
1642 if (!currentWindowState) {
1643 recover();
1644 return;
1645 }
1646}
1647
1649 Qt::WindowFlags previousWindowFlags, Qt::WindowFlags currentWindowFlags)
1650{
1651 const auto flagsChange = previousWindowFlags ^ currentWindowFlags;
1652
1653 bool minMaxCloseButtonStateChanged = (flagsChange & (Qt::WindowMinMaxButtonsHint | Qt::WindowCloseButtonHint)) != 0;
1654 bool framelessChanged = (flagsChange & Qt::FramelessWindowHint) != 0;
1655
1656 if (minMaxCloseButtonStateChanged || framelessChanged) {
1658 .maxButtonShown = currentWindowFlags.testFlag(Qt::WindowMaximizeButtonHint),
1659 .minButtonShown = currentWindowFlags.testFlag(Qt::WindowMinimizeButtonHint),
1660 .closeButtonShown = currentWindowFlags.testFlag(Qt::WindowCloseButtonHint),
1661 });
1662 }
1663
1664 bool windowStaysOnTopChanged = (flagsChange & Qt::WindowStaysOnTopHint) != 0;
1665 if (windowStaysOnTopChanged)
1666 setWindowStaysOnTop(currentWindowFlags.testFlag(Qt::WindowStaysOnTopHint));
1667
1668 bool transparentForInputChanged = (flagsChange & Qt::WindowTransparentForInput) != 0;
1669 if (transparentForInputChanged)
1670 setWindowTransparentForInput(currentWindowFlags.testFlag(Qt::WindowTransparentForInput));
1671
1672 if (framelessChanged)
1673 setFramelessWindow(currentWindowFlags.testFlag(Qt::FramelessWindowHint));
1674
1675 bool focusableChanged = (flagsChange & Qt::WindowDoesNotAcceptFocus) != 0;
1676 if (focusableChanged) {
1677 bool windowAcceptsFocus = !currentWindowFlags.testFlag(Qt::WindowDoesNotAcceptFocus);
1678 setFocusable(windowAcceptsFocus);
1679 }
1680
1681 bool disableWindowShadowChanged = (flagsChange & Qt::NoDropShadowWindowHint) != 0;
1682 if (disableWindowShadowChanged && currentWindowFlags.testFlag(Qt::NoDropShadowWindowHint))
1684
1685 bool expandedClientAreaChanged = (flagsChange & Qt::ExpandedClientAreaHint) != 0;
1686 if (expandedClientAreaChanged && QOhosDeviceInfo::isPhone())
1687 applyPhoneWindowChrome();
1688}
1689
1690QArkUi::QQtEmbeddedWindowNode::NodeAreaInfo QOhosView::nodeAreaInfo() const
1691{
1692 return m_nativeNode->nodeAreaInfo();
1693}
1694
1696{
1697 return m_nodeLaidOut;
1698}
1699
1706
1708{
1709 return !(*this == other);
1710}
1711
1712void QOhosView::setOrResetWindowProxy(std::shared_ptr<QOhosWindowProxy> windowProxy, QWindow *optLogicalParent)
1713{
1714 m_ohosWindowProxy.reset();
1715 m_ohosWindowProxy = windowProxy
1716 ? QtOhos::makeSharedPtrWithAttachedExtraData<QOhosWindowProxy>(
1717 windowProxy,
1718 QWindowProxyRegistry::instance().registerQWindowWithWindowProxy(ownerWindow(), *windowProxy))
1719 : nullptr;
1720 m_optLogicalParent = optLogicalParent;
1721 syncWindowStateImmediate(WindowStateSyncReason::ViewTypeChanged);
1722}
1723
1725{
1726 auto *platformWindow = m_optLogicalParent != nullptr
1727 ? QOhosPlatformWindow::fromQWindowOrNull(m_optLogicalParent)
1728 : nullptr;
1729
1730 return platformWindow != nullptr
1731 ? platformWindow->ownedViewOrNull()
1732 : nullptr;
1733}
1734
1735const QOhosView *QOhosView::ancestorViewWithWindowOrNull() const
1736{
1737 const QOhosView *parent = viewParentOrNull();
1738 while (parent != nullptr && !parent->m_ohosWindowProxy)
1739 parent = parent->viewParentOrNull();
1740
1741 return parent != nullptr && parent->m_ohosWindowProxy
1742 ? parent
1743 : nullptr;
1744}
1745
1747{
1748 return m_ohosWindowProxy ? m_ohosWindowProxy->snapshot() : QPixmap();
1749}
1750
1752{
1753 return m_nativeNode->nodeScreenGeometryPixels();
1754}
1755
1757{
1758 return m_nativeNode->nodeParentRelativeGeometryPixels();
1759}
1760
1762{
1763 if (m_pendingSelfMinimizeEchoes <= 0)
1764 return false;
1765
1766 --m_pendingSelfMinimizeEchoes;
1767 return true;
1768}
1769
1770QT_END_NAMESPACE
void externalContentClickDetected()
static QOhosPlatformIntegration * instance()
static WindowGeometryPersistencePolicy getMainWindowGeometryPersistencePolicy()
QOhosInputMethodEventHandler * inputMethodEventHandler() const
bool mainWindowTagValueOrFalse() const
bool floatWindowTagValueOrFalse() const
DecorationPreset decorationPreset() const
void clearNativeWindowSurface()
void windowStatusChange(QOhosWindowProxy::WindowStatus windowStatus)
void setParentOrReparent(QOhosView &parentView)
void requestActivate()
bool consumePendingSelfMinimizeEcho()
void setCursor(const QCursor &cursor)
void handleWindowFlagsChange(Qt::WindowFlags previousWindowFlags, Qt::WindowFlags currentWindowFlags)
void addForeignWindowChild(QOhosForeignWindow *foreignWindow)
void handleWindowStateChange(Qt::WindowStates previousWindowState, Qt::WindowStates currentWindowState)
void restoreMainWindow()
void setFocusable(bool focusable)
QArkUi::QQtEmbeddedWindowNode::NodeAreaInfo nodeAreaInfo() const
QOhosSurface * surfaceOrNull() const
void windowVisibilityChange(bool visibility)
void setPositionOnScreenImmediate(const QPoint &position, QOhosDisplayInfo::JsDisplayId jsDisplayId)
QList< QRect > displayCutoutRects() const
void setTransparentBackground(bool transparent)
void setModality(Qt::WindowModality modality)
WId viewWindowId() const
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 hide()
WindowStateSyncReason
Definition qohosview.h:90
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 lower()
bool isNodeLaidOut() const
void windowDisplayIdChanged(QOhosDisplayInfo::JsDisplayId)
void minimize()
void setNativeNodeVisibility(bool visible)
void setWindowStaysOnTop(bool staysOnTop)
void setFullScreen()
void maximize()
ViewGeometry viewGeometry() const
void setSize(const QSize &size)
void recover()
bool startMoving()
void setPosition(const QPoint &position)
QOhosView(QWindow *ownerWindow, QSharedPointer< QNativeNode > nativeNode, QOhosPropertiesProvider propertiesProvider)
bool isSubWindowCoveringFullScreen() const
void showImmediate()
QRect nodeParentRelativeGeometryPixels() const
void setTitle(const QString &title)
const QOhosView * viewParentOrNull() const
QRect nodeScreenGeometryPixels() const
void raise()
void setWindowRectAutoSave(bool enabed)
QtOhosQpa::enums::ohos::window::MaximizePresentation MaximizePresentation
static std::shared_ptr< QOhosWindowProxy > createFloatWindow(const FloatWindowCreateInfo &createInfo)
QtOhosQpa::enums::ohos::window::WindowEventType WindowEventType
std::optional< QOhosDisplayInfo::JsDisplayId > tryGetMainWindowJsDisplayId() const
QtOhosQpa::enums::ohos::bundle::bundleManager::SupportWindowMode SupportWindowMode
QOhosWindowProxyExistingMainWindowCreateInfo ExistingMainWindowCreateInfo
static std::shared_ptr< QOhosWindowProxy > createForExistingMainWindow(const ExistingMainWindowCreateInfo &createInfo)
QtOhosQpa::enums::ohos::window::ModalityType ModalityType
bool isWindowRectAutoSave() const
QOhosWindowProxySubWindowCreateInfo SubWindowCreateInfo
QtOhosQpa::enums::ohos::window::AvoidAreaType AvoidAreaType
QOhosWindowProxyMainWindowCreateInfo MainWindowCreateInfo
QOhosWindowProxyFloatWindowCreateInfo FloatWindowCreateInfo
void maximize(MaximizePresentation maximizePresentation)
static std::shared_ptr< QOhosWindowProxy > createMainWindow(const MainWindowCreateInfo &createInfo)
QOhosWindowProxy::AvoidAreaType AvoidAreaType
Definition qohosview.cpp:91
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 ...))
Definition qohosview.cpp:78
std::optional< QColor > tryGetBackgroundColorFromWindow(QWindow *window)
QCursor makeTransparentBitmapCursor(QSize cursorSize)
QWindow * syntheticParentForQWindowOrNull(QWindow *qWindow)
std::optional< QOhosWindowProxy::ModalityType > mapQtWindowModalityToOhosOrDefault(Qt::WindowModality windowModality)
Definition qohosview.cpp:56
QBitmap getCursorMask(const QCursor &cursor)
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 queryQOhosRuntimeDeviceAndMode()
bool operator==(const WindowMinMaxCloseButtonsState &other) const
bool operator!=(const WindowMinMaxCloseButtonsState &other) const
QOhosView::ViewType viewType
Definition qohosview.cpp:46