4#include <qarkui/window.h>
7#include <qarkui/qarkuiutils.h>
9#include <window_manager/oh_window.h>
10#include <window_manager/oh_window_comm.h>
18QRect makeQRectFromWindowManagerRect(
const ::WindowManager_Rect &wmRect)
21 QPoint(wmRect.posX, wmRect.posY),
22 QSize(wmRect.width, wmRect.height));
29 ::WindowManager_WindowProperties windowProperties;
30 auto errorCode = ::OH_WindowManager_GetWindowProperties(
31 static_cast<std::int32_t>(jsWindowId.value()),
34 if (errorCode != ::OK)
37 return WindowProperties {
38 .windowRect = makeQRectFromWindowManagerRect(windowProperties.windowRect),
39 .drawableRect = makeQRectFromWindowManagerRect(windowProperties.drawableRect),
40 .id = JsWindowId(windowProperties.id),
41 .displayId = QOhosDisplayInfo::JsDisplayId(windowProperties.displayId),
46 std::string owningQAbilityInstanceId, JsWindowId windowId,
47 QNapi::Object jsWindow, QtOhos::QObjectThreadSafeRef owningQWindowRef)
48 : m_owningQAbilityInstanceId(
std::move(owningQAbilityInstanceId))
58 const auto windowShownErrorCode = callArkUi(
59 Q_OHOS_NAMED_FUNC(::OH_WindowManager_IsWindowShown),
60 static_cast<std::int32_t>(m_jsWindowId.value()), &result);
61 if (windowShownErrorCode == ::WindowManager_ErrorCode::WINDOW_MANAGER_ERRORCODE_INVALID_PARAM)
62 qOhosReportFatalErrorAndAbort(
"%s: error: %d", Q_FUNC_INFO, windowShownErrorCode);
63 return windowShownErrorCode == ::WindowManager_ErrorCode::OK
70 if (QtOhos::JsWindowsTracker::isWindowClosing(m_jsWindow.Value()))
72 return m_jsWindow.eval<QNapi::Boolean>(
"isFocused()").Value();
77 return m_owningQAbilityInstanceId;
87 return m_owningQWindowRef;
92 return m_jsWindow.Value();
JsWindowRef(std::string owningQAbilityInstanceId, JsWindowId windowId, QNapi::Object jsWindow, QtOhos::QObjectThreadSafeRef owningQWindowRef)
QtOhos::QObjectThreadSafeRef owningQWindowRef() const
bool isWindowShown() const
const std::string & owningQAbilityInstanceId() const
std::optional< WindowProperties > tryGetWindowProperties(JsWindowId jsWindowId)
Combined button and popup list for selecting options.