From 72782fab3cec998e46ef9e51baaca258448ba2b6 Mon Sep 17 00:00:00 2001 From: zhanghaibo Date: Wed, 26 Jun 2024 18:30:59 +0800 Subject: [PATCH] delete hot areas after layout Signed-off-by: zhanghaibo Change-Id: I17cfbaa5128cd6d41dde2a7baef3b02182cef136 --- .../entrance/subwindow/subwindow_ohos.cpp | 16 +------------ .../ohos/entrance/subwindow/subwindow_ohos.h | 1 - .../pattern/overlay/overlay_manager.cpp | 23 ++++++++++++------- .../pattern/overlay/overlay_manager.h | 2 +- 4 files changed, 17 insertions(+), 25 deletions(-) diff --git a/adapter/ohos/entrance/subwindow/subwindow_ohos.cpp b/adapter/ohos/entrance/subwindow/subwindow_ohos.cpp index 3f343d6f8a8..f7583e5314c 100644 --- a/adapter/ohos/entrance/subwindow/subwindow_ohos.cpp +++ b/adapter/ohos/entrance/subwindow/subwindow_ohos.cpp @@ -561,11 +561,6 @@ void SubwindowOhos::ShowMenuNG(const RefPtr customNode, const NG: menuWrapperPattern->RegisterMenuCallback(menuNode, menuParam); menuWrapperPattern->SetMenuTransitionEffect(menuNode, menuParam); } - - std::set menuTargetId = std::move(menuTargetId_); - for (auto& child : menuTargetId) { - ClearMenuNG(child, true); - } ShowWindow(); ResizeWindow(); CHECK_NULL_VOID(window_); @@ -584,11 +579,6 @@ void SubwindowOhos::ShowMenuNG(std::function&& buildFunc, std::function< CHECK_NULL_VOID(context); auto overlay = context->GetOverlayManager(); CHECK_NULL_VOID(overlay); - - std::set menuTargetId = std::move(menuTargetId_); - for (auto& child : menuTargetId) { - ClearMenuNG(child, true); - } ShowWindow(); ResizeWindow(); CHECK_NULL_VOID(window_); @@ -699,14 +689,10 @@ void SubwindowOhos::ClearMenuNG(int32_t targetId, bool inWindow, bool showAnimat auto overlay = context->GetOverlayManager(); CHECK_NULL_VOID(overlay); if (showAnimation) { - int32_t id = overlay->CleanMenuInSubWindowWithAnimation(); - if (id >= 0) { - menuTargetId_.insert(id); - } + overlay->CleanMenuInSubWindowWithAnimation(); HideFilter(true); } else { overlay->CleanMenuInSubWindow(targetId); - menuTargetId_.erase(targetId); overlay->RemoveFilter(); } overlay->EraseMenuInfo(targetId); diff --git a/adapter/ohos/entrance/subwindow/subwindow_ohos.h b/adapter/ohos/entrance/subwindow/subwindow_ohos.h index fa4fb8d30f9..575bd32c93f 100644 --- a/adapter/ohos/entrance/subwindow/subwindow_ohos.h +++ b/adapter/ohos/entrance/subwindow/subwindow_ohos.h @@ -209,7 +209,6 @@ private: bool haveDialog_ = false; bool isShowed_ = false; sptr parentWindow_ = nullptr; - std::set menuTargetId_; }; } // namespace OHOS::Ace diff --git a/frameworks/core/components_ng/pattern/overlay/overlay_manager.cpp b/frameworks/core/components_ng/pattern/overlay/overlay_manager.cpp index d6427300911..86f09f1d95e 100644 --- a/frameworks/core/components_ng/pattern/overlay/overlay_manager.cpp +++ b/frameworks/core/components_ng/pattern/overlay/overlay_manager.cpp @@ -1817,11 +1817,21 @@ void OverlayManager::ShowMenuInSubWindow(int32_t targetId, const NG::OffsetF& of } auto rootNode = rootNodeWeak_.Upgrade(); CHECK_NULL_VOID(rootNode); - auto subwindowMgr = SubwindowManager::GetInstance(); + + std::vector idsNeedClean; for (auto child: rootNode->GetChildren()) { - subwindowMgr->DeleteHotAreas(Container::CurrentId(), child->GetId()); + idsNeedClean.push_back(child->GetId()); } + auto pipeline = rootNode->GetContext(); + CHECK_NULL_VOID(pipeline); + pipeline->AddAfterLayoutTask([idsNeedClean, containerId = Container::CurrentId()] { + auto subwindowMgr = SubwindowManager::GetInstance(); + for (auto child : idsNeedClean) { + subwindowMgr->DeleteHotAreas(containerId, child); + } + }); rootNode->Clean(); + auto menuWrapperPattern = menu->GetPattern(); CHECK_NULL_VOID(menuWrapperPattern); if (menuWrapperPattern->IsContextMenu() && menuWrapperPattern->GetPreviewMode() != MenuPreviewMode::NONE) { @@ -1950,11 +1960,11 @@ void OverlayManager::DeleteMenu(int32_t targetId) EraseMenuInfo(targetId); } -int32_t OverlayManager::CleanMenuInSubWindowWithAnimation() +void OverlayManager::CleanMenuInSubWindowWithAnimation() { TAG_LOGD(AceLogTag::ACE_OVERLAY, "clean menu insubwindow with animation enter"); auto rootNode = rootNodeWeak_.Upgrade(); - CHECK_NULL_RETURN(rootNode, -1); + CHECK_NULL_VOID(rootNode); RefPtr menu; for (const auto& child : rootNode->GetChildren()) { auto node = DynamicCast(child); @@ -1963,11 +1973,8 @@ int32_t OverlayManager::CleanMenuInSubWindowWithAnimation() break; } } - CHECK_NULL_RETURN(menu, -1); + CHECK_NULL_VOID(menu); PopMenuAnimation(menu); - - auto menuWrapper = AceType::DynamicCast(menu->GetPattern()); - return menuWrapper->GetTargetId(); } void OverlayManager::CleanPreviewInSubWindow() diff --git a/frameworks/core/components_ng/pattern/overlay/overlay_manager.h b/frameworks/core/components_ng/pattern/overlay/overlay_manager.h index 926aa290f4e..ed7c8471f37 100644 --- a/frameworks/core/components_ng/pattern/overlay/overlay_manager.h +++ b/frameworks/core/components_ng/pattern/overlay/overlay_manager.h @@ -136,7 +136,7 @@ public: void CleanMenuInSubWindow(int32_t targetId); void CleanPreviewInSubWindow(); void CleanPopupInSubWindow(); - int32_t CleanMenuInSubWindowWithAnimation(); + void CleanMenuInSubWindowWithAnimation(); void HideAllMenus(); void ClearToastInSubwindow(); -- Gitee