mirror of
https://gitee.com/openharmony/arkui_ace_engine
synced 2024-11-30 18:52:04 +00:00
acquire window Id of window scene
Signed-off-by: baoyang <baoyang9@huawei.com> Change-Id: Ibc2b42037406671c288fc1fed9daf54c404d634f
This commit is contained in:
parent
ed64766fb9
commit
c2a07422d2
@ -38,6 +38,7 @@ build_component_ng("security_component_pattern_ng") {
|
||||
"input:libmmi-client",
|
||||
"napi:ace_napi",
|
||||
"security_component_manager:libsecurity_component_sdk",
|
||||
"window_manager:scene_session",
|
||||
]
|
||||
}
|
||||
}
|
||||
|
@ -20,9 +20,11 @@
|
||||
#include "adapter/ohos/entrance/ace_container.h"
|
||||
#include "base/log/ace_scoring_log.h"
|
||||
#include "base/utils/system_properties.h"
|
||||
#include "base/utils/utils.h"
|
||||
#include "core/common/container.h"
|
||||
#include "core/components_ng/pattern/button/button_layout_property.h"
|
||||
#include "core/components_ng/pattern/text/text_layout_property.h"
|
||||
#include "core/components_ng/pattern/window_scene/scene/system_window_scene.h"
|
||||
#include "core/components_v2/inspector/inspector_constants.h"
|
||||
|
||||
namespace OHOS::Ace::NG {
|
||||
@ -321,6 +323,25 @@ double SecurityComponentHandler::CalculateCurrentVisibleRatio(const RectF& visib
|
||||
return visibleRect.Width() * visibleRect.Height() / (renderRect.Width() * renderRect.Height());
|
||||
}
|
||||
|
||||
bool SecurityComponentHandler::GetWindowSceneWindowId(RefPtr<FrameNode>& node, uint32_t& windId)
|
||||
{
|
||||
CHECK_NULL_RETURN(node, false);
|
||||
auto parent = node->GetParent();
|
||||
while (parent != nullptr && parent->GetTag() != V2::WINDOW_SCENE_ETS_TAG) {
|
||||
parent = parent->GetParent();
|
||||
}
|
||||
CHECK_NULL_RETURN(parent, false);
|
||||
auto windowSceneFrameNode = AceType::DynamicCast<FrameNode>(parent);
|
||||
CHECK_NULL_RETURN(windowSceneFrameNode, false);
|
||||
auto windowScene = windowSceneFrameNode->GetPattern<SystemWindowScene>();
|
||||
CHECK_NULL_RETURN(windowScene, false);
|
||||
auto session = windowScene->GetSession();
|
||||
CHECK_NULL_RETURN(session, false);
|
||||
|
||||
windId = static_cast<uint32_t>(session->GetPersistentId());
|
||||
return true;
|
||||
}
|
||||
|
||||
bool SecurityComponentHandler::InitBaseInfo(OHOS::Security::SecurityComponent::SecCompBase& buttonInfo,
|
||||
RefPtr<FrameNode>& node)
|
||||
{
|
||||
@ -364,6 +385,9 @@ bool SecurityComponentHandler::InitBaseInfo(OHOS::Security::SecurityComponent::S
|
||||
if (pipeline->IsFocusWindowIdSetted()) {
|
||||
windId = pipeline->GetFocusWindowId();
|
||||
}
|
||||
if (container->IsScenceBoardWindow()) {
|
||||
GetWindowSceneWindowId(node, windId);
|
||||
}
|
||||
buttonInfo.windowId_ = static_cast<int32_t>(windId);
|
||||
return true;
|
||||
}
|
||||
|
@ -69,6 +69,7 @@ private:
|
||||
static bool CheckParentNodesEffect(RefPtr<FrameNode>& node);
|
||||
static void GetVisibleRect(RefPtr<FrameNode>& node, RectF& visibleRect);
|
||||
static double CalculateCurrentVisibleRatio(const RectF& visibleRect, const RectF& renderRect);
|
||||
static bool GetWindowSceneWindowId(RefPtr<FrameNode>& node, uint32_t& windId);
|
||||
static bool InitBaseInfo(OHOS::Security::SecurityComponent::SecCompBase& buttonInfo, RefPtr<FrameNode>& node);
|
||||
static bool InitChildInfo(OHOS::Security::SecurityComponent::SecCompBase& buttonInfo, RefPtr<FrameNode>& node);
|
||||
};
|
||||
|
@ -45,13 +45,16 @@ ohos_unittest("security_component_test_ng") {
|
||||
sources += [
|
||||
"$ace_root/frameworks/core/components_ng/pattern/security_component/security_component_handler.cpp",
|
||||
"$ace_root/frameworks/core/components_ng/pattern/security_component/security_component_probe.cpp",
|
||||
"$ace_root/frameworks/core/components_ng/pattern/window_scene/scene/system_window_scene.cpp",
|
||||
"$ace_root/test/mock/adapter/mock_ace_container.cpp",
|
||||
]
|
||||
external_deps = [
|
||||
"ability_runtime:abilitykit_native",
|
||||
"c_utils:utils",
|
||||
"graphic_2d:librender_service_client",
|
||||
"input:libmmi-client",
|
||||
"napi:ace_napi",
|
||||
"window_manager:scene_session",
|
||||
]
|
||||
}
|
||||
configs = [ "$ace_root/test/unittest:ace_unittest_config" ]
|
||||
|
Loading…
Reference in New Issue
Block a user