diff --git a/frameworks/core/components_ng/base/frame_node.h b/frameworks/core/components_ng/base/frame_node.h index 8baad7f15b86b89af3a377298b0c0946ecb73ccf..fee2b2079476f9700e80bb02083d17357b8b82f3 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 83314bce931a882f4abec671b424642e39c2d1da..f9d0fefbb14ef27130b28c25676c7839d5527dcf 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 f30d4e644ad3120beb5443b54ffe6dfdff735702..571c986346efbe0d9ff5b8a1e317293c31bdaa46 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 1bfd4f26402341bdff894d1a790918a8711d7216..f3456352aedf88e126064be64d61719a0962338c 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 483de8f7ae3b2337d044f47ae3dca466c8b3d94e..93ddc3d9789a34bb857cc91257f18c243bfd6cf6 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 3378c5f3259b859c58bd898ab5266fd52d441281..61ad2b28669906e04d630dcd40355dc11bb549c2 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", ]