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