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 = QOhosJsThreadGateway::eval([](QOhosJsState &jsState) {
405 return QtOhos::JsState::castFrom(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 Q_EMIT nodeAreaChanged(nodeAreaChangeEvent);
592 });
593
594 m_nativeNode->setNodeVisibilityChangeHandler(
595 [this](bool visible) {
596 if (m_ohosWindowProxy == nullptr)
597 Q_EMIT windowVisibilityChange(visible);
598 });
599
600 std::vector<std::shared_ptr<void>> writeCallbacks = {
601 m_windowPropertiesProvider.addPropertyWriteCallback<double, &QOhosPlatformWindow::windowCornerRadiusProperty>(
602 [this](double windowCornerRadius) {
603 setWindowCornerRadius(windowCornerRadius);
604 }),
605 m_windowPropertiesProvider.addPropertyWriteCallback<bool, &QOhosPlatformWindow::windowPrivacyModeSettingProperty>(
606 [this](bool windowPrivacyModeSetting) {
607 setPrivacyMode(windowPrivacyModeSetting);
608 }),
609 m_windowPropertiesProvider.addPropertyWriteCallback<QColor, &QOhosPlatformWindow::surfaceBackgroundColorProperty>(
610 [this](QColor surfaceBackgroundColor) {
611 setBackgroundColor(surfaceBackgroundColor);
612 }),
613 m_windowPropertiesProvider.addPropertyWriteCallback<bool, &QOhosPlatformWindow::windowKeepScreenOnProperty>(
614 [this](bool keepScreenOn) {
615 setWindowKeepScreenOn(keepScreenOn);
616 }),
617 m_windowPropertiesProvider.addPropertyWriteCallback<bool, &QOhosPlatformWindow::windowFixedSizeStateProperty>(
618 [this](bool fixedSizeStateEnabled) {
619 setFixedSizeStateEnabled(fixedSizeStateEnabled);
620 }),
621 m_windowPropertiesProvider.addPropertyWriteCallback<int, &QOhosPlatformWindow::windowBrightnessProperty>(
622 [this](int brightness) {
623 setBrightness(brightness);
624 }),
625 m_windowPropertiesProvider.addPropertyWriteCallback<int, &QOhosPlatformWindow::windowContrastProperty>(
626 [this](int contrast) {
627 setContrast(contrast);
628 }),
629 m_windowPropertiesProvider.addPropertyWriteCallback<int, &QOhosPlatformWindow::windowSaturationProperty>(
630 [this](int saturation) {
631 setSaturation(saturation);
632 }),
633 m_windowPropertiesProvider.addPropertyWriteCallback<bool, &QOhosPlatformWindow::windowDragResizableProperty>(
634 [this](bool dragResizable) {
635 setWindowDragResizable(dragResizable);
636 }),
637 };
638
639 m_windowPropertiesProviderCallbacksHandle = QtOhos::moveToSharedPtr(std::move(writeCallbacks));
640}
641
643{
644 // This call is necessary in order to avoid receiving callbacks
645 // from the underlying XComponent after we terminate the window.
646 // Not having this resulted in exceptions thrown from the system
647 // because QOhosNativeXComponent reffered to the window object that is null.
648 m_nativeNode.reset();
649}
650
651void QOhosView::setPosition(const QPoint &position)
652{
653 setSystemUpdateProperty(&SystemUpdateData::position, {position, {}});
654}
655
657 const QPoint &position, QOhosDisplayInfo::JsDisplayId jsDisplayId)
658{
659 setSystemUpdateProperty(&SystemUpdateData::position, {position, jsDisplayId});
660 flushSystemPropertyUpdatesImmediate();
661}
662
663void QOhosView::setSize(const QSize &size)
664{
665 setSystemUpdateProperty(&SystemUpdateData::size, size);
666}
667
668void QOhosView::setSizeLimits(const QSize &minSize, const QSize &maxSize)
669{
670 setSystemUpdateProperty(&SystemUpdateData::sizeLimits, std::make_pair(minSize, maxSize));
671}
672
673void QOhosView::setTransparentBackground(bool transparent)
674{
675 setSystemUpdateProperty(&SystemUpdateData::backgroundTransparent, transparent);
676}
677
678void QOhosView::setFocusable(bool focusable)
679{
680 setSystemUpdateProperty(&SystemUpdateData::focusable, focusable);
681}
682
683void QOhosView::setBackgroundColor(const QColor &color)
684{
685 setSystemUpdateProperty(&SystemUpdateData::backgroundColor, color);
686}
687
688void QOhosView::setBrightness(int brightness)
689{
690 setSystemUpdateProperty(&SystemUpdateData::brightness, brightness);
691}
692
693void QOhosView::setContrast(int contrast)
694{
695 setSystemUpdateProperty(&SystemUpdateData::contrast, contrast);
696}
697
698void QOhosView::setSaturation(int saturation)
699{
700 setSystemUpdateProperty(&SystemUpdateData::saturation, saturation);
701}
702
703void QOhosView::setWindowKeepScreenOn(bool keepScreenOn)
704{
705 if (m_ohosWindowProxy != nullptr)
706 m_ohosWindowProxy->setWindowKeepScreenOn(keepScreenOn);
707}
708
709void QOhosView::setFixedSizeStateEnabled(bool enabled)
710{
711 if (m_ohosWindowProxy == nullptr || viewType() != ViewType::MainWindow)
712 return;
713
715 qOhosPrintfWarning(
716 "%s: fixed size state is not supported while in HandheldDeviceFullScreen mode",
717 Q_FUNC_INFO);
718 return;
719 }
720
721 using SupportWindowMode = QOhosWindowProxy::SupportWindowMode;
722 const auto supportedWindowModes = enabled
723 ? std::set<SupportWindowMode>({SupportWindowMode::FLOATING})
724 : std::set<SupportWindowMode>({SupportWindowMode::FULL_SCREEN, SupportWindowMode::FLOATING, SupportWindowMode::SPLIT});
725
726 m_ohosWindowProxy->setSupportedWindowModes(supportedWindowModes);
727}
728
729void QOhosView::showWindow()
730{
731 auto *ohosPlatformWindow = static_cast<QOhosPlatformWindow *>(m_ownerWindow->handle());
732 m_ohosWindowProxy->showWindow(
733 QOhosWindowProxy::ShowWindowOptions{
734 .focusOnShow = ohosPlatformWindow->shouldShowWindowWithoutActivating()
735 ? std::optional(false)
736 : std::nullopt,
737 });
738}
739
740void QOhosView::sendAsyncSyntheticWindowActiveEvent()
741{
742 QMetaObject::invokeMethod(
743 this,
744 [this]() {
745 QOhosWindowProxy::WindowEvent syntheticWindowActiveEvent = {
746 .type = QOhosWindowProxy::WindowEventType::WINDOW_ACTIVE,
747 };
748 Q_EMIT windowEvent(syntheticWindowActiveEvent);
749 },
750 Qt::QueuedConnection);
751}
752
753void QOhosView::setCursor(const QCursor &cursor)
754{
755 setSystemUpdateProperty(&SystemUpdateData::cursor, cursor);
756}
757
758void QOhosView::setModality(Qt::WindowModality modality)
759{
760 setSystemUpdateProperty(&SystemUpdateData::modality, modality);
761}
762
763void QOhosView::setTitle(const QString &title)
764{
765 setSystemUpdateProperty(&SystemUpdateData::title, title);
766}
767
769{
770 if (m_ohosWindowProxy == nullptr) {
771 m_nativeNode->raise();
772 return;
773 }
774
775 switch (viewType()) {
776 case ViewType::MainWindow:
777 showWindow();
778 break;
779 case ViewType::SubWindow:
780 m_ohosWindowProxy->raiseToAppTop();
781 break;
782 case ViewType::FloatWindow:
783 case ViewType::EmbeddedWindow:
784 break;
785 }
786}
787
789{
790 if (m_ohosWindowProxy != nullptr && m_ownerWindow->isVisible())
791 showWindow();
792 else
793 m_nativeNode->lower();
794}
795
796void QOhosView::updateWindowSize(const QSize &size)
797{
798 if (m_ohosWindowProxy != nullptr)
799 m_ohosWindowProxy->setSize(size);
800 else
801 m_nativeNode->setSize(size);
802}
803
804void QOhosView::updateWindowPosition(const std::pair<QPoint, std::optional<QOhosDisplayInfo::JsDisplayId>> &positionProp)
805{
806 QPoint position;
807 std::optional<QOhosDisplayInfo::JsDisplayId> displayId;
808 std::tie(position, displayId) = positionProp;
809
810 if (m_ohosWindowProxy != nullptr) {
811 m_ohosWindowProxy->moveWindowToGlobalOrGlobalDisplay(position, displayId);
812 } else {
813 m_nativeNode->setPosition(position);
814 }
815}
816
817void QOhosView::updateWindowBackgroundTransparency(bool transparent)
818{
819 if (m_ohosWindowProxy != nullptr) {
820 auto opaqueSystemBackgroundRgb = QGuiApplicationPrivate::platformTheme()
821 ->palette(QPlatformTheme::SystemPalette)
822 ->window()
823 .color()
824 .rgb();
825 m_ohosWindowProxy->setWindowBackgroundColor(
826 transparent
827 ? QColor(Qt::transparent)
828 : tryGetBackgroundColorFromWindow(m_ownerWindow).value_or(
829 QColor(opaqueSystemBackgroundRgb)));
830 }
831}
832
833void QOhosView::updateWindowCursor(const QCursor &cursor)
834{
835 if (m_ohosWindowProxy == nullptr)
836 return;
837
838 if (cursor.shape() == Qt::BitmapCursor || cursor.shape() == Qt::BlankCursor) {
839 auto bitmapCursor =
840 cursor.shape() == Qt::BlankCursor
841 ? makeTransparentBitmapCursor({1, 1})
842 : cursor;
843
844 QImage bitmapCursorImage = bitmapCursor.pixmap().isNull()
845 ? createImageFromBitmapAndMask(getCursorBitmap(bitmapCursor), getCursorMask(bitmapCursor))
846 : bitmapCursor.pixmap().toImage();
847
848 m_ohosWindowProxy->setCustomCursor(bitmapCursorImage, bitmapCursor.hotSpot());
849 } else {
850 m_ohosWindowProxy->setPointerStyleSync(cursor);
851 }
852}
853
854void QOhosView::updateWindowFocusable(bool focusable)
855{
856 if (m_ohosWindowProxy != nullptr)
857 m_ohosWindowProxy->setWindowFocusable(focusable);
858 m_nativeNode->setFocusable(focusable);
859}
860
861void QOhosView::updateWindowBackgroundColor(const QColor &color)
862{
863 m_nativeNode->setBackgroundColor(color);
864}
865
866void QOhosView::updateWindowBrightness(int brightness)
867{
868 m_nativeNode->setBrightness(brightness);
869}
870
871void QOhosView::updateWindowContrast(int contrast)
872{
873 m_nativeNode->setContrast(contrast);
874}
875
876void QOhosView::updateWindowSaturation(int saturation)
877{
878 m_nativeNode->setSaturation(saturation);
879}
880
881void QOhosView::updateWindowTransparentForInput(bool transparentForInput)
882{
883 if (m_ohosWindowProxy != nullptr)
884 m_ohosWindowProxy->setWindowTouchable(!transparentForInput);
885 m_nativeNode->setTransparentForInput(transparentForInput);
886}
887
888void QOhosView::updateWindowSizeLimits(const std::pair<QSize, QSize> &sizeLimits)
889{
890 if (m_ohosWindowProxy != nullptr) {
891 auto windowMargins = QOhosPlatformWindow::fromQWindow(m_ownerWindow)->frameMargins();
892 m_ohosWindowProxy->setWindowLimits(
893 getQSizeGrownBy(sizeLimits.first, windowMargins),
894 getQSizeGrownBy(sizeLimits.second, windowMargins));
895 }
896}
897
898void QOhosView::updateWindowModality(Qt::WindowModality modality)
899{
900 if (m_ohosWindowProxy != nullptr) {
901 if (viewType() != ViewType::SubWindow) {
902 qCWarning(QtForOhos, "%s: Modality is supported only for sub-windows.", Q_FUNC_INFO);
903 return;
904 }
905 if (modality == Qt::WindowModality::ApplicationModal) {
906 qCWarning(
907 QtForOhos,
908 "%s: Qt::ApplicationModal policy is unsupported by the platform. The window will behave like Qt::WindowModal.",
909 Q_FUNC_INFO);
910 }
911
912 auto ohosModalityType = mapQtWindowModalityToOhosOrDefault(modality);
913 if (ohosModalityType.has_value())
914 m_ohosWindowProxy->setSubWindowModalEnabled(ohosModalityType.value());
915 else
916 m_ohosWindowProxy->setSubWindowModalDisabled();
917 }
918}
919
920void QOhosView::updateWindowTitle(const QString &title)
921{
922 if (m_ohosWindowProxy != nullptr)
923 m_ohosWindowProxy->setTitle(title);
924}
925
926void QOhosView::scheduleSystemUpdateIfNeeded()
927{
928 if (m_updatePending)
929 return;
930 m_updatePending = QMetaObject::invokeMethod(
931 this,
932 [this]() {
933 flushSystemPropertyUpdatesImmediate();
934 },
935 Qt::QueuedConnection);
936}
937
939{
940 return m_ownerWindow;
941}
942
944{
945 auto *platformWindow = QOhosPlatformWindow::fromQWindow(m_ownerWindow);
946
947 auto currentViewTypeInfo = determineViewTypeAndLogicalParent(platformWindow);
948 const bool hadWindowProxy = m_ohosWindowProxy != nullptr;
949 const bool needsWindowProxy = !hadWindowProxy
950 && currentViewTypeInfo.viewType != ViewType::EmbeddedWindow;
951 const bool windowProxyRoleChanged = hadWindowProxy
952 && viewType() != currentViewTypeInfo.viewType;
953
954 if (needsWindowProxy || windowProxyRoleChanged) {
955 auto qOhosWindowProxy = tryCreateWindowProxyIfNeeded(currentViewTypeInfo.viewType, currentViewTypeInfo.optLogicalParent);
956
957 if (qOhosWindowProxy != nullptr
958 && currentViewTypeInfo.viewType == ViewType::SubWindow) {
959 constexpr bool preventSubWindowClose = true;
960 qOhosWindowProxy->setSubWindowCloseHandler(
961 [this]() {
962 if (!m_ownerWindow.isNull()) {
963 qOhosPrintfDebug("onSubWindowCloseHandler: calling close()");
964 QOhosCloseEventContext::runWithCloseRootCauseSet(
965 QOhosCloseEventContext::CloseRootCause::SubWindowClose,
966 [&]() {
967 m_ownerWindow->close();
968 });
969 }
970 },
971 preventSubWindowClose);
972 }
973
974 m_viewType = currentViewTypeInfo.viewType;
975 setOrResetWindowProxy(qOhosWindowProxy, currentViewTypeInfo.optLogicalParent);
976
977 if (qOhosWindowProxy != nullptr) {
978 m_nativeNode->setParent(qOhosWindowProxy->nodeXComponent());
979 m_nativeNode->fillToParent();
980 }
981#if QT_CONFIG(draganddrop)
982 m_nativeNode->enableDropDisallowedBadge();
983#endif
984 } else {
985 syncWindowStateImmediate();
986 }
987
988 if (viewType() == ViewType::MainWindow) {
989 const auto windowStates = m_ownerWindow->windowStates();
990 if (windowStates.testFlag(Qt::WindowState::WindowFullScreen)) {
991 // A phone window created fullscreen still shows the system bars, so
992 // hide them explicitly. On 2-in-1/tablet the window is already
993 // immersive at creation; re-applying would only make it twitch.
994 if (hadWindowProxy || QOhosDeviceInfo::isPhone())
996 } else if (windowStates.testFlag(Qt::WindowState::WindowMaximized)) {
998 } else if (QOhosDeviceInfo::isPhone()
999 && m_ownerWindow->flags().testFlag(Qt::ExpandedClientAreaHint)) {
1000 applyPhoneWindowChrome();
1001 }
1002 } else if (viewType() == ViewType::SubWindow && m_ohosWindowProxy != nullptr) {
1003 m_ohosWindowProxy->setFollowParentMultiScreenPolicy(true);
1004 }
1005
1006 if (m_ohosWindowProxy != nullptr) {
1007 if (hadWindowProxy)
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 == nullptr) {
1259 return;
1260 }
1261
1262 if (m_ohosWindowProxy->tryHideAbility()) {
1263 m_lastMainWindowHideMethod = WindowHideMethod::HideAbility;
1264 return;
1265 }
1266
1267 if (QOhosPlatformWindow::isWindowBeingClosedOrDestroyed(m_ownerWindow)) {
1269 return;
1270 }
1271
1272 m_ohosWindowProxy->minimize();
1273 m_lastMainWindowHideMethod = WindowHideMethod::Minimize;
1274
1275 auto *platformWindow = QOhosPlatformWindow::fromQWindow(m_ownerWindow);
1276 if (!platformWindow->windowStates().testFlag(Qt::WindowMinimized))
1277 ++m_pendingSelfMinimizeEchoes;
1278}
1279
1280void QOhosView::syncWindowStateImmediate(WindowStateSyncReason reason)
1281{
1282 if (m_ohosWindowProxy == nullptr && m_optLogicalParent == nullptr)
1283 return;
1284
1285 std::vector<std::function<void()>> postSurfaceDrawTasks;
1286 auto updatePostSurfaceDrawTask = qScopeGuard([&]() {
1287 if (!postSurfaceDrawTasks.empty()) {
1288 m_optPostSurfaceDrawTask = [postSurfaceDrawTasks = std::move(postSurfaceDrawTasks)]() {
1289 for (const auto &task: postSurfaceDrawTasks)
1290 task();
1291 };
1292 }
1293 });
1294
1295 if (reason == WindowStateSyncReason::ViewTypeChanged && m_ohosWindowProxy
1296 && viewType() == ViewType::MainWindow) {
1297 postSurfaceDrawTasks.emplace_back(
1298 [weakWindowProxy = QtOhos::makeWeakPtr(m_ohosWindowProxy)]() {
1299 auto windowProxy = weakWindowProxy.lock();
1300 if (windowProxy)
1301 windowProxy->removeStartingWindow();
1302 });
1303 }
1304
1305 auto *platformWindow = QOhosPlatformWindow::fromQWindow(m_ownerWindow);
1306
1307 auto targetWindowLimitsToSet =
1308 viewType() == ViewType::EmbeddedWindow
1309 ? std::make_pair(m_ownerWindow->minimumSize(), m_ownerWindow->maximumSize())
1310 : std::make_pair(platformWindow->windowMinimumSize(), platformWindow->windowMaximumSize());
1311
1312 auto windowFlags = QOhosPlatformWindow::platformWindowFlagsForQWindow(m_ownerWindow);
1313 bool focusable = !windowFlags.testFlag(Qt::WindowDoesNotAcceptFocus);
1314
1315 auto submitSystemPropertyUpdate = [](auto &targetProperty, const auto &targetValue) {
1316 targetProperty.optPendingUpdateRequest = targetValue;
1317 };
1318
1319 auto submitOrResetSystemPropertyUpdate = [&submitSystemPropertyUpdate](
1320 auto &targetProperty,
1321 const auto &targetValue,
1322 WindowGeometryPersistenceState windowGeometryPersistenceState) {
1323 if (windowGeometryPersistenceState == WindowGeometryPersistenceState::Enabled)
1324 targetProperty.optPendingUpdateRequest.reset();
1325 else
1326 submitSystemPropertyUpdate(targetProperty, targetValue);
1327 };
1328
1329 submitSystemPropertyUpdate(m_updateData.title, m_ownerWindow->title());
1330
1331 auto windowGeometryPersistenceState =
1332 viewType() == ViewType::MainWindow
1333 && m_geometryPersistencePolicy != ViewGeometryPersistencePolicy::Ignore
1334 ? syncWindowGeometryPersistenceState(m_ohosWindowProxy.get())
1335 : WindowGeometryPersistenceState::Disabled;
1336
1337 auto currentRuntimeDeviceTypeAndMode = queryQOhosRuntimeDeviceAndMode();
1338 bool windowGeometrySyncEnabled = false;
1339 switch (currentRuntimeDeviceTypeAndMode) {
1342 windowGeometrySyncEnabled = true;
1343 break;
1344 case QOhosRuntimeDeviceTypeAndMode::HandheldDeviceFullScreen:
1345 windowGeometrySyncEnabled = viewType() != ViewType::MainWindow;
1346 break;
1347 }
1348
1349 std::optional<QOhosDisplayInfo::JsDisplayId> targetDisplayId;
1350 switch (viewType()) {
1351 case ViewType::SubWindow:
1352 if (m_optLogicalParent == nullptr)
1353 qOhosReportFatalErrorAndAbort("%s: logical parent for a subwindow is null", Q_FUNC_INFO);
1354 targetDisplayId = tryGetSubWindowJsDisplayId(m_optLogicalParent, *m_ohosWindowProxy);
1355 break;
1356 case ViewType::MainWindow:
1357 {
1358 targetDisplayId = m_ohosWindowProxy->tryGetMainWindowJsDisplayId();
1359 break;
1360 }
1361 case ViewType::FloatWindow:
1362 case ViewType::EmbeddedWindow:
1363 break;
1364 }
1365
1366 auto targetGeometryToSet = platformWindow->lastRequestedWindowFrameGeometry();
1367
1368 if (windowGeometrySyncEnabled) {
1369 submitSystemPropertyUpdate(m_updateData.sizeLimits, targetWindowLimitsToSet);
1370 submitOrResetSystemPropertyUpdate(
1371 m_updateData.size, targetGeometryToSet.size(), windowGeometryPersistenceState);
1372
1373 if (!qt_window_private(m_ownerWindow)->positionAutomatic) {
1374 submitOrResetSystemPropertyUpdate(
1375 m_updateData.position,
1376 std::make_pair(targetGeometryToSet.topLeft(), targetDisplayId),
1377 windowGeometryPersistenceState);
1378 }
1379 }
1380
1381 submitSystemPropertyUpdate(m_updateData.backgroundTransparent, isWindowTransparencyRequested());
1382
1383 if (currentRuntimeDeviceTypeAndMode == QOhosRuntimeDeviceTypeAndMode::_2in1)
1384 submitSystemPropertyUpdate(m_updateData.focusable, focusable);
1385
1386 if (viewType() == ViewType::SubWindow)
1387 submitSystemPropertyUpdate(m_updateData.modality, m_ownerWindow->modality());
1388
1389 submitSystemPropertyUpdate(
1390 m_updateData.windowMinMaxCloseButtonsState,
1392 .maxButtonShown = windowFlags.testFlag(Qt::WindowMaximizeButtonHint),
1393 .minButtonShown = windowFlags.testFlag(Qt::WindowMinimizeButtonHint),
1394 .closeButtonShown = windowFlags.testFlag(Qt::WindowCloseButtonHint),
1395 });
1396
1397 submitSystemPropertyUpdate(
1398 m_updateData.windowStaysOnTop, windowFlags.testFlag(Qt::WindowStaysOnTopHint));
1399
1400 submitSystemPropertyUpdate(m_updateData.frameless, windowFlags.testFlag(Qt::FramelessWindowHint));
1401
1402 submitSystemPropertyUpdate(
1403 m_updateData.windowTransparentForInput, windowFlags.testFlag(Qt::WindowTransparentForInput));
1404
1405 flushSystemPropertyUpdatesImmediate();
1406
1407 bool disableWindowShadow = windowFlags.testFlag(Qt::WindowType::NoDropShadowWindowHint);
1408 if (disableWindowShadow)
1410
1411 if (!m_ownerWindow->mask().isNull() && m_ohosWindowProxy != nullptr) {
1412 m_ohosWindowProxy->setWindowMask(
1413 QOhosWindowProxy::WindowMask {
1414 .windowMaskRegion = m_ownerWindow->mask(),
1415 },
1416 targetGeometryToSet.size());
1417 }
1418 const auto privacyModeSetting = m_windowPropertiesProvider
1419 .tryGetProperty<bool, &QOhosPlatformWindow::windowPrivacyModeSettingProperty>();
1420 if (privacyModeSetting.has_value())
1421 setPrivacyMode(privacyModeSetting.value());
1422
1423 const auto windowCornerRadius = m_windowPropertiesProvider
1424 .tryGetProperty<double, &QOhosPlatformWindow::windowCornerRadiusProperty>();
1425 if (windowCornerRadius.has_value())
1426 setWindowCornerRadius(windowCornerRadius.value());
1427
1428 const auto keepScreenOn = m_windowPropertiesProvider
1429 .tryGetProperty<bool, &QOhosPlatformWindow::windowKeepScreenOnProperty>();
1430 if (keepScreenOn.has_value())
1431 setWindowKeepScreenOn(keepScreenOn.value());
1432
1433 auto fixedSizeStateEnabled = m_windowPropertiesProvider
1434 .tryGetProperty<bool, &QOhosPlatformWindow::windowFixedSizeStateProperty>();
1435 if (fixedSizeStateEnabled.has_value())
1436 setFixedSizeStateEnabled(fixedSizeStateEnabled.value());
1437
1438 auto windowDragResizable = m_windowPropertiesProvider
1439 .tryGetProperty<bool, &QOhosPlatformWindow::windowDragResizableProperty>();
1440 if (windowDragResizable.has_value())
1441 setWindowDragResizable(windowDragResizable.value());
1442
1443 // NOTE - when position automatic is set we do not control window position
1444 // therefore no window callback about window position change will be sent
1445 // and the screen that given window belongs to needs to be synchronized
1446 bool shouldSynchronizeTargetDisplayIdWithQpa =
1447 qt_window_private(m_ownerWindow)->positionAutomatic
1448 && reason == WindowStateSyncReason::ViewTypeChanged
1449 && m_ohosWindowProxy != nullptr;
1450
1451 if (shouldSynchronizeTargetDisplayIdWithQpa) {
1452 auto optTargetDisplayId = m_ohosWindowProxy->getWindowProperties().displayId;
1453 if (optTargetDisplayId.has_value()) {
1454 QOhosDisplayInfo::JsDisplayId syntheticDisplayIdChangeEvent = optTargetDisplayId.value();
1455 Q_EMIT windowDisplayIdChanged(syntheticDisplayIdChangeEvent);
1456 }
1457 }
1458}
1459
1460void QOhosView::flushSystemPropertyUpdatesImmediate()
1461{
1462 static const auto systemDataPropertyUpdateFuncPairsTuple = makeSystemUpdateDataPropertyUpdateFuncPairsTuple();
1463
1464 QtOhos::tupleForEach(
1465 systemDataPropertyUpdateFuncPairsTuple,
1466 [&](const auto &updateDataMemberPtrUpdateFuncPair) {
1467 auto memberPtr = updateDataMemberPtrUpdateFuncPair.first;
1468 auto updateFuncPtr = updateDataMemberPtrUpdateFuncPair.second;
1469 auto &property = m_updateData.*memberPtr;
1470 auto optUpdateRequest = std::exchange(property.optPendingUpdateRequest, {});
1471 if (optUpdateRequest.has_value())
1472 (this->*updateFuncPtr)(optUpdateRequest.value());
1473 });
1474 m_updatePending = false;
1475}
1476
1477QOhosWindowProxy *QOhosView::flushedWindowProxyOrNull()
1478{
1479 if (m_ohosWindowProxy == nullptr)
1480 return nullptr;
1481
1482 flushSystemPropertyUpdatesImmediate();
1483 return m_ohosWindowProxy.get();
1484}
1485
1486void QOhosView::addForeignWindowChild(QOhosForeignWindow *foreignWindow)
1487{
1488 m_nativeNode->addForeignWindowChild(foreignWindow);
1489}
1490
1492{
1493 auto *surface = m_nativeNode->surfaceOrNull();
1494 return surface != nullptr
1495 ? surface->surfaceResolution()
1496 : std::nullopt;
1497}
1498
1500{
1501 return m_ohosWindowProxy != nullptr
1502 ? m_ohosWindowProxy->getImmersiveModeEnabledState()
1503 : false;
1504}
1505
1507{
1508 if (viewType() == ViewType::SubWindow) {
1509 auto *screen = m_ownerWindow->screen();
1510 return screen != nullptr && m_ownerWindow->geometry().size() == screen->geometry().size();
1511 }
1512
1513 return false;
1514}
1515
1516void QOhosView::updateWindowMinMaxCloseButtonsState(const WindowMinMaxCloseButtonsState &state)
1517{
1518 if (m_ohosWindowProxy != nullptr) {
1519 m_ohosWindowProxy->setWindowTitleButtonVisible(
1520 state.maxButtonShown, state.minButtonShown, state.closeButtonShown);
1521 }
1522}
1523
1524void QOhosView::updateWindowStaysOnTop(bool staysOnTop)
1525{
1526 if (m_ohosWindowProxy != nullptr)
1527 m_ohosWindowProxy->setWindowTopmost(staysOnTop);
1528}
1529
1530void QOhosView::updateWindowFrameless(bool frameless)
1531{
1532 bool supportsFramelessWindow = viewType() == ViewType::MainWindow || viewType() == ViewType::SubWindow;
1533 if (m_ohosWindowProxy != nullptr && supportsFramelessWindow) {
1534 m_ohosWindowProxy->setWindowDecorVisible(!frameless);
1535 m_ohosWindowProxy->setWindowTitleMoveEnabled(!frameless);
1536 }
1537}
1538
1539void QOhosView::setWindowDragResizable(bool dragResizable)
1540{
1541 if (m_ohosWindowProxy != nullptr)
1542 m_ohosWindowProxy->enableDrag(dragResizable);
1543}
1544
1546{
1547 setSystemUpdateProperty(&SystemUpdateData::windowMinMaxCloseButtonsState, state);
1548}
1549
1550void QOhosView::setWindowStaysOnTop(bool staysOnTop)
1551{
1552 setSystemUpdateProperty(&SystemUpdateData::windowStaysOnTop, staysOnTop);
1553}
1554
1555void QOhosView::setFramelessWindow(bool frameless)
1556{
1557 setSystemUpdateProperty(&SystemUpdateData::frameless, frameless);
1558}
1559
1561{
1562 if (m_ohosWindowProxy != nullptr) {
1563 constexpr double windowShadowDisabledRadius = 0.0;
1564 m_ohosWindowProxy->setWindowShadowRadius(windowShadowDisabledRadius);
1565 }
1566}
1567
1568void QOhosView::setWindowCornerRadius(double radius)
1569{
1570 if (m_ohosWindowProxy != nullptr)
1571 m_ohosWindowProxy->setWindowCornerRadius(radius);
1572}
1573
1574void QOhosView::setWindowTransparentForInput(bool transparentForInput)
1575{
1576 setSystemUpdateProperty(&SystemUpdateData::windowTransparentForInput, transparentForInput);
1577}
1578
1580{
1581 if (m_ohosWindowProxy != nullptr)
1582 return m_ohosWindowProxy->startMoving();
1583 return false;
1584}
1585
1586void QOhosView::setPrivacyMode(bool privacyModeEnabled)
1587{
1588 if (m_ohosWindowProxy != nullptr)
1589 m_ohosWindowProxy->setWindowPrivacyMode(privacyModeEnabled);
1590}
1591
1592void QOhosView::startDrag(
1593 const std::vector<QImage> &images, const QPointF &hotspot,
1594 const QMimeData &mimeData, QOhosConsumer<Qt::DropAction> dropActionConsumer)
1595{
1596 m_nativeNode->startDrag(images, hotspot, mimeData, std::move(dropActionConsumer));
1597}
1598
1600{
1601 const auto lastMainWindowHideMethod = std::exchange(m_lastMainWindowHideMethod, {});
1602 if (m_ohosWindowProxy == nullptr || !m_ohosWindowProxy->qtIsMainWindow())
1603 return;
1604
1605 if (!lastMainWindowHideMethod.has_value()) {
1606 m_ohosWindowProxy->restore();
1607 return;
1608 }
1609
1610 switch (lastMainWindowHideMethod.value()) {
1611 case WindowHideMethod::NativeNodeVisibility:
1612 case WindowHideMethod::Minimize:
1613 m_ohosWindowProxy->restore();
1614 break;
1615 case WindowHideMethod::HideAbility:
1616 m_ohosWindowProxy->showAbility();
1617 break;
1618 }
1619}
1620
1622 Qt::WindowStates previousWindowState, Qt::WindowStates currentWindowState)
1623{
1624 auto stateChange = previousWindowState ^ currentWindowState;
1625 if (stateChange.testFlag(Qt::WindowState::WindowMinimized) && !currentWindowState.testFlag(Qt::WindowState::WindowMinimized)) {
1626 if (viewType() == ViewType::MainWindow)
1628 else if (m_ohosWindowProxy)
1629 showWindow();
1630 }
1631
1632 if (stateChange.testFlag(Qt::WindowState::WindowMaximized) && currentWindowState.testFlag(Qt::WindowState::WindowMaximized)) {
1633 maximize();
1634 return;
1635 }
1636
1637 if (stateChange.testFlag(Qt::WindowState::WindowFullScreen) && currentWindowState.testFlag(Qt::WindowState::WindowFullScreen)) {
1639 return;
1640 }
1641
1642 if (stateChange.testFlag(Qt::WindowState::WindowMinimized) && currentWindowState.testFlag(Qt::WindowState::WindowMinimized)) {
1643 minimize();
1644 return;
1645 }
1646
1647 if (!currentWindowState) {
1648 recover();
1649 return;
1650 }
1651}
1652
1654 Qt::WindowFlags previousWindowFlags, Qt::WindowFlags currentWindowFlags)
1655{
1656 const auto flagsChange = previousWindowFlags ^ currentWindowFlags;
1657
1658 bool minMaxCloseButtonStateChanged = (flagsChange & (Qt::WindowMinMaxButtonsHint | Qt::WindowCloseButtonHint)) != 0;
1659 bool framelessChanged = (flagsChange & Qt::FramelessWindowHint) != 0;
1660
1661 if (minMaxCloseButtonStateChanged || framelessChanged) {
1663 .maxButtonShown = currentWindowFlags.testFlag(Qt::WindowMaximizeButtonHint),
1664 .minButtonShown = currentWindowFlags.testFlag(Qt::WindowMinimizeButtonHint),
1665 .closeButtonShown = currentWindowFlags.testFlag(Qt::WindowCloseButtonHint),
1666 });
1667 }
1668
1669 bool windowStaysOnTopChanged = (flagsChange & Qt::WindowStaysOnTopHint) != 0;
1670 if (windowStaysOnTopChanged)
1671 setWindowStaysOnTop(currentWindowFlags.testFlag(Qt::WindowStaysOnTopHint));
1672
1673 bool transparentForInputChanged = (flagsChange & Qt::WindowTransparentForInput) != 0;
1674 if (transparentForInputChanged)
1675 setWindowTransparentForInput(currentWindowFlags.testFlag(Qt::WindowTransparentForInput));
1676
1677 if (framelessChanged)
1678 setFramelessWindow(currentWindowFlags.testFlag(Qt::FramelessWindowHint));
1679
1680 bool focusableChanged = (flagsChange & Qt::WindowDoesNotAcceptFocus) != 0;
1681 if (focusableChanged) {
1682 bool windowAcceptsFocus = !currentWindowFlags.testFlag(Qt::WindowDoesNotAcceptFocus);
1683 setFocusable(windowAcceptsFocus);
1684 }
1685
1686 bool disableWindowShadowChanged = (flagsChange & Qt::NoDropShadowWindowHint) != 0;
1687 if (disableWindowShadowChanged && currentWindowFlags.testFlag(Qt::NoDropShadowWindowHint))
1689
1690 bool expandedClientAreaChanged = (flagsChange & Qt::ExpandedClientAreaHint) != 0;
1691 if (expandedClientAreaChanged && QOhosDeviceInfo::isPhone())
1692 applyPhoneWindowChrome();
1693}
1694
1695QArkUi::QQtEmbeddedWindowNode::NodeAreaInfo QOhosView::nodeAreaInfo() const
1696{
1697 return m_nativeNode->nodeAreaInfo();
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()
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