diff --git a/frameworks/core/accessibility/accessibility_manager_ng.cpp b/frameworks/core/accessibility/accessibility_manager_ng.cpp index afcf48bbf88..c5333cd78b9 100644 --- a/frameworks/core/accessibility/accessibility_manager_ng.cpp +++ b/frameworks/core/accessibility/accessibility_manager_ng.cpp @@ -18,6 +18,7 @@ #include "core/accessibility/accessibility_constants.h" #include "core/accessibility/accessibility_session_adapter.h" #include "core/components_ng/pattern/pattern.h" +#include "core/pipeline_ng/pipeline_context.h" namespace OHOS::Ace::NG { void AccessibilityManagerNG::HandleAccessibilityHoverEvent(const RefPtr& root, const MouseEvent& event) @@ -86,8 +87,18 @@ void AccessibilityManagerNG::HandleAccessibilityHoverEvent(const RefPtr(sourceType), - static_cast(eventType), time); + + if (IsHandlePipelineAccessibilityHoverEnter(root)) { + TouchEvent event; + event.x = pointX; + event.y = pointY; + event.sourceType = static_cast(sourceType); + event.time = time; + HandlePipelineAccessibilityHoverEnter(root, event, eventType); + } else { + HandleAccessibilityHoverEventInner(root, point, static_cast(sourceType), + static_cast(eventType), time); + } } void AccessibilityManagerNG::HandleAccessibilityHoverEventInner( @@ -100,9 +111,12 @@ void AccessibilityManagerNG::HandleAccessibilityHoverEventInner( static constexpr size_t THROTTLE_INTERVAL_HOVER_EVENT = 100; uint64_t duration = static_cast(std::chrono::duration_cast(time - hoverState_.time).count()); - if (!hoverState_.idle && duration < THROTTLE_INTERVAL_HOVER_EVENT) { - return; + if (!hoverState_.idle) { + if ((!IsEventTypeChangeDirectHandleHover(eventType)) && (duration < THROTTLE_INTERVAL_HOVER_EVENT)) { + return; + } } + static constexpr size_t MIN_SOURCE_CHANGE_GAP_MS = 1000; if (sourceType != hoverState_.source && !hoverState_.idle) { if (duration < MIN_SOURCE_CHANGE_GAP_MS) { @@ -169,6 +183,7 @@ void AccessibilityManagerNG::HandleAccessibilityHoverEventInner( hoverState_.time = time; hoverState_.source = sourceType; hoverState_.idle = eventType == AccessibilityHoverEventType::EXIT; + hoverState_.eventType = eventType; } bool AccessibilityManagerNG::DeliverAccessibilityHoverEvent(const RefPtr& hoverNode, const PointF& point) @@ -267,4 +282,53 @@ bool AccessibilityManagerNG::ConvertPointFromAncestorToNode( } return true; } + +bool AccessibilityManagerNG::IsEventTypeChangeDirectHandleHover(AccessibilityHoverEventType eventType) +{ + if ((hoverState_.eventType == AccessibilityHoverEventType::MOVE) + && (eventType == AccessibilityHoverEventType::EXIT)) { + return true; + } + return false; +} + +bool AccessibilityManagerNG::IsHandlePipelineAccessibilityHoverEnter(const RefPtr& root) +{ + auto pipeline = root->GetContext(); + CHECK_NULL_RETURN(pipeline, false); + auto ngPipeline = AceType::DynamicCast(pipeline); + CHECK_NULL_RETURN(ngPipeline, false); + + auto container = Container::GetContainer(ngPipeline->GetInstanceId()); + if (container && (container->IsUIExtensionWindow())) { + return true; + } + return false; +} + +void AccessibilityManagerNG::HandlePipelineAccessibilityHoverEnter( + const RefPtr& root, + TouchEvent& event, + int32_t eventType) +{ + AccessibilityHoverEventType eventHoverType = static_cast(eventType); + event.type = TouchType::HOVER_MOVE; + switch (eventHoverType) { + case AccessibilityHoverEventType::ENTER: + event.type = TouchType::HOVER_ENTER; + break; + case AccessibilityHoverEventType::MOVE: + event.type = TouchType::HOVER_MOVE; + break; + case AccessibilityHoverEventType::EXIT: + event.type = TouchType::HOVER_EXIT; + break; + default: + break; + } + + auto pipeline = root->GetContext(); + CHECK_NULL_VOID(pipeline); + pipeline->OnAccessibilityHoverEvent(event, root); +} } // namespace OHOS::Ace::NG diff --git a/frameworks/core/accessibility/accessibility_manager_ng.h b/frameworks/core/accessibility/accessibility_manager_ng.h index 93ec69c90d8..cb65f19c924 100644 --- a/frameworks/core/accessibility/accessibility_manager_ng.h +++ b/frameworks/core/accessibility/accessibility_manager_ng.h @@ -23,6 +23,7 @@ #include "base/geometry/ng/point_t.h" #include "base/utils/type_definition.h" #include "core/event/ace_events.h" +#include "accessibility_constants.h" namespace OHOS::Ace { struct MouseEvent; @@ -37,6 +38,7 @@ struct AccessibilityHoverState { std::vector> nodesHovering; TimeStamp time; bool idle = true; + AccessibilityHoverEventType eventType = AccessibilityHoverEventType::MOVE; }; class AccessibilityManagerNG final: public AceType { @@ -81,6 +83,13 @@ private: const RefPtr& rootNode, const PointF& pointRoot, SourceType sourceType, AccessibilityHoverEventType eventType, TimeStamp time); + bool IsEventTypeChangeDirectHandleHover(AccessibilityHoverEventType eventType); + bool IsHandlePipelineAccessibilityHoverEnter(const RefPtr& root); + void HandlePipelineAccessibilityHoverEnter( + const RefPtr& root, + TouchEvent& event, + int32_t eventType); + AccessibilityHoverState hoverState_; }; } // namespace NG