mirror of
https://gitee.com/openharmony/window_window_manager
synced 2025-02-06 16:08:21 +00:00
Add property named drawableRect in windowProperties
Signed-off-by: tian-xun <tianxun3@huawei.com>
This commit is contained in:
parent
d982295db7
commit
f7b7b2a9d1
@ -1389,7 +1389,14 @@ napi_value JsWindow::OnGetProperties(napi_env env, napi_callback_info info)
|
||||
WLOGFE("window is nullptr or get invalid param");
|
||||
return;
|
||||
}
|
||||
auto objValue = CreateJsWindowPropertiesObject(env, weakWindow);
|
||||
Rect drawableRect = g_emptyRect;
|
||||
auto uicontent = weakWindow->GetUIContent();
|
||||
if (uicontent == nullptr) {
|
||||
WLOGFW("uicontent is nullptr");
|
||||
} else {
|
||||
uicontent->GetAppPaintSize(drawableRect);
|
||||
}
|
||||
auto objValue = CreateJsWindowPropertiesObject(env, weakWindow, drawableRect);
|
||||
if (objValue != nullptr) {
|
||||
task.Resolve(env, objValue);
|
||||
} else {
|
||||
@ -1415,7 +1422,14 @@ napi_value JsWindow::OnGetWindowPropertiesSync(napi_env env, napi_callback_info
|
||||
WLOGFE("window is nullptr or get invalid param");
|
||||
return NapiThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY);
|
||||
}
|
||||
auto objValue = CreateJsWindowPropertiesObject(env, window);
|
||||
Rect drawableRect = g_emptyRect;
|
||||
auto uicontent = window->GetUIContent();
|
||||
if (uicontent == nullptr) {
|
||||
WLOGFW("uicontent is nullptr");
|
||||
} else {
|
||||
uicontent->GetAppPaintSize(drawableRect);
|
||||
}
|
||||
auto objValue = CreateJsWindowPropertiesObject(env, window, drawableRect);
|
||||
WLOGI("Window [%{public}u, %{public}s] get properties end",
|
||||
window->GetWindowId(), window->GetWindowName().c_str());
|
||||
if (objValue != nullptr) {
|
||||
|
@ -419,7 +419,7 @@ napi_value GetRectAndConvertToJsValue(napi_env env, const Rect& rect)
|
||||
return objValue;
|
||||
}
|
||||
|
||||
napi_value CreateJsWindowPropertiesObject(napi_env env, sptr<Window>& window)
|
||||
napi_value CreateJsWindowPropertiesObject(napi_env env, sptr<Window>& window, const Rect& drawableRect)
|
||||
{
|
||||
WLOGI("CreateJsWindowPropertiesObject");
|
||||
napi_value objValue = nullptr;
|
||||
@ -429,12 +429,19 @@ napi_value CreateJsWindowPropertiesObject(napi_env env, sptr<Window>& window)
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Rect rect = window->GetRect();
|
||||
napi_value rectObj = GetRectAndConvertToJsValue(env, rect);
|
||||
if (rectObj == nullptr) {
|
||||
WLOGFE("GetRect failed!");
|
||||
Rect windowRect = window->GetRect();
|
||||
napi_value windowRectObj = GetRectAndConvertToJsValue(env, windowRect);
|
||||
if (windowRectObj == nullptr) {
|
||||
WLOGFE("GetWindowRect failed!");
|
||||
}
|
||||
napi_set_named_property(env, objValue, "windowRect", rectObj);
|
||||
napi_set_named_property(env, objValue, "windowRect", windowRectObj);
|
||||
|
||||
napi_value drawableRectObj = GetRectAndConvertToJsValue(env, drawableRect);
|
||||
if (drawableRectObj == nullptr) {
|
||||
WLOGFE("GetDrawableRect failed!");
|
||||
}
|
||||
napi_set_named_property(env, objValue, "drawableRect", drawableRectObj);
|
||||
|
||||
WindowType type = window->GetType();
|
||||
if (NATIVE_JS_TO_WINDOW_TYPE_MAP.count(type) != 0) {
|
||||
napi_set_named_property(env, objValue, "type", CreateJsValue(env, NATIVE_JS_TO_WINDOW_TYPE_MAP.at(type)));
|
||||
|
@ -173,7 +173,7 @@ struct SystemBarPropertyFlag {
|
||||
};
|
||||
|
||||
napi_value GetRectAndConvertToJsValue(napi_env env, const Rect& rect);
|
||||
napi_value CreateJsWindowPropertiesObject(napi_env env, sptr<Window>& window);
|
||||
napi_value CreateJsWindowPropertiesObject(napi_env env, sptr<Window>& window, const Rect& drawableRect);
|
||||
bool SetSystemBarPropertiesFromJs(napi_env env, napi_value jsObject,
|
||||
std::map<WindowType, SystemBarProperty>& properties, std::map<WindowType, SystemBarPropertyFlag>& propertyFlags,
|
||||
sptr<Window>& window);
|
||||
|
@ -87,6 +87,7 @@ public:
|
||||
MOCK_METHOD4(
|
||||
FocusMoveSearch, void(int32_t elementId, int32_t direction, int32_t baseParent,
|
||||
Accessibility::AccessibilityElementInfo &output));
|
||||
MOCK_METHOD1(GetAppPaintSize, void(OHOS::Rosen::Rect& drawableRect));
|
||||
};
|
||||
} // namespace Ace
|
||||
} // namespace OHOS
|
||||
|
Loading…
x
Reference in New Issue
Block a user