支持模态窗模整个应用进程意见修改2

Signed-off-by: 苏嵋岩 <sumeiyan@huawei.com>
This commit is contained in:
苏嵋岩 2024-09-26 22:07:13 +08:00
parent 1ddd39f2b6
commit f1f8f205b9
7 changed files with 17 additions and 22 deletions

View File

@ -1204,7 +1204,7 @@ struct SystemWindowOptions {
int32_t windowType = -1; int32_t windowType = -1;
}; };
enum class ModalityType : uint32_t { enum class ModalityType : uint8_t {
WINDOW_MODALITY, WINDOW_MODALITY,
APPLICATION_MODALITY, APPLICATION_MODALITY,
}; };

View File

@ -903,10 +903,9 @@ napi_value JsExtensionWindow::OnCreateSubWindowWithOptions(napi_env env, napi_ca
extWindow->NotifyModalUIExtensionMayBeCovered(false); extWindow->NotifyModalUIExtensionMayBeCovered(false);
} }
task.Resolve(env, CreateJsWindowObject(env, window)); task.Resolve(env, CreateJsWindowObject(env, window));
TLOGNI(WmsLogTag::WMS_UIEXT, TLOGNI(WmsLogTag::WMS_UIEXT, "%{public}s [NAPI]Create sub window %{public}s end",
"%{public}s [NAPI]Create sub window %{public}s end",
where, windowName.c_str()); where, windowName.c_str());
}; };
napi_value callback = (argv[2] != nullptr && GetType(env, argv[2]) == napi_function) ? argv[2] : nullptr; napi_value callback = (argv[2] != nullptr && GetType(env, argv[2]) == napi_function) ? argv[2] : nullptr;
napi_value result = nullptr; napi_value result = nullptr;
NapiAsyncTask::Schedule("JsExtensionWindow::OnCreateSubWindowWithOptions", NapiAsyncTask::Schedule("JsExtensionWindow::OnCreateSubWindowWithOptions",

View File

@ -5949,7 +5949,7 @@ napi_value JsWindow::OnSetSubWindowModal(napi_env env, napi_callback_info info)
return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM); return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM);
} }
ModalityType modalityType = ModalityType::WINDOW_MODALITY; ModalityType modalityType = ModalityType::WINDOW_MODALITY;
using T = std::underlying_type_t<ModalityType>; using T = std::underlying_type_t<ApiModalityType>;
T type = 0; T type = 0;
if (argc == 2 && ConvertFromJsValue(env, argv[INDEX_ONE], type)) { // 2: the param num if (argc == 2 && ConvertFromJsValue(env, argv[INDEX_ONE], type)) { // 2: the param num
if (!isModal) { if (!isModal) {
@ -5967,8 +5967,7 @@ napi_value JsWindow::OnSetSubWindowModal(napi_env env, napi_callback_info info)
const char* const where = __func__; const char* const where = __func__;
NapiAsyncTask::CompleteCallback complete = NapiAsyncTask::CompleteCallback complete =
[where, window = windowToken_, isModal, modalityType](napi_env env, NapiAsyncTask& task, [where, window = windowToken_, isModal, modalityType](napi_env env, NapiAsyncTask& task, int32_t status) {
int32_t status) {
if (window == nullptr) { if (window == nullptr) {
TLOGNE(WmsLogTag::WMS_SUB, "%{public}s window is nullptr", where); TLOGNE(WmsLogTag::WMS_SUB, "%{public}s window is nullptr", where);
WmErrorCode wmErrorCode = WM_JS_TO_ERROR_CODE_MAP.at(WMError::WM_ERROR_NULLPTR); WmErrorCode wmErrorCode = WM_JS_TO_ERROR_CODE_MAP.at(WMError::WM_ERROR_NULLPTR);
@ -5976,11 +5975,10 @@ napi_value JsWindow::OnSetSubWindowModal(napi_env env, napi_callback_info info)
return; return;
} }
if (!WindowHelper::IsSubWindow(window->GetType())) { if (!WindowHelper::IsSubWindow(window->GetType())) {
TLOGNE(WmsLogTag::WMS_SUB, TLOGNE(WmsLogTag::WMS_SUB, "%{public}s invalid call, type:%{public}d",
"%{public}s invalid call, type:%{public}d",
where, window->GetType()); where, window->GetType());
WmErrorCode wmErrorCode = WmErrorCode::WM_ERROR_INVALID_CALLING; task.Reject(env, JsErrUtils::CreateJsError(env,
task.Reject(env, JsErrUtils::CreateJsError(env, wmErrorCode, "invalid window type.")); WmErrorCode::WM_ERROR_INVALID_CALLING, "invalid window type."));
return; return;
} }
WMError ret = window->SetSubWindowModal(isModal, modalityType); WMError ret = window->SetSubWindowModal(isModal, modalityType);
@ -5988,15 +5986,14 @@ napi_value JsWindow::OnSetSubWindowModal(napi_env env, napi_callback_info info)
task.Resolve(env, NapiGetUndefined(env)); task.Resolve(env, NapiGetUndefined(env));
} else { } else {
WmErrorCode wmErrorCode = WM_JS_TO_ERROR_CODE_MAP.at(ret); WmErrorCode wmErrorCode = WM_JS_TO_ERROR_CODE_MAP.at(ret);
TLOGNE(WmsLogTag::WMS_SUB, TLOGNE(WmsLogTag::WMS_SUB, "%{public}s set failed, ret is %{public}d",
"%{public}s set failed, ret is %{public}d",
where, wmErrorCode); where, wmErrorCode);
task.Reject(env, JsErrUtils::CreateJsError(env, wmErrorCode, "Set subwindow modal failed")); task.Reject(env, JsErrUtils::CreateJsError(env, wmErrorCode, "Set subwindow modal failed"));
} }
TLOGNI(WmsLogTag::WMS_SUB, TLOGNI(WmsLogTag::WMS_SUB,
"%{public}s id:%{public}u, name:%{public}s, isModal:%{public}d, modalityType:%{public}d", "%{public}s id:%{public}u, name:%{public}s, isModal:%{public}d, modalityType:%{public}u",
where, window->GetWindowId(), window->GetWindowName().c_str(), isModal, modalityType); where, window->GetWindowId(), window->GetWindowName().c_str(), isModal, modalityType);
}; };
napi_value lastParam = nullptr; napi_value lastParam = nullptr;
napi_value result = nullptr; napi_value result = nullptr;
NapiAsyncTask::Schedule("JsWindow::SetSubWindowModal", NapiAsyncTask::Schedule("JsWindow::SetSubWindowModal",
@ -6040,7 +6037,7 @@ napi_value JsWindow::OnSetWindowDecorHeight(napi_env env, napi_callback_info inf
WLOGFE("Set window decor height failed"); WLOGFE("Set window decor height failed");
return NapiThrowError(env, ret); return NapiThrowError(env, ret);
} }
WLOGI("Window [%{public}u, %{public}s] OnSetDecorHeight end, height = %{public}d", WLOGI("Window [%{public}u, %{public}s] OnSetDecorHeight end, height = %{public}u",
windowToken_->GetWindowId(), windowToken_->GetWindowName().c_str(), height); windowToken_->GetWindowId(), windowToken_->GetWindowName().c_str(), height);
return NapiGetUndefined(env); return NapiGetUndefined(env);
} }

View File

@ -1100,7 +1100,7 @@ static bool ParseModalityParam(napi_env env, napi_value jsObject, const sptr<Win
} }
windowOption->SetWindowTopmost(isTopmost); windowOption->SetWindowTopmost(isTopmost);
} }
using T = std::underlying_type_t<ModalityType>; using T = std::underlying_type_t<ApiModalityType>;
T modalityType = 0; T modalityType = 0;
if (ParseJsValue(jsObject, env, "modalityType", modalityType)) { if (ParseJsValue(jsObject, env, "modalityType", modalityType)) {
if (!isModal) { if (!isModal) {

View File

@ -669,10 +669,9 @@ napi_value JsWindowStage::OnCreateSubWindowWithOptions(napi_env env, napi_callba
return; return;
} }
task.Resolve(env, CreateJsWindowObject(env, window)); task.Resolve(env, CreateJsWindowObject(env, window));
TLOGNI(WmsLogTag::WMS_SUB, TLOGNI(WmsLogTag::WMS_SUB, "%{public}s [NAPI]Create sub window %{public}s end",
"%{public}s [NAPI]Create sub window %{public}s end",
where, windowName.c_str()); where, windowName.c_str());
}; };
napi_value callback = (argv[2] != nullptr && GetType(env, argv[2]) == napi_function) ? argv[2] : nullptr; napi_value callback = (argv[2] != nullptr && GetType(env, argv[2]) == napi_function) ? argv[2] : nullptr;
napi_value result = nullptr; napi_value result = nullptr;
NapiAsyncTask::Schedule("JsWindowStage::OnCreateSubWindowWithOptions", NapiAsyncTask::Schedule("JsWindowStage::OnCreateSubWindowWithOptions",

View File

@ -803,7 +803,7 @@ struct SystemWindowOptions {
int32_t windowType = -1; int32_t windowType = -1;
}; };
enum class ModalityType : uint32_t { enum class ModalityType : uint8_t {
WINDOW_MODALITY, WINDOW_MODALITY,
APPLICATION_MODALITY, APPLICATION_MODALITY,
}; };

View File

@ -1,4 +1,4 @@
/* /*
* Copyright (c) 2023 Huawei Device Co., Ltd. * Copyright (c) 2023 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.