diff --git a/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp b/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp index 92662e5adadcade2dfb25ab1d283c7f32af31194..1bfce7edce1e4f6b45e24a812adfc37e2a65c3d2 100644 --- a/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp +++ b/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp @@ -5672,9 +5672,9 @@ napi_value JsWindow::OnGetTitleButtonRect(napi_env env, napi_callback_info info) return NapiThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY); } TitleButtonRect titleButtonRect; - WMError ret = windowToken_->GetTitleButtonArea(titleButtonRect); - if (ret != WMError::WM_OK) { - return NapiThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY); + WmErrorCode ret = WM_JS_TO_ERROR_CODE_MAP.at(windowToken_->GetTitleButtonArea(titleButtonRect)); + if (ret != WmErrorCode::WM_OK) { + return NapiThrowError(env, ret); } WLOGI("Window [%{public}u, %{public}s] OnGetTitleButtonRect end", window->GetWindowId(), window->GetWindowName().c_str()); diff --git a/interfaces/kits/napi/window_runtime/window_napi/js_window_listener.cpp b/interfaces/kits/napi/window_runtime/window_napi/js_window_listener.cpp index 6c82920852f1c6a85481964c9ada3bf897d19cc8..759b07ebe588a1f41dd9b0fc7ec7bc68f70de25d 100644 --- a/interfaces/kits/napi/window_runtime/window_napi/js_window_listener.cpp +++ b/interfaces/kits/napi/window_runtime/window_napi/js_window_listener.cpp @@ -495,14 +495,7 @@ void JsWindowListener::OnWindowTitleButtonRectChanged(const TitleButtonRect& tit if (titleButtonRectValue == nullptr) { return; } - napi_value objValue = nullptr; - napi_create_object(env, &objValue); - if (objValue == nullptr) { - WLOGFE("Failed to get object"); - return; - } - napi_set_named_property(env, objValue, "titleButtonRect", titleButtonRectValue); - napi_value argv[] = { objValue }; + napi_value argv[] = { titleButtonRectValue }; thisListener->CallJsMethod(WINDOW_TITLE_BUTTON_RECT_CHANGE_CB.c_str(), argv, ArraySize(argv)); } ); diff --git a/wm/src/window_session_impl.cpp b/wm/src/window_session_impl.cpp index 7a4ff73f27c001a2d1117c8f1afcbf1bda0ae6eb..ac4a06787bf34fc42f907516e07f6e16de33e400 100644 --- a/wm/src/window_session_impl.cpp +++ b/wm/src/window_session_impl.cpp @@ -1585,7 +1585,7 @@ WMError WindowSessionImpl::GetTitleButtonArea(TitleButtonRect& titleButtonRect) if (!res) { WLOGFE("get window title buttons area failed"); titleButtonRect.IsUninitializedRect(); - return WMError::WM_DO_NOTHING; + return WMError::WM_OK; } auto display = SingletonContainer::Get().GetDisplayById(property_->GetDisplayId()); if (display == nullptr) {