4#include <render/qohoswindowproxy.h>
6#include <QtCore/qcoreapplication.h>
7#include <QtCore/qset.h>
8#include <QtCore/private/qnapi_p.h>
9#include <QtCore/qscopeguard.h>
10#include <QtGui/private/qohosimageconversions_p.h>
11#include <QtGui/qguiapplication.h>
12#include <QtGui/qimage.h>
16#include <multimedia/image_framework/image/pixelmap_native.h>
17#include <qarkui/input.h>
18#include <qarkui/qarkuiutils.h>
19#include <qarkui/qxcomponentregistry.h>
20#include <qarkui/window.h>
21#include <qarkui/window_manager.h>
22#include <qohosdeviceinfo_p.h>
23#include <qohosdisplayinfo.h>
24#include <qohosjsutils.h>
25#include <qohospixelmapconversions.h>
26#include <qohosplugincore.h>
27#include <qohosqpaenums.h>
28#include <qohossettings.h>
29#include <qohosutils.h>
30#include <render/qohosbatchingrequestshandler.h>
31#include <render/qohosjswindowregistry.h>
32#include <render/qohoswindowproxydatafactory.h>
33#include <render/qxcomponent.h>
46 ohosWindowRect.get<QNapi::Number>(
"left"),
47 ohosWindowRect.get<QNapi::Number>(
"top"),
48 ohosWindowRect.get<QNapi::Number>(
"width"),
49 ohosWindowRect.get<QNapi::Number>(
"height"),
56 .visible = avoidAreaObject.get<QNapi::Boolean>(
"visible"),
57 .leftRect = ohosWindowRectToQRect(avoidAreaObject.get<QNapi::Object>(
"leftRect")),
58 .topRect = ohosWindowRectToQRect(avoidAreaObject.get<QNapi::Object>(
"topRect")),
59 .rightRect = ohosWindowRectToQRect(avoidAreaObject.get<QNapi::Object>(
"rightRect")),
60 .bottomRect = ohosWindowRectToQRect(avoidAreaObject.get<QNapi::Object>(
"bottomRect")),
69 case Qt::UpArrowCursor:
77 case Qt::SizeVerCursor:
79 case Qt::SizeHorCursor:
81 case Qt::SizeBDiagCursor:
83 case Qt::SizeFDiagCursor:
85 case Qt::SizeAllCursor:
90 case Qt::SplitVCursor:
92 case Qt::SplitHCursor:
94 case Qt::PointingHandCursor:
96 case Qt::ForbiddenCursor:
98 case Qt::WhatsThisCursor:
102 case Qt::OpenHandCursor:
104 case Qt::ClosedHandCursor:
106 case Qt::DragCopyCursor:
108 case Qt::DragMoveCursor:
110 case Qt::DragLinkCursor:
113 case Qt::BitmapCursor:
116 case Qt::CustomCursor:
126 auto propOrEmpty = QNapi::getOptionalPropOrEmpty<QNapi::Number>(object, propertyName);
127 return !propOrEmpty.IsEmpty()
128 ?
std::optional<
double>(propOrEmpty)
134 auto windowPropsObj = jsWindow.eval<QNapi::Object>(
"getWindowProperties()");
135 auto displayIdOrEmpty = QNapi::getOptionalPropOrEmpty<QNapi::Number>(windowPropsObj,
"displayId");
136 return QArkUi::WindowProperties {
137 .windowRect = ohosWindowRectToQRect(windowPropsObj.get<QNapi::Object>(
"windowRect")),
138 .drawableRect = ohosWindowRectToQRect(windowPropsObj.get<QNapi::Object>(
"drawableRect")),
139 .id = QArkUi::JsWindowId(windowPropsObj.get<QNapi::Number>(
"id")),
140 .displayId = !displayIdOrEmpty.IsEmpty()
141 ? std::optional(QOhosDisplayInfo::JsDisplayId{displayIdOrEmpty.DoubleValue()})
148 auto moveConfigurationObject = QNapi::makeObject(env);
149 if (moveConfiguration.displayId.has_value()) {
150 moveConfigurationObject.set(
151 "displayId", moveConfiguration.displayId.value().value());
153 return moveConfigurationObject;
156template<
typename ...Args>
158 std::function<
void(Args...)> QOhosWindowProxy::WindowCallbacks::*memberPtr,
161 auto weakQtWindowCallbacks = QtOhos::makeWeakPtr(qtWindowCallbacks);
163 return [memberPtr, weakQtWindowCallbacks](Args ...args) {
164 QtOhos::invokeInQtThread([memberPtr, weakQtWindowCallbacks, args...]() {
165 auto qtWindowCallbacks = weakQtWindowCallbacks.lock();
166 if (qtWindowCallbacks)
167 (*qtWindowCallbacks.*memberPtr)(args...);
174 std::function<
void(T)> QOhosWindowProxy::WindowCallbacks::*memberPtr,
177 auto weakQtWindowCallbacks = QtOhos::makeWeakPtr(qtWindowCallbacks);
179 return QtOhos::makeCompressingAsyncConsumer<T>(
180 [memberPtr, weakQtWindowCallbacks](T value) {
181 auto qtWindowCallbacks = weakQtWindowCallbacks.lock();
182 if (qtWindowCallbacks)
183 (*qtWindowCallbacks.*memberPtr)(value);
185 QtOhos::invokeInQtThread);
190 constexpr bool containsPolicyExcludeEdgeValue =
true;
192 auto drawableRectInScreenSpace =
193 windowProperties.drawableRect.translated(windowProperties.windowRect.topLeft());
194 return !drawableRectInScreenSpace.contains(point, containsPolicyExcludeEdgeValue);
200 case ::MOUSE_ACTION_MOVE:
201 return QEvent::NonClientAreaMouseMove;
202 case ::MOUSE_ACTION_BUTTON_DOWN:
203 return QEvent::NonClientAreaMouseButtonPress;
204 case ::MOUSE_ACTION_BUTTON_UP:
205 return QEvent::NonClientAreaMouseButtonRelease;
206 case ::MOUSE_ACTION_CANCEL:
207 case ::MOUSE_ACTION_AXIS_BEGIN:
208 case ::MOUSE_ACTION_AXIS_UPDATE:
209 case ::MOUSE_ACTION_AXIS_END:
218 case ::MOUSE_BUTTON_LEFT:
219 return Qt::LeftButton;
220 case ::MOUSE_BUTTON_MIDDLE:
221 return Qt::MiddleButton;
222 case ::MOUSE_BUTTON_RIGHT:
223 return Qt::RightButton;
224 case ::MOUSE_BUTTON_FORWARD:
225 return Qt::ForwardButton;
226 case ::MOUSE_BUTTON_BACK:
227 return Qt::BackButton;
228 case ::MOUSE_BUTTON_NONE:
237 case ::TOUCH_ACTION_MOVE:
238 return QEvent::NonClientAreaMouseMove;
239 case ::TOUCH_ACTION_DOWN:
240 return QEvent::NonClientAreaMouseButtonPress;
241 case ::TOUCH_ACTION_UP:
242 return QEvent::NonClientAreaMouseButtonRelease;
243 case ::TOUCH_ACTION_CANCEL:
249template<
typename EnumsContainer>
253 for (
auto enumValue : enums) {
256 output +=
std::to_string(
static_cast<std::underlying_type_t<
decltype(enumValue)>>(enumValue));
263 return ability.eval<QNapi::Boolean>(
"context.isTerminating()");
270 return QtOhos::JsWindowsTracker::isWindowClosing(jsWindow) || (boundToAbility && isAbilityTerminating(abilityPeer->qAbility()));
275const QOhosWindowProxy::EventHandlerDescriptor QOhosWindowProxy::eventHandlerDescriptors[] = {
277 .eventName =
"avoidAreaChange",
278 .eventHandler = &QOhosWindowProxy::JsScopeData::handleAvoidAreaChangeCallback,
279 .eventHandlerFlags = {},
282 .eventName =
"touchOutside",
283 .eventHandler = &QOhosWindowProxy::JsScopeData::handleWindowTouchOutsideCallback,
284 .eventHandlerFlags = {},
287 .eventName =
"windowEvent",
288 .eventHandler = &QOhosWindowProxy::JsScopeData::handleWindowEventCallback,
289 .eventHandlerFlags = EventHandlerFlagBits::allowCallWhenAbilityIsTerminating,
292 .eventName =
"windowRectChange",
293 .eventHandler = &QOhosWindowProxy::JsScopeData::handleWindowRectChangeCallback,
294 .eventHandlerFlags = {},
297 .eventName =
"rectChangeInGlobalDisplay",
298 .eventHandler = &QOhosWindowProxy::JsScopeData::handleWindowRectChangeInGlobalDisplayCallback,
299 .eventHandlerFlags = {},
302 .eventName =
"windowStatusChange",
303 .eventHandler = &QOhosWindowProxy::JsScopeData::handleWindowStatusCallback,
304 .eventHandlerFlags = {},
307 .eventName =
"windowVisibilityChange",
308 .eventHandler = &QOhosWindowProxy::JsScopeData::handleWindowVisibilityCallback,
309 .eventHandlerFlags = {},
312 .eventName =
"displayIdChange",
313 .eventHandler = &QOhosWindowProxy::JsScopeData::handleWindowDisplayIdChangeCallback,
314 .eventHandlerFlags = EventHandlerFlagBits::allowEventHandlerRegistrationFailure,
318QOhosWindowProxy::QOhosWindowProxy(
319 const std::function<
void(
QtOhos::
JsState &, QOhosConsumer<QtOhos::JsState &, QOhosWindowProxyData>)> &makeWindowProxyDataInJsThread)
321 auto jsThreadInitResult = QOhosJsThreadGateway::evalWithPromise<JsThreadInitResult>(
322 [&](QOhosJsState &jsState, QOhosTaskPromise<JsThreadInitResult> evalPromise) {
323 auto sharedEvalPromise = QtOhos::moveToSharedPtr(std::move(evalPromise).makeChained(Q_FUNC_INFO));
324 makeWindowProxyDataInJsThread(
325 QtOhos::JsState::castFrom(jsState),
326 [sharedEvalPromise,
this](QtOhos::JsState &jsState, QOhosWindowProxyData windowProxyData) {
327 (*sharedEvalPromise)(initInJsThread(jsState, std::move(windowProxyData)));
331 m_windowProxyType = jsThreadInitResult.windowProxyType;
332 m_nodeXComponent = std::move(jsThreadInitResult.nodeXComponent);
333 m_qAbilityInstanceId =
std::move(jsThreadInitResult.qAbilityInstanceId);
334 m_jsWindowRegistrationHandle = std::move(jsThreadInitResult.jsWindowRegistrationHandle);
337QOhosWindowProxy::JsThreadInitResult QOhosWindowProxy::initInJsThread(
340 *m_jsScopeData = JsScopeData(
341 windowProxyData.windowProxyType,
342 std::move(windowProxyData.jsWindow),
343 std::move(windowProxyData.jsKeepAliveData),
344 std::move(windowProxyData.qAbilityPeer),
345 windowProxyData.owningQWindowRef);
347 std::vector<std::shared_ptr<
void>> eventListenersHandles;
348 for (
const auto &eventHandlerDescriptor : eventHandlerDescriptors) {
349 eventListenersHandles.push_back(
350 m_jsScopeData->registerEventListener(
351 eventHandlerDescriptor.eventName, eventHandlerDescriptor.eventHandler,
352 eventHandlerDescriptor.eventHandlerFlags));
354 m_jsScopeData->m_eventListenersHandle = QtOhos::moveToSharedPtr(std::move(eventListenersHandles));
356 return JsThreadInitResult {
357 .windowProxyType = windowProxyData.windowProxyType,
358 .nodeXComponent = std::move(windowProxyData.nodeXComponent),
359 .qAbilityInstanceId = m_jsScopeData->jsWindowRef->owningQAbilityInstanceId(),
360 .jsWindowRegistrationHandle = QOhosJsWindowRegistry::instance(jsState).registerJsWindow(m_jsScopeData->jsWindowRef),
372 m_jsWindowRegistrationHandle.reset();
373 m_subWindowCloseRegistrationHandle.reset();
378 QOhosJsThreadGateway::invokeAndWaitForContinue(
379 [&](QOhosJsState &, QOhosTaskPromise<> taskPromise) {
380 if (m_jsScopeData->isWindowClosing()) {
384 auto optQUiAbilityPeer
385 = QtOhos::QUiAbilityPeer::tryCastFromQAbilityPeerOrNull(m_jsScopeData->qAbilityPeer);
386 if (!optQUiAbilityPeer) {
390 auto promise = optQUiAbilityPeer->windowStage().evalToPromiseOrRejectOnThrow(
391 "removeStartingWindow()");
393 .onCatch(QtOhos::makeErrorLoggingJsCallback(Q_FUNC_INFO))
394 .onFinally(std::move(taskPromise).makeChained(Q_FUNC_INFO));
402 auto displayIdValue = optMoveToTargetDisplay.value_or(QOhosDisplayInfo::JsDisplayId(-1)).value();
403 qOhosPrintfDebug(
"%s: %d,%d,%f", Q_FUNC_INFO, point.x(), point.y(), displayIdValue);
405 QOhosJsThreadGateway::invokeAndWaitForContinue(
406 [&](QOhosJsState &jsState, QOhosTaskPromise<> taskPromise) {
407 if (m_jsScopeData->isWindowClosing()) {
412 const auto primaryJsDisplayId = QOhosDisplayInfo::JsDisplayId(0);
414 auto targetDisplayId = optMoveToTargetDisplay.has_value()
415 ? optMoveToTargetDisplay.value()
416 : getWindowProperties().displayId.value_or(primaryJsDisplayId);
418 auto optDisplayInfo = qTransform(
419 QOhosDisplayInfo::tryGetDisplayById(jsState, targetDisplayId),
420 [&](
auto displayObject) {
421 return QOhosDisplayInfo::makeFromOhosDisplayObject(jsState, displayObject);
424 auto optIsDisplayMainOrExtended = qTransform(
426 [](
const QOhosDisplayInfo &displayInfo) {
427 return displayInfo.isDisplayMainOrExtended();
430 bool isDisplayMainOrExtended;
431 if (optIsDisplayMainOrExtended.has_value()) {
432 isDisplayMainOrExtended = optIsDisplayMainOrExtended.value();
435 "%s: no display source mode detected. Assumming main/extended screen", Q_FUNC_INFO);
436 isDisplayMainOrExtended =
true;
439 QNapi::Promise promise;
440 if (!isDisplayMainOrExtended) {
441 auto optDisplayOffset = qAndThen(
443 [](
const QOhosDisplayInfo &displayInfo) {
444 return displayInfo.topLeftOffsetPixels;
447 const QPoint defaultDisplayOffset(0, 0);
448 auto targetCoordinates = point - optDisplayOffset.value_or(defaultDisplayOffset);
450 if (!optMoveToTargetDisplay.has_value())
451 qOhosPrintfWarning(
"%s: trying to move window to not valid target display", Q_FUNC_INFO);
453 auto moveConfigurationObject = toNapiObject(
456 .displayId = optMoveToTargetDisplay,
459 promise = m_jsScopeData->jsWindowRef->evalToPromiseOrRejectOnThrow(
460 "moveWindowToGlobal(*)", {targetCoordinates.x(), targetCoordinates.y(), moveConfigurationObject});
462 promise = m_jsScopeData->jsWindowRef->evalToPromiseOrRejectOnThrow(
463 "moveWindowToGlobalDisplay(*)", {point.x(), point.y()});
467 .onCatch(QtOhos::makeErrorLoggingJsCallback(Q_FUNC_INFO))
468 .onFinally(std::move(taskPromise));
472void QOhosWindowProxy::
setSize(
const QSize &size)
474 qOhosPrintfDebug(
"%s: %d,%d", Q_FUNC_INFO, size.width(), size.height());
476 QOhosJsThreadGateway::invokeAndWaitForContinue(
477 [&](QOhosJsState &, QOhosTaskPromise<> taskPromise) {
478 if (m_jsScopeData->isWindowClosing()) {
483 const auto currentSize = getWindowPropertiesFromJsWindow(
484 m_jsScopeData->jsWindowRef->jsObject()).windowRect.size();
485 if (currentSize == size) {
490 auto promise = m_jsScopeData->jsWindowRef->evalToPromiseOrRejectOnThrow(
491 "resizeAsync(*)", {size.width(), size.height()});
493 .onCatch(QtOhos::makeErrorLoggingJsCallback(Q_FUNC_INFO))
494 .onFinally(std::move(taskPromise).makeChained(Q_FUNC_INFO));
501 qCDebug(QtForOhos) << Q_FUNC_INFO << color;
503 QOhosJsThreadGateway::runAndWait([&](QOhosJsState &) {
504 if (m_jsScopeData->isWindowClosing())
506 m_jsScopeData->jsWindowRef->eval(
"setWindowBackgroundColor(*)", {color.name(QColor::HexArgb).toStdString()});
511void QOhosWindowProxy::
setCustomCursor(
const QImage &customCursorImage,
const QPoint &hotSpot)
513 const auto maxOhosCustomCursorSize = QSize(256, 256);
514 const auto customCursorSize = customCursorImage.size();
515 if (customCursorSize.width() > maxOhosCustomCursorSize.width()
516 || customCursorSize.height() > maxOhosCustomCursorSize.height()) {
518 "%s: can't set %dx%d custom cursor, OHOS max custom cursor size is %dx%d",
519 Q_FUNC_INFO, customCursorSize.width(), customCursorSize.height(),
520 maxOhosCustomCursorSize.width(), maxOhosCustomCursorSize.height());
524 auto convertedImage = customCursorImage.convertToFormat(QImage::Format_RGBA8888);
525 QOhosJsThreadGateway::invokeAndWaitForContinue([&](QOhosJsState &jsState, QOhosTaskPromise<> taskPromise) {
526 if (m_jsScopeData->isWindowClosing()) {
530 auto windowId = m_jsScopeData->jsWindowRef->jsObject().get<QNapi::Number>(
"getWindowProperties().id");
532 auto jsCursor = QNapi::makeObject(
535 {
"pixelMap", makeOhosNapiPixelMapFromQImage(jsState, convertedImage)},
536 {
"focusX", hotSpot.x()},
537 {
"focusY", hotSpot.y()},
540 auto jsCursorConfig = QNapi::makeObject(
543 {
"followSystem",
false},
546 jsState.evalToPromiseOrRejectOnThrow(
547 "@ohos.multimodalInput.pointer.setCustomCursor(*)", {windowId, jsCursor, jsCursorConfig})
548 .onCatch(QtOhos::makeErrorLoggingJsCallback(
"setCustomCursor()"))
549 .onFinally(std::move(taskPromise).makeChained(Q_FUNC_INFO));
556 QOhosJsThreadGateway::runAndWait([&](QOhosJsState &jsState) {
557 if (m_jsScopeData->isWindowClosing())
559 auto windowId = m_jsScopeData->jsWindowRef->jsObject().get<QNapi::Number>(
"getWindowProperties().id");
562 "@ohos.multimodalInput.pointer.setPointerStyleSync(*)",
563 {windowId, jsState.mapOhosEnumToJs(convertToOhosCursor(cursor.shape()))});
570 return QOhosJsThreadGateway::eval(
571 [&](QOhosJsState &) {
572 if (m_jsScopeData->isWindowClosing())
573 return QArkUi::WindowProperties {};
574 return getWindowPropertiesFromJsWindow(m_jsScopeData->jsWindowRef->jsObject());
583 QOhosJsThreadGateway::runAndWait([&](QOhosJsState &) {
584 m_jsScopeData->windowCallbackReceiver = QtOhos::moveToSharedPtr(WindowCallbacks {
585 .onWindowEvent = makeQtThreadWindowCallbackDelegate(&WindowCallbacks::onWindowEvent, sharedWindowCallbackReceiver),
586 .onWindowStatusChange = makeQtThreadWindowCallbackDelegate(&WindowCallbacks::onWindowStatusChange, sharedWindowCallbackReceiver),
587 .onWindowVisibilityChange = makeQtThreadWindowCallbackDelegate(&WindowCallbacks::onWindowVisibilityChange, sharedWindowCallbackReceiver),
588 .onTouchOutside = makeQtThreadWindowCallbackDelegate(&WindowCallbacks::onTouchOutside, sharedWindowCallbackReceiver),
589 .onAvoidAreaChange = makeQtThreadWindowCallbackDelegate(&WindowCallbacks::onAvoidAreaChange, sharedWindowCallbackReceiver),
590 .onWindowRectChange = makeCompressingQtThreadWindowCallbackDelegate(&WindowCallbacks::onWindowRectChange, sharedWindowCallbackReceiver),
591 .onWindowRectChangeInGlobalDisplay = makeCompressingQtThreadWindowCallbackDelegate(&WindowCallbacks::onWindowRectChangeInGlobalDisplay, sharedWindowCallbackReceiver),
592 .onWindowDisplayIdChange = makeQtThreadWindowCallbackDelegate(&WindowCallbacks::onWindowDisplayIdChange, sharedWindowCallbackReceiver),
597 m_qtWindowCallbacksReceiverHandle = sharedWindowCallbackReceiver;
601 QObject *contextObject, QOhosConsumer<std::vector<NonClientAreaMouseEvent>> mouseEventBatchConsumer)
603 auto qtConsumer = QtOhos::moveToSharedPtr(std::move(mouseEventBatchConsumer));
604 auto weakQtConsumer = QtOhos::makeWeakPtr(qtConsumer);
607 QtOhos::QObjectThreadSafeRef(contextObject),
608 [weakQtConsumer](std::vector<NonClientAreaMouseEvent> &&batch) {
609 auto qtConsumer = weakQtConsumer.lock();
611 (*qtConsumer)(
std::move(batch));
614 QOhosJsThreadGateway::runAndWait([&](QOhosJsState &) {
615 m_jsScopeData->nonClientAreaEventsDispatcher->mouseEventsConsumer = std::move(jsConsumer);
619 m_qtNonClientAreaMouseWindowCallbackReceiverHandle = qtConsumer;
623 QObject *contextObject, QOhosConsumer<std::vector<NonClientAreaTouchEvent>> touchEventBatchConsumer)
625 auto qtConsumer = QtOhos::moveToSharedPtr(std::move(touchEventBatchConsumer));
626 auto weakQtConsumer = QtOhos::makeWeakPtr(qtConsumer);
629 QtOhos::QObjectThreadSafeRef(contextObject),
630 [weakQtConsumer](std::vector<NonClientAreaTouchEvent> &&batch) {
631 auto qtConsumer = weakQtConsumer.lock();
633 (*qtConsumer)(
std::move(batch));
636 QOhosJsThreadGateway::runAndWait([&](QOhosJsState &) {
637 m_jsScopeData->nonClientAreaEventsDispatcher->touchEventsConsumer = std::move(jsConsumer);
641 m_qtNonClientAreaTouchWindowCallbackReceiverHandle = qtConsumer;
651 qCDebug(QtForOhos,
"%s", Q_FUNC_INFO);
652 QOhosJsThreadGateway::invokeAndWaitForContinue([&](QOhosJsState &, QOhosTaskPromise<> taskPromise) {
653 if (m_jsScopeData->isWindowClosing()) {
657 auto promise = m_jsScopeData->jsWindowRef->evalToPromiseOrRejectOnThrow(
"raiseToAppTop()");
659 .onCatch(QtOhos::makeErrorLoggingJsCallback(Q_FUNC_INFO))
660 .onFinally(std::move(taskPromise).makeChained(Q_FUNC_INFO));
667 qCDebug(QtForOhos,
"%s", Q_FUNC_INFO);
668 QOhosJsThreadGateway::invokeAndWaitForContinue([&](QOhosJsState &jsState, QOhosTaskPromise<> taskPromise) {
669 if (m_jsScopeData->isWindowClosing()) {
674 std::vector<std::pair<std::string, QNapi::ValueWrapper>> jsOptionsProps;
676 if (options.focusOnShow.has_value())
677 jsOptionsProps.emplace_back(
"focusOnShow", options.focusOnShow.value());
679 std::vector<QNapi::ValueWrapper> showWindowArgs;
680 constexpr bool brokenHandlingOfEmptyOptionsParamInOhos =
true;
681 if (!(jsOptionsProps.empty() && brokenHandlingOfEmptyOptionsParamInOhos))
682 showWindowArgs.push_back(QNapi::makeObject(jsState.env(), jsOptionsProps));
684 auto promise = m_jsScopeData->jsWindowRef->evalToPromiseOrRejectOnThrow(
"showWindow(*)", showWindowArgs);
686 .onCatch(QtOhos::makeErrorLoggingJsCallback(Q_FUNC_INFO))
687 .onFinally(std::move(taskPromise).makeChained(Q_FUNC_INFO));
694 qCDebug(QtForOhos,
"%s", Q_FUNC_INFO);
695 QOhosJsThreadGateway::invokeAndWaitForContinue([&](QOhosJsState &, QOhosTaskPromise<> taskPromise) {
696 if (m_jsScopeData->isWindowClosing()) {
701 m_jsScopeData->jsWindowRef->evalToPromiseOrRejectOnThrow(
"recover()")
702 .onCatch(QtOhos::makeErrorLoggingJsCallback(
"recover()"))
703 .onFinally(std::move(taskPromise).makeChained(Q_FUNC_INFO));
710 qCDebug(QtForOhos,
"%s", Q_FUNC_INFO);
711 QOhosJsThreadGateway::invokeAndWaitForContinue([&](QOhosJsState &, QOhosTaskPromise<> taskPromise) {
712 if (m_jsScopeData->isWindowClosing()) {
716 m_jsScopeData->jsWindowRef->evalToPromiseOrRejectOnThrow(
"restore()")
717 .onCatch(QtOhos::makeErrorLoggingJsCallback(Q_FUNC_INFO))
718 .onFinally(std::move(taskPromise).makeChained(Q_FUNC_INFO));
725 qCDebug(QtForOhos,
"%s", Q_FUNC_INFO);
726 QOhosJsThreadGateway::invokeAndWaitForContinue([&](QOhosJsState &, QOhosTaskPromise<> taskPromise) {
727 if (m_jsScopeData->isWindowClosing()) {
731 m_jsScopeData->jsWindowRef->evalToPromiseOrRejectOnThrow(
"minimize()")
732 .onCatch(QtOhos::makeErrorLoggingJsCallback(Q_FUNC_INFO))
733 .onFinally(std::move(taskPromise).makeChained(Q_FUNC_INFO));
740 qCDebug(QtForOhos,
"%s", Q_FUNC_INFO);
743 qCWarning(QtForOhos(),
"%s: Maximize is currently supported only on main windows", Q_FUNC_INFO);
747 QOhosJsThreadGateway::invokeAndWaitForContinue(
748 [&](QOhosJsState &jsState, QOhosTaskPromise<> taskPromise) {
749 if (m_jsScopeData->isWindowClosing()) {
754 m_jsScopeData->jsWindowRef->evalToPromiseOrRejectOnThrow(
755 "maximize(*)", {jsState.mapOhosEnumToJs(maximizePresentation)})
756 .onCatch(QtOhos::makeErrorLoggingJsCallback(
"maximize()"))
757 .onFinally(std::move(taskPromise).makeChained(Q_FUNC_INFO));
764 qCDebug(QtForOhos,
"%s: %s", Q_FUNC_INFO, isLayoutFullScreen ?
"true" :
"false");
765 QOhosJsThreadGateway::invokeAndWaitForContinue(
766 [&](QOhosJsState &, QOhosTaskPromise<> taskPromise) {
767 if (m_jsScopeData->isWindowClosing()) {
771 m_jsScopeData->jsWindowRef->evalToPromiseOrRejectOnThrow(
772 "setWindowLayoutFullScreen(*)", {isLayoutFullScreen})
773 .onCatch(QtOhos::makeErrorLoggingJsCallback(
"setWindowLayoutFullScreen()"))
774 .onFinally(std::move(taskPromise).makeChained(Q_FUNC_INFO));
781 qCDebug(QtForOhos) << Q_FUNC_INFO << names;
782 QOhosJsThreadGateway::invokeAndWaitForContinue(
783 [&](QOhosJsState &jsState, QOhosTaskPromise<> taskPromise) {
784 if (m_jsScopeData->isWindowClosing()) {
788 m_jsScopeData->jsWindowRef->evalToPromiseOrRejectOnThrow(
789 "setWindowSystemBarEnable(*)",
790 {QNapi::makeArray(jsState.env(), names, std::mem_fn(&QString::toStdString))})
791 .onCatch(QtOhos::makeErrorLoggingJsCallback(
"setWindowSystemBarEnable()"))
792 .onFinally(std::move(taskPromise).makeChained(Q_FUNC_INFO));
799 qCDebug(QtForOhos,
"%s", Q_FUNC_INFO);
801 QOhosJsThreadGateway::invokeAndWaitForContinue([&](QOhosJsState &, QOhosTaskPromise<> taskPromise) {
802 if (m_jsScopeData->isWindowClosing()) {
807 m_jsScopeData->qAbilityPeer->qAbility().evalToPromiseOrRejectOnThrow(
"context.showAbility()")
808 .onCatch(QtOhos::makeErrorLoggingJsCallback(
"showAbility()"))
809 .onFinally(std::move(taskPromise).makeChained(Q_FUNC_INFO));
816 qCDebug(QtForOhos,
"%s", Q_FUNC_INFO);
818 return QOhosJsThreadGateway::evalWithPromise<
bool>([&](QOhosJsState &, QOhosTaskPromise<
bool> evalPromise) {
819 if (m_jsScopeData->isWindowClosing()) {
824 auto thenCatchPromises = std::move(evalPromise).makeThenCatchBranches(Q_FUNC_INFO);
825 m_jsScopeData->qAbilityPeer->qAbility().evalToPromiseOrRejectOnThrow(
"context.hideAbility()")
827 [thenPromise = std::move(thenCatchPromises.first)](
const QtOhos::CallbackInfo &) {
831 [catchPromise = std::move(thenCatchPromises.second)](
const QtOhos::CallbackInfo &cbInfo) {
832 QtOhos::logJsCallbackError(cbInfo,
"got error from hideAbility()");
841 return QOhosJsThreadGateway::eval(
842 [&](QOhosJsState &) {
843 if (m_jsScopeData->isWindowClosing())
845 return m_jsScopeData->jsWindowRef->eval<QNapi::Boolean>(
"getImmersiveModeEnabledState()").Value();
852 qCDebug(QtForOhos,
"%s: %s", Q_FUNC_INFO, privacyMode ?
"true" :
"false");
854 QOhosJsThreadGateway::invokeAndWaitForContinue([&](QOhosJsState &, QOhosTaskPromise<> taskPromise) {
855 if (m_jsScopeData->isWindowClosing()) {
860 m_jsScopeData->jsWindowRef->evalToPromiseOrRejectOnThrow(
"setWindowPrivacyMode(*)", {privacyMode})
861 .onCatch(QtOhos::makeErrorLoggingJsCallback(
"setPrivacyMode()"))
862 .onFinally(std::move(taskPromise).makeChained(Q_FUNC_INFO));
869 qCDebug(QtForOhos,
"%s: %s", Q_FUNC_INFO, focusable ?
"true" :
"false");
870 QOhosJsThreadGateway::invokeAndWaitForContinue([&](QOhosJsState &, QOhosTaskPromise<> taskPromise) {
871 if (m_jsScopeData->isWindowClosing()) {
876 m_jsScopeData->jsWindowRef->evalToPromiseOrRejectOnThrow(
"setWindowFocusable(*)", {focusable})
877 .onCatch(QtOhos::makeErrorLoggingJsCallback(
"setWindowFocusable()"))
878 .onFinally(std::move(taskPromise).makeChained(Q_FUNC_INFO));
885 qCDebug(QtForOhos,
"%s: %s", Q_FUNC_INFO, touchable ?
"true" :
"false");
886 QOhosJsThreadGateway::invokeAndWaitForContinue([&](QOhosJsState &, QOhosTaskPromise<> taskPromise) {
887 if (m_jsScopeData->isWindowClosing()) {
892 m_jsScopeData->jsWindowRef->evalToPromiseOrRejectOnThrow(
"setWindowTouchable(*)", {touchable})
893 .onCatch(QtOhos::makeErrorLoggingJsCallback(
"setWindowTouchable()"))
894 .onFinally(std::move(taskPromise).makeChained(Q_FUNC_INFO));
902 QtForOhos,
"%s: (%d x %d)-(%d x %d)", Q_FUNC_INFO, minSize.width(), minSize.height(),
903 maxSize.width(), maxSize.height());
904 QOhosJsThreadGateway::invokeAndWaitForContinue(
905 [&](QOhosJsState &jsState, QOhosTaskPromise<> taskPromise) {
906 if (m_jsScopeData->isWindowClosing()) {
910 auto windowLimits = QNapi::makeObject(
913 {
"minWidth", minSize.width()},
914 {
"minHeight", minSize.height()},
915 {
"maxWidth", maxSize.width()},
916 {
"maxHeight", maxSize.height()},
919 std::vector<QNapi::ValueWrapper> setWindowLimitsArgs = {windowLimits};
920 if (QOhosDeviceInfo::is2in1()) {
921 constexpr bool isForcible =
true;
922 setWindowLimitsArgs.push_back(isForcible);
924 m_jsScopeData->jsWindowRef->evalToPromiseOrRejectOnThrow(
925 "setWindowLimits(*)", setWindowLimitsArgs)
926 .onCatch(QtOhos::makeErrorLoggingJsCallback(
"setWindowLimits()"))
927 .onFinally(std::move(taskPromise).makeChained(Q_FUNC_INFO));
934 qCDebug(QtForOhos,
"%s", Q_FUNC_INFO);
935 return QOhosJsThreadGateway::eval(
936 [&](QOhosJsState &) {
937 if (m_jsScopeData->isWindowClosing())
938 return WindowLimits {};
939 auto windowLimitsObject = m_jsScopeData->jsWindowRef->eval<QNapi::Object>(
"getWindowLimits()");
940 return WindowLimits {
941 .minWidth = getOptionalNumberPropAsOptionalDouble(windowLimitsObject,
"minWidth"),
942 .minHeight = getOptionalNumberPropAsOptionalDouble(windowLimitsObject,
"minHeight"),
943 .maxWidth = getOptionalNumberPropAsOptionalDouble(windowLimitsObject,
"maxWidth"),
944 .maxHeight = getOptionalNumberPropAsOptionalDouble(windowLimitsObject,
"maxHeight"),
952 qCDebug(QtForOhos,
"%s: %d", Q_FUNC_INFO, avoidAreaType);
953 return QOhosJsThreadGateway::eval(
954 [&](QOhosJsState &jsState) {
955 if (m_jsScopeData->isWindowClosing())
957 auto avoidAreaObject = m_jsScopeData->jsWindowRef->eval<QNapi::Object>(
958 "getWindowAvoidArea(*)", {jsState.mapOhosEnumToJs(avoidAreaType)});
959 return mapAvoidAreaFromJs(avoidAreaObject);
965 const WindowMask &windowMask,
const std::optional<QSize> &ohosMaskSizeOverride)
970 auto ohosMaskSize = ohosMaskSizeOverride.has_value()
971 ? ohosMaskSizeOverride.value()
974 if (ohosMaskSize.isEmpty()) {
975 const auto *maskSrcSizeMsg = ohosMaskSizeOverride.has_value()
976 ?
"overridden mask source"
978 if (ohosMaskSizeOverride.has_value()) {
980 "%s failed - %s size is 0x0", maskSrcSizeMsg,
981 "QOhosWindowProxy::setWindowMask");
986 QOhosJsThreadGateway::invokeAndWaitForContinue([&](QOhosJsState &jsState, QOhosTaskPromise<> taskPromise) {
987 if (m_jsScopeData->isWindowClosing()) {
991 auto *env = jsState.env();
993 QNapi::Array maskRowsArray = QNapi::Array::New(env, ohosMaskSize.height());
994 const int defaultValue = windowMask.windowMaskRegion.isEmpty() ? 1 : 0;
996 for (
int rowIndex = 0; rowIndex < ohosMaskSize.height(); ++rowIndex) {
997 auto arr = QNapi::Array::New(env, ohosMaskSize.width());
998 arr.fill(defaultValue);
999 maskRowsArray[rowIndex] = arr;
1002 auto valueToSet = QNapi::Number::New(env, 1);
1003 for (
const auto &rect: windowMask.windowMaskRegion) {
1004 auto top = qBound(0, rect.top(), ohosMaskSize.height() - 1);
1005 auto bottom = qBound(0, rect.bottom(), ohosMaskSize.height() - 1);
1006 auto left = qBound(0, rect.left(), ohosMaskSize.width() - 1);
1007 auto right = qBound(0, rect.right(), ohosMaskSize.width() - 1);
1009 for (
auto rowIndex = top; rowIndex <= bottom; ++rowIndex) {
1010 auto row = maskRowsArray.Get(rowIndex).As<QNapi::Array>();
1011 for (
auto columnIndex = left; columnIndex <= right; ++columnIndex)
1012 row[columnIndex] = valueToSet;
1016 m_jsScopeData->jsWindowRef->evalToPromiseOrRejectOnThrow(
"setWindowMask(*)", {maskRowsArray})
1017 .onCatch(QtOhos::makeErrorLoggingJsCallback(
"setWindowMask()"))
1018 .onFinally(std::move(taskPromise).makeChained(Q_FUNC_INFO));
1028 QOhosJsThreadGateway::invokeAndWaitForContinue(
1029 [&](QOhosJsState &, QOhosTaskPromise<> taskPromise) {
1030 if (m_jsScopeData->isWindowClosing()) {
1034 m_jsScopeData->jsWindowRef->evalToPromiseOrRejectOnThrow(
"setSubWindowModal(*)", {
false})
1035 .onCatch(QtOhos::makeErrorLoggingJsCallback(
"setSubWindowModal()"))
1036 .onFinally(std::move(taskPromise).makeChained(Q_FUNC_INFO));
1048 "%s: APPLICATION_MODALITY option can be used only on devices in the freeform window state - skipping",
1053 QOhosJsThreadGateway::invokeAndWaitForContinue(
1054 [&](QOhosJsState &jsState, QOhosTaskPromise<> taskPromise) {
1055 if (m_jsScopeData->isWindowClosing()) {
1059 m_jsScopeData->jsWindowRef->evalToPromiseOrRejectOnThrow(
1060 "setSubWindowModal(*)", {
true, jsState.mapOhosEnumToJs(modalityType)})
1061 .onCatch(QtOhos::makeErrorLoggingJsCallback(
"setSubWindowModal()"))
1062 .onFinally(std::move(taskPromise).makeChained(Q_FUNC_INFO));
1069 QOhosJsThreadGateway::invokeAndWaitForContinue(
1070 [&](QOhosJsState &, QOhosTaskPromise<> taskPromise) {
1071 if (m_jsScopeData->isWindowClosing()) {
1076 m_jsScopeData->jsWindowRef->evalToPromiseOrRejectOnThrow(
"setWindowTitle(*)", {title.toStdString()})
1077 .onCatch(QtOhos::makeErrorLoggingJsCallback(Q_FUNC_INFO))
1078 .onFinally(std::move(taskPromise).makeChained(Q_FUNC_INFO));
1086 "%s: isMaximizeVisible:%s, isMinimizeVisible:%s, isCloseVisible:%s",
1087 Q_FUNC_INFO, maximizeVisible ?
"true" :
"false", minimizeVisible ?
"true":
"false",
1088 closeVisible ?
"true" :
"false");
1093 QOhosJsThreadGateway::runAndWait(
1094 [&](QOhosJsState &jsState) {
1095 if (m_jsScopeData->isWindowClosing())
1098 constexpr auto capabilityNotSupportedErrorCode = 801;
1099 QtOhos::runIgnoringJsBusinessError(
1100 jsState, capabilityNotSupportedErrorCode,
"setWindowTitleButtonVisible()",
1102 m_jsScopeData->jsWindowRef->eval(
1103 "setWindowTitleButtonVisible(*)",
1104 {maximizeVisible, minimizeVisible, closeVisible});
1116 qOhosPrintfWarning(
"%s: can be used only on 2-in-1 devices or tablets in PC mode - skipping", Q_FUNC_INFO);
1120 qOhosPrintfDebug(
"%s: topMost: %s", Q_FUNC_INFO, topmost ?
"true" :
"false");
1122 QOhosJsThreadGateway::invokeAndWaitForContinue(
1123 [&](QOhosJsState &, QOhosTaskPromise<> taskPromise) {
1124 if (m_jsScopeData->isWindowClosing()) {
1129 m_jsScopeData->jsWindowRef->evalToPromiseOrRejectOnThrow(
"setWindowTopmost(*)", {topmost})
1130 .onCatch(QtOhos::makeErrorLoggingJsCallback(Q_FUNC_INFO))
1131 .onFinally(std::move(taskPromise).makeChained(Q_FUNC_INFO));
1138 QOhosJsThreadGateway::runAndWait([&](QOhosJsState &) {
1139 if (m_jsScopeData->isWindowClosing())
1142 m_jsScopeData->jsWindowRef->eval(
"setWindowDecorVisible(*)", {visible});
1150 qOhosPrintfWarning(
"%s: can be used only on 2-in-1 devices or tablets in PC mode - skipping", Q_FUNC_INFO);
1154 QOhosJsThreadGateway::runAndWait([&](QOhosJsState &) {
1155 if (m_jsScopeData->isWindowClosing())
1158 m_jsScopeData->jsWindowRef->eval(
"setWindowTitleMoveEnabled(*)", {enabled});
1166 qOhosPrintfWarning(
"%s: can be used only on 2-in-1 devices or tablets - skipping", Q_FUNC_INFO);
1173 QOhosJsThreadGateway::runAndWait([&](QOhosJsState &) {
1174 m_jsScopeData->jsWindowRef->eval(
"setWindowShadowRadius(*)", {radius});
1184 QOhosJsThreadGateway::invokeAndWaitForContinue(
1185 [&](QOhosJsState &, QOhosTaskPromise<> taskPromise) {
1186 m_jsScopeData->jsWindowRef->evalToPromiseOrRejectOnThrow(
"setWindowCornerRadius(*)", {radius})
1187 .onCatch(QtOhos::makeErrorLoggingJsCallback(Q_FUNC_INFO))
1188 .onFinally(std::move(taskPromise).makeChained(Q_FUNC_INFO));
1195 return QOhosJsThreadGateway::evalWithPromise<
bool>(
1196 [&](QOhosJsState &, QOhosTaskPromise<
bool> evalPromise) {
1197 if (m_jsScopeData->isWindowClosing()) {
1201 auto optQUiAbilityPeer = QtOhos::QUiAbilityPeer::tryCastFromQAbilityPeerOrNull(m_jsScopeData->qAbilityPeer);
1202 if (!optQUiAbilityPeer) {
1207 auto thenCatchPromises = std::move(evalPromise).makeThenCatchBranches(Q_FUNC_INFO);
1208 optQUiAbilityPeer->windowStage()
1209 .evalToPromiseOrRejectOnThrow(
"isWindowRectAutoSave()")
1211 [thenPromise = std::move(thenCatchPromises.first)](
const QtOhos::CallbackInfo &cbInfo) {
1212 bool windowRectAutoSaveEnabled = cbInfo.getFirstArg<QNapi::Boolean>(Q_FUNC_INFO);
1213 thenPromise(windowRectAutoSaveEnabled);
1216 [catchPromise = std::move(thenCatchPromises.second)](
const QtOhos::CallbackInfo &cbInfo) {
1217 QtOhos::logJsCallbackError(cbInfo,
"isWindowRectAutoSave()");
1218 catchPromise(
false);
1229 QOhosJsThreadGateway::invokeAndWaitForContinue(
1230 [&](QOhosJsState &, QOhosTaskPromise<> taskPromise) {
1231 if (m_jsScopeData->isWindowClosing()) {
1235 m_jsScopeData->jsWindowRef->evalToPromiseOrRejectOnThrow(
"setFollowParentMultiScreenPolicy(*)", {enabled})
1236 .onCatch(QtOhos::makeErrorLoggingJsCallback(
"setFollowParentMultiScreenPolicy()"))
1237 .onFinally(std::move(taskPromise).makeChained(Q_FUNC_INFO));
1246 QOhosJsThreadGateway::invokeAndWaitForContinue(
1247 [&](QOhosJsState &, QOhosTaskPromise<> taskPromise) {
1248 if (m_jsScopeData->isWindowClosing()) {
1253 m_jsScopeData->jsWindowRef->evalToPromiseOrRejectOnThrow(
"setWindowKeepScreenOn(*)", {keepScreenOn})
1254 .onCatch(QtOhos::makeErrorLoggingJsCallback(
"setWindowKeepScreenOn()"))
1255 .onFinally(std::move(taskPromise).makeChained(Q_FUNC_INFO));
1262 qCDebug(QtForOhos,
"%s: %s", Q_FUNC_INFO, mapEnumsToLogString(supportedWindowModes).c_str());
1264 QOhosJsThreadGateway::invokeAndWaitForContinue(
1265 [&](QOhosJsState &jsState, QOhosTaskPromise<> taskPromise) {
1266 if (m_jsScopeData->isWindowClosing()) {
1270 auto qUiAbilityPeer = QtOhos::QUiAbilityPeer::tryCastFromQAbilityPeerOrNull(m_jsScopeData->qAbilityPeer);
1271 if (!qUiAbilityPeer) {
1276 auto jsSupportedWindowModes = QNapi::makeArray(
1277 jsState.env(), supportedWindowModes,
1279 return jsState.mapOhosEnumToJs(mode);
1282 qUiAbilityPeer->windowStage().evalToPromiseOrRejectOnThrow(
"setSupportedWindowModes(*)", {jsSupportedWindowModes})
1283 .onCatch(QtOhos::makeErrorLoggingJsCallback(
"setSupportedWindowModes()"))
1284 .onFinally(std::move(taskPromise).makeChained(Q_FUNC_INFO));
1291 constexpr bool isSaveBySpecifiedFlag =
true;
1293 QOhosJsThreadGateway::invokeAndWaitForContinue(
1294 [&](QOhosJsState &, QOhosTaskPromise<> taskPromise) {
1295 if (m_jsScopeData->isWindowClosing()) {
1299 auto optQUiAbilityPeer = QtOhos::QUiAbilityPeer::tryCastFromQAbilityPeerOrNull(m_jsScopeData->qAbilityPeer);
1300 if (!optQUiAbilityPeer) {
1305 optQUiAbilityPeer->windowStage()
1306 .evalToPromiseOrRejectOnThrow(
"setWindowRectAutoSave(*)", {enabled, isSaveBySpecifiedFlag})
1307 .onCatch(QtOhos::makeErrorLoggingJsCallback(
"setWindowRectAutoSave()"))
1308 .onFinally(std::move(taskPromise).makeChained(Q_FUNC_INFO));
1314 std::function<
void()> handler,
bool handlerReturnValue)
1316 m_subWindowCloseRegistrationHandle =
1317 registerSubWindowCloseHandler(std::move(handler), handlerReturnValue);
1322 m_subWindowCloseRegistrationHandle.reset();
1325std::shared_ptr<
void> QOhosWindowProxy::registerSubWindowCloseHandler(
1326 std::function<
void()> handler,
bool handlerReturnValue)
1328 auto sharedHandler = QtOhos::moveToSharedPtr(std::move(handler));
1329 auto jsWindowRegistrationHandle = QOhosJsThreadGateway::eval(
1330 [&](QOhosJsState &jsState) {
1331 return QtOhos::makeProxyWithJsThreadDeleter(
1332 m_jsScopeData->registerSubWindowCloseHandler(
1334 [weakHandler = QtOhos::makeWeakPtr(sharedHandler), handlerReturnValue]() {
1335 QtOhos::invokeInQtThread(
1337 auto sharedHandler = weakHandler.lock();
1341 return handlerReturnValue;
1346 return QtOhos::moveToSharedPtr(
1347 std::make_tuple(sharedHandler, jsWindowRegistrationHandle));
1350std::shared_ptr<QOhosWindowProxy>
1353 return std::shared_ptr<QOhosWindowProxy>(
1354 new QOhosWindowProxy(
1355 [&](QtOhos::JsState &jsState, QOhosConsumer<QtOhos::JsState &, QOhosWindowProxyData> windowProxyDataConsumer) {
1356 makeWindowProxyDataForExistingMainWindowInJsThread(jsState, createInfo, std::move(windowProxyDataConsumer));
1360std::shared_ptr<QOhosWindowProxy>
1363 return std::shared_ptr<QOhosWindowProxy>(
1364 new QOhosWindowProxy(
1365 [&](QtOhos::JsState &jsState, QOhosConsumer<QtOhos::JsState &, QOhosWindowProxyData> windowProxyDataConsumer) {
1366 makeWindowProxyDataForFloatWindowInJsThread(jsState, createInfo, std::move(windowProxyDataConsumer));
1370std::shared_ptr<QOhosWindowProxy>
1373 return std::shared_ptr<QOhosWindowProxy>(
1374 new QOhosWindowProxy(
1375 [&](QtOhos::JsState &jsState, QOhosConsumer<QtOhos::JsState &, QOhosWindowProxyData> windowProxyDataConsumer) {
1376 makeWindowProxyDataForMainWindowInJsThread(jsState, createInfo, std::move(windowProxyDataConsumer));
1382 return m_nodeXComponent;
1387 return m_qAbilityInstanceId;
1390std::shared_ptr<QOhosWindowProxy>
1393 return std::shared_ptr<QOhosWindowProxy>(
1394 new QOhosWindowProxy(
1395 [&](QtOhos::JsState &jsState, QOhosConsumer<QtOhos::JsState &, QOhosWindowProxyData> windowProxyDataConsumer) {
1399 if (m_jsScopeData->isWindowClosing()) {
1400 makeWindowProxyDataForSubWindowInJsThread(
1401 jsState, createInfo, std::move(windowProxyDataConsumer));
1403 makeWindowProxyDataForSubWindowInJsThread(
1404 jsState, m_jsScopeData->jsWindowRef->jsObject(), createInfo,
1405 std::move(windowProxyDataConsumer));
1410QOhosWindowProxy::JsScopeData::JsScopeData() =
default;
1412QOhosWindowProxy::JsScopeData::JsScopeData(
1413 WindowProxyType windowProxyType, QNapi::Reference<QNapi::Object> jsWindow,
1414 std::shared_ptr<
void> optKeepAliveData,
1416 QtOhos::QObjectThreadSafeRef owningQWindowRef)
1417 : windowProxyType(windowProxyType)
1418 , windowCallbackReceiver(
nullptr)
1419 , windowDestroyedFromSystem(
false)
1420 , optKeepAliveData(optKeepAliveData)
1421 , qAbilityPeer(qAbilityPeer)
1422 , nonClientAreaEventsDispatcher(std::make_shared<NonClientAreaEventsDispatcher>())
1423 , m_windowFrameMouseFilterHandle(
1424 QArkUi::registerMouseEventsConsumer(
1425 getWindowPropertiesFromJsWindow(jsWindow.Value()).id,
1426 [dispatcher = nonClientAreaEventsDispatcher](
const QArkUi::MouseEvent &event) {
1427 dispatcher->onMouseEventFromArkUi(event);
1429 , m_windowFrameTouchFilterHandle(
1430 QArkUi::registerTouchEventsConsumer(
1431 getWindowPropertiesFromJsWindow(jsWindow.Value()).id,
1432 [dispatcher = nonClientAreaEventsDispatcher](
const QArkUi::TouchEvent &event) {
1433 dispatcher->onTouchEventFromArkUi(event);
1436 std::make_shared<QArkUi::JsWindowRef>(
1437 qAbilityPeer->instanceId(),
1438 getWindowPropertiesFromJsWindow(jsWindow.Value()).id,
1444QOhosWindowProxy::JsScopeData::~JsScopeData()
1447 if (isWindowClosingFromSystem(jsWindowRef->jsObject(), windowProxyType, qAbilityPeer)) {
1448 windowDestroyedFromSystem =
true;
1452 QtOhos::JsWindowsTracker::tagWindowAsClosing(jsWindowRef->jsObject(),
"QOhosWindowProxy::JsScopeData destructor");
1458 windowDestroyedFromSystem =
true;
1460 "Attempting to terminate qAbility with instance id: %s",
1461 jsWindowRef->owningQAbilityInstanceId().c_str());
1462 qAbilityPeer->qAbility().eval(
"context.terminateSelf()");
1463 }
else if (!windowDestroyedFromSystem) {
1466 jsWindowRef->eval(
"destroyWindow()");
1471std::shared_ptr<
void> QOhosWindowProxy::JsScopeData::registerEventListener(
1472 const std::string &eventName,
1474 QFlags<EventHandlerFlagBits> eventHandlerFlags)
1477 std::weak_ptr<JsScopeData> weakSelf = shared_from_this();
1478 bool ignoreWhenAbilityIsTerminating = !eventHandlerFlags.testFlag(EventHandlerFlagBits::allowCallWhenAbilityIsTerminating);
1480 return registerQOhosOnOffMethodsBasedEventHandler(
1481 jsWindowRef->jsObject(), eventName,
1482 [weakSelf, handleFunction, eventName, ignoreWhenAbilityIsTerminating](
const QtOhos::
CallbackInfo &cbInfo) {
1483 auto self = weakSelf.lock();
1484 if (Q_UNLIKELY(!self)) {
1486 "callback '%s' called for destroyed QOhosWindowProxy::JsScopeData, ignoring",
1491 if (self->isWindowClosing() && ignoreWhenAbilityIsTerminating) {
1493 "QOhosWindowProxy: Received callback for event '%s' during termination of the related QAbility.",
1498 if (Q_UNLIKELY(self->windowDestroyedFromSystem)) {
1500 "QOhosWindowProxy: Received callback for event '%s' after WINDOW_DESTROYED",
1505 ((*self).*handleFunction)(cbInfo);
1508 .optEventSourceAliveCheckFunc = {},
1511 .optOnCallExceptionHandler = [&](
const Napi::Error &error) {
1512 constexpr std::uint32_t capabilityNotSupportedErrorCode = 801;
1513 constexpr std::uint32_t windowStateIsAbnormalErrorCode = 1300002;
1515 const QSet<std::uint32_t> ignorableErrorCodes = {
1516 capabilityNotSupportedErrorCode,
1517 windowStateIsAbnormalErrorCode,
1520 auto errorCode = QtOhos::tryGetCodeFromJsBusinessError(error);
1522 auto ignorableError =
1523 eventHandlerFlags.testFlag(EventHandlerFlagBits::allowEventHandlerRegistrationFailure)
1524 && errorCode.has_value()
1525 && ignorableErrorCodes.contains(errorCode.value());
1527 if (!ignorableError)
1531 "%s: Ignored error %u while registering for window event '%s'",
1532 Q_FUNC_INFO, errorCode.value(), eventName.c_str());
1537std::shared_ptr<
void> QOhosWindowProxy::JsScopeData::registerSubWindowCloseHandler(
1538 QOhosJsState &,
std::function<
bool()> handler)
1540 auto weakSelf = QtOhos::makeWeakPtr(shared_from_this());
1541 return registerQOhosOnOffMethodsBasedEventHandler(
1542 jsWindowRef->jsObject(),
"subWindowClose",
1544 bool deferClose = handler();
1545 auto self = weakSelf.lock();
1546 if (self && !deferClose)
1547 QtOhos::JsWindowsTracker::tagWindowAsClosing(self->jsWindowRef->jsObject(),
"subWindowClose => false");
1548 return QNapi::Boolean::New(cbInfo.Env(), deferClose);
1552void QOhosWindowProxy::JsScopeData::handleWindowEventCallback(
const QtOhos::
CallbackInfo &cbInfo)
1554 auto eventType = cbInfo.getFirstArg<QNapi::Number>(Q_FUNC_INFO);
1559 event
.type = cbInfo
.jsState().mapOhosEnumFromJs<WindowEventType>(eventType);
1560 }
catch (
const Napi::Error &err) {
1562 "Error converting WindowEventType to known value: %s. Event will be ignored.", err.what());
1568 "Received WindowEvent for window when it's closing. WindowEventType: %d",
1576void QOhosWindowProxy::JsScopeData::handleWindowStatusCallback(
const QtOhos::
CallbackInfo &cbInfo)
1578 auto windowStatusType = cbInfo.getFirstArg<QNapi::Number>(Q_FUNC_INFO);
1579 if (windowCallbackReceiver !=
nullptr) {
1580 windowCallbackReceiver->onWindowStatusChange(
1582 .type = cbInfo.jsState().mapOhosEnumFromJs<WindowStatusType>(windowStatusType),
1587void QOhosWindowProxy::JsScopeData::handleWindowVisibilityCallback(
const QtOhos::
CallbackInfo &cbInfo)
1589 auto windowVisibility = cbInfo.getFirstArg<QNapi::Boolean>(Q_FUNC_INFO);
1590 if (windowCallbackReceiver !=
nullptr)
1591 windowCallbackReceiver->onWindowVisibilityChange(windowVisibility);
1594void QOhosWindowProxy::JsScopeData::handleWindowTouchOutsideCallback(
const QtOhos::
CallbackInfo &)
1596 if (windowCallbackReceiver !=
nullptr)
1597 windowCallbackReceiver->onTouchOutside();
1600void QOhosWindowProxy::JsScopeData::handleAvoidAreaChangeCallback(
const QtOhos::
CallbackInfo &cbInfo)
1602 if (windowCallbackReceiver !=
nullptr) {
1603 auto callbackArg = cbInfo.getFirstArg<QNapi::Object>(Q_FUNC_INFO);
1604 windowCallbackReceiver->onAvoidAreaChange(
1605 cbInfo.jsState().mapOhosEnumFromJs<AvoidAreaType>(callbackArg.get<QNapi::Number>(
"type")),
1606 mapAvoidAreaFromJs(callbackArg.get<QNapi::Object>(
"area")));
1610void QOhosWindowProxy::JsScopeData::handleWindowRectChangeCallback(
const QtOhos::
CallbackInfo &cbInfo)
1612 auto rectChangeOptionsObjectArg = cbInfo.getFirstArg<QNapi::Object>(Q_FUNC_INFO);
1613 auto rectChangeOptions = RectChangeOptions {
1614 .rect = ohosWindowRectToQRect(rectChangeOptionsObjectArg.get<QNapi::Object>(
"rect")),
1615 .reason = cbInfo.jsState().mapOhosEnumFromJs<RectChangeReason>(rectChangeOptionsObjectArg.get<QNapi::Number>(
"reason")),
1618 if (windowCallbackReceiver !=
nullptr)
1619 windowCallbackReceiver->onWindowRectChange(rectChangeOptions);
1622void QOhosWindowProxy::JsScopeData::handleWindowRectChangeInGlobalDisplayCallback(
const QtOhos::
CallbackInfo &cbInfo)
1624 auto rectChangeOptionsObjectArg = cbInfo.getFirstArg<QNapi::Object>(Q_FUNC_INFO);
1625 auto rectChangeOptions = RectChangeOptions {
1626 .rect = ohosWindowRectToQRect(rectChangeOptionsObjectArg.get<QNapi::Object>(
"rect")),
1627 .reason = cbInfo.jsState().mapOhosEnumFromJs<RectChangeReason>(rectChangeOptionsObjectArg.get<QNapi::Number>(
"reason")),
1630 if (windowCallbackReceiver !=
nullptr)
1631 windowCallbackReceiver->onWindowRectChangeInGlobalDisplay(rectChangeOptions);
1634void QOhosWindowProxy::JsScopeData::handleWindowDisplayIdChangeCallback(
const QtOhos::
CallbackInfo &cbInfo)
1636 auto displayIdNumber = cbInfo.getFirstArg<QNapi::Number>(Q_FUNC_INFO);
1639 if (windowCallbackReceiver !=
nullptr)
1640 windowCallbackReceiver->onWindowDisplayIdChange(displayId);
1646 QtOhos::JsWindowsTracker::tagWindowAsClosing(jsWindowRef->jsObject(),
"WINDOW_DESTROYED");
1647 windowDestroyedFromSystem =
true;
1650 if (windowCallbackReceiver !=
nullptr)
1651 windowCallbackReceiver->onWindowEvent(windowEvent);
1654bool QOhosWindowProxy::JsScopeData::isWindowClosing()
const
1656 return isWindowClosingFromSystem(jsWindowRef->jsObject(), windowProxyType, qAbilityPeer);
1661 if (mouseEventsConsumer ==
nullptr)
1664 auto optAction = tryMapMouseEventActionToNonClientAreaEventType(event.action);
1665 if (!optAction.has_value())
1669 if (!optWindowProperties.has_value()) {
1671 "%s: Failed to retrieve window properties for js window: %f. Ignoring event.",
1672 Q_FUNC_INFO, event.jsWindowId.value());
1676 const auto &windowProperties = optWindowProperties.value();
1677 if (!isPointInNonClientArea(event.displayPosition, windowProperties))
1680 auto windowOrigin = windowProperties.windowRect.topLeft() + windowProperties.drawableRect.topLeft();
1682 .timestamp = std::chrono::duration_cast<std::chrono::milliseconds>(event.actionTime),
1683 .action = optAction.value(),
1684 .button = tryMapMouseEventButtonToQt(event.button).value_or(Qt::NoButton),
1685 .displayPosition = event.displayPosition,
1686 .localPosition = event.displayPosition - windowOrigin,
1687 .globalPosition = event.globalPosition,
1690 mouseEventsConsumer(nonClientAreaMouseEvent);
1695 if (touchEventsConsumer ==
nullptr)
1698 auto optAction = tryMapTouchEventActionToNonClientAreaEventType(event.action);
1699 if (!optAction.has_value())
1703 if (!optWindowProperties.has_value()) {
1705 "%s: Failed to retrieve window properties for js window: %f. Ignoring event.",
1706 Q_FUNC_INFO, event.jsWindowId.value());
1710 const auto &windowProperties = optWindowProperties.value();
1711 if (!isPointInNonClientArea(event.displayPosition, windowProperties))
1714 auto windowOrigin = windowProperties.windowRect.topLeft() + windowProperties.drawableRect.topLeft();
1717 .timestamp =
std::chrono::duration_cast<
std::chrono::milliseconds>(event.actionTime),
1718 .action = optAction.value(),
1719 .displayPosition = event.displayPosition,
1720 .localPosition = event.displayPosition - windowOrigin,
1721 .globalPosition = event.globalPosition,
1724 touchEventsConsumer(nonClientAreaTouchEvent);
1729 return QOhosJsThreadGateway::evalWithPromise<QPixmap>(
1730 [&](QOhosJsState &, QOhosTaskPromise<QPixmap> evalPromise) {
1731 auto thenCatchPromises = std::move(evalPromise).makeThenCatchBranches(Q_FUNC_INFO);
1732 m_jsScopeData->jsWindowRef->evalToPromiseOrRejectOnThrow(
"snapshot()")
1734 [thenPromise = std::move(thenCatchPromises.first)](
const QtOhos::CallbackInfo &cbInfo) {
1735 auto napiPixmap = cbInfo.getFirstArg<QNapi::Object>(Q_FUNC_INFO);
1737 ::OH_PixelmapNative *pixelMapNativePtr;
1738 QArkUi::callArkUiOrFailOnErrorResult(
1739 Q_OHOS_NAMED_FUNC(::OH_PixelmapNative_ConvertPixelmapNativeFromNapi),
1740 cbInfo.Env(), napiPixmap, &pixelMapNativePtr);
1741 auto pixelMap = wrapOhosNativePixelMapPtr(pixelMapNativePtr);
1744 QPixmap::fromImage(createQImageFromNativePixelMap(pixelMap.get())));
1747 [catchPromise = std::move(thenCatchPromises.second)](
const QtOhos::CallbackInfo &cbInfo) {
1748 QtOhos::logJsCallbackError(cbInfo,
"Got error from snapshot()");
1749 catchPromise(QPixmap());
1759 return QOhosJsThreadGateway::evalWithPromise<QList<QRect>>(
1760 [&](QOhosJsState &jsState, QOhosTaskPromise<QList<QRect>> evalPromise) {
1761 if (m_jsScopeData->isWindowClosing()) {
1762 evalPromise(QList<QRect>());
1766 auto optWindowDisplay = qAndThen(
1767 getWindowPropertiesFromJsWindow(
1768 m_jsScopeData->jsWindowRef->jsObject()).displayId,
1769 [&](QOhosDisplayInfo::JsDisplayId id) {
1770 return QOhosDisplayInfo::tryGetDisplayById(jsState, id);
1772 auto display = optWindowDisplay.has_value()
1773 ? optWindowDisplay.value()
1774 : jsState.eval<QNapi::Object>(
"@ohos.display.getDefaultDisplaySync()");
1776 auto branches = std::move(evalPromise).makeThenCatchBranches(Q_FUNC_INFO);
1778 .evalToPromiseOrRejectOnThrow(
"getCutoutInfo()")
1780 [thenPromise = std::move(branches.first)](
const QtOhos::CallbackInfo &cbInfo) {
1781 auto cutoutInfo = cbInfo.getFirstArg<QNapi::Object>(Q_FUNC_INFO);
1782 auto cutoutRects = QNapi::getArrayElements<QList<QRect>, QNapi::Object>(
1783 cutoutInfo.get<QNapi::Array>(
"boundingRects"), [](QNapi::Object r) {
1784 return QRect(r.get<QNapi::Number>(
"left"),
1785 r.get<QNapi::Number>(
"top"),
1786 r.get<QNapi::Number>(
"width"),
1787 r.get<QNapi::Number>(
"height"));
1789 thenPromise(cutoutRects);
1792 [catchPromise = std::move(branches.second)](
const QtOhos::CallbackInfo &cbInfo) {
1793 QtOhos::logJsCallbackError(cbInfo,
"getCutoutInfo() failed");
1794 catchPromise(QList<QRect>());
1802 QOhosJsThreadGateway::invokeAndWaitForContinue(
1803 [&](QOhosJsState &, QOhosTaskPromise<> taskPromise) {
1804 if (m_jsScopeData->isWindowClosing()) {
1809 m_jsScopeData->jsWindowRef->evalToPromiseOrRejectOnThrow(
"startMoving()")
1810 .onCatch(QtOhos::makeErrorLoggingJsCallback(
"startMoving()"))
1811 .onFinally(std::move(taskPromise).makeChained(Q_FUNC_INFO));
1823 qCWarning(QtForOhos(),
"%s: enableDrag is not supported on main windows", Q_FUNC_INFO);
1827 QOhosJsThreadGateway::invokeAndWaitForContinue(
1828 [&](QOhosJsState &, QOhosTaskPromise<> taskPromise) {
1829 if (m_jsScopeData->isWindowClosing()) {
1833 m_jsScopeData->jsWindowRef->evalToPromiseOrRejectOnThrow(
"enableDrag(*)", {enable})
1834 .onCatch(QtOhos::makeErrorLoggingJsCallback(
"enableDrag()"))
1835 .onFinally(std::move(taskPromise).makeChained(Q_FUNC_INFO));
1842 return QOhosJsThreadGateway::eval(
1843 [&](QOhosJsState &) -> std::optional<
bool> {
1844 if (m_jsScopeData->isWindowClosing())
1845 return std::nullopt;
1847 return m_jsScopeData->jsWindowRef->eval<QNapi::Boolean>(
"isFocused()");
1852std::vector<QArkUi::JsWindowId> QOhosWindowProxy::queryWindowIdsByCoordinate(
1853 QOhosDisplayInfo::JsDisplayId displayId,
const QPoint &queryLocation,
std::uint32_t queryLimit)
1855 return QOhosJsThreadGateway::evalWithPromise<std::vector<QArkUi::JsWindowId>>(
1856 [&](QOhosJsState &jsState,
auto evalPromise) {
1857 auto thenCatchPromises = std::move(evalPromise).makeThenCatchBranches(Q_FUNC_INFO);
1858 jsState.evalToPromiseOrRejectOnThrow(
"@ohos.window.getWindowsByCoordinate(*)", {
1864 .onThen([thenPromise = std::move(thenCatchPromises.first)](
const QtOhos::CallbackInfo &cbInfo) {
1865 auto windowsArray = cbInfo.getFirstArg<QNapi::Array>(Q_FUNC_INFO);
1867 QNapi::getArrayElements<std::vector<QArkUi::JsWindowId>, QNapi::Object>(
1869 [&](QNapi::Object jsWindow) {
1870 return getWindowPropertiesFromJsWindow(jsWindow).id;
1873 .onCatch([catchPromise = std::move(thenCatchPromises.second)](
const QtOhos::CallbackInfo &cbInfo) {
1874 QtOhos::logJsCallbackError(
1875 cbInfo,
"got error from @ohos.window.getWindowsByCoordinate()");
1882std::vector<QArkUi::JsWindowId> QOhosWindowProxy::queryQtManagedWindowIdsByPredicate(
1883 const std::function<
bool(QOhosJsState &,
const QArkUi::JsWindowRef &)> &predicate)
1885 return QOhosJsThreadGateway::eval([&](QOhosJsState &jsState) {
1886 return QOhosJsWindowRegistry::instance(jsState).queryByPredicate(jsState, predicate);
1894 QOhosJsThreadGateway::invokeAndWaitForContinue(
1895 [&](QOhosJsState &jsState, QOhosTaskPromise<> taskPromise) {
1896 if (m_jsScopeData->isWindowClosing()) {
1901 auto moveConfigurationObject = toNapiObject(jsState.env(), moveConfiguration);
1902 auto moveConfigurationObjectStr = QNapi::toJsonString(moveConfigurationObject);
1905 Q_FUNC_INFO, position.x(), position.y(),
1906 moveConfigurationObjectStr.c_str());
1908 m_jsScopeData->jsWindowRef->evalToPromiseOrRejectOnThrow(
1909 "moveWindowToGlobal(*)", {position.x(), position.y(), moveConfigurationObject})
1910 .onCatch(QtOhos::makeErrorLoggingJsCallback(Q_FUNC_INFO))
1911 .onFinally(std::move(taskPromise).makeChained(Q_FUNC_INFO));
1918 return qtIsMainWindow()
1919 ? getWindowProperties().displayId
1920 : QOhosJsThreadGateway::eval(
1921 [&](QOhosJsState &) {
1923 = QtOhos::QUiAbilityPeer::tryCastFromQAbilityPeerOrNull(m_jsScopeData->qAbilityPeer);
1924 return qUiAbilityPeer
1925 ? getWindowPropertiesFromJsWindow(qUiAbilityPeer->window()).displayId
1933 QOhosJsThreadGateway::invokeAndWaitForContinue(
1934 [&](QOhosJsState &jsState, QOhosTaskPromise<> taskPromise) {
1935 if (m_jsScopeData->isWindowClosing() || targetProxy.m_jsScopeData->isWindowClosing()) {
1940 auto srcWindowId = getWindowPropertiesFromJsWindow(m_jsScopeData->jsWindowRef->jsObject()).id;
1941 auto targetWindowId = getWindowPropertiesFromJsWindow(targetProxy.m_jsScopeData->jsWindowRef->jsObject()).id;
1942 jsState.evalToPromiseOrRejectOnThrow(
1943 "@ohos.window.shiftAppWindowFocus(*)", {srcWindowId.value(), targetWindowId.value()})
1944 .onCatch(QtOhos::makeErrorLoggingJsCallback(
"@ohos.window.shiftAppWindowFocus()"))
1945 .onFinally(std::move(taskPromise).makeChained(Q_FUNC_INFO));
bool isWindowPcModeEnabled() const
static QOhosSettings & instance()
void setWindowRectAutoSave(bool enabed)
void setSubWindowModalEnabled(ModalityType ModalityType)
QtOhosQpa::enums::ohos::window::MaximizePresentation MaximizePresentation
void setWindowKeepScreenOn(bool keepScreenOn)
void moveWindowToGlobal(const QPoint &position, const MoveConfiguration &moveConfiguration)
static std::shared_ptr< QOhosWindowProxy > createFloatWindow(const FloatWindowCreateInfo &createInfo)
void setWindowMask(const WindowMask &windowMask, const std::optional< QSize > &ohosMaskSizeOverride={})
QArkUi::WindowProperties getWindowProperties() const
void moveWindowToGlobalOrGlobalDisplay(const QPoint &position, std::optional< QOhosDisplayInfo::JsDisplayId > optDisplayId)
void setSubWindowModalDisabled()
void setWindowPrivacyMode(bool privacyMode)
void resetSubWindowCloseHandler()
QtOhosQpa::enums::ohos::window::WindowEventType WindowEventType
AvoidArea getWindowAvoidArea(AvoidAreaType type) const
void setWindowLayoutFullScreen(bool isLayoutFullScreen)
std::optional< QOhosDisplayInfo::JsDisplayId > tryGetMainWindowJsDisplayId() const
void enableDrag(bool enable)
void setWindowCornerRadius(double radius)
QOhosWindowProxyExistingMainWindowCreateInfo ExistingMainWindowCreateInfo
void setSupportedWindowModes(const std::set< SupportWindowMode > &supportedWindowModes)
void removeStartingWindow()
void setWindowSystemBarEnable(const QStringList &names)
std::shared_ptr< QOhosWindowProxy > createSubWindow(const SubWindowCreateInfo &createInfo)
static std::shared_ptr< QOhosWindowProxy > createForExistingMainWindow(const ExistingMainWindowCreateInfo &createInfo)
void setWindowTouchable(bool touchable)
void setTitle(const QString &title)
void setFollowParentMultiScreenPolicy(bool enabled)
void setWindowTopmost(bool topmost)
std::shared_ptr< QXComponentNode > nodeXComponent() const
void setWindowCallbackReceiver(std::unique_ptr< WindowCallbacks > receiver)
void setSubWindowCloseHandler(std::function< void()> handler, bool handlerReturnValue)
std::optional< bool > isFocused() const
QtOhosQpa::enums::ohos::window::ModalityType ModalityType
void setWindowLimits(const QSize &minSize, const QSize &maxSize)
bool isWindowRectAutoSave() const
void setWindowDecorVisible(bool visible)
void showWindow(const ShowWindowOptions &options=ShowWindowOptions())
void shiftAppWindowFocus(QOhosWindowProxy &targetProxy)
QOhosWindowProxySubWindowCreateInfo SubWindowCreateInfo
void setNonClientAreaMouseWindowCallbackReceiver(QObject *contextObject, QOhosConsumer< std::vector< NonClientAreaMouseEvent > > mouseEventBatchConsumer)
QtOhosQpa::enums::ohos::window::AvoidAreaType AvoidAreaType
void setCustomCursor(const QImage &customCursorImage, const QPoint &hotSpot)
void setWindowTitleMoveEnabled(bool enabled)
void setWindowFocusable(bool focusable)
void setWindowBackgroundColor(const QColor &color)
void setSize(const QSize &size)
QOhosWindowProxyMainWindowCreateInfo MainWindowCreateInfo
void setWindowShadowRadius(double radius)
bool qtIsMainWindow() const
QOhosWindowProxyFloatWindowCreateInfo FloatWindowCreateInfo
void setWindowTitleButtonVisible(bool maximizeVisible, bool minimizeVisible, bool closeVisible)
bool getImmersiveModeEnabledState()
void setPointerStyleSync(const QCursor &cursor)
QList< QRect > getDisplayCutoutRects() const
WindowLimits getWindowLimits() const
std::string qAbilityInstanceId() const
void maximize(MaximizePresentation maximizePresentation)
void setNonClientAreaTouchWindowCallbackReceiver(QObject *contextObject, QOhosConsumer< std::vector< NonClientAreaTouchEvent > > touchEventBatchConsumer)
static std::shared_ptr< QOhosWindowProxy > createMainWindow(const MainWindowCreateInfo &createInfo)
JsState & jsState() const
std::optional< WindowProperties > tryGetWindowProperties(JsWindowId jsWindowId)
Combined button and popup list for selecting options.
QRect ohosWindowRectToQRect(const QNapi::Object &ohosWindowRect)
bool isPointInNonClientArea(const QPoint &point, const QArkUi::WindowProperties &windowProperties)
std::optional< QEvent::Type > tryMapMouseEventActionToNonClientAreaEventType(::Input_MouseEventAction action)
std::optional< double > getOptionalNumberPropAsOptionalDouble(const QNapi::Object &object, const std::string &propertyName)
QOhosPointerStyle convertToOhosCursor(Qt::CursorShape shape)
QOhosWindowProxy::AvoidArea mapAvoidAreaFromJs(const QNapi::Object &avoidAreaObject)
std::string mapEnumsToLogString(const EnumsContainer &enums)
std::optional< Qt::MouseButton > tryMapMouseEventButtonToQt(::Input_MouseEventButton button)
bool isWindowClosingFromSystem(QNapi::Object jsWindow, WindowProxyType windowType, std::shared_ptr< QtOhos::QAbilityPeer > abilityPeer)
bool isAbilityTerminating(QNapi::Object ability)
QtOhosQpa::enums::ohos::multimodalInput::pointer::PointerStyle QOhosPointerStyle
QArkUi::WindowProperties getWindowPropertiesFromJsWindow(QNapi::Object jsWindow)
std::function< void(Args...)> makeQtThreadWindowCallbackDelegate(std::function< void(Args...)> QOhosWindowProxy::WindowCallbacks::*memberPtr, std::shared_ptr< QOhosWindowProxy::WindowCallbacks > qtWindowCallbacks)
std::function< void(T)> makeCompressingQtThreadWindowCallbackDelegate(std::function< void(T)> QOhosWindowProxy::WindowCallbacks::*memberPtr, std::shared_ptr< QOhosWindowProxy::WindowCallbacks > qtWindowCallbacks)
QNapi::Object toNapiObject(napi_env env, const QOhosWindowProxy::MoveConfiguration &moveConfiguration)
std::optional< QEvent::Type > tryMapTouchEventActionToNonClientAreaEventType(::Input_TouchEventAction action)
std::string const char * mapBoolToTrueFalseStr(bool value)
QXComponent< QXComponentType::Node > QXComponentNode
void onTouchEventFromArkUi(const QArkUi::TouchEvent &event) const
void onMouseEventFromArkUi(const QArkUi::MouseEvent &event) const