From 5958c7ae7e831b2937c9af7ebad0bfcc48cab30f Mon Sep 17 00:00:00 2001 From: ia_oi Date: Tue, 15 Oct 2024 21:36:55 +0800 Subject: [PATCH] =?UTF-8?q?=E6=89=8B=E6=9F=84=E8=B6=8A=E8=BF=87=E5=9B=BE?= =?UTF-8?q?=E7=89=87=E9=80=89=E5=8C=BA=E6=B6=88=E5=A4=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: ia_oi --- ui/touch_selection/longpress_drag_selector.h | 4 +++ .../touch_selection_controller.cc | 36 ++++++++++++++++++- .../touch_selection_controller.h | 2 ++ .../touch_selection_draggable.h | 4 +++ 4 files changed, 45 insertions(+), 1 deletion(-) diff --git a/ui/touch_selection/longpress_drag_selector.h b/ui/touch_selection/longpress_drag_selector.h index eac8208055..2dfed47690 100644 --- a/ui/touch_selection/longpress_drag_selector.h +++ b/ui/touch_selection/longpress_drag_selector.h @@ -37,6 +37,10 @@ class UI_TOUCH_SELECTION_EXPORT LongPressDragSelector bool WillHandleTouchEvent(const MotionEvent& event) override; bool IsActive() const override; +#ifdef OHOS_CLIPBOARD + bool IsDragging() const override { return state_ == DRAGGING; } +#endif + // Called just prior to a longpress event being handled. void OnLongPressEvent(base::TimeTicks event_time, const gfx::PointF& position); diff --git a/ui/touch_selection/touch_selection_controller.cc b/ui/touch_selection/touch_selection_controller.cc index 554cc6c010..320271e398 100644 --- a/ui/touch_selection/touch_selection_controller.cc +++ b/ui/touch_selection/touch_selection_controller.cc @@ -11,6 +11,7 @@ #include "base/metrics/histogram_macros.h" #include "base/metrics/user_metrics.h" #include "base/notreached.h" +#include "base/logging.h" namespace ui { namespace { @@ -69,16 +70,40 @@ TouchSelectionController::~TouchSelectionController() { void TouchSelectionController::OnSelectionBoundsChanged( const gfx::SelectionBound& start, const gfx::SelectionBound& end) { - if (start == start_ && end_ == end) + if (start == start_ && end_ == end) { +#ifdef OHOS_CLIPBOARD + reset_selection_temporarily_ = false; +#endif return; + } if (start.type() == gfx::SelectionBound::EMPTY || end.type() == gfx::SelectionBound::EMPTY || !show_touch_handles_) { +#ifdef OHOS_CLIPBOARD + if (active_status_ == SELECTION_ACTIVE && start_selection_handle_ && + end_selection_handle_ && show_touch_handles_) { + if (start_selection_handle_->IsActive() || + end_selection_handle_->IsActive()) { + LOG(INFO) << "selection temporarily hide"; + reset_selection_temporarily_ = true; + return; + } + } + if (longpress_drag_selector_.IsDragging()) { + LOG(INFO) << "long selection temporarily hide"; + reset_selection_temporarily_ = true; + return; + } +#endif HideHandles(); return; } +#ifdef OHOS_CLIPBOARD + reset_selection_temporarily_ = false; +#endif + // Swap the Handles when the start and end selection points cross each other. if (active_status_ == SELECTION_ACTIVE) { // Bounds have the same orientation. @@ -460,6 +485,9 @@ void TouchSelectionController::OnDragBegin( base::RecordAction(base::UserMetricsAction("SelectionChanged")); selection_handle_dragged_ = true; +#ifdef OHOS_CLIPBOARD + reset_selection_temporarily_ = false; +#endif // When moving the handle we want to move only the extent point. Before doing // so we must make sure that the base point is set correctly. client_->SelectBetweenCoordinates(base, extent); @@ -499,6 +527,12 @@ void TouchSelectionController::OnDragUpdate( void TouchSelectionController::OnDragEnd( const TouchSelectionDraggable& draggable) { +#ifdef OHOS_CLIPBOARD + if(reset_selection_temporarily_){ + LOG(INFO)<<"reset_selection_temporarily_ HideHandles"; + HideHandles(); + } +#endif if (&draggable == insertion_handle_.get()) client_->OnSelectionEvent(INSERTION_HANDLE_DRAG_STOPPED); else diff --git a/ui/touch_selection/touch_selection_controller.h b/ui/touch_selection/touch_selection_controller.h index bca3eac0ed..60058dbb6b 100644 --- a/ui/touch_selection/touch_selection_controller.h +++ b/ui/touch_selection/touch_selection_controller.h @@ -275,6 +275,8 @@ class UI_TOUCH_SELECTION_EXPORT TouchSelectionController #ifdef OHOS_CLIPBOARD bool is_long_press_ = false; + + bool reset_selection_temporarily_ = false; #endif }; diff --git a/ui/touch_selection/touch_selection_draggable.h b/ui/touch_selection/touch_selection_draggable.h index 2f5b15c80e..8aff07877b 100644 --- a/ui/touch_selection/touch_selection_draggable.h +++ b/ui/touch_selection/touch_selection_draggable.h @@ -48,6 +48,10 @@ class UI_TOUCH_SELECTION_EXPORT TouchSelectionDraggable { // Whether a drag is active OR being detected for the current touch sequence. virtual bool IsActive() const = 0; + +#ifdef OHOS_CLIPBOARD + virtual bool IsDragging() const { return false; } +#endif }; } // namespace ui -- Gitee