mirror of
https://gitee.com/openharmony/msdp_device_status
synced 2024-11-27 09:41:43 +00:00
Restore the drag default dynamic effect
Signed-off-by: 邢江盼 <xingjiangpan2@huawei.com>
This commit is contained in:
parent
d6fbc564f2
commit
5351b77c4a
@ -104,7 +104,7 @@ bool Client::StartEventRunner()
|
||||
{
|
||||
CALL_DEBUG_ENTER;
|
||||
CHK_PID_AND_TID();
|
||||
auto runner = AppExecFwk::EventRunner::Create(THREAD_NAME, AppExecFwk::ThreadMode::FFRT);
|
||||
auto runner = AppExecFwk::EventRunner::Create(THREAD_NAME);
|
||||
CHKPF(runner);
|
||||
eventHandler_ = std::make_shared<AppExecFwk::EventHandler>(runner);
|
||||
|
||||
|
@ -35,7 +35,7 @@ const std::string THREAD_NAME { "os_ClientEventHandler" };
|
||||
SocketClient::SocketClient(std::shared_ptr<ITunnelClient> tunnel)
|
||||
: tunnel_(tunnel)
|
||||
{
|
||||
auto runner = AppExecFwk::EventRunner::Create(THREAD_NAME, AppExecFwk::ThreadMode::FFRT);
|
||||
auto runner = AppExecFwk::EventRunner::Create(THREAD_NAME);
|
||||
eventHandler_ = std::make_shared<AppExecFwk::EventHandler>(runner);
|
||||
}
|
||||
|
||||
|
@ -266,7 +266,6 @@ public:
|
||||
float CalculateWidthScale();
|
||||
float GetMaxWidthScale(int32_t width);
|
||||
int32_t AddSelectedPixelMap(std::shared_ptr<OHOS::Media::PixelMap> pixelMap);
|
||||
void MouseDragMonitorPosition(int32_t displayX, int32_t displayY);
|
||||
|
||||
private:
|
||||
int32_t CheckDragData(const DragData &dragData);
|
||||
@ -350,8 +349,6 @@ private:
|
||||
|
||||
private:
|
||||
int64_t interruptNum_ { -1 };
|
||||
int64_t mouseDragMonitorDisplayX_ { -1 };
|
||||
int64_t mouseDragMonitorDisplayY_ { -1 };
|
||||
std::shared_ptr<Rosen::RSCanvasNode> canvasNode_ { nullptr };
|
||||
std::shared_ptr<DrawSVGModifier> drawSVGModifier_ { nullptr };
|
||||
std::shared_ptr<DrawPixelMapModifier> drawPixelMapModifier_ { nullptr };
|
||||
|
@ -176,7 +176,10 @@ private:
|
||||
uint64_t displayId_ { 0 };
|
||||
uint64_t screenId_ { 0 };
|
||||
int32_t lastEventId_ { -1 };
|
||||
int64_t mouseDragMonitorDisplayX_ { -1 };
|
||||
int64_t mouseDragMonitorDisplayY_ { -1 };
|
||||
bool mouseDragMonitorState_ { false };
|
||||
bool existMouseMoveDragCallback_ { false };
|
||||
};
|
||||
} // namespace DeviceStatus
|
||||
} // namespace Msdp
|
||||
|
@ -264,9 +264,6 @@ int32_t DragDrawing::Init(const DragData &dragData, IContext* context)
|
||||
FI_HILOGE("Draw mouse icon failed");
|
||||
return INIT_FAIL;
|
||||
}
|
||||
if ((mouseDragMonitorDisplayX_ != -1) && (mouseDragMonitorDisplayY_ != -1)) {
|
||||
UpdateDragPosition(g_drawingInfo.displayId, mouseDragMonitorDisplayX_, mouseDragMonitorDisplayY_);
|
||||
}
|
||||
rsUiDirector_->SendMessages();
|
||||
FI_HILOGI("leave");
|
||||
return INIT_SUCCESS;
|
||||
@ -556,12 +553,6 @@ int32_t DragDrawing::AddSelectedPixelMap(std::shared_ptr<OHOS::Media::PixelMap>
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
void DragDrawing::MouseDragMonitorPosition(int32_t displayX, int32_t displayY)
|
||||
{
|
||||
mouseDragMonitorDisplayX_ = displayX;
|
||||
mouseDragMonitorDisplayY_ = displayY;
|
||||
}
|
||||
|
||||
void DragDrawing::OnDragSuccess(IContext* context)
|
||||
{
|
||||
FI_HILOGI("enter");
|
||||
@ -726,7 +717,7 @@ void DragDrawing::NotifyDragInfo(const std::string &sourceName, const std::strin
|
||||
std::shared_ptr<AppExecFwk::EventHandler> DragDrawing::GetSuperHubHandler()
|
||||
{
|
||||
if (superHubHandler_ == nullptr) {
|
||||
auto runner = AppExecFwk::EventRunner::Create(SUPER_HUB_THREAD_NAME, AppExecFwk::ThreadMode::FFRT);
|
||||
auto runner = AppExecFwk::EventRunner::Create(SUPER_HUB_THREAD_NAME);
|
||||
superHubHandler_ = std::make_shared<AppExecFwk::EventHandler>(std::move(runner));
|
||||
}
|
||||
return superHubHandler_;
|
||||
@ -890,7 +881,7 @@ void DragDrawing::OnDragStyleAnimation()
|
||||
return;
|
||||
}
|
||||
if (handler_ == nullptr) {
|
||||
auto runner = AppExecFwk::EventRunner::Create(THREAD_NAME, AppExecFwk::ThreadMode::FFRT);
|
||||
auto runner = AppExecFwk::EventRunner::Create(THREAD_NAME);
|
||||
handler_ = std::make_shared<AppExecFwk::EventHandler>(std::move(runner));
|
||||
}
|
||||
CheckStyleNodeModifier(dragStyleNode);
|
||||
@ -906,7 +897,7 @@ void DragDrawing::OnDragStyle(std::shared_ptr<Rosen::RSCanvasNode> dragStyleNode
|
||||
CHKPV(stylePixelMap);
|
||||
#ifdef OHOS_DRAG_ENABLE_ANIMATION
|
||||
if (handler_ == nullptr) {
|
||||
auto runner = AppExecFwk::EventRunner::Create(THREAD_NAME, AppExecFwk::ThreadMode::FFRT);
|
||||
auto runner = AppExecFwk::EventRunner::Create(THREAD_NAME);
|
||||
CHKPV(runner);
|
||||
handler_ = std::make_shared<AppExecFwk::EventHandler>(std::move(runner));
|
||||
}
|
||||
@ -981,7 +972,7 @@ void DragDrawing::OnStopDragSuccess(std::shared_ptr<Rosen::RSCanvasNode> shadowN
|
||||
auto animateCb = [this] { return this->InitVSync(END_ALPHA, END_SCALE_SUCCESS); };
|
||||
#ifdef OHOS_DRAG_ENABLE_ANIMATION
|
||||
ResetAnimationParameter();
|
||||
auto runner = AppExecFwk::EventRunner::Create(THREAD_NAME, AppExecFwk::ThreadMode::FFRT);
|
||||
auto runner = AppExecFwk::EventRunner::Create(THREAD_NAME);
|
||||
CHKPV(runner);
|
||||
handler_ = std::make_shared<AppExecFwk::EventHandler>(std::move(runner));
|
||||
if (!handler_->PostTask([this] { return this->OnStopAnimationSuccess(); })) {
|
||||
@ -1045,7 +1036,7 @@ void DragDrawing::OnStopDragFail(std::shared_ptr<Rosen::RSSurfaceNode> surfaceNo
|
||||
auto animateCb = [this] { return this->InitVSync(END_ALPHA, END_SCALE_FAIL); };
|
||||
#ifdef OHOS_DRAG_ENABLE_ANIMATION
|
||||
ResetAnimationParameter();
|
||||
auto runner = AppExecFwk::EventRunner::Create(THREAD_NAME, AppExecFwk::ThreadMode::FFRT);
|
||||
auto runner = AppExecFwk::EventRunner::Create(THREAD_NAME);
|
||||
CHKPV(runner);
|
||||
handler_ = std::make_shared<AppExecFwk::EventHandler>(std::move(runner));
|
||||
if (!handler_->PostTask([this] { this->OnStopAnimationFail(); })) {
|
||||
@ -1067,7 +1058,7 @@ int32_t DragDrawing::RunAnimation(std::function<int32_t()> cb)
|
||||
{
|
||||
FI_HILOGD("enter");
|
||||
ResetAnimationParameter();
|
||||
auto runner = AppExecFwk::EventRunner::Create(THREAD_NAME, AppExecFwk::ThreadMode::FFRT);
|
||||
auto runner = AppExecFwk::EventRunner::Create(THREAD_NAME);
|
||||
CHKPR(runner, RET_ERR);
|
||||
handler_ = std::make_shared<AppExecFwk::EventHandler>(std::move(runner));
|
||||
if (!handler_->PostTask(cb)) {
|
||||
|
@ -277,7 +277,10 @@ int32_t DragManager::StopDrag(const DragDropResult &dropResult, const std::strin
|
||||
FI_HILOGE("Notify drag result failed");
|
||||
}
|
||||
lastEventId_ = -1;
|
||||
mouseDragMonitorDisplayX_ = -1;
|
||||
mouseDragMonitorDisplayY_ = -1;
|
||||
mouseDragMonitorState_ = false;
|
||||
existMouseMoveDragCallback_ = false;
|
||||
DRAG_DATA_MGR.ResetDragData();
|
||||
SetAllowStartDrag(true);
|
||||
SetCooperatePriv(0);
|
||||
@ -439,16 +442,20 @@ void DragManager::DragCallback(std::shared_ptr<MMI::PointerEvent> pointerEvent)
|
||||
(pointerAction == MMI::PointerEvent::POINTER_ACTION_MOVE) && mouseDragMonitorState_) {
|
||||
MMI::PointerEvent::PointerItem pointerItem;
|
||||
pointerEvent->GetPointerItem(pointerEvent->GetPointerId(), pointerItem);
|
||||
dragDrawing_.MouseDragMonitorPosition(pointerItem.GetDisplayX(), pointerItem.GetDisplayY());
|
||||
mouseDragMonitorDisplayX_ = pointerItem.GetDisplayX();
|
||||
mouseDragMonitorDisplayY_ = pointerItem.GetDisplayY();
|
||||
existMouseMoveDragCallback_ = true;
|
||||
}
|
||||
if (pointerAction == MMI::PointerEvent::POINTER_ACTION_PULL_MOVE) {
|
||||
dragDrawing_.MouseDragMonitorPosition(-1, -1);
|
||||
mouseDragMonitorDisplayX_ = -1;
|
||||
mouseDragMonitorDisplayY_ = -1;
|
||||
OnDragMove(pointerEvent);
|
||||
return;
|
||||
}
|
||||
FI_HILOGD("DragCallback, pointerAction:%{public}d", pointerAction);
|
||||
if (pointerAction == MMI::PointerEvent::POINTER_ACTION_PULL_UP) {
|
||||
dragDrawing_.MouseDragMonitorPosition(-1, -1);
|
||||
mouseDragMonitorDisplayX_ = -1;
|
||||
mouseDragMonitorDisplayY_ = -1;
|
||||
CHKPV(context_);
|
||||
int32_t ret = context_->GetDelegateTasks().PostAsyncTask([this, pointerEvent] {
|
||||
return this->OnDragUp(pointerEvent);
|
||||
@ -741,9 +748,12 @@ int32_t DragManager::AddPointerEventHandler(uint32_t deviceTags)
|
||||
}
|
||||
#endif // OHOS_DRAG_ENABLE_MONITOR
|
||||
FI_HILOGI("Add drag poniter event handle successfully");
|
||||
FI_HILOGI("leave");
|
||||
return RET_OK;
|
||||
} else {
|
||||
FI_HILOGI("leave");
|
||||
return RET_ERR;
|
||||
}
|
||||
FI_HILOGI("leave");
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
int32_t DragManager::AddKeyEventMonitor()
|
||||
@ -759,9 +769,12 @@ int32_t DragManager::AddKeyEventMonitor()
|
||||
return RET_ERR;
|
||||
}
|
||||
FI_HILOGI("Add drag key event monitor successfully");
|
||||
FI_HILOGI("leave");
|
||||
return RET_OK;
|
||||
} else {
|
||||
FI_HILOGI("leave");
|
||||
return RET_ERR;
|
||||
}
|
||||
FI_HILOGI("leave");
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
int32_t DragManager::RemovePointerEventHandler()
|
||||
@ -848,8 +861,11 @@ int32_t DragManager::OnStartDrag()
|
||||
FI_HILOGE("Init drag drawing cancel, drag animation is running");
|
||||
return RET_ERR;
|
||||
}
|
||||
if (!mouseDragMonitorState_) {
|
||||
if (!mouseDragMonitorState_ || !existMouseMoveDragCallback_) {
|
||||
dragDrawing_.Draw(dragData.displayId, dragData.displayX, dragData.displayY);
|
||||
} else if (mouseDragMonitorState_ && existMouseMoveDragCallback_ && (mouseDragMonitorDisplayX_ != -1)
|
||||
&& (mouseDragMonitorDisplayY_ != -1)) {
|
||||
dragDrawing_.Draw(dragData.displayId, mouseDragMonitorDisplayX_, mouseDragMonitorDisplayY_);
|
||||
}
|
||||
FI_HILOGI("Start drag, appened extra data");
|
||||
MMI::InputManager::GetInstance()->AppendExtraData(extraData);
|
||||
@ -870,14 +886,8 @@ int32_t DragManager::OnStartDrag()
|
||||
int32_t DragManager::OnStopDrag(DragResult result, bool hasCustomAnimation)
|
||||
{
|
||||
FI_HILOGI("Add custom animation:%{public}s", hasCustomAnimation ? "true" : "false");
|
||||
if (RemovePointerEventHandler() != RET_OK) {
|
||||
FI_HILOGE("Failed to remove pointer event handler");
|
||||
return RET_ERR;
|
||||
}
|
||||
if (RemoveKeyEventMonitor() != RET_OK) {
|
||||
FI_HILOGE("Failed to remove key event handler");
|
||||
return RET_ERR;
|
||||
}
|
||||
RemovePointerEventHandler();
|
||||
RemoveKeyEventMonitor();
|
||||
dragAction_.store(DragAction::MOVE);
|
||||
FI_HILOGI("Stop drag, appened extra data");
|
||||
MMI::InputManager::GetInstance()->AppendExtraData(DragManager::CreateExtraData(false));
|
||||
|
@ -96,7 +96,7 @@ int32_t DragVSyncStation::Init()
|
||||
return RET_OK;
|
||||
}
|
||||
if (handler_ == nullptr) {
|
||||
auto runner = AppExecFwk::EventRunner::Create(THREAD_NAME, AppExecFwk::ThreadMode::FFRT);
|
||||
auto runner = AppExecFwk::EventRunner::Create(THREAD_NAME);
|
||||
handler_ = std::make_shared<AppExecFwk::EventHandler>(std::move(runner));
|
||||
SetThreadQosLevel(handler_);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user