!31360 修复dragController鼠标拖拽快速抬手缩略图不消失

Merge pull request !31360 from liukaii/gitee_liukai
This commit is contained in:
openharmony_ci 2024-04-26 12:37:33 +00:00 committed by Gitee
commit 2591377d6c
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
5 changed files with 87 additions and 5 deletions

View File

@ -83,6 +83,7 @@
OHOS::Ace::UIDisplaySync::*;
OHOS::Ace::Dimension::*;
OHOS::Ace::Matrix4::*;
OHOS::Ace::NG::DragDropFuncWrapper::*;
virtual?thunk?to?OHOS::Ace::Animator::~Animator??;

View File

@ -18,6 +18,7 @@ build_component_ng("manager_ng") {
sources = [
"display_sync/ui_display_sync.cpp",
"display_sync/ui_display_sync_manager.cpp",
"drag_drop/drag_drop_func_wrapper.cpp",
"drag_drop/drag_drop_manager.cpp",
"drag_drop/drag_drop_proxy.cpp",
"drag_drop/utils/drag_animation_helper.cpp",

View File

@ -0,0 +1,42 @@
/*
* Copyright (c) 2024 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "core/components_ng/manager/drag_drop/drag_drop_func_wrapper.h"
namespace OHOS::Ace::NG {
void DragDropFuncWrapper::SetDraggingPointerAndPressedState(int32_t currentPointerId, int32_t containerId)
{
auto pipelineContext = PipelineContext::GetContextByContainerId(containerId);
CHECK_NULL_VOID(pipelineContext);
auto manager = pipelineContext->GetDragDropManager();
CHECK_NULL_VOID(manager);
manager->SetDraggingPointer(currentPointerId);
manager->SetDraggingPressedState(true);
}
void DragDropFuncWrapper::DecideWhetherToStopDragging(
const PointerEvent& pointerEvent, const std::string& extraParams, int32_t currentPointerId, int32_t containerId)
{
auto pipelineContext = PipelineContext::GetContextByContainerId(containerId);
CHECK_NULL_VOID(pipelineContext);
auto manager = pipelineContext->GetDragDropManager();
CHECK_NULL_VOID(manager);
if (!manager->IsDraggingPressed(currentPointerId)) {
manager->OnDragEnd(pointerEvent, extraParams);
}
}
} // namespace OHOS::Ace

View File

@ -0,0 +1,31 @@
/*
* Copyright (c) 2024 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_MANAGER_DRAG_DROP_DRAG_DROP_FUNC_WRAPPER_H
#define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_MANAGER_DRAG_DROP_DRAG_DROP_FUNC_WRAPPER_H
#include "core/pipeline_ng/pipeline_context.h"
namespace OHOS::Ace::NG {
/* DragDropFuncWrapper as a utility class, all function calls must use containerId. */
class ACE_FORCE_EXPORT DragDropFuncWrapper {
public:
static void SetDraggingPointerAndPressedState(int32_t currentPointerId, int32_t containerId);
static void DecideWhetherToStopDragging(const PointerEvent& pointerEvent,
const std::string& extraParams, int32_t currentPointerId, int32_t containerId);
};
} // namespace OHOS::Ace::NG
#endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_MANAGER_DRAG_DROP_DRAG_DROP_FUNC_WRAPPER_H

View File

@ -43,6 +43,7 @@
#include "core/common/ace_engine.h"
#include "core/common/container_scope.h"
#include "core/common/udmf/udmf_client.h"
#include "core/components_ng/manager/drag_drop/drag_drop_func_wrapper.h"
#include "core/event/ace_events.h"
#include "frameworks/bridge/common/utils/engine_helper.h"
#include "drag_preview.h"
@ -57,8 +58,9 @@ constexpr float PIXELMAP_WIDTH_RATE = -0.5f;
constexpr float PIXELMAP_HEIGHT_RATE = -0.2f;
constexpr size_t STR_BUFFER_SIZE = 1024;
constexpr int32_t PARAMETER_NUM = 2;
constexpr int32_t argCount3 = 3;
constexpr int32_t SOURCE_TYPE_MOUSE = 1;
constexpr int32_t MOUSE_POINTER_ID = 1001;
using DragNotifyMsg = Msdp::DeviceStatus::DragNotifyMsg;
using DragRet = OHOS::Ace::DragRet;
@ -598,8 +600,10 @@ void HandleOnDragStart(DragControllerAsyncCtx* asyncCtx)
auto taskExecutor = container->GetTaskExecutor();
CHECK_NULL_VOID(taskExecutor);
taskExecutor->PostTask(
[globalX = asyncCtx->globalX, globalY = asyncCtx->globalY, context = pipelineContext]() {
context->OnDragEvent({ globalX, globalY }, DragEventAction::DRAG_EVENT_START_FOR_CONTROLLER);
[ctx = asyncCtx, context = pipelineContext]() {
context->OnDragEvent({ ctx->globalX, ctx->globalY }, DragEventAction::DRAG_EVENT_START_FOR_CONTROLLER);
NG::DragDropFuncWrapper::DecideWhetherToStopDragging(
{ ctx->globalX, ctx->globalY }, ctx->extraParams, ctx->pointerId, ctx->instanceId);
},
TaskExecutor::TaskType::UI, "ArkUIDragHandleDragEventStart");
}
@ -708,7 +712,7 @@ void StartDragService(DragControllerAsyncCtx* asyncCtx)
OnDragCallback callback = [asyncCtx](const DragNotifyMsg& dragNotifyMsg) {
HandleSuccess(asyncCtx, dragNotifyMsg, DragStatus::ENDED);
};
NG::DragDropFuncWrapper::SetDraggingPointerAndPressedState(asyncCtx->pointerId, asyncCtx->instanceId);
int32_t ret = Msdp::DeviceStatus::InteractionManager::GetInstance()->StartDrag(dragData.value(),
std::make_shared<OHOS::Ace::StartDragListenerImpl>(callback));
napi_handle_scope scope = nullptr;
@ -842,7 +846,7 @@ void OnComplete(DragControllerAsyncCtx* asyncCtx)
OnDragCallback callback = [asyncCtx](const DragNotifyMsg& dragNotifyMsg) {
HandleSuccess(asyncCtx, dragNotifyMsg, DragStatus::ENDED);
};
NG::DragDropFuncWrapper::SetDraggingPointerAndPressedState(asyncCtx->pointerId, asyncCtx->instanceId);
int32_t ret = Msdp::DeviceStatus::InteractionManager::GetInstance()->StartDrag(dragData,
std::make_shared<OHOS::Ace::StartDragListenerImpl>(callback));
if (ret != 0) {
@ -1314,6 +1318,9 @@ bool ConfirmCurPointerEventInfo(DragControllerAsyncCtx *asyncCtx, const RefPtr<C
};
bool getPointSuccess = container->GetCurPointerEventInfo(
asyncCtx->pointerId, asyncCtx->globalX, asyncCtx->globalY, asyncCtx->sourceType, std::move(stopDragCallback));
if (asyncCtx->sourceType == SOURCE_TYPE_MOUSE) {
asyncCtx->pointerId = MOUSE_POINTER_ID;
}
return getPointSuccess;
}