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
qohosplatformwindow.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 <qohosplatformwindow.h>
5
6#include <QtCore/private/qohoslogger_p.h>
7#include <QtCore/qpointer.h>
8#include <QtGui/private/qguiapplication_p.h>
9#include <QtGui/private/qhighdpiscaling_p.h>
10#include <QtGui/private/qohoswindowhints_p.h>
11#include <QtGui/private/qwindow_p.h>
12#include <algorithm>
13#include <cmath>
14#include <iterator>
15#include <memory>
16#include <qguiapplication.h>
17#include <qohosdeviceinfo_p.h>
18#include <qohosinputcontext.h>
19#include <qohosinputmethodeventhandler.h>
20#include <qohosjsmain.h>
21#include <qohosplatformintegration.h>
22#include <qohosplatformscreen.h>
23#include <qohosruntimedevicetypeandmode.h>
24#include <qohossettings.h>
25#include <qohosutils.h>
26#include <qpa/qwindowsysteminterface.h>
27#include <render/qohosview.h>
28#include <render/qwindowproxyregistry.h>
29
31
32namespace
33{
34
35constexpr int defaultWindowWidth = 160;
36constexpr int defaultWindowHeight = 160;
37
38QOhosView *getWindowsViewOrNull(QWindow *targetWindow)
39{
40 auto *platformWindow = QOhosPlatformWindow::fromQWindowOrNull(targetWindow);
41 if (platformWindow == nullptr) {
42 qCWarning(QtForOhos, "%s: Target window does not contain PlatformWindow", Q_FUNC_INFO);
43 return nullptr;
44 }
45
46 auto *view = platformWindow->ownedViewOrNull();
47 if (view == nullptr) {
48 qCCritical(QtForOhos, "%s: Target window does not contain a view", Q_FUNC_INFO);
49 return nullptr;
50 }
51
52 return view;
53}
54
55}
56
57const QOhosPropertyDescriptor<QWindow *> QOhosPlatformWindow::subWindowOfTagProperty{"_q_platform_ohos_subWindowOf"};
58const QOhosPropertyDescriptor<bool> QOhosPlatformWindow::mainWindowTagProperty{"_q_platform_ohos_mainWindow"};
59const QOhosPropertyDescriptor<bool> QOhosPlatformWindow::floatWindowTagProperty{QOhosWindowHints::floatWindowKey};
60const QOhosPropertyDescriptor<double> QOhosPlatformWindow::windowCornerRadiusProperty{QOhosWindowHints::cornerRadiusKey};
61const QOhosPropertyDescriptor<bool> QOhosPlatformWindow::windowPrivacyModeSettingProperty{QOhosWindowHints::privacyModeKey};
62const QOhosPropertyDescriptor<QColor> QOhosPlatformWindow::surfaceBackgroundColorProperty{QOhosWindowHints::surfaceBackgroundColorKey};
64const QOhosPropertyDescriptor<bool> QOhosPlatformWindow::windowKeepScreenOnProperty{QOhosWindowHints::keepScreenOnKey};
65const QOhosPropertyDescriptor<bool> QOhosPlatformWindow::windowDragResizableProperty{QOhosWindowHints::dragResizableKey};
66const QOhosPropertyDescriptor<bool> QOhosPlatformWindow::windowFixedSizeStateProperty{"_q_platform_ohos_fixedSizeState"};
67const QOhosPropertyDescriptor<int> QOhosPlatformWindow::windowBrightnessProperty{QOhosWindowHints::brightnessKey};
68const QOhosPropertyDescriptor<int> QOhosPlatformWindow::windowContrastProperty{QOhosWindowHints::contrastKey};
69const QOhosPropertyDescriptor<int> QOhosPlatformWindow::windowSaturationProperty{QOhosWindowHints::saturationKey};
70
74{
75 m_windowFlags = Qt::Widget;
76 m_windowState = window->windowStates();
77 m_windowId = QtOhos::InternalWindowId::generate();
78}
79
80void QOhosPlatformWindow::setGeometry(const QRect &rect)
81{
82 const bool frameTopLeftGiven =
83 qt_window_private(window())->positionPolicy == QWindowPrivate::WindowFrameInclusive;
84 const QMargins margins = frameMargins();
85 const QRect clientRect = frameTopLeftGiven
86 ? rect.translated(margins.left(), margins.top())
87 : rect;
88
89 qOhosPrintfDebug(
90 "%s: pos: %d,%d size: %d,%d",
91 Q_FUNC_INFO,
92 clientRect.x(), clientRect.y(),
93 clientRect.width(), clientRect.height());
94
95 m_lastRequestedWindowFrameGeometry = clientRect.marginsAdded(margins);
96 QPlatformWindow::setGeometry(clientRect);
97}
98
100{
101 QRect availableGeometry = screen()->availableGeometry();
102 return geometry().width() > 0
103 && geometry().height() > 0
104 && availableGeometry.width() > 0
105 && availableGeometry.height() > 0;
106}
107
109{
111 QPlatformWindow::setVisible(visible);
112}
113
114void QOhosPlatformWindow::setCursor(const QCursor &cursor)
115{
116 auto *view = ownedViewOrNull();
117 if (view != nullptr) {
118 m_cursor = cursor;
119 view->setCursor(cursor);
120 }
121}
122
123void QOhosPlatformWindow::setWindowTitle(const QString &title)
124{
125 auto *view = ownedViewOrNull();
126 if (view != nullptr)
127 view->setTitle(title);
128}
129
130void QOhosPlatformWindow::setParent(const QPlatformWindow *newParent)
131{
132 if (newParent != nullptr && newParent->isForeignWindow())
133 qOhosReportFatalErrorAndAbort("Reparenting to foreign windows is not supported");
134
135 m_parent = parent();
136
137 auto *view = ownedViewOrNull();
138
139 if (newParent == nullptr) {
141 return;
142 }
143
144 auto *parentView = static_cast<const QOhosPlatformWindow *>(newParent)->ownedViewOrNull();
145 view->setParentOrReparent(*parentView);
146}
147
149{
150 if (!m_displayId.has_value())
151 return QPlatformWindow::screen();
152
154 auto *platformScreen = screenManager.platformScreenForDisplayIdOrNull(m_displayId.value());
155 if (platformScreen != nullptr)
156 return platformScreen;
157
158 qCWarning(QtForOhos)
159 << Q_FUNC_INFO << "window:" << window()
160 << "display id" << m_displayId.value().value()
161 << "has no platform screen. Returning QWindow associated one.";
162
163 return QPlatformWindow::screen();
164}
165
166void QOhosPlatformWindow::setWindowState(Qt::WindowStates state)
167{
168 if (m_windowState == state)
169 return;
170
171 auto oldWindowState = std::exchange(m_windowState, state);
172 onWindowStateChanged(oldWindowState, m_windowState);
173}
174
175void QOhosPlatformWindow::setWindowFlags(Qt::WindowFlags flags)
176{
177 static QSet<Qt::WindowType> disableFocusableWindowTypes{Qt::ToolTip, Qt::Popup};
178
179 auto *qWindow = window();
180 auto correctedFlags = flags;
181 bool ohosOverrideDisableFocusableFeatures = disableFocusableWindowTypes.contains(qWindow->type());
182 if (ohosOverrideDisableFocusableFeatures) {
183 qCDebug(
184 QtForOhos,
185 "Setting Qt::WindowDoesNotAcceptFocus flag on window %s(%s) because of its type",
186 qPrintable(internalWindowId().toString()),
187 qPrintable(qWindow->objectName()));
188 correctedFlags.setFlag(Qt::WindowDoesNotAcceptFocus, true);
189 }
190
191 if (correctedFlags.testFlag(Qt::FramelessWindowHint)) {
192 correctedFlags.setFlag(Qt::WindowMaximizeButtonHint, false);
193 correctedFlags.setFlag(Qt::WindowMinimizeButtonHint, false);
194 correctedFlags.setFlag(Qt::WindowCloseButtonHint, false);
195 } else if (!correctedFlags.testFlag(Qt::CustomizeWindowHint)) {
196 correctedFlags.setFlag(Qt::WindowMaximizeButtonHint, true);
197 correctedFlags.setFlag(Qt::WindowMinimizeButtonHint, true);
198 correctedFlags.setFlag(Qt::WindowCloseButtonHint, true);
199 }
200
201 auto previousWindowFlags = std::exchange(m_windowFlags, correctedFlags);
202 onWindowFlagsChanged(previousWindowFlags, m_windowFlags);
203}
204
206{
207 return m_windowFlags;
208}
209
211{
212 return static_cast<QOhosPlatformScreen *>(screen());
213}
214
216{
217 return m_lastRequestedWindowFrameGeometry;
218}
219
221{
222 auto *view = ownedViewOrNull();
223 if (view == nullptr)
224 return;
225
226 setWindowOrWidgetProperty<bool, &windowFixedSizeStateProperty>(
227 window(), windowMinimumSize() == windowMaximumSize());
228
229 view->setSizeLimits(windowMinimumSize(), windowMaximumSize());
230}
231
233{
234 return m_exposed;
235}
236
238{
239 return m_windowId;
240}
241
242std::optional<double> QOhosPlatformWindow::windowId() const
243{
244 auto internalId = internalWindowId();
245 auto jsWinId = QWindowProxyRegistry::instance().tryMapInternalWindowIdToJsWindowId(internalId);
246 if (!jsWinId.has_value())
247 return std::nullopt;
248
249 qOhosPrintfInfo(
250 "PlatformWindow WIID: %s is returning JsWindowId: %f to the user",
251 qPrintable(internalId.toString()), jsWinId.value().value());
252
253 return jsWinId.value().value();
254}
255
257{
258 return window()->isTopLevel();
259}
260
262{
263 constexpr Qt::WindowType showWithoutDecorationWindowTypes[] = {
264 Qt::WindowType::Popup,
265 Qt::WindowType::SplashScreen,
266 Qt::WindowType::ToolTip,
267 };
268
269 auto *qWindow = window();
270 bool showWithoutDecoration =
271 qWindow->parent() != nullptr
272 || std::find(
273 std::begin(showWithoutDecorationWindowTypes),
274 std::end(showWithoutDecorationWindowTypes),
275 qWindow->type()) != std::end(showWithoutDecorationWindowTypes)
276 || windowFlags().testFlag(Qt::WindowType::FramelessWindowHint)
277 || floatWindowTagValueOrFalse();
278
279 return showWithoutDecoration
282}
283
285{
286 if (m_optFrameMargins)
287 return *m_optFrameMargins;
288
289 // TODO: Read this information from the system in the future
290 // getWindowDecorHeight: https://developer.huawei.com/consumer/en/doc/harmonyos-references/arkts-apis-window-window#getwindowdecorheight11
291 // WindowProperties.drawableRect: https://developer.huawei.com/consumer/en/doc/harmonyos-references/arkts-apis-window-i#windowproperties
292 // Check if its viable and adapt the frameGeometry code in window to use getWIndowDecorHeight.
293
294 const auto *screen = platformScreen();
295 if (screen == nullptr)
296 return QMargins{};
297
299 // https://gitcode.com/openharmony/window_window_manager/tree/master/utils/include/wm_common_inner.h
300 constexpr auto predefinedWindowTitleBarHeight = 37;
301 const int titlebarHeightPixels = std::round(predefinedWindowTitleBarHeight * screen->pixelScalingCoefficient());
302 return QMargins{0, titlebarHeightPixels, 0, 0};
303 }
304
305 return QMargins{};
306}
307
309{
310 return nullptr;
311}
312
313QOhosPlatformWindow *QOhosPlatformWindow::fromQWindowOrNull(QWindow *window)
314{
315 auto *platformWindow = window->handle();
316 return platformWindow != nullptr
317 ? static_cast<QOhosPlatformWindow *>(platformWindow)
318 : nullptr;
319}
320
321QOhosPlatformWindow *QOhosPlatformWindow::fromQWindow(QWindow *window)
322{
323 QOhosPlatformWindow *platformWindow = fromQWindowOrNull(window);
324 if (platformWindow == nullptr)
325 qOhosReportFatalErrorAndAbort("QWindow %s does not have QPlatformWindow", qPrintable(window->objectName()));
326 return platformWindow;
327}
328
329void QOhosPlatformWindow::tagWindowOrWidgetAsSubWindowOf(QObject *windowOrWidgetToTag, QWindow *targetMainWindow)
330{
331 setWindowOrWidgetProperty<QWindow *, &subWindowOfTagProperty>(windowOrWidgetToTag, targetMainWindow);
332}
333
334void QOhosPlatformWindow::tagWindowOrWidgetAsMainWindow(QObject *windowOrWidgetToTag, bool forceMainWindow)
335{
336 setWindowOrWidgetProperty<bool, &mainWindowTagProperty>(windowOrWidgetToTag, forceMainWindow);
337}
338
339void QOhosPlatformWindow::tagWindowOrWidgetAsFloatWindow(
340 QObject *windowOrWidgetToTag, bool showAsFloatWindow)
341{
342 setWindowOrWidgetProperty<bool, &floatWindowTagProperty>(windowOrWidgetToTag, showAsFloatWindow);
343}
344
346{
347 auto *tagValue = QOhosPlatformWindow::getWindowOrWidgetAsSubWindowOfTagValue(window());
348 const auto &allWindows = QGuiApplicationPrivate::window_list;
349 bool tagValueValid = tagValue != nullptr && allWindows.contains(tagValue);
350 qCDebug(
351 QtForOhos, "Window %s(%s) - subWindowOf tag %s value: %p",
352 qPrintable(internalWindowId().toString()), qPrintable(window()->objectName()),
353 tagValueValid ? "valid" : "invalid",
354 tagValue);
355
356 return tagValueValid ? tagValue : nullptr;
357}
358
360{
361 return m_propertiesStore.tryGetProperty<bool, &mainWindowTagProperty>().value_or(false);
362}
363
365{
366 const auto showWithoutActivating = window()->property("_q_showWithoutActivating");
367 return showWithoutActivating.isValid() && showWithoutActivating.toBool() && window()->modality() == Qt::NonModal;
368}
369
370QWindow *QOhosPlatformWindow::getWindowOrWidgetAsSubWindowOfTagValue(QObject *windowOrWidget)
371{
372 return tryGetWindowOrWidgetProperty<QWindow *, &subWindowOfTagProperty>(windowOrWidget).value_or(nullptr);
373}
374
375Qt::WindowFlags QOhosPlatformWindow::platformWindowFlagsForQWindow(QWindow *window)
376{
377 auto *platformWindow = QOhosPlatformWindow::fromQWindow(window);
378 return platformWindow->windowFlags();
379}
380
381bool QOhosPlatformWindow::isEmbeddedWindow(QWindow *window)
382{
383 auto *platformWindow = QOhosPlatformWindow::fromQWindowOrNull(window);
384 auto *view = platformWindow != nullptr ? platformWindow->ownedViewOrNull() : nullptr;
385 return view != nullptr && view->viewType() == QOhosView::ViewType::EmbeddedWindow;
386}
387
389{
390 auto windows = qGuiApp->allWindows();
391 for (auto *window : windows) {
392 if (window->type() == Qt::Popup && window->isVisible())
393 QWindowSystemInterface::handleCloseEvent(window);
394 }
395}
396
398{
399 return nullptr;
400}
401
403{
404 auto *qWindow = window();
405
406 setWindowFlags(qWindow->flags());
407
408 auto initialWindowGeom = windowGeometry();
409 auto initialGeom = initialGeometry(window(), initialWindowGeom, defaultWindowWidth, defaultWindowHeight);
410 QOhosPlatformWindow::setGeometry(initialGeom);
411
412 m_parent = parent();
413}
414
416{
417 return m_windowState;
418}
419
420void QOhosPlatformWindow::setWindowStateFromOhos(Qt::WindowStates state)
421{
422 if (m_lastWindowState != state) {
423 m_windowState = state;
424 m_lastWindowState = state;
425 QWindowSystemInterface::handleWindowStateChanged(window(), m_windowState);
426 }
427}
428
430{
431 if (windowFlags().testFlag(Qt::WindowDoesNotAcceptFocus))
432 return;
433
434 auto *view = ownedViewOrNull();
435 if (view != nullptr)
437}
438
439void QOhosPlatformWindow::setWindowMarginsFromOhos(const QMargins &margins)
440{
441 bool marginsChanged = !m_optFrameMargins || *m_optFrameMargins != margins;
442 if (!marginsChanged)
443 return;
444
445 if (m_optFrameMargins) {
446 *m_optFrameMargins = margins;
447 } else {
448 m_optFrameMargins = std::make_unique<QMargins>(margins);
449 }
450
451 qCDebug(QtForOhos) << "Window margins changed: " << *m_optFrameMargins;
452}
453
455{
456 return m_safeAreaMargins;
457}
458
460{
461 if (m_safeAreaMargins == margins)
462 return;
463
464 m_safeAreaMargins = margins;
465 qCDebug(QtForOhos) << "Safe area margins changed: " << m_safeAreaMargins;
467}
468
470{
471 m_exposed = exposed;
472
473 if (exposed && !m_optLastReportedWindowSize) {
474 m_optLastReportedWindowSize = geometry().size();
475 QWindowSystemInterface::handleGeometryChange(window(), geometry());
476 }
477
478 sendExposeUpdate();
479}
480
482{
483 auto *qWindow = window();
484 auto *view = ownedViewOrNull();
485 bool needsGeometryUpdate =
486 view != nullptr
487 && view->viewType() == QOhosView::ViewType::EmbeddedWindow
488 && window()->isVisible();
489 if (needsGeometryUpdate) {
490 auto scaledGeometry = window()->geometry();
491 qWindow->setGeometry(scaledGeometry);
493 }
494
495 qWindow->requestUpdate();
496 setWindowGeometryFromOhos(windowGeometry());
497}
498
499std::shared_ptr<void> QOhosPlatformWindow::setSurfaceConsumer(
500 QWindow *targetWindow, QObject *surfaceConsumerContext,
501 std::function<void(std::optional<void *>)> surfaceConsumer)
502{
503 qCDebug(
504 QtForOhos,
505 "%s: %s",
506 Q_FUNC_INFO,
507 surfaceConsumerContext->metaObject()->className());
508
509 auto *view = getWindowsViewOrNull(targetWindow);
510 if (view == nullptr)
511 return nullptr;
512
513 if (surfaceConsumerContext->thread() != view->thread() || view->thread() != QThread::currentThread()) {
514 qOhosReportFatalErrorAndAbort(
515 "%s: inter-thread surface consumer connection is not supported", Q_FUNC_INFO);
516 }
517
518 auto sharedSurfaceConsumer = QtOhos::moveToSharedPtr(std::move(surfaceConsumer));
519
520 auto *surface = view->surfaceOrNull();
521 if (surface != nullptr) {
522 QMetaObject::invokeMethod(
523 surfaceConsumerContext,
524 [weakSurfaceConsumer = std::weak_ptr<decltype(surfaceConsumer)>(sharedSurfaceConsumer),
525 targetWindow = QPointer<QWindow>(targetWindow)]() {
526 auto sharedSurfaceConsumer = weakSurfaceConsumer.lock();
527 if (!sharedSurfaceConsumer || targetWindow == nullptr)
528 return;
529
530 auto *view = getWindowsViewOrNull(targetWindow);
531 if (view == nullptr)
532 return;
533
534 auto *surface = view->surfaceOrNull();
535 (*sharedSurfaceConsumer)(
536 surface != nullptr
537 ? std::optional<void *>(surface->nativeWindow())
538 : std::nullopt);
539 },
540 Qt::QueuedConnection);
541 }
542
543 auto surfaceStatusChangedConnectionHandle = QObject::connect(
544 view, &QOhosView::surfaceStatusChanged, surfaceConsumerContext,
545 [view = QPointer<QOhosView>(view), sharedSurfaceConsumer](const std::optional<QSize> &) {
546 if (view == nullptr)
547 return;
548 auto *surface = view->surfaceOrNull();
549 (*sharedSurfaceConsumer)(
550 surface != nullptr
551 ? std::optional<void *>(surface->nativeWindow())
552 : std::nullopt);
553 });
554
555 if (!surfaceStatusChangedConnectionHandle) {
556 qCCritical(
557 QtForOhos,
558 "%s: Connection between ohos view and surface consumer context failed",
559 Q_FUNC_INFO);
560 return nullptr;
561 }
562
563 auto viewDestroyedConnectionHandle = QObject::connect(
564 view, &QObject::destroyed, surfaceConsumerContext,
565 [sharedSurfaceConsumer]() {
566 (*sharedSurfaceConsumer)({});
567 },
568 Qt::QueuedConnection);
569
570 if (!viewDestroyedConnectionHandle) {
571 qCCritical(
572 QtForOhos,
573 "%s: Connecting view destroyed signal to surface consumer context failed",
574 Q_FUNC_INFO);
575 return nullptr;
576 }
577
578 return QtOhos::makeDestroyNotifier(
579 [surfaceStatusChangedConnectionHandle = std::move(surfaceStatusChangedConnectionHandle),
580 viewDestroyedConnectionHandle = std::move(viewDestroyedConnectionHandle)] () mutable {
581 QObject::disconnect(surfaceStatusChangedConnectionHandle);
582 QObject::disconnect(viewDestroyedConnectionHandle);
583 });
584}
585
587{
588 return m_propertiesStore.tryGetProperty<bool, &floatWindowTagProperty>().value_or(false);
589}
590
592{
593 return ownedViewOrNull() != nullptr ? ownedViewOrNull()->makeSnapshot() : QPixmap();
594}
595
596void QOhosPlatformWindow::setDisplayIdFromOhos(std::optional<QOhosDisplayInfo::JsDisplayId> displayId)
597{
598 if (m_displayId != displayId) {
599 m_displayId = displayId;
600
601 qCDebug(QtForOhos)
602 << "Screen changed - window:" << window()
603 << "displayId:" << (displayId.has_value()
604 ? QString::number(displayId.value().value())
605 : QString::fromUtf8("<NO DISPLAY>"));
606
607 QOhosPlatformScreen *screen = m_displayId.has_value()
608 ? QOhosPlatformIntegration::instance()
609 ->screenManager()->platformScreenForDisplayIdOrNull(m_displayId.value())
610 : nullptr;
611
612 QWindowSystemInterface::handleWindowScreenChanged(
613 window(),
614 screen != nullptr
615 ? screen->screen()
616 : nullptr);
617 }
618}
619
620void QOhosPlatformWindow::setWindowGeometryFromOhos(const QRect &nativeWindowDrawGeometry)
621{
622 qCDebug(QtForOhos) << "window:" << window() << "geometry change to:" << nativeWindowDrawGeometry;
623 m_optLastReportedWindowSize = nativeWindowDrawGeometry.size();
624 QWindowSystemInterface::handleGeometryChange(window(), nativeWindowDrawGeometry);
625
626 if (isExposed() && window()->isVisible())
627 sendExposeUpdate();
628}
629
631{
632 return m_optLastReportedWindowSize.value_or(
633 QHighDpi::toNativeWindowGeometry(qt_window_private(window())->geometry, window()).size());
634}
635
641
643{
644 if (active) {
645 auto *ohosInputContext = qobject_cast<QOhosInputContext *>(QOhosPlatformIntegration::instance()->inputContext());
646 if (ohosInputContext != nullptr) {
647 ohosInputContext->setLastInputTypeToTriggerSoftKeyboard(QOhosInputContext::RequestKeyboardReason::NONE);
648 }
649 } else {
650 if (QOhosPlatformIntegration::instance()->inputContext()->isInputPanelVisible())
651 QOhosPlatformIntegration::instance()->inputContext()->hideInputPanel();
652 }
653}
654
658
662
664{
665 return QOhosPropertiesProvider(m_propertiesStore);
666}
667
669{
670 qCDebug(QtForOhos) << Q_FUNC_INFO << "window:" << window() << "grab:" << grab;
671
673 if (grab)
674 inputHandler->grabMouse(window());
675 else
676 inputHandler->stopAnyMouseGrab();
677
678 return true;
679}
680
682{
683 qCDebug(QtForOhos) << Q_FUNC_INFO << "window:" << window() << "grab:" << grab;
684
686 if (grab)
687 inputHandler->grabKeyboard(window());
688 else
689 inputHandler->stopAnyKeyboardGrab();
690
691 return true;
692}
693
695{
696 auto platformWindowFlags = QOhosPlatformWindow::platformWindowFlagsForQWindow(window());
697 return !platformWindowFlags.testFlag(Qt::WindowDoesNotAcceptFocus);
698}
699
701{
702 auto platformWindowFlags = QOhosPlatformWindow::platformWindowFlagsForQWindow(window());
703 return !platformWindowFlags.testFlag(Qt::WindowTransparentForInput);
704}
705
707{
708 switch (event->type()) {
709 case QEvent::ApplicationPaletteChange:
710 if (auto *ohosView = ownedViewOrNull())
712 break;
713 case QEvent::DynamicPropertyChange: {
714 auto propertyName = static_cast<QDynamicPropertyChangeEvent *>(event)->propertyName();
715 m_propertiesStore.notifyPropertyWrite(propertyName);
716 break;
717 }
718 case QEvent::Leave:
719 case QEvent::WindowUnblocked:
720 if (auto *inputMethodEventHandler = QOhosPlatformIntegration::instance()->inputMethodEventHandler())
721 inputMethodEventHandler->forgetEnteredWindow(window());
722 break;
723 default: break;
724 }
725
726 return QPlatformWindow::windowEvent(event);
727}
728
729bool QOhosPlatformWindow::isWindowBeingClosedOrDestroyed(QWindow *window)
730{
731 QWindowPrivate *windowPriv = qt_window_private(window);
732 return windowPriv && (windowPriv->inClose || windowPriv->visibilityOnDestroy);
733}
734
735void QOhosPlatformWindow::sendExposeUpdate()
736{
737 auto exposedSize = m_exposed
738 ? geometry().size()
739 : QSize();
740
741 QWindowSystemInterface::handleExposeEvent(window(), QRegion(QRect(QPoint(), exposedSize)));
742}
743
744QT_END_NAMESPACE
QOhosScreenManager * screenManager() const
static QOhosPlatformIntegration * instance()
QOhosInputMethodEventHandler * inputMethodEventHandler() const
static const QOhosPropertyDescriptor< bool > windowKeepScreenOnProperty
static const QOhosPropertyDescriptor< QColor > surfaceBackgroundColorProperty
void setWindowTitle(const QString &title) override
Reimplement to set the window title to title.
QOhosPlatformScreen * platformScreen() const
bool mainWindowTagValueOrFalse() const
Qt::WindowStates windowStates() const
void setDisplayIdFromOhos(std::optional< QOhosDisplayInfo::JsDisplayId > displayId)
bool setMouseGrabEnabled(bool grab) override
void setWindowStateFromOhos(Qt::WindowStates state)
static const QOhosPropertyDescriptor< int > windowBrightnessProperty
static const QOhosPropertyDescriptor< bool > mainWindowTagProperty
static const QOhosPropertyDescriptor< QWindow * > subWindowOfTagProperty
void setGeometry(const QRect &rect) override
This function is called by Qt whenever a window is moved or resized using the QWindow API.
bool setKeyboardGrabEnabled(bool grab) override
static const QOhosPropertyDescriptor< bool > windowPrivacyModeSettingProperty
bool windowEvent(QEvent *event) override
Reimplement this method to be able to do any platform specific event handling.
static const QOhosPropertyDescriptor< double > windowCornerRadiusProperty
QRect lastRequestedWindowFrameGeometry() const
QMargins safeAreaMargins() const override
The safe area margins of a window represent the area that is safe to place content within,...
static const QOhosPropertyDescriptor< int > windowSaturationProperty
void setExposedFromOhos(bool exposed)
static const QOhosPropertyDescriptor< int > windowContrastProperty
QOhosPropertiesProvider propertiesProvider()
static const QOhosPropertyDescriptor< bool > floatWindowTagProperty
void setVisible(bool visible) override
Reimplemented in subclasses to show the surface if visible is true, and hide it if visible is false.
static const QOhosPropertyDescriptor< bool > windowDragResizableProperty
virtual void onWindowFlagsChanged(Qt::WindowFlags previousWindowFlags, Qt::WindowFlags currentWindowFlags)
QtOhos::InternalWindowId internalWindowId() const
void propagateSizeHints() override
Reimplement to propagate the size hints of the QWindow.
virtual QOhosSurface * ownedSurfaceOrNull() const
virtual void onWindowStateChanged(Qt::WindowStates oldWindowState, Qt::WindowStates currentWindowState)
void setParent(const QPlatformWindow *newParent) override
This function is called to enable native child window in QPA.
QOhosPlatformWindow(QWindow *window)
void setCursor(const QCursor &cursor)
bool shouldDisplayAsOhosWindow() const
static const QOhosPropertyDescriptor< int > nativeNodeRenderFitPolicyHintProperty
void setWindowGeometryFromOhos(const QRect &nativeWindowDrawGeometry)
std::optional< double > windowId() const override
QMargins frameMargins() const override
void initialize() override
Called as part of QWindow::create(), after constructing the window.
void setSafeAreaMarginsFromOhos(const QMargins &margins)
QPlatformScreen * screen() const override
QSize lastReportedWindowSize() const
void setWindowFlags(Qt::WindowFlags flags) override
Requests setting the window flags of this surface to flags.
bool floatWindowTagValueOrFalse() const
void setWindowState(Qt::WindowStates state) override
Requests setting the window state of this surface to type.
void notifyInputSystemsWindowActiveStatusChanged(bool active)
static const QOhosPropertyDescriptor< bool > windowFixedSizeStateProperty
bool isExposed() const final
Returns if this window is exposed in the windowing system.
void requestActivateWindow() override
Reimplement to let Qt be able to request activation/focus for a window.
DecorationPreset decorationPreset() const
QWindow * validSubWindowOfTagValueOrNull() const
Qt::WindowFlags windowFlags() const
bool shouldShowWindowWithoutActivating() const
virtual QOhosView * ownedViewOrNull() const
void setWindowMarginsFromOhos(const QMargins &margins)
QOhosPlatformScreen * platformScreenForDisplayIdOrNull(QOhosDisplayInfo::JsDisplayId displayId) const
void setParentOrReparent(QOhosView &parentView)
void requestActivate()
void tryDetachFromEmbeddedParent()
void forceGeometryUpdate()
void handlePaletteChange()
QRect window() const
Returns the window rectangle.
static QWindowProxyRegistry & instance()
Combined button and popup list for selecting options.
constexpr int defaultWindowHeight
QOhosView * getWindowsViewOrNull(QWindow *targetWindow)
constexpr int defaultWindowWidth
#define qGuiApp