From 16a1ab90cff3a2dbfbe95e56144c48ca396d0660 Mon Sep 17 00:00:00 2001 From: hellohyh001 Date: Tue, 13 Jun 2023 06:07:08 +0000 Subject: [PATCH] update Signed-off-by: hellohyh001 Change-Id: I8d193862a1acfe52c19c210ca75cfc303a31b676 --- .../core/components_ng/base/frame_node.h | 2 +- .../pattern/window_scene/BUILD.gn | 6 +++++- .../pattern/window_scene/scene/window_node.cpp | 18 ++++++++++++++++-- .../pattern/window_scene/scene/window_node.h | 1 + .../test/mock/base/mock_frame_node.cpp | 5 +++++ .../core/pattern/window_scene/BUILD.gn | 2 ++ 6 files changed, 30 insertions(+), 4 deletions(-) diff --git a/frameworks/core/components_ng/base/frame_node.h b/frameworks/core/components_ng/base/frame_node.h index 8baad7f15b8..fee2b207947 100644 --- a/frameworks/core/components_ng/base/frame_node.h +++ b/frameworks/core/components_ng/base/frame_node.h @@ -320,7 +320,7 @@ public: void AddHotZoneRect(const DimensionRect& hotZoneRect) const; void RemoveLastHotZoneRect() const; - bool IsOutOfTouchTestRegion(const PointF& parentLocalPoint); + virtual bool IsOutOfTouchTestRegion(const PointF& parentLocalPoint); bool IsLayoutDirtyMarked() const { diff --git a/frameworks/core/components_ng/pattern/window_scene/BUILD.gn b/frameworks/core/components_ng/pattern/window_scene/BUILD.gn index 83314bce931..f9d0fefbb14 100644 --- a/frameworks/core/components_ng/pattern/window_scene/BUILD.gn +++ b/frameworks/core/components_ng/pattern/window_scene/BUILD.gn @@ -22,6 +22,7 @@ if (is_ohos_standard_system) { "$window_manager_path/interfaces/innerkits", "$window_manager_path/interfaces/innerkits/wm", "$window_manager_path/wm/include", + "$window_manager_path/window_scene/intention_event/include", ] } } @@ -42,7 +43,10 @@ build_component_ng("window_scene") { if (is_ohos_standard_system) { configs = [ ":window_scene_config" ] - deps = [ "$graphic_standard_path/rosen/modules/render_service_client:librender_service_client" ] + deps = [ + "$graphic_standard_path/rosen/modules/render_service_client:librender_service_client", + "$window_manager_path/window_scene/intention_event:libwindow_event_process", + ] external_deps = [ "ability_runtime:abilitykit_native", diff --git a/frameworks/core/components_ng/pattern/window_scene/scene/window_node.cpp b/frameworks/core/components_ng/pattern/window_scene/scene/window_node.cpp index f30d4e644ad..571c986346e 100644 --- a/frameworks/core/components_ng/pattern/window_scene/scene/window_node.cpp +++ b/frameworks/core/components_ng/pattern/window_scene/scene/window_node.cpp @@ -21,18 +21,22 @@ #include "base/utils/utils.h" #include "core/components_ng/pattern/window_scene/scene/window_pattern.h" #include "core/pipeline_ng/pipeline_context.h" +#include "window_event_process.h" namespace OHOS::Ace::NG { HitTestResult WindowNode::TouchTest(const PointF& globalPoint, const PointF& parentLocalPoint, const TouchRestrict& touchRestrict, TouchTestResult& result, int32_t touchId) { auto rectWithTransform = GetPaintRectWithTransform(); - if (!rectWithTransform.IsInRegion(parentLocalPoint)) { + TouchEvent touchEvent = touchRestrict.touchEvent; + if (!WindowEventHandler->IsInWindowHotRect(rectWithTransform, parentLocalPoint, + static_cast(touchEvent.sourceType))) { + LOGE("parentLocalPoint is not in window scene regin, point:%{public}s", parentLocalPoint.ToString().c_str()); return HitTestResult::OUT_OF_REGION; } auto context = GetContext(); CHECK_NULL_RETURN(context, HitTestResult::BUBBLING); - DispatchPointerEvent(touchRestrict.touchEvent, rectWithTransform); + DispatchPointerEvent(touchEvent, rectWithTransform); auto callback = [weak = WeakClaim(this), rectWithTransform](const TouchEvent& point) { auto windowNode = weak.Upgrade(); CHECK_NULL_VOID(windowNode); @@ -70,4 +74,14 @@ RefPtr WindowNode::GetOrCreateWindowNode( ElementRegister::GetInstance()->AddUINode(windowNode); return windowNode; } + +bool WindowNode::IsOutOfTouchTestRegion(const PointF& parentLocalPoint) +{ + const auto& rect = GetGeometryNode()->GetFrameRect(); + if (!WindowEventHandler->IsInWindowHotRect(rect, parentLocalPoint, static_cast(SourceType::TOUCH))) { + LOGE("parentLocalPoint is not in window scene regin, point:%{public}s", parentLocalPoint.ToString().c_str()); + return false; + } + return true; +} } // namespace OHOS::Ace::NG diff --git a/frameworks/core/components_ng/pattern/window_scene/scene/window_node.h b/frameworks/core/components_ng/pattern/window_scene/scene/window_node.h index 1bfd4f26402..f3456352aed 100644 --- a/frameworks/core/components_ng/pattern/window_scene/scene/window_node.h +++ b/frameworks/core/components_ng/pattern/window_scene/scene/window_node.h @@ -37,6 +37,7 @@ public: const std::string& tag, int32_t nodeId, const std::function(void)>& patternCreator); void DispatchPointerEvent(const TouchEvent& point, const RectF& rectWithTransform) const; + bool IsOutOfTouchTestRegion(const PointF& parentLocalPoint) override; }; } // namespace OHOS::Ace::NG diff --git a/frameworks/core/components_ng/test/mock/base/mock_frame_node.cpp b/frameworks/core/components_ng/test/mock/base/mock_frame_node.cpp index 483de8f7ae3..93ddc3d9789 100644 --- a/frameworks/core/components_ng/test/mock/base/mock_frame_node.cpp +++ b/frameworks/core/components_ng/test/mock/base/mock_frame_node.cpp @@ -167,6 +167,11 @@ RefPtr FrameNode::GetAncestorNodeOfFrame() const return nullptr; } +bool FrameNode::IsOutOfTouchTestRegion(const PointF& parentLocalPoint) +{ + return false; +} + bool FrameNode::IsMeasureBoundary() { return false; diff --git a/test/unittest/core/pattern/window_scene/BUILD.gn b/test/unittest/core/pattern/window_scene/BUILD.gn index 3378c5f3259..61ad2b28669 100755 --- a/test/unittest/core/pattern/window_scene/BUILD.gn +++ b/test/unittest/core/pattern/window_scene/BUILD.gn @@ -144,6 +144,7 @@ ohos_unittest("window_scene_test") { "$window_manager_path/interfaces/innerkits", "$window_manager_path/interfaces/innerkits/wm", "$window_manager_path/wm/include", + "$window_manager_path/window_scene/intention_event/include", ] deps = [ @@ -153,6 +154,7 @@ ohos_unittest("window_scene_test") { "$ace_root/test/unittest:ace_unittest_trace", "$cjson_root:cjson", "$graphic_standard_path/rosen/modules/render_service_client:librender_service_client", + "$window_manager_path/window_scene/intention_event:libwindow_event_process", "//third_party/googletest:gmock_main", ] -- Gitee