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 auto *view = ownedViewOrNull();
259 return view ? view->abilityObjectRef() : QHarmonyJsObjectRef();
260}
261
263{
264 auto *view = ownedViewOrNull();
265 return view ? view->jsWindowObjectRef() : QHarmonyJsObjectRef();
266}
267
269{
270 return window()->isTopLevel();
271}
272
274{
275 constexpr Qt::WindowType showWithoutDecorationWindowTypes[] = {
276 Qt::WindowType::Popup,
277 Qt::WindowType::SplashScreen,
278 Qt::WindowType::ToolTip,
279 };
280
281 auto *qWindow = window();
282 bool showWithoutDecoration =
283 qWindow->parent() != nullptr
284 || std::find(
285 std::begin(showWithoutDecorationWindowTypes),
286 std::end(showWithoutDecorationWindowTypes),
287 qWindow->type()) != std::end(showWithoutDecorationWindowTypes)
288 || windowFlags().testFlag(Qt::WindowType::FramelessWindowHint)
289 || floatWindowTagValueOrFalse();
290
291 return showWithoutDecoration
294}
295
297{
298 if (m_optFrameMargins)
299 return *m_optFrameMargins;
300
301 // TODO: Read this information from the system in the future
302 // getWindowDecorHeight: https://developer.huawei.com/consumer/en/doc/harmonyos-references/arkts-apis-window-window#getwindowdecorheight11
303 // WindowProperties.drawableRect: https://developer.huawei.com/consumer/en/doc/harmonyos-references/arkts-apis-window-i#windowproperties
304 // Check if its viable and adapt the frameGeometry code in window to use getWIndowDecorHeight.
305
306 const auto *screen = platformScreen();
307 if (screen == nullptr)
308 return QMargins{};
309
311 // https://gitcode.com/openharmony/window_window_manager/tree/master/utils/include/wm_common_inner.h
312 constexpr auto predefinedWindowTitleBarHeight = 37;
313 const int titlebarHeightPixels = std::round(predefinedWindowTitleBarHeight * screen->pixelScalingCoefficient());
314 return QMargins{0, titlebarHeightPixels, 0, 0};
315 }
316
317 return QMargins{};
318}
319
321{
322 return nullptr;
323}
324
325QOhosPlatformWindow *QOhosPlatformWindow::fromQWindowOrNull(QWindow *window)
326{
327 auto *platformWindow = window->handle();
328 return platformWindow != nullptr
329 ? static_cast<QOhosPlatformWindow *>(platformWindow)
330 : nullptr;
331}
332
333QOhosPlatformWindow *QOhosPlatformWindow::fromQWindow(QWindow *window)
334{
335 QOhosPlatformWindow *platformWindow = fromQWindowOrNull(window);
336 if (platformWindow == nullptr)
337 qOhosReportFatalErrorAndAbort("QWindow %s does not have QPlatformWindow", qPrintable(window->objectName()));
338 return platformWindow;
339}
340
341void QOhosPlatformWindow::tagWindowOrWidgetAsSubWindowOf(QObject *windowOrWidgetToTag, QWindow *targetMainWindow)
342{
343 setWindowOrWidgetProperty<QWindow *, &subWindowOfTagProperty>(windowOrWidgetToTag, targetMainWindow);
344}
345
346void QOhosPlatformWindow::tagWindowOrWidgetAsMainWindow(QObject *windowOrWidgetToTag, bool forceMainWindow)
347{
348 setWindowOrWidgetProperty<bool, &mainWindowTagProperty>(windowOrWidgetToTag, forceMainWindow);
349}
350
351void QOhosPlatformWindow::tagWindowOrWidgetAsFloatWindow(
352 QObject *windowOrWidgetToTag, bool showAsFloatWindow)
353{
354 setWindowOrWidgetProperty<bool, &floatWindowTagProperty>(windowOrWidgetToTag, showAsFloatWindow);
355}
356
358{
359 auto *tagValue = QOhosPlatformWindow::getWindowOrWidgetAsSubWindowOfTagValue(window());
360 const auto &allWindows = QGuiApplicationPrivate::window_list;
361 bool tagValueValid = tagValue != nullptr && allWindows.contains(tagValue);
362 qCDebug(
363 QtForOhos, "Window %s(%s) - subWindowOf tag %s value: %p",
364 qPrintable(internalWindowId().toString()), qPrintable(window()->objectName()),
365 tagValueValid ? "valid" : "invalid",
366 tagValue);
367
368 return tagValueValid ? tagValue : nullptr;
369}
370
372{
373 return m_propertiesStore.tryGetProperty<bool, &mainWindowTagProperty>().value_or(false);
374}
375
377{
378 const auto showWithoutActivating = window()->property("_q_showWithoutActivating");
379 return showWithoutActivating.isValid() && showWithoutActivating.toBool() && window()->modality() == Qt::NonModal;
380}
381
382QWindow *QOhosPlatformWindow::getWindowOrWidgetAsSubWindowOfTagValue(QObject *windowOrWidget)
383{
384 return tryGetWindowOrWidgetProperty<QWindow *, &subWindowOfTagProperty>(windowOrWidget).value_or(nullptr);
385}
386
387Qt::WindowFlags QOhosPlatformWindow::platformWindowFlagsForQWindow(QWindow *window)
388{
389 auto *platformWindow = QOhosPlatformWindow::fromQWindow(window);
390 return platformWindow->windowFlags();
391}
392
393bool QOhosPlatformWindow::isEmbeddedWindow(QWindow *window)
394{
395 auto *platformWindow = QOhosPlatformWindow::fromQWindowOrNull(window);
396 auto *view = platformWindow != nullptr ? platformWindow->ownedViewOrNull() : nullptr;
397 return view != nullptr && view->viewType() == QOhosView::ViewType::EmbeddedWindow;
398}
399
401{
402 auto windows = qGuiApp->allWindows();
403 for (auto *window : windows) {
404 if (window->type() == Qt::Popup && window->isVisible())
405 QWindowSystemInterface::handleCloseEvent(window);
406 }
407}
408
410{
411 return nullptr;
412}
413
415{
416 auto *qWindow = window();
417
418 setWindowFlags(qWindow->flags());
419
420 auto initialWindowGeom = windowGeometry();
421 auto initialGeom = initialGeometry(window(), initialWindowGeom, defaultWindowWidth, defaultWindowHeight);
422 QOhosPlatformWindow::setGeometry(initialGeom);
423
424 m_parent = parent();
425}
426
428{
429 return m_windowState;
430}
431
432void QOhosPlatformWindow::setWindowStateFromOhos(Qt::WindowStates state)
433{
434 if (m_lastWindowState != state) {
435 m_windowState = state;
436 m_lastWindowState = state;
437 QWindowSystemInterface::handleWindowStateChanged(window(), m_windowState);
438 }
439}
440
442{
443 if (windowFlags().testFlag(Qt::WindowDoesNotAcceptFocus))
444 return;
445
446 auto *view = ownedViewOrNull();
447 if (view != nullptr)
449}
450
452{
453 const auto refusedState = m_windowState;
454 m_windowState &= ~(Qt::WindowMaximized | Qt::WindowFullScreen);
455 QWindowSystemInterface::handleWindowStateChanged(window(), m_windowState, refusedState);
456}
457
458void QOhosPlatformWindow::setWindowMarginsFromOhos(const QMargins &margins)
459{
460 bool marginsChanged = !m_optFrameMargins || *m_optFrameMargins != margins;
461 if (!marginsChanged)
462 return;
463
464 if (m_optFrameMargins) {
465 *m_optFrameMargins = margins;
466 } else {
467 m_optFrameMargins = std::make_unique<QMargins>(margins);
468 }
469
470 qCDebug(QtForOhos) << "Window margins changed: " << *m_optFrameMargins;
471}
472
474{
475 return m_safeAreaMargins;
476}
477
479{
480 if (m_safeAreaMargins == margins)
481 return;
482
483 m_safeAreaMargins = margins;
484 qCDebug(QtForOhos) << "Safe area margins changed: " << m_safeAreaMargins;
486}
487
489{
490 m_exposed = exposed;
491
492 if (exposed && !m_optLastReportedWindowSize) {
493 m_optLastReportedWindowSize = geometry().size();
494 QWindowSystemInterface::handleGeometryChange(window(), geometry());
495 }
496
497 sendExposeUpdate();
498}
499
501{
502 auto *qWindow = window();
503 auto *view = ownedViewOrNull();
504 bool needsGeometryUpdate =
505 view != nullptr
506 && view->viewType() == QOhosView::ViewType::EmbeddedWindow
507 && window()->isVisible();
508 if (needsGeometryUpdate) {
509 auto scaledGeometry = window()->geometry();
510 qWindow->setGeometry(scaledGeometry);
512 }
513
514 qWindow->requestUpdate();
515 setWindowGeometryFromOhos(windowGeometry());
516}
517
518std::shared_ptr<void> QOhosPlatformWindow::setSurfaceConsumer(
519 QWindow *targetWindow, QObject *surfaceConsumerContext,
520 std::function<void(std::optional<void *>)> surfaceConsumer)
521{
522 qCDebug(
523 QtForOhos,
524 "%s: %s",
525 Q_FUNC_INFO,
526 surfaceConsumerContext->metaObject()->className());
527
528 auto *view = getWindowsViewOrNull(targetWindow);
529 if (view == nullptr)
530 return nullptr;
531
532 if (surfaceConsumerContext->thread() != view->thread() || view->thread() != QThread::currentThread()) {
533 qOhosReportFatalErrorAndAbort(
534 "%s: inter-thread surface consumer connection is not supported", Q_FUNC_INFO);
535 }
536
537 auto sharedSurfaceConsumer = QtOhos::moveToSharedPtr(std::move(surfaceConsumer));
538
539 auto *surface = view->surfaceOrNull();
540 if (surface != nullptr) {
541 QMetaObject::invokeMethod(
542 surfaceConsumerContext,
543 [weakSurfaceConsumer = std::weak_ptr<decltype(surfaceConsumer)>(sharedSurfaceConsumer),
544 targetWindow = QPointer<QWindow>(targetWindow)]() {
545 auto sharedSurfaceConsumer = weakSurfaceConsumer.lock();
546 if (!sharedSurfaceConsumer || targetWindow == nullptr)
547 return;
548
549 auto *view = getWindowsViewOrNull(targetWindow);
550 if (view == nullptr)
551 return;
552
553 auto *surface = view->surfaceOrNull();
554 (*sharedSurfaceConsumer)(
555 surface != nullptr
556 ? std::optional<void *>(surface->nativeWindow())
557 : std::nullopt);
558 },
559 Qt::QueuedConnection);
560 }
561
562 auto surfaceStatusChangedConnectionHandle = QObject::connect(
563 view, &QOhosView::surfaceStatusChanged, surfaceConsumerContext,
564 [view = QPointer<QOhosView>(view), sharedSurfaceConsumer](const std::optional<QSize> &) {
565 if (view == nullptr)
566 return;
567 auto *surface = view->surfaceOrNull();
568 (*sharedSurfaceConsumer)(
569 surface != nullptr
570 ? std::optional<void *>(surface->nativeWindow())
571 : std::nullopt);
572 });
573
574 if (!surfaceStatusChangedConnectionHandle) {
575 qCCritical(
576 QtForOhos,
577 "%s: Connection between ohos view and surface consumer context failed",
578 Q_FUNC_INFO);
579 return nullptr;
580 }
581
582 auto viewDestroyedConnectionHandle = QObject::connect(
583 view, &QObject::destroyed, surfaceConsumerContext,
584 [sharedSurfaceConsumer]() {
585 (*sharedSurfaceConsumer)({});
586 },
587 Qt::QueuedConnection);
588
589 if (!viewDestroyedConnectionHandle) {
590 qCCritical(
591 QtForOhos,
592 "%s: Connecting view destroyed signal to surface consumer context failed",
593 Q_FUNC_INFO);
594 return nullptr;
595 }
596
597 return QtOhos::makeDestroyNotifier(
598 [surfaceStatusChangedConnectionHandle = std::move(surfaceStatusChangedConnectionHandle),
599 viewDestroyedConnectionHandle = std::move(viewDestroyedConnectionHandle)] () mutable {
600 QObject::disconnect(surfaceStatusChangedConnectionHandle);
601 QObject::disconnect(viewDestroyedConnectionHandle);
602 });
603}
604
606{
607 return m_propertiesStore.tryGetProperty<bool, &floatWindowTagProperty>().value_or(false);
608}
609
611{
612 return ownedViewOrNull() != nullptr ? ownedViewOrNull()->makeSnapshot() : QPixmap();
613}
614
615void QOhosPlatformWindow::setDisplayIdFromOhos(std::optional<QOhosDisplayInfo::JsDisplayId> displayId)
616{
617 if (m_displayId != displayId) {
618 m_displayId = displayId;
619
620 qCDebug(QtForOhos)
621 << "Screen changed - window:" << window()
622 << "displayId:" << (displayId.has_value()
623 ? QString::number(displayId.value().value())
624 : QString::fromUtf8("<NO DISPLAY>"));
625
626 QOhosPlatformScreen *screen = m_displayId.has_value()
627 ? QOhosPlatformIntegration::instance()
628 ->screenManager()->platformScreenForDisplayIdOrNull(m_displayId.value())
629 : nullptr;
630
631 QWindowSystemInterface::handleWindowScreenChanged(
632 window(),
633 screen != nullptr
634 ? screen->screen()
635 : nullptr);
636 }
637}
638
639void QOhosPlatformWindow::setWindowGeometryFromOhos(const QRect &nativeWindowDrawGeometry)
640{
641 qCDebug(QtForOhos) << "window:" << window() << "geometry change to:" << nativeWindowDrawGeometry;
642 m_optLastReportedWindowSize = nativeWindowDrawGeometry.size();
643 QWindowSystemInterface::handleGeometryChange(window(), nativeWindowDrawGeometry);
644
645 if (isExposed() && window()->isVisible())
646 sendExposeUpdate();
647}
648
650{
651 return m_optLastReportedWindowSize.value_or(
652 QHighDpi::toNativeWindowGeometry(qt_window_private(window())->geometry, window()).size());
653}
654
660
662{
663 if (active) {
664 auto *ohosInputContext = qobject_cast<QOhosInputContext *>(QOhosPlatformIntegration::instance()->inputContext());
665 if (ohosInputContext != nullptr) {
666 ohosInputContext->setLastInputTypeToTriggerSoftKeyboard(QOhosInputContext::RequestKeyboardReason::NONE);
667 }
668 } else {
669 if (QOhosPlatformIntegration::instance()->inputContext()->isInputPanelVisible())
670 QOhosPlatformIntegration::instance()->inputContext()->hideInputPanel();
671 }
672}
673
677
681
683{
684 return QOhosPropertiesProvider(m_propertiesStore);
685}
686
688{
689 qCDebug(QtForOhos) << Q_FUNC_INFO << "window:" << window() << "grab:" << grab;
690
692 if (grab)
693 inputHandler->grabMouse(window());
694 else
695 inputHandler->stopAnyMouseGrab();
696
697 return true;
698}
699
701{
702 qCDebug(QtForOhos) << Q_FUNC_INFO << "window:" << window() << "grab:" << grab;
703
705 if (grab)
706 inputHandler->grabKeyboard(window());
707 else
708 inputHandler->stopAnyKeyboardGrab();
709
710 return true;
711}
712
714{
715 auto platformWindowFlags = QOhosPlatformWindow::platformWindowFlagsForQWindow(window());
716 return !platformWindowFlags.testFlag(Qt::WindowDoesNotAcceptFocus);
717}
718
720{
721 auto platformWindowFlags = QOhosPlatformWindow::platformWindowFlagsForQWindow(window());
722 return !platformWindowFlags.testFlag(Qt::WindowTransparentForInput);
723}
724
726{
727 switch (event->type()) {
728 case QEvent::ApplicationPaletteChange:
729 if (auto *ohosView = ownedViewOrNull())
731 break;
732 case QEvent::DynamicPropertyChange: {
733 auto propertyName = static_cast<QDynamicPropertyChangeEvent *>(event)->propertyName();
734 m_propertiesStore.notifyPropertyWrite(propertyName);
735 break;
736 }
737 case QEvent::Leave:
738 case QEvent::WindowUnblocked:
739 if (auto *inputMethodEventHandler = QOhosPlatformIntegration::instance()->inputMethodEventHandler())
740 inputMethodEventHandler->forgetEnteredWindow(window());
741 break;
742 default: break;
743 }
744
745 return QPlatformWindow::windowEvent(event);
746}
747
748bool QOhosPlatformWindow::isWindowBeingClosedOrDestroyed(QWindow *window)
749{
750 QWindowPrivate *windowPriv = qt_window_private(window);
751 return windowPriv && (windowPriv->inClose || windowPriv->visibilityOnDestroy);
752}
753
754void QOhosPlatformWindow::sendExposeUpdate()
755{
756 auto exposedSize = m_exposed
757 ? geometry().size()
758 : QSize();
759
760 QWindowSystemInterface::handleExposeEvent(window(), QRegion(QRect(QPoint(), exposedSize)));
761}
762
763QT_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
QHarmonyJsObjectRef ability() 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
QHarmonyJsObjectRef jsWindow() const override
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