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/qwindow_p.h>
10#include <algorithm>
11#include <cmath>
12#include <iterator>
13#include <memory>
14#include <qguiapplication.h>
15#include <qohosdeviceinfo_p.h>
16#include <qohosinputcontext.h>
17#include <qohosinputmethodeventhandler.h>
18#include <qohosjsmain.h>
19#include <qohosplatformintegration.h>
20#include <qohosplatformscreen.h>
21#include <qohosqpafunctions_p.h>
22#include <qohosruntimedevicetypeandmode.h>
23#include <qohossettings.h>
24#include <qohosutils.h>
25#include <qpa/qwindowsysteminterface.h>
26#include <render/qohosview.h>
27#include <private/qwindow_p.h>
28#include <utility>
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
69
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 QRect adjustedRect = rect;
83 if (qt_window_private(const_cast<QWindow *>(window()))->positionPolicy
84 == QWindowPrivate::WindowFrameInclusive) {
85 const auto margins = frameMargins();
86 adjustedRect.adjust(margins.left(), margins.top(), -margins.right(), -margins.bottom());
87 }
88
89 qOhosPrintfDebug(
90 "%s: pos: %d,%d size: %d,%d",
91 Q_FUNC_INFO,
92 adjustedRect.x(), adjustedRect.y(),
93 adjustedRect.width(), adjustedRect.height());
94 QPlatformWindow::setGeometry(adjustedRect);
95}
96
98{
99 QRect availableGeometry = screen()->availableGeometry();
100 return geometry().width() > 0
101 && geometry().height() > 0
102 && availableGeometry.width() > 0
103 && availableGeometry.height() > 0;
104}
105
107{
109 QPlatformWindow::setVisible(visible);
110}
111
112void QOhosPlatformWindow::setCursor(const QCursor &cursor)
113{
114 auto *view = ownedViewOrNull();
115 if (view != nullptr) {
116 m_cursor = cursor;
117 view->setCursor(cursor);
118 }
119}
120
121void QOhosPlatformWindow::setWindowTitle(const QString &title)
122{
123 auto *view = ownedViewOrNull();
124 if (view != nullptr)
125 view->setTitle(title);
126}
127
128void QOhosPlatformWindow::setParent(const QPlatformWindow *newParent)
129{
130 if (newParent != nullptr && newParent->isForeignWindow())
131 qOhosReportFatalErrorAndAbort("Reparenting to foreign windows is not supported");
132
133 m_parent = parent();
134
135 auto *view = ownedViewOrNull();
136
137 if (newParent == nullptr) {
139 return;
140 }
141
142 auto *parentView = static_cast<const QOhosPlatformWindow *>(newParent)->ownedViewOrNull();
143 view->setParentOrReparent(*parentView);
144}
145
147{
148 if (platformScreen == nullptr) {
149 qCWarning(QtForOhos) << Q_FUNC_INFO << "platform screen is null. Ignoring";
151 }
152
153 auto *view = ownedViewOrNull();
154 if (view == nullptr) {
155 qCWarning(QtForOhos) << Q_FUNC_INFO << "view is nullptr";
157 }
158
159 auto screenDisplayId = platformScreen->displayInfo().id;
160 m_lastRequestedDisplayId = makeQOhosOptional(screenDisplayId);
161
162 if (view->viewType() == QOhosView::ViewType::EmbeddedWindow) {
163 qCWarning(QtForOhos) << Q_FUNC_INFO << "view is of invalid type";
165 }
166
167 if (m_displayId == screenDisplayId) {
168 qCWarning(QtForOhos) << Q_FUNC_INFO << "Screen has not changed. Ignoring";
170 }
171
172 auto currentWindowPosition = windowFrameGeometry().topLeft();
173 auto availableArea = platformScreen->availableGeometry();
174
175 auto adjustedWindowPosition = QPoint(
176 qBound<int>(availableArea.left(), currentWindowPosition.x(), availableArea.right()),
177 qBound<int>(availableArea.top(), currentWindowPosition.y(), availableArea.bottom()));
178
179 qCDebug(QtForOhos)
180 << Q_FUNC_INFO << "window:" << window()
181 << "screen id" << screenDisplayId.value()
182 << "target position:" << adjustedWindowPosition;
183
184 view->setPositionOnScreenImmediate(adjustedWindowPosition, screenDisplayId);
186}
187
189{
190 if (!m_displayId.hasValue())
191 return QPlatformWindow::screen();
192
194 auto *platformScreen = screenManager.platformScreenForDisplayIdOrNull(m_displayId.value());
195 if (platformScreen != nullptr)
196 return platformScreen;
197
198 qCWarning(QtForOhos)
199 << Q_FUNC_INFO << "window:" << window()
200 << "display id" << m_displayId.value().value()
201 << "has no platform screen. Returning QWindow associated one.";
202
203 return QPlatformWindow::screen();
204}
205
206void QOhosPlatformWindow::setWindowState(Qt::WindowStates state)
207{
208 if (m_windowState == state)
209 return;
210
211 auto oldWindowState = std::exchange(m_windowState, state);
212 onWindowStateChanged(oldWindowState, m_windowState);
213}
214
215void QOhosPlatformWindow::setWindowFlags(Qt::WindowFlags flags)
216{
217 static QSet<Qt::WindowType> disableFocusableWindowTypes{Qt::ToolTip, Qt::Popup};
218
219 auto *qWindow = window();
220 auto correctedFlags = flags;
221 bool ohosOverrideDisableFocusableFeatures = disableFocusableWindowTypes.contains(qWindow->type());
222 if (ohosOverrideDisableFocusableFeatures) {
223 qCDebug(
224 QtForOhos,
225 "Setting Qt::WindowDoesNotAcceptFocus flag on window %s(%s) because of its type",
226 qPrintable(internalWindowId().toString()),
227 qPrintable(qWindow->objectName()));
228 correctedFlags.setFlag(Qt::WindowDoesNotAcceptFocus, true);
229 }
230
231 if (correctedFlags.testFlag(Qt::FramelessWindowHint)) {
232 correctedFlags.setFlag(Qt::WindowMaximizeButtonHint, false);
233 correctedFlags.setFlag(Qt::WindowMinimizeButtonHint, false);
234 correctedFlags.setFlag(Qt::WindowCloseButtonHint, false);
235 } else if (!correctedFlags.testFlag(Qt::CustomizeWindowHint)) {
236 correctedFlags.setFlag(Qt::WindowMaximizeButtonHint, true);
237 correctedFlags.setFlag(Qt::WindowMinimizeButtonHint, true);
238 correctedFlags.setFlag(Qt::WindowCloseButtonHint, true);
239 }
240
241 auto previousWindowFlags = std::exchange(m_windowFlags, correctedFlags);
242 onWindowFlagsChanged(previousWindowFlags, m_windowFlags);
243}
244
246{
247 return m_windowFlags;
248}
249
251{
252 return static_cast<QOhosPlatformScreen *>(screen());
253}
254
256{
257 return std::exchange(m_lastRequestedDisplayId, makeEmptyQOhosOptional());
258}
259
261{
262 auto *view = ownedViewOrNull();
263 if (view == nullptr)
264 return;
265
266 setWindowOrWidgetProperty<bool, &windowFixedSizeStateProperty>(
267 window(), windowMinimumSize() == windowMaximumSize());
268
269 view->setSizeLimits(windowMinimumSize(), windowMaximumSize());
270}
271
273{
274 return !m_lastExposedRegion.isEmpty();
275}
276
278{
279 return m_windowId;
280}
281
283{
284 return window()->isTopLevel();
285}
286
288{
289 constexpr Qt::WindowType showWithoutDecorationWindowTypes[] = {
290 Qt::WindowType::Popup,
291 Qt::WindowType::SplashScreen,
292 Qt::WindowType::ToolTip,
293 };
294
295 auto *qWindow = window();
296 bool showWithoutDecoration =
297 qWindow->parent() != nullptr
298 || std::find(
299 std::begin(showWithoutDecorationWindowTypes),
300 std::end(showWithoutDecorationWindowTypes),
301 qWindow->type()) != std::end(showWithoutDecorationWindowTypes)
302 || windowFlags().testFlag(Qt::WindowType::FramelessWindowHint)
303 || floatWindowTagValueOrFalse();
304
305 return showWithoutDecoration
308}
309
311{
312 if (m_optFrameMargins)
313 return *m_optFrameMargins;
314
315 // TODO: Read this information from the system in the future
316 // getWindowDecorHeight: https://developer.huawei.com/consumer/en/doc/harmonyos-references/arkts-apis-window-window#getwindowdecorheight11
317 // WindowProperties.drawableRect: https://developer.huawei.com/consumer/en/doc/harmonyos-references/arkts-apis-window-i#windowproperties
318 // Check if its viable and adapt the frameGeometry code in window to use getWIndowDecorHeight.
319
320 const auto *screen = platformScreen();
321 if (screen == nullptr)
322 return QMargins{};
323
325 // https://gitcode.com/openharmony/window_window_manager/tree/master/utils/include/wm_common_inner.h
326 constexpr auto predefinedWindowTitleBarHeight = 37;
327 const int titlebarHeightPixels = std::round(predefinedWindowTitleBarHeight * screen->pixelScalingCoefficient());
328 return QMargins{0, titlebarHeightPixels, 0, 0};
329 }
330
331 return QMargins{};
332}
333
335{
336 return nullptr;
337}
338
339QOhosPlatformWindow *QOhosPlatformWindow::fromQWindowOrNull(QWindow *window)
340{
341 auto *platformWindow = window->handle();
342 return platformWindow != nullptr
343 ? static_cast<QOhosPlatformWindow *>(platformWindow)
344 : nullptr;
345}
346
347QOhosPlatformWindow *QOhosPlatformWindow::fromQWindow(QWindow *window)
348{
349 QOhosPlatformWindow *platformWindow = fromQWindowOrNull(window);
350 if (platformWindow == nullptr)
351 qOhosReportFatalErrorAndAbort("QWindow %s does not have QPlatformWindow", qPrintable(window->objectName()));
352 return platformWindow;
353}
354
355void QOhosPlatformWindow::tagWindowOrWidgetAsSubWindowOf(QObject *windowOrWidgetToTag, QWindow *targetMainWindow)
356{
357 setWindowOrWidgetProperty<QWindow *, &subWindowOfTagProperty>(windowOrWidgetToTag, targetMainWindow);
358}
359
360void QOhosPlatformWindow::tagWindowOrWidgetAsMainWindow(QObject *windowOrWidgetToTag, bool forceMainWindow)
361{
362 setWindowOrWidgetProperty<bool, &mainWindowTagProperty>(windowOrWidgetToTag, forceMainWindow);
363}
364
365void QOhosPlatformWindow::tagWindowOrWidgetAsFloatWindow(
366 QObject *windowOrWidgetToTag, bool showAsFloatWindow)
367{
368 setWindowOrWidgetProperty<bool, &floatWindowTagProperty>(windowOrWidgetToTag, showAsFloatWindow);
369}
370
371void QOhosPlatformWindow::setWindowPrivacyMode(QObject *window, bool privacyModeEnabled)
372{
373 setWindowOrWidgetProperty<bool, &windowPrivacyModeSettingProperty>(window, privacyModeEnabled);
374}
375
376void QOhosPlatformWindow::setWindowCornerRadius(QObject *windowOrWidget, double radius)
377{
378 setWindowOrWidgetProperty<double, &windowCornerRadiusProperty>(windowOrWidget, radius);
379}
380
382{
383 auto *tagValue = QOhosPlatformWindow::getWindowOrWidgetAsSubWindowOfTagValue(window());
384 const auto &allWindows = QGuiApplicationPrivate::window_list;
385 bool tagValueValid = tagValue != nullptr && allWindows.contains(tagValue);
386 qCDebug(
387 QtForOhos, "Window %s(%s) - subWindowOf tag %s value: %p",
388 qPrintable(internalWindowId().toString()), qPrintable(window()->objectName()),
389 tagValueValid ? "valid" : "invalid",
390 tagValue);
391
392 return tagValueValid ? tagValue : nullptr;
393}
394
396{
397 return m_propertiesStore.tryGetProperty<bool, &mainWindowTagProperty>().valueOr(false);
398}
399
401{
402 const auto showWithoutActivating = window()->property("_q_showWithoutActivating");
403 return showWithoutActivating.isValid() && showWithoutActivating.toBool() && window()->modality() == Qt::NonModal;
404}
405
406QWindow *QOhosPlatformWindow::getWindowOrWidgetAsSubWindowOfTagValue(QObject *windowOrWidget)
407{
408 return tryGetWindowOrWidgetProperty<QWindow *, &subWindowOfTagProperty>(windowOrWidget).valueOr(nullptr);
409}
410
411void QOhosPlatformWindow::setWindowOrWidgetNativeNodeRenderFitPolicyHint(
412 QObject *windowOrWidget, QOhosPlatformWindow::NativeNodeRenderFitPolicy renderFitPolicy)
413{
414 setWindowOrWidgetProperty<NativeNodeRenderFitPolicy, &nativeNodeRenderFitPolicyHintProperty>(windowOrWidget, renderFitPolicy);
415}
416
417Qt::WindowFlags QOhosPlatformWindow::platformWindowFlagsForQWindow(QWindow *window)
418{
419 auto *platformWindow = QOhosPlatformWindow::fromQWindow(window);
420 return platformWindow->windowFlags();
421}
422
423void QOhosPlatformWindow::setSurfaceBackgroundColor(QObject *windowOrWidget, const QColor &color)
424{
425 setWindowOrWidgetProperty<QColor, &surfaceBackgroundColorProperty>(windowOrWidget, color);
426}
427
428void QOhosPlatformWindow::setWindowKeepScreenOn(QObject *windowOrWidget, bool keepScreenOn)
429{
430 setWindowOrWidgetProperty<bool, &windowKeepScreenOnProperty>(windowOrWidget, keepScreenOn);
431}
432
433void QOhosPlatformWindow::setBrightness(QObject *windowOrWidget, int brightness)
434{
435 setWindowOrWidgetProperty<int, &windowBrightnessProperty>(windowOrWidget, brightness);
436}
437
438void QOhosPlatformWindow::setContrast(QObject *windowOrWidget, int contrast)
439{
440 setWindowOrWidgetProperty<int, &windowContrastProperty>(windowOrWidget, contrast);
441}
442
443void QOhosPlatformWindow::setSaturation(QObject *windowOrWidget, int saturation)
444{
445 setWindowOrWidgetProperty<int, &windowSaturationProperty>(windowOrWidget, saturation);
446}
447
449{
450 auto windows = qGuiApp->allWindows();
451 for (auto *window : windows) {
452 if (window->type() == Qt::Popup && window->isVisible())
453 QWindowSystemInterface::handleCloseEvent(window);
454 }
455}
456
458{
459 return nullptr;
460}
461
463{
464 auto *qWindow = window();
465
466 setWindowFlags(qWindow->flags());
467
468 auto initialWindowGeom = windowGeometry();
469 auto initialGeom = initialGeometry(window(), initialWindowGeom, defaultWindowWidth, defaultWindowHeight);
470 setGeometry(initialGeom);
471
472 m_parent = parent();
473}
474
476{
477 return m_windowState;
478}
479
480void QOhosPlatformWindow::setWindowStateFromOhos(Qt::WindowStates state)
481{
482 if (m_windowState != state) {
483 m_windowState = state;
484 QWindowSystemInterface::handleWindowStateChanged(window(), m_windowState);
485 }
486}
487
489{
490 if (windowFlags().testFlag(Qt::WindowDoesNotAcceptFocus))
491 return;
492
493 auto *view = ownedViewOrNull();
494 if (view != nullptr)
496}
497
498void QOhosPlatformWindow::setWindowMarginsFromOhos(const QMargins &margins)
499{
500 bool marginsChanged = !m_optFrameMargins || *m_optFrameMargins != margins;
501 if (!marginsChanged)
502 return;
503
504 if (m_optFrameMargins) {
505 *m_optFrameMargins = margins;
506 } else {
507 m_optFrameMargins = std::make_unique<QMargins>(margins);
508 }
509
510 qCDebug(QtForOhos) << "Window margins changed: " << *m_optFrameMargins;
511}
512
514{
515 auto *qWindow = window();
516 auto *view = ownedViewOrNull();
517 bool needsGeometryUpdate =
518 view != nullptr
519 && view->viewType() == QOhosView::ViewType::EmbeddedWindow
520 && window()->isVisible();
521 if (needsGeometryUpdate) {
522 auto scaledGeometry = window()->geometry();
523 qWindow->setGeometry(scaledGeometry);
525 }
526
527 qWindow->requestUpdate();
528 setWindowGeometryFromOhos(windowGeometry());
529}
530
531std::shared_ptr<void> QOhosPlatformWindow::setSurfaceConsumer(
532 QWindow *targetWindow, QObject *surfaceConsumerContext,
533 std::function<void(QOhosOptional<void *>)> surfaceConsumer)
534{
535 qCDebug(
536 QtForOhos,
537 "%s: %s",
538 Q_FUNC_INFO,
539 surfaceConsumerContext->metaObject()->className());
540
541 auto *view = getWindowsViewOrNull(targetWindow);
542 if (view == nullptr)
543 return nullptr;
544
545 auto sharedSurfaceConsumer = QtOhos::moveToSharedPtr(std::move(surfaceConsumer));
546
547 auto *surface = view->surfaceOrNull();
548 if (surface != nullptr) {
549 QMetaObject::invokeMethod(
550 surfaceConsumerContext,
551 [weakSurfaceConsumer = std::weak_ptr<decltype(surfaceConsumer)>(sharedSurfaceConsumer),
552 targetWindow = QPointer<QWindow>(targetWindow)]() {
553 auto sharedSurfaceConsumer = weakSurfaceConsumer.lock();
554 if (!sharedSurfaceConsumer || targetWindow == nullptr)
555 return;
556
557 auto *view = getWindowsViewOrNull(targetWindow);
558 if (view == nullptr)
559 return;
560
561 auto *surface = view->surfaceOrNull();
562 (*sharedSurfaceConsumer)(
563 surface != nullptr
564 ? QOhosOptional<void *>(surface->nativeWindow())
565 : makeEmptyQOhosOptional());
566 },
567 Qt::QueuedConnection);
568 }
569
570 auto surfaceStatusChangedConnectionHandle = QObject::connect(
571 view, &QOhosView::surfaceStatusChanged, surfaceConsumerContext,
572 [view = QPointer<QOhosView>(view), sharedSurfaceConsumer]() {
573 if (view == nullptr)
574 return;
575 auto *surface = view->surfaceOrNull();
576 (*sharedSurfaceConsumer)(
577 surface != nullptr
578 ? QOhosOptional<void *>(surface->nativeWindow())
579 : makeEmptyQOhosOptional());
580 }, Qt::QueuedConnection);
581
582 if (!surfaceStatusChangedConnectionHandle) {
583 qCCritical(
584 QtForOhos,
585 "%s: Connection between ohos view and surface consumer context failed",
586 Q_FUNC_INFO);
587 return nullptr;
588 }
589
590 auto viewDestroyedConnectionHandle = QObject::connect(
591 view, &QObject::destroyed, surfaceConsumerContext,
592 [sharedSurfaceConsumer]() {
593 (*sharedSurfaceConsumer)(makeEmptyQOhosOptional());
594 },
595 Qt::QueuedConnection);
596
597 if (!viewDestroyedConnectionHandle) {
598 qCCritical(
599 QtForOhos,
600 "%s: Connecting view destroyed signal to surface consumer context failed",
601 Q_FUNC_INFO);
602 return nullptr;
603 }
604
605 return QtOhos::makeDestroyNotifier(
606 [surfaceStatusChangedConnectionHandle = std::move(surfaceStatusChangedConnectionHandle),
607 viewDestroyedConnectionHandle = std::move(viewDestroyedConnectionHandle)] () mutable {
608 QObject::disconnect(surfaceStatusChangedConnectionHandle);
609 QObject::disconnect(viewDestroyedConnectionHandle);
610 });
611}
612
614{
615 return m_propertiesStore.tryGetProperty<bool, &floatWindowTagProperty>().valueOr(false);
616}
617
619{
620 m_lastExposedRegion = QRegion();
621 QWindowSystemInterface::handleExposeEvent(window(), m_lastExposedRegion);
622}
623
625{
626 auto fullWindowExposedRegion = QRegion{QRect{{}, windowGeometry().size()}};
627 if (m_lastExposedRegion.intersected(fullWindowExposedRegion) != fullWindowExposedRegion) {
628 m_lastExposedRegion = fullWindowExposedRegion;
629 QWindowSystemInterface::handleExposeEvent(window(), fullWindowExposedRegion);
630 }
631}
632
634{
635 return ownedViewOrNull() != nullptr ? ownedViewOrNull()->makeSnapshot() : QPixmap();
636}
637
639{
640 if (m_displayId != displayId) {
641 m_displayId = displayId;
642
643 qCWarning(QtForOhos)
644 << "Screen changed - window:" << window()
645 << "displayId:" << (displayId.hasValue()
646 ? QString::number(displayId.value().value())
647 : QString::fromUtf8("<NO DISPLAY>"));
648
649 QOhosPlatformScreen *screen = m_displayId.hasValue()
650 ? QOhosPlatformIntegration::instance()
651 ->screenManager()->platformScreenForDisplayIdOrNull(m_displayId.value())
652 : nullptr;
653
654 QWindowSystemInterface::handleWindowScreenChanged(
655 window(),
656 screen != nullptr
657 ? screen->screen()
658 : nullptr);
659 }
660}
661
662void QOhosPlatformWindow::setWindowGeometryFromOhos(const QRect &nativeWindowDrawGeometry)
663{
664 if (nativeWindowDrawGeometry == m_lastReportedGeometryFromSystem && nativeWindowDrawGeometry == windowGeometry())
665 return;
666
667 auto optOldGeometry = std::exchange(m_lastReportedGeometryFromSystem, nativeWindowDrawGeometry);
668 if (optOldGeometry.hasValue()) {
669 qCDebug(QtForOhos) << "window:" << window() << "geometry change from:"
670 << optOldGeometry.value() << "to:" << nativeWindowDrawGeometry;
671 }
672 QWindowSystemInterface::handleGeometryChange(window(), nativeWindowDrawGeometry);
673 QWindowSystemInterface::handleExposeEvent(window(), QRect(QPoint(), nativeWindowDrawGeometry.size()));
674}
675
681
683{
684 if (active) {
685 auto *ohosInputContext = qobject_cast<QOhosInputContext *>(QOhosPlatformIntegration::instance()->inputContext());
686 if (ohosInputContext != nullptr) {
687 ohosInputContext->setLastInputTypeToTriggerSoftKeyboard(QOhosInputContext::RequestKeyboardReason::NONE);
688 }
689 } else {
690 if (QOhosPlatformIntegration::instance()->inputContext()->isInputPanelVisible())
691 QOhosPlatformIntegration::instance()->inputContext()->hideInputPanel();
692 }
693}
694
698
702
704{
705 return QOhosPropertiesProvider(m_propertiesStore);
706}
707
709{
710 qCDebug(QtForOhos) << Q_FUNC_INFO << "window:" << window() << "grab:" << grab;
711
713 if (grab)
714 inputHandler->grabMouse(window());
715 else
716 inputHandler->stopAnyMouseGrab();
717
718 return true;
719}
720
722{
723 qCDebug(QtForOhos) << Q_FUNC_INFO << "window:" << window() << "grab:" << grab;
724
726 if (grab)
727 inputHandler->grabKeyboard(window());
728 else
729 inputHandler->stopAnyKeyboardGrab();
730
731 return true;
732}
733
735{
736 auto platformWindowFlags = QOhosPlatformWindow::platformWindowFlagsForQWindow(window());
737 return !platformWindowFlags.testFlag(Qt::WindowDoesNotAcceptFocus);
738}
739
741{
742 auto platformWindowFlags = QOhosPlatformWindow::platformWindowFlagsForQWindow(window());
743 return !platformWindowFlags.testFlag(Qt::WindowTransparentForInput);
744}
745
747{
748 switch (event->type()) {
749 case QEvent::ApplicationPaletteChange:
750 if (auto *ohosView = ownedViewOrNull())
752 break;
753 case QEvent::DynamicPropertyChange: {
754 auto propertyName = static_cast<QDynamicPropertyChangeEvent *>(event)->propertyName();
755 m_propertiesStore.notifyPropertyWrite(propertyName);
756 break;
757 }
758 case QEvent::Hide:
759 if (isWindowBeingClosedOrDestroyed(window())) {
760 auto *ohosView = ownedViewOrNull();
761 if (ohosView && ohosView->viewType() == QOhosView::ViewType::MainWindow)
762 ohosView->setNativeNodeVisibility(false);
763 }
764 break;
765 default: break;
766 }
767
768 return QPlatformWindow::windowEvent(event);
769}
770
772{
773 QWindowPrivate *windowPriv = qt_window_private(window);
774 return windowPriv && (windowPriv->inClose || windowPriv->visibilityOnDestroy);
775}
776
777QT_END_NAMESPACE
std::enable_if_t< qohosplugincore_h_detail::isQOhosOptional< QOhosInvokeResult< Func, T > >, QOhosInvokeResult< Func, T > > andThen(Func &&func) const
QOhosScreenManager * screenManager() const
static QOhosPlatformIntegration * instance()
QOhosInputMethodEventHandler * inputMethodEventHandler() const
const QOhosDisplayInfo & displayInfo() 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(QOhosOptional< 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
QOhosOptional< QOhosDisplayInfo::JsDisplayId > tryTakeLastRequestedDisplayId()
static const QOhosPropertyDescriptor< int > windowSaturationProperty
static const QOhosPropertyDescriptor< int > windowContrastProperty
QOhosPropertiesProvider propertiesProvider()
static const QOhosPropertyDescriptor< bool > floatWindowTagProperty
bool isWindowBeingClosedOrDestroyed(QWindow *window) const
void setVisible(bool visible) override
Reimplemented in subclasses to show the surface if visible is true, and hide it if visible is false.
virtual void onWindowFlagsChanged(Qt::WindowFlags previousWindowFlags, Qt::WindowFlags currentWindowFlags)
static const QOhosPropertyDescriptor< NativeNodeRenderFitPolicy > nativeNodeRenderFitPolicyHintProperty
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
void setWindowGeometryFromOhos(const QRect &nativeWindowDrawGeometry)
ScreenChangeResult tryChangeScreen(QOhosPlatformScreen *screen)
QMargins frameMargins() const override
void initialize() override
Called as part of QWindow::create(), after constructing the window.
QPlatformScreen * screen() const override
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()
void setNativeNodeVisibility(bool visible)
QRect window() const
Returns the window rectangle.
Combined button and popup list for selecting options.
constexpr int defaultWindowHeight
QOhosView * getWindowsViewOrNull(QWindow *targetWindow)
constexpr int defaultWindowWidth
#define qGuiApp
QOhosOptional< void > makeEmptyQOhosOptional()