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 {};
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 {};
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 {};
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 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 if (qOhosWindowProxy != nullptr) {
975 m_nativeNode->setParent(qOhosWindowProxy->nodeXComponent());
976 m_nativeNode->fillToParent();
977 }
978
979 m_viewType = currentViewTypeInfo.viewType;
980 setOrResetWindowProxy(qOhosWindowProxy, currentViewTypeInfo.optLogicalParent);
981 } else {
982 syncWindowStateImmediate();
983 }
984
985 if (viewType() == ViewType::MainWindow) {
986 const auto windowStates = m_ownerWindow->windowStates();
987 if (windowStates.testFlag(Qt::WindowState::WindowFullScreen)) {
988 // A phone window created fullscreen still shows the system bars, so
989 // hide them explicitly. On 2-in-1/tablet the window is already
990 // immersive at creation; re-applying would only make it twitch.
991 if (hadWindowProxy || QOhosDeviceInfo::isPhone())
993 } else if (windowStates.testFlag(Qt::WindowState::WindowMaximized)) {
995 } else if (QOhosDeviceInfo::isPhone()
996 && m_ownerWindow->flags().testFlag(Qt::ExpandedClientAreaHint)) {
997 applyPhoneWindowChrome();
998 }
999 } else if (viewType() == ViewType::SubWindow && m_ohosWindowProxy != nullptr) {
1000 m_ohosWindowProxy->setFollowParentMultiScreenPolicy(true);
1001 }
1002
1003 if (m_ohosWindowProxy != nullptr) {
1005 showWindow();
1006 }
1007
1008 auto *surface = surfaceOrNull();
1009 if (surface != nullptr)
1011
1012 m_nativeNode->setVisibility(true);
1013}
1014
1015void QOhosView::applyPhoneWindowChrome()
1016{
1017 if (m_ohosWindowProxy == nullptr)
1018 return;
1019
1020 // Lay the window out under the system bars when fullscreen or when the
1021 // client area is expanded; only fullscreen also hides the bars.
1022 const bool fullScreen = m_ownerWindow->windowStates().testFlag(Qt::WindowFullScreen);
1023 const bool expanded = m_ownerWindow->flags().testFlag(Qt::ExpandedClientAreaHint);
1024 m_ohosWindowProxy->setWindowLayoutFullScreen(fullScreen || expanded);
1025 m_ohosWindowProxy->setWindowSystemBarEnable(
1026 fullScreen ? QStringList{}
1027 : QStringList{ QStringLiteral("status"), QStringLiteral("navigation") });
1028}
1029
1031{
1032 auto *windowProxy = flushedWindowProxyOrNull();
1033 if (windowProxy == nullptr)
1034 return;
1035
1037 windowProxy->maximize(QOhosWindowProxy::MaximizePresentation::ENTER_IMMERSIVE);
1038 else
1039 applyPhoneWindowChrome();
1040}
1041
1043{
1044 auto *windowProxy = flushedWindowProxyOrNull();
1045 if (windowProxy == nullptr)
1046 return;
1047
1049 windowProxy->recover();
1050 else
1051 applyPhoneWindowChrome();
1052}
1053
1055{
1056 auto *windowProxy = flushedWindowProxyOrNull();
1057 if (windowProxy != nullptr)
1058 windowProxy->minimize();
1059}
1060
1062{
1063 if (m_ohosWindowProxy != nullptr) {
1064 if (QGuiApplicationPrivate::focus_window) {
1065 const auto *focusPlatformWindow = QOhosPlatformWindow::fromQWindow(QGuiApplicationPrivate::focus_window);
1066 const auto *focusView = focusPlatformWindow->ownedViewOrNull();
1067 if (focusView && focusView != this) {
1068 if (focusView->m_ohosWindowProxy) {
1069 focusView->m_ohosWindowProxy->shiftAppWindowFocus(*m_ohosWindowProxy);
1070 } else {
1071 // If the previously focused window is an EmbeddedWindow.
1072 sendAsyncSyntheticWindowActiveEvent();
1073 }
1074 }
1075 }
1076 } else {
1077 // for EmbeddedWindow
1078 sendAsyncSyntheticWindowActiveEvent();
1079 }
1080}
1081
1083{
1084 auto *windowProxy = flushedWindowProxyOrNull();
1085 if (windowProxy != nullptr)
1086 windowProxy->maximize(QOhosWindowProxy::MaximizePresentation::EXIT_IMMERSIVE);
1087}
1088
1089std::unique_ptr<QOhosView> QOhosView::createForWindow(QOhosPlatformWindow *window, QOhosPropertiesProvider windowPropertiesProvider)
1090{
1091 auto *qWindow = window->window();
1092 QNativeNode::CreateInfo createInfo;
1093 createInfo.geometry = window->geometry();
1094 createInfo.window = qWindow;
1095 createInfo.backgroundColor = windowPropertiesProvider.tryGetProperty<QColor, &QOhosPlatformWindow::surfaceBackgroundColorProperty>();
1096 createInfo.renderFitPolicyHint = qTransform(
1097 windowPropertiesProvider.tryGetProperty<int, &QOhosPlatformWindow::nativeNodeRenderFitPolicyHintProperty>(),
1098 [](int renderFit) {
1099 return static_cast<::ArkUI_RenderFit>(renderFit);
1100 });
1101
1102 QPlatformWindow *parentPlatformWindow = window->parent();
1103
1104 if (parentPlatformWindow != nullptr) {
1105 auto *parentPlatformWindow = static_cast<QOhosPlatformWindow *>(window->parent());
1106 auto *parentView = parentPlatformWindow->ownedViewOrNull();
1107 createInfo.optParent = parentView != nullptr
1108 ? std::optional(parentView->m_nativeNode.get())
1109 : std::nullopt;
1110 }
1111
1112 auto nativeNode = QSharedPointer<QNativeNode>::create(createInfo);
1113 return std::make_unique<QOhosView>(qWindow, nativeNode, windowPropertiesProvider);
1114}
1115
1117{
1118 QOhosView::ViewGeometry result;
1119 if (m_ohosWindowProxy != nullptr) {
1120 auto windowProperties = m_ohosWindowProxy->getWindowProperties();
1121 result.frameGeometry = windowProperties.windowRect;
1122 // Translate relative coordinates of the window to absolute screen values
1123 result.geometry = windowProperties.drawableRect.translated(windowProperties.windowRect.topLeft());
1124 // HACK:
1125 // "result.geometry" might contain invalid size but (1) it will likely contain proper
1126 // top-left corner coords and (2) "result.frameGeometry" is also valid, so adjust the
1127 // invalidated size based on these two.
1128 result.geometry.setSize(
1129 evaluateGeometrySizeBasedOnFrameGeometry(result.geometry.topLeft(), result.frameGeometry));
1130 result.displayId = windowProperties.displayId;
1131 } else {
1132 result.frameGeometry = m_nativeNode->geometry().toRect();
1133 result.geometry = result.frameGeometry;
1134
1135 const auto *ancestorViewWithWindow = ancestorViewWithWindowOrNull();
1136 result.displayId = ancestorViewWithWindow != nullptr
1137 ? ancestorViewWithWindow->m_ohosWindowProxy->getWindowProperties().displayId
1138 : std::nullopt;
1139 }
1140
1141 return result;
1142}
1143
1144QMargins QOhosView::avoidAreaMargins(QOhosWindowProxy::AvoidAreaType type) const
1145{
1146 auto avoidArea = m_avoidAreasProvider(type);
1147 QMargins margins;
1148 tryUpdateMaximumMarginsFromAvoidArea(margins, avoidArea);
1149 return margins;
1150}
1151
1153{
1154 return m_viewType.value_or(ViewType::EmbeddedWindow);
1155}
1156
1158{
1159 auto *platformWindow = QOhosPlatformWindow::fromQWindow(m_ownerWindow);
1160 auto targetWindowGeometry = platformWindow->geometry().marginsAdded(platformWindow->frameMargins());
1161
1162 m_updateData.position.optPendingUpdateRequest = {targetWindowGeometry.topLeft(), {}};
1163 m_updateData.size.optPendingUpdateRequest = targetWindowGeometry.size();
1164 scheduleSystemUpdateIfNeeded();
1165}
1166
1168{
1169 switch (viewType()) {
1170 case ViewType::MainWindow:
1171 hideMainWindow();
1172 break;
1173 case ViewType::FloatWindow:
1174 case ViewType::SubWindow:
1175 {
1176 setOrResetWindowProxy(nullptr, nullptr);
1177 auto syntheticWindowHiddenEvent = QOhosWindowProxy::WindowEvent {
1178 .type = QOhosWindowProxy::WindowEventType::WINDOW_HIDDEN,
1179 };
1180 Q_EMIT windowEvent(syntheticWindowHiddenEvent);
1181 break;
1182 }
1183 case ViewType::EmbeddedWindow:
1184 Q_EMIT windowVisibilityChange(false);
1185 break;
1186 }
1187
1188 m_nativeNode->setVisibility(false);
1189}
1190
1192{
1193 setTransparentBackground(isWindowTransparencyRequested());
1194}
1195
1196void QOhosView::setWindowMask(const QOhosWindowProxy::WindowMask &mask)
1197{
1198 if (m_ohosWindowProxy != nullptr)
1199 m_ohosWindowProxy->setWindowMask(mask);
1200}
1201
1202QOhosSurface *QOhosView::surfaceOrNull() const
1203{
1204 return m_nativeNode->surfaceOrNull();
1205}
1206
1208{
1209 return m_nativeNode->windowId();
1210}
1211
1213{
1214 qCDebug(QtForOhos) << "view:" << this << "setParentOrReparent parentView:" << &parentView;
1215 m_nativeNode->setParent(*parentView.m_nativeNode);
1216 m_viewType.reset();
1217 setOrResetWindowProxy(nullptr, parentView.ownerWindow());
1218}
1219
1221{
1222 if (viewType() != ViewType::EmbeddedWindow) {
1223 qCDebug(QtForOhos) << Q_FUNC_INFO << m_ownerWindow;
1224 return;
1225 }
1226
1227 m_nativeNode->detachFromParentIfPresent();
1228 m_optLogicalParent = nullptr;
1229
1230 if (m_ownerWindow->isVisible() && !m_ohosWindowProxy)
1232}
1233
1235{
1236 m_nativeNode->setVisibility(visible);
1237 m_lastMainWindowHideMethod = WindowHideMethod::NativeNodeVisibility;
1238}
1239
1240void QOhosView::hideMainWindow()
1241{
1242 if (m_ohosWindowProxy->tryHideAbility()) {
1243 m_lastMainWindowHideMethod = WindowHideMethod::HideAbility;
1244 return;
1245 }
1246
1247 if (QOhosPlatformWindow::isWindowBeingClosedOrDestroyed(m_ownerWindow)) {
1249 return;
1250 }
1251
1252 m_ohosWindowProxy->minimize();
1253 m_lastMainWindowHideMethod = WindowHideMethod::Minimize;
1254}
1255
1256void QOhosView::syncWindowStateImmediate(WindowStateSyncReason reason)
1257{
1258 if (m_ohosWindowProxy == nullptr && m_optLogicalParent == nullptr)
1259 return;
1260
1261 std::vector<std::function<void()>> postSurfaceDrawTasks;
1262 auto updatePostSurfaceDrawTask = qScopeGuard([&]() {
1263 if (!postSurfaceDrawTasks.empty()) {
1264 m_optPostSurfaceDrawTask = [postSurfaceDrawTasks = std::move(postSurfaceDrawTasks)]() {
1265 for (const auto &task: postSurfaceDrawTasks)
1266 task();
1267 };
1268 }
1269 });
1270
1271 if (reason == WindowStateSyncReason::ViewTypeChanged && m_ohosWindowProxy
1272 && viewType() == ViewType::MainWindow) {
1273 postSurfaceDrawTasks.emplace_back(
1274 [weakWindowProxy = QtOhos::makeWeakPtr(m_ohosWindowProxy)]() {
1275 auto windowProxy = weakWindowProxy.lock();
1276 if (windowProxy)
1277 windowProxy->removeStartingWindow();
1278 });
1279 }
1280
1281 auto *platformWindow = QOhosPlatformWindow::fromQWindow(m_ownerWindow);
1282
1283 auto targetWindowLimitsToSet =
1284 viewType() == ViewType::EmbeddedWindow
1285 ? std::make_pair(m_ownerWindow->minimumSize(), m_ownerWindow->maximumSize())
1286 : std::make_pair(platformWindow->windowMinimumSize(), platformWindow->windowMaximumSize());
1287
1288 auto windowFlags = QOhosPlatformWindow::platformWindowFlagsForQWindow(m_ownerWindow);
1289 bool focusable = !windowFlags.testFlag(Qt::WindowDoesNotAcceptFocus);
1290
1291 auto submitSystemPropertyUpdate = [](auto &targetProperty, const auto &targetValue) {
1292 targetProperty.optPendingUpdateRequest = targetValue;
1293 };
1294
1295 auto submitOrResetSystemPropertyUpdate = [&submitSystemPropertyUpdate](
1296 auto &targetProperty,
1297 const auto &targetValue,
1298 WindowGeometryPersistenceState windowGeometryPersistenceState) {
1299 if (windowGeometryPersistenceState == WindowGeometryPersistenceState::Enabled)
1300 targetProperty.optPendingUpdateRequest.reset();
1301 else
1302 submitSystemPropertyUpdate(targetProperty, targetValue);
1303 };
1304
1305 submitSystemPropertyUpdate(m_updateData.title, m_ownerWindow->title());
1306
1307 auto windowGeometryPersistenceState =
1308 viewType() == ViewType::MainWindow
1309 && m_geometryPersistencePolicy != ViewGeometryPersistencePolicy::Ignore
1310 ? syncWindowGeometryPersistenceState(m_ohosWindowProxy.get())
1311 : WindowGeometryPersistenceState::Disabled;
1312
1313 auto currentRuntimeDeviceTypeAndMode = queryQOhosRuntimeDeviceAndMode();
1314 bool windowGeometrySyncEnabled = false;
1315 switch (currentRuntimeDeviceTypeAndMode) {
1318 windowGeometrySyncEnabled = true;
1319 break;
1320 case QOhosRuntimeDeviceTypeAndMode::HandheldDeviceFullScreen:
1321 windowGeometrySyncEnabled = viewType() != ViewType::MainWindow;
1322 break;
1323 }
1324
1325 std::optional<QOhosDisplayInfo::JsDisplayId> targetDisplayId;
1326 switch (viewType()) {
1327 case ViewType::SubWindow:
1328 if (m_optLogicalParent == nullptr)
1329 qOhosReportFatalErrorAndAbort("%s: logical parent for a subwindow is null", Q_FUNC_INFO);
1330 targetDisplayId = tryGetSubWindowJsDisplayId(m_optLogicalParent, *m_ohosWindowProxy);
1331 break;
1332 case ViewType::MainWindow:
1333 {
1334 targetDisplayId = m_ohosWindowProxy->tryGetMainWindowJsDisplayId();
1335 break;
1336 }
1337 case ViewType::FloatWindow:
1338 case ViewType::EmbeddedWindow:
1339 break;
1340 }
1341
1342 auto targetGeometryToSet = platformWindow->lastRequestedWindowFrameGeometry();
1343
1344 if (windowGeometrySyncEnabled) {
1345 submitSystemPropertyUpdate(m_updateData.sizeLimits, targetWindowLimitsToSet);
1346 submitOrResetSystemPropertyUpdate(
1347 m_updateData.size, targetGeometryToSet.size(), windowGeometryPersistenceState);
1348
1349 if (!qt_window_private(m_ownerWindow)->positionAutomatic) {
1350 submitOrResetSystemPropertyUpdate(
1351 m_updateData.position,
1352 std::make_pair(targetGeometryToSet.topLeft(), targetDisplayId),
1353 windowGeometryPersistenceState);
1354 }
1355 }
1356
1357 submitSystemPropertyUpdate(m_updateData.backgroundTransparent, isWindowTransparencyRequested());
1358
1359 if (currentRuntimeDeviceTypeAndMode == QOhosRuntimeDeviceTypeAndMode::_2in1)
1360 submitSystemPropertyUpdate(m_updateData.focusable, focusable);
1361
1362 if (viewType() == ViewType::SubWindow)
1363 submitSystemPropertyUpdate(m_updateData.modality, m_ownerWindow->modality());
1364
1365 submitSystemPropertyUpdate(
1366 m_updateData.windowMinMaxCloseButtonsState,
1368 .maxButtonShown = windowFlags.testFlag(Qt::WindowMaximizeButtonHint),
1369 .minButtonShown = windowFlags.testFlag(Qt::WindowMinimizeButtonHint),
1370 .closeButtonShown = windowFlags.testFlag(Qt::WindowCloseButtonHint),
1371 });
1372
1373 submitSystemPropertyUpdate(
1374 m_updateData.windowStaysOnTop, windowFlags.testFlag(Qt::WindowStaysOnTopHint));
1375
1376 submitSystemPropertyUpdate(m_updateData.frameless, windowFlags.testFlag(Qt::FramelessWindowHint));
1377
1378 submitSystemPropertyUpdate(
1379 m_updateData.windowTransparentForInput, windowFlags.testFlag(Qt::WindowTransparentForInput));
1380
1381 flushSystemPropertyUpdatesImmediate();
1382
1383 bool disableWindowShadow = windowFlags.testFlag(Qt::WindowType::NoDropShadowWindowHint);
1384 if (disableWindowShadow)
1386
1387 if (!m_ownerWindow->mask().isNull() && m_ohosWindowProxy != nullptr) {
1388 m_ohosWindowProxy->setWindowMask(
1389 QOhosWindowProxy::WindowMask {
1390 .windowMaskRegion = m_ownerWindow->mask(),
1391 },
1392 targetGeometryToSet.size());
1393 }
1394 const auto privacyModeSetting = m_windowPropertiesProvider
1395 .tryGetProperty<bool, &QOhosPlatformWindow::windowPrivacyModeSettingProperty>();
1396 if (privacyModeSetting.has_value())
1397 setPrivacyMode(privacyModeSetting.value());
1398
1399 const auto windowCornerRadius = m_windowPropertiesProvider
1400 .tryGetProperty<double, &QOhosPlatformWindow::windowCornerRadiusProperty>();
1401 if (windowCornerRadius.has_value())
1402 setWindowCornerRadius(windowCornerRadius.value());
1403
1404 const auto keepScreenOn = m_windowPropertiesProvider
1405 .tryGetProperty<bool, &QOhosPlatformWindow::windowKeepScreenOnProperty>();
1406 if (keepScreenOn.has_value())
1407 setWindowKeepScreenOn(keepScreenOn.value());
1408
1409 auto fixedSizeStateEnabled = m_windowPropertiesProvider
1410 .tryGetProperty<bool, &QOhosPlatformWindow::windowFixedSizeStateProperty>();
1411 if (fixedSizeStateEnabled.has_value())
1412 setFixedSizeStateEnabled(fixedSizeStateEnabled.value());
1413
1414 auto windowDragResizable = m_windowPropertiesProvider
1415 .tryGetProperty<bool, &QOhosPlatformWindow::windowDragResizableProperty>();
1416 if (windowDragResizable.has_value())
1417 setWindowDragResizable(windowDragResizable.value());
1418
1419 // NOTE - when position automatic is set we do not control window position
1420 // therefore no window callback about window position change will be sent
1421 // and the screen that given window belongs to needs to be synchronized
1422 bool shouldSynchronizeTargetDisplayIdWithQpa =
1423 qt_window_private(m_ownerWindow)->positionAutomatic
1424 && reason == WindowStateSyncReason::ViewTypeChanged
1425 && m_ohosWindowProxy != nullptr;
1426
1427 if (shouldSynchronizeTargetDisplayIdWithQpa) {
1428 auto optTargetDisplayId = m_ohosWindowProxy->getWindowProperties().displayId;
1429 if (optTargetDisplayId.has_value()) {
1430 QOhosDisplayInfo::JsDisplayId syntheticDisplayIdChangeEvent = optTargetDisplayId.value();
1431 Q_EMIT windowDisplayIdChanged(syntheticDisplayIdChangeEvent);
1432 }
1433 }
1434}
1435
1436void QOhosView::flushSystemPropertyUpdatesImmediate()
1437{
1438 static const auto systemDataPropertyUpdateFuncPairsTuple = makeSystemUpdateDataPropertyUpdateFuncPairsTuple();
1439
1440 QtOhos::tupleForEach(
1441 systemDataPropertyUpdateFuncPairsTuple,
1442 [&](const auto &updateDataMemberPtrUpdateFuncPair) {
1443 auto memberPtr = updateDataMemberPtrUpdateFuncPair.first;
1444 auto updateFuncPtr = updateDataMemberPtrUpdateFuncPair.second;
1445 auto &property = m_updateData.*memberPtr;
1446 auto optUpdateRequest = std::exchange(property.optPendingUpdateRequest, {});
1447 if (optUpdateRequest.has_value())
1448 (this->*updateFuncPtr)(optUpdateRequest.value());
1449 });
1450 m_updatePending = false;
1451}
1452
1453QOhosWindowProxy *QOhosView::flushedWindowProxyOrNull()
1454{
1455 if (m_ohosWindowProxy == nullptr)
1456 return nullptr;
1457
1458 flushSystemPropertyUpdatesImmediate();
1459 return m_ohosWindowProxy.get();
1460}
1461
1462void QOhosView::addForeignWindowChild(QOhosForeignWindow *foreignWindow)
1463{
1464 m_nativeNode->addForeignWindowChild(foreignWindow);
1465}
1466
1468{
1469 auto *surface = m_nativeNode->surfaceOrNull();
1470 return surface != nullptr
1471 ? surface->surfaceResolution()
1472 : std::nullopt;
1473}
1474
1476{
1477 return m_ohosWindowProxy != nullptr
1478 ? m_ohosWindowProxy->getImmersiveModeEnabledState()
1479 : false;
1480}
1481
1483{
1484 if (viewType() == ViewType::SubWindow) {
1485 auto *screen = m_ownerWindow->screen();
1486 return screen != nullptr && m_ownerWindow->geometry().size() == screen->geometry().size();
1487 }
1488
1489 return false;
1490}
1491
1492void QOhosView::updateWindowMinMaxCloseButtonsState(const WindowMinMaxCloseButtonsState &state)
1493{
1494 if (m_ohosWindowProxy != nullptr) {
1495 m_ohosWindowProxy->setWindowTitleButtonVisible(
1496 state.maxButtonShown, state.minButtonShown, state.closeButtonShown);
1497 }
1498}
1499
1500void QOhosView::updateWindowStaysOnTop(bool staysOnTop)
1501{
1502 if (m_ohosWindowProxy != nullptr)
1503 m_ohosWindowProxy->setWindowTopmost(staysOnTop);
1504}
1505
1506void QOhosView::updateWindowFrameless(bool frameless)
1507{
1508 bool supportsFramelessWindow = viewType() == ViewType::MainWindow || viewType() == ViewType::SubWindow;
1509 if (m_ohosWindowProxy != nullptr && supportsFramelessWindow) {
1510 m_ohosWindowProxy->setWindowDecorVisible(!frameless);
1511 m_ohosWindowProxy->setWindowTitleMoveEnabled(!frameless);
1512 }
1513}
1514
1515void QOhosView::setWindowDragResizable(bool dragResizable)
1516{
1517 if (m_ohosWindowProxy != nullptr)
1518 m_ohosWindowProxy->enableDrag(dragResizable);
1519}
1520
1522{
1523 setSystemUpdateProperty(&SystemUpdateData::windowMinMaxCloseButtonsState, state);
1524}
1525
1526void QOhosView::setWindowStaysOnTop(bool staysOnTop)
1527{
1528 setSystemUpdateProperty(&SystemUpdateData::windowStaysOnTop, staysOnTop);
1529}
1530
1531void QOhosView::setFramelessWindow(bool frameless)
1532{
1533 setSystemUpdateProperty(&SystemUpdateData::frameless, frameless);
1534}
1535
1537{
1538 if (m_ohosWindowProxy != nullptr) {
1539 constexpr double windowShadowDisabledRadius = 0.0;
1540 m_ohosWindowProxy->setWindowShadowRadius(windowShadowDisabledRadius);
1541 }
1542}
1543
1544void QOhosView::setWindowCornerRadius(double radius)
1545{
1546 if (m_ohosWindowProxy != nullptr)
1547 m_ohosWindowProxy->setWindowCornerRadius(radius);
1548}
1549
1550void QOhosView::setWindowTransparentForInput(bool transparentForInput)
1551{
1552 setSystemUpdateProperty(&SystemUpdateData::windowTransparentForInput, transparentForInput);
1553}
1554
1556{
1557 if (m_ohosWindowProxy != nullptr)
1558 return m_ohosWindowProxy->startMoving();
1559 return false;
1560}
1561
1562void QOhosView::setPrivacyMode(bool privacyModeEnabled)
1563{
1564 if (m_ohosWindowProxy != nullptr)
1565 m_ohosWindowProxy->setWindowPrivacyMode(privacyModeEnabled);
1566}
1567
1568void QOhosView::startDrag(
1569 const std::vector<QImage> &images, const QPointF &hotspot,
1570 const QMimeData &mimeData, QOhosConsumer<Qt::DropAction> dropActionConsumer)
1571{
1572 m_nativeNode->startDrag(images, hotspot, mimeData, std::move(dropActionConsumer));
1573}
1574
1576{
1577 const auto lastMainWindowHideMethod = std::exchange(m_lastMainWindowHideMethod, {});
1578 if (m_ohosWindowProxy == nullptr || !m_ohosWindowProxy->qtIsMainWindow())
1579 return;
1580
1581 if (!lastMainWindowHideMethod.has_value()) {
1582 m_ohosWindowProxy->restore();
1583 return;
1584 }
1585
1586 switch (lastMainWindowHideMethod.value()) {
1587 case WindowHideMethod::NativeNodeVisibility:
1588 case WindowHideMethod::Minimize:
1589 m_ohosWindowProxy->restore();
1590 break;
1591 case WindowHideMethod::HideAbility:
1592 m_ohosWindowProxy->showAbility();
1593 break;
1594 }
1595}
1596
1598 Qt::WindowStates previousWindowState, Qt::WindowStates currentWindowState)
1599{
1600 auto stateChange = previousWindowState ^ currentWindowState;
1601 if (stateChange.testFlag(Qt::WindowState::WindowMinimized) && !currentWindowState.testFlag(Qt::WindowState::WindowMinimized))
1603
1604 if (stateChange.testFlag(Qt::WindowState::WindowMaximized) && currentWindowState.testFlag(Qt::WindowState::WindowMaximized)) {
1605 maximize();
1606 return;
1607 }
1608
1609 if (stateChange.testFlag(Qt::WindowState::WindowFullScreen) && currentWindowState.testFlag(Qt::WindowState::WindowFullScreen)) {
1611 return;
1612 }
1613
1614 if (stateChange.testFlag(Qt::WindowState::WindowMinimized) && currentWindowState.testFlag(Qt::WindowState::WindowMinimized)) {
1615 minimize();
1616 return;
1617 }
1618
1619 if (!currentWindowState) {
1620 recover();
1621 return;
1622 }
1623}
1624
1626 Qt::WindowFlags previousWindowFlags, Qt::WindowFlags currentWindowFlags)
1627{
1628 const auto flagsChange = previousWindowFlags ^ currentWindowFlags;
1629
1630 bool minMaxCloseButtonStateChanged = (flagsChange & (Qt::WindowMinMaxButtonsHint | Qt::WindowCloseButtonHint)) != 0;
1631 bool framelessChanged = (flagsChange & Qt::FramelessWindowHint) != 0;
1632
1633 if (minMaxCloseButtonStateChanged || framelessChanged) {
1635 .maxButtonShown = currentWindowFlags.testFlag(Qt::WindowMaximizeButtonHint),
1636 .minButtonShown = currentWindowFlags.testFlag(Qt::WindowMinimizeButtonHint),
1637 .closeButtonShown = currentWindowFlags.testFlag(Qt::WindowCloseButtonHint),
1638 });
1639 }
1640
1641 bool windowStaysOnTopChanged = (flagsChange & Qt::WindowStaysOnTopHint) != 0;
1642 if (windowStaysOnTopChanged)
1643 setWindowStaysOnTop(currentWindowFlags.testFlag(Qt::WindowStaysOnTopHint));
1644
1645 bool transparentForInputChanged = (flagsChange & Qt::WindowTransparentForInput) != 0;
1646 if (transparentForInputChanged)
1647 setWindowTransparentForInput(currentWindowFlags.testFlag(Qt::WindowTransparentForInput));
1648
1649 if (framelessChanged)
1650 setFramelessWindow(currentWindowFlags.testFlag(Qt::FramelessWindowHint));
1651
1652 bool focusableChanged = (flagsChange & Qt::WindowDoesNotAcceptFocus) != 0;
1653 if (focusableChanged) {
1654 bool windowAcceptsFocus = !currentWindowFlags.testFlag(Qt::WindowDoesNotAcceptFocus);
1655 setFocusable(windowAcceptsFocus);
1656 }
1657
1658 bool disableWindowShadowChanged = (flagsChange & Qt::NoDropShadowWindowHint) != 0;
1659 if (disableWindowShadowChanged && currentWindowFlags.testFlag(Qt::NoDropShadowWindowHint))
1661
1662 bool expandedClientAreaChanged = (flagsChange & Qt::ExpandedClientAreaHint) != 0;
1663 if (expandedClientAreaChanged && QOhosDeviceInfo::isPhone())
1664 applyPhoneWindowChrome();
1665}
1666
1667QArkUi::QQtEmbeddedWindowNode::NodeAreaInfo QOhosView::nodeAreaInfo() const
1668{
1669 return m_nativeNode->nodeAreaInfo();
1670}
1671
1678
1680{
1681 return !(*this == other);
1682}
1683
1684void QOhosView::setOrResetWindowProxy(std::shared_ptr<QOhosWindowProxy> windowProxy, QWindow *optLogicalParent)
1685{
1686 m_ohosWindowProxy.reset();
1687 m_ohosWindowProxy = windowProxy
1688 ? QtOhos::makeSharedPtrWithAttachedExtraData<QOhosWindowProxy>(
1689 windowProxy,
1690 QWindowProxyRegistry::instance().registerQWindowWithWindowProxy(ownerWindow(), *windowProxy))
1691 : nullptr;
1692 m_optLogicalParent = optLogicalParent;
1693 syncWindowStateImmediate(WindowStateSyncReason::ViewTypeChanged);
1694}
1695
1697{
1698 auto *platformWindow = m_optLogicalParent != nullptr
1699 ? QOhosPlatformWindow::fromQWindowOrNull(m_optLogicalParent)
1700 : nullptr;
1701
1702 return platformWindow != nullptr
1703 ? platformWindow->ownedViewOrNull()
1704 : nullptr;
1705}
1706
1707const QOhosView *QOhosView::ancestorViewWithWindowOrNull() const
1708{
1709 const QOhosView *parent = viewParentOrNull();
1710 while (parent != nullptr && !parent->m_ohosWindowProxy)
1711 parent = parent->viewParentOrNull();
1712
1713 return parent != nullptr && parent->m_ohosWindowProxy
1714 ? parent
1715 : nullptr;
1716}
1717
1719{
1720 return m_ohosWindowProxy ? m_ohosWindowProxy->snapshot() : QPixmap();
1721}
1722
1724{
1725 return m_nativeNode->nodeScreenGeometryPixels();
1726}
1727
1729{
1730 return m_nativeNode->nodeParentRelativeGeometryPixels();
1731}
1732
1733QT_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()
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)
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:88
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)
static std::shared_ptr< QOhosWindowProxy > createFloatWindow(const FloatWindowCreateInfo &createInfo)
QtOhos::enums::ohos::window::ModalityType ModalityType
std::optional< QOhosDisplayInfo::JsDisplayId > tryGetMainWindowJsDisplayId() const
QtOhos::enums::ohos::window::AvoidAreaType AvoidAreaType
QOhosWindowProxyExistingMainWindowCreateInfo ExistingMainWindowCreateInfo
static std::shared_ptr< QOhosWindowProxy > createForExistingMainWindow(const ExistingMainWindowCreateInfo &createInfo)
QtOhos::enums::ohos::window::MaximizePresentation MaximizePresentation
bool isWindowRectAutoSave() const
QOhosWindowProxySubWindowCreateInfo SubWindowCreateInfo
QtOhos::enums::ohos::window::WindowEventType WindowEventType
QOhosWindowProxyMainWindowCreateInfo MainWindowCreateInfo
QOhosWindowProxyFloatWindowCreateInfo FloatWindowCreateInfo
QtOhos::enums::ohos::bundle::bundleManager::SupportWindowMode SupportWindowMode
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