diff --git a/frameworks/native/interaction/test/unittest/src/interaction_manager_test.cpp b/frameworks/native/interaction/test/unittest/src/interaction_manager_test.cpp index 80f69358e..b65218d6b 100644 --- a/frameworks/native/interaction/test/unittest/src/interaction_manager_test.cpp +++ b/frameworks/native/interaction/test/unittest/src/interaction_manager_test.cpp @@ -1310,6 +1310,7 @@ HWTEST_F(InteractionManagerTest, InteractionManagerTest_StartDrag_Mouse, TestSiz std::make_shared(callback)); ASSERT_EQ(ret, RET_OK); ret = InteractionManager::GetInstance()->SetDragWindowVisible(true); + InteractionManager::GetInstance()->SetDragWindowScreenId(TOUCH_POINTER_ID, TOUCH_POINTER_ID); EXPECT_EQ(ret, RET_OK); SimulateMovePointerEvent({ DRAG_SRC_X, DRAG_SRC_Y }, { DRAG_DST_X, DRAG_DST_Y }, MMI::PointerEvent::SOURCE_TYPE_MOUSE, MOUSE_POINTER_ID, true); diff --git a/intention/cooperate/plugin/src/cooperate_free.cpp b/intention/cooperate/plugin/src/cooperate_free.cpp index b068501a5..b67a21bdc 100644 --- a/intention/cooperate/plugin/src/cooperate_free.cpp +++ b/intention/cooperate/plugin/src/cooperate_free.cpp @@ -60,11 +60,11 @@ void CooperateFree::OnLeaveState(Context &context) void CooperateFree::SetPointerVisible(Context &context) { + CHKPV(env_); bool hasLocalPointerDevice = env_->GetDeviceManager().HasLocalPointerDevice(); bool visible = !context.NeedHideCursor() && hasLocalPointerDevice; FI_HILOGI("Set pointer visible:%{public}s, HasLocalPointerDevice:%{public}s", visible ? "true" : "false", hasLocalPointerDevice ? "true" : "false"); - CHKPV(env_); env_->GetInput().SetPointerVisibility(visible, PRIORITY); } diff --git a/intention/cooperate/plugin/src/cooperate_out.cpp b/intention/cooperate/plugin/src/cooperate_out.cpp index cfc6a589d..e0518264d 100644 --- a/intention/cooperate/plugin/src/cooperate_out.cpp +++ b/intention/cooperate/plugin/src/cooperate_out.cpp @@ -58,11 +58,11 @@ void CooperateOut::OnLeaveState(Context &context) void CooperateOut::SetPointerVisible(Context &context) { + CHKPV(env_); bool hasLocalPointerDevice = env_->GetDeviceManager().HasLocalPointerDevice(); bool visible = !context.NeedHideCursor() && hasLocalPointerDevice; FI_HILOGI("Set pointer visible:%{public}s, HasLocalPointerDevice:%{public}s", visible ? "true" : "false", hasLocalPointerDevice ? "true" : "false"); - CHKPV(env_); env_->GetInput().SetPointerVisibility(visible, PRIORITY); } diff --git a/services/interaction/drag/src/drag_manager.cpp b/services/interaction/drag/src/drag_manager.cpp index ee988fcbb..77031259f 100644 --- a/services/interaction/drag/src/drag_manager.cpp +++ b/services/interaction/drag/src/drag_manager.cpp @@ -197,12 +197,16 @@ int32_t DragManager::StartDrag(const DragData &dragData, int32_t pid) } std::string packageName = std::string(); CHKPR(context_, RET_ERR); - dragOutSession_ = context_->GetSocketSessionManager().FindSessionByPid(pid); - if (dragOutSession_ != nullptr) { + if (pid == -1) { + packageName = "Cross-device drag"; + } else { context_->GetSocketSessionManager().AddSessionDeletedCallback(pid, [this](SocketSessionPtr session) { this->OnSessionLost(session); }); + dragOutSession_ = context_->GetSocketSessionManager().FindSessionByPid(pid); + if (dragOutSession_ != nullptr) { + packageName = dragOutSession_->GetProgramName(); + } } - packageName = (pid == -1) ? "Cross-device drag" : dragOutSession_->GetProgramName(); PrintDragData(dragData, packageName); if (InitDataManager(dragData) != RET_OK) { FI_HILOGE("Failed to init data manager"); diff --git a/services/interaction/drag/src/drag_vsync_station.cpp b/services/interaction/drag/src/drag_vsync_station.cpp index 169582d06..ede5d3c9e 100644 --- a/services/interaction/drag/src/drag_vsync_station.cpp +++ b/services/interaction/drag/src/drag_vsync_station.cpp @@ -66,9 +66,7 @@ void DragVSyncStation::StopVSyncRequest() handler_->RemoveAllFileDescriptorListeners(); handler_ = nullptr; } - if (receiver_ != nullptr) { - receiver_ = nullptr; - } + receiver_ = nullptr; vSyncPeriod_ = 0; if (mmiHandleTid_ > 0) { OHOS::QOS::ResetQosForOtherThread(mmiHandleTid_); @@ -157,7 +155,7 @@ void DragVSyncStation::OnVSyncInner(uint64_t nanoTimestamp) std::lock_guard lock(mtx_); vSyncCallbacks.swap(vSyncCallbacks_); } - for (auto &callback : vSyncCallbacks) { + for (auto const &callback : vSyncCallbacks) { if (callback.second != nullptr) { (*callback.second)(nanoTimestamp); }