From 566068fd1098d9e76b08011d30f54bf68c1f2b11 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=9F=A6=E5=9B=BD=E5=AE=81?= Date: Thu, 4 Jul 2024 17:01:37 +0800 Subject: [PATCH 1/3] =?UTF-8?q?windowTitleButtonRectChange=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3=E8=BF=94=E5=9B=9E=E5=80=BC=E6=95=B4=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 韦国宁 --- .../window_runtime/window_napi/js_window_listener.cpp | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) 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 6c82920852..2ea4c9e7b0 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,8 @@ 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)); } ); -- Gitee From 0fe33c59d7bc6dcdc09463ed63c3b429765bf519 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=9F=A6=E5=9B=BD=E5=AE=81?= Date: Thu, 4 Jul 2024 18:07:27 +0800 Subject: [PATCH 2/3] =?UTF-8?q?windowTitleButtonRectChange=E5=9B=9E?= =?UTF-8?q?=E8=B0=83=E6=8E=A5=E5=8F=A3=E8=BF=94=E5=9B=9E=E5=80=BC=E4=BF=AE?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 韦国宁 --- .../kits/napi/window_runtime/window_napi/js_window_listener.cpp | 1 - 1 file changed, 1 deletion(-) 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 2ea4c9e7b0..759b07ebe5 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,7 +495,6 @@ void JsWindowListener::OnWindowTitleButtonRectChanged(const TitleButtonRect& tit if (titleButtonRectValue == nullptr) { return; } - napi_value argv[] = { titleButtonRectValue }; thisListener->CallJsMethod(WINDOW_TITLE_BUTTON_RECT_CHANGE_CB.c_str(), argv, ArraySize(argv)); } -- Gitee From 86f9d57f806a54175866b3dcd27becb61dbf6e10 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=9F=A6=E5=9B=BD=E5=AE=81?= Date: Mon, 8 Jul 2024 16:00:37 +0800 Subject: [PATCH 3/3] =?UTF-8?q?getTitleButtonRect()=E8=BF=94=E5=9B=9E?= =?UTF-8?q?=E9=94=99=E8=AF=AF=E7=A0=81=E6=95=B4=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 韦国宁 --- .../kits/napi/window_runtime/window_napi/js_window.cpp | 6 +++--- wm/src/window_session_impl.cpp | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) 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 92662e5ada..1bfce7edce 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/wm/src/window_session_impl.cpp b/wm/src/window_session_impl.cpp index 7a4ff73f27..ac4a06787b 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) { -- Gitee