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