diff --git a/frameworks/native/interaction/src/interaction_manager.cpp b/frameworks/native/interaction/src/interaction_manager.cpp index 8e73753bd..91a96230e 100644 --- a/frameworks/native/interaction/src/interaction_manager.cpp +++ b/frameworks/native/interaction/src/interaction_manager.cpp @@ -189,6 +189,11 @@ int32_t InteractionManager::RotateDragWindowSync(const std::shared_ptr &summarys) { return INTER_MGR_IMPL.GetDragSummary(summarys); diff --git a/intention/drag/client/include/drag_client.h b/intention/drag/client/include/drag_client.h index 443cfc1e0..f257a4fe7 100644 --- a/intention/drag/client/include/drag_client.h +++ b/intention/drag/client/include/drag_client.h @@ -54,6 +54,7 @@ public: const PreviewStyle &previewStyle, const PreviewAnimation &animation); int32_t RotateDragWindowSync(ITunnelClient &tunnel, const std::shared_ptr& rsTransaction = nullptr); + int32_t SetDragWindowScreenId(ITunnelClient &tunnel, uint64_t displayId, uint64_t screenId); int32_t GetDragSummary(ITunnelClient &tunnel, std::map &summary); int32_t GetDragState(ITunnelClient &tunnel, DragState &dragState); int32_t EnterTextEditorArea(ITunnelClient &tunnel, bool enable); diff --git a/intention/drag/client/src/drag_client.cpp b/intention/drag/client/src/drag_client.cpp index c41750ff4..5413d27c3 100644 --- a/intention/drag/client/src/drag_client.cpp +++ b/intention/drag/client/src/drag_client.cpp @@ -317,6 +317,18 @@ int32_t DragClient::RotateDragWindowSync(ITunnelClient &tunnel, return ret; } +int32_t DragClient::SetDragWindowScreenId(ITunnelClient &tunnel, uint64_t displayId, uint64_t screenId) +{ + SetDragWindowScreenIdParam param { displayId, screenId }; + DefaultReply reply {}; + + int32_t ret = tunnel.SetParam(Intention::DRAG, DragRequestID::SET_DRAG_WINDOW_SCREEN_ID, param, reply); + if (ret != RET_OK) { + FI_HILOGE("ITunnelClient::SetParam fail"); + } + return ret; +} + int32_t DragClient::GetDragSummary(ITunnelClient &tunnel, std::map &summary) { DefaultParam param {}; diff --git a/intention/drag/data/include/drag_params.h b/intention/drag/data/include/drag_params.h index 8ad9d083b..359ce188c 100644 --- a/intention/drag/data/include/drag_params.h +++ b/intention/drag/data/include/drag_params.h @@ -50,6 +50,7 @@ enum DragRequestID : uint32_t { GET_DRAG_ACTION, GET_EXTRA_INFO, ERASE_MOUSE_ICON, + SET_DRAG_WINDOW_SCREEN_ID, }; struct StartDragParam final : public ParamBase { @@ -172,6 +173,17 @@ struct RotateDragWindowSyncParam final : public ParamBase { std::shared_ptr rsTransaction_ { nullptr }; }; +struct SetDragWindowScreenIdParam final : public ParamBase { + SetDragWindowScreenIdParam() = default; + SetDragWindowScreenIdParam(uint64_t displayId, uint64_t screenId); + + bool Marshalling(MessageParcel &parcel) const override; + bool Unmarshalling(MessageParcel &parcel) override; + + uint64_t displayId_ { 0 }; + uint64_t screenId_ { 0 }; +}; + struct GetDragSummaryReply final : public ParamBase { GetDragSummaryReply() = default; explicit GetDragSummaryReply(std::map &&summary); diff --git a/intention/drag/data/src/drag_params.cpp b/intention/drag/data/src/drag_params.cpp index 552a84847..fb5d49c15 100644 --- a/intention/drag/data/src/drag_params.cpp +++ b/intention/drag/data/src/drag_params.cpp @@ -264,6 +264,20 @@ bool RotateDragWindowSyncParam::Unmarshalling(MessageParcel &parcel) return true; } +SetDragWindowScreenIdParam::SetDragWindowScreenIdParam(uint64_t displayId, uint64_t screenId) + : displayId_(displayId), screenId_(screenId) +{} + +bool SetDragWindowScreenIdParam::Marshalling(MessageParcel &parcel) const +{ + return (parcel.WriteUint64(displayId_) && parcel.WriteUint64(screenId_)); +} + +bool SetDragWindowScreenIdParam::Unmarshalling(MessageParcel &parcel) +{ + return (parcel.ReadUint64(displayId_) && parcel.ReadUint64(screenId_)); +} + GetDragSummaryReply::GetDragSummaryReply(std::map &&summary) : summary_(std::move(summary)) {} diff --git a/intention/drag/server/include/drag_server.h b/intention/drag/server/include/drag_server.h index 09ec333b6..4e4533d98 100644 --- a/intention/drag/server/include/drag_server.h +++ b/intention/drag/server/include/drag_server.h @@ -57,6 +57,7 @@ private: int32_t GetDragAction(CallingContext &context, MessageParcel &data, MessageParcel &reply); int32_t GetExtraInfo(CallingContext &context, MessageParcel &data, MessageParcel &reply); int32_t EnterTextEditorArea(CallingContext &context, MessageParcel &data, MessageParcel &reply); + int32_t SetDragWindowScreenId(CallingContext &context, MessageParcel &data, MessageParcel &reply); std::string GetPackageName(Security::AccessToken::AccessTokenID tokenId); IContext *env_ { nullptr }; diff --git a/intention/drag/server/src/drag_server.cpp b/intention/drag/server/src/drag_server.cpp index 81d4d0b0c..424bad5e0 100644 --- a/intention/drag/server/src/drag_server.cpp +++ b/intention/drag/server/src/drag_server.cpp @@ -128,6 +128,9 @@ int32_t DragServer::SetParam(CallingContext &context, uint32_t id, MessageParcel case DragRequestID::UPDATE_PREVIEW_STYLE_WITH_ANIMATION: { return UpdatePreviewAnimation(context, data, reply); } + case DragRequestID::SET_DRAG_WINDOW_SCREEN_ID: { + return SetDragWindowScreenId(context, data, reply); + } default: { FI_HILOGE("Unexpected request ID (%{public}u)", id); return RET_ERR; @@ -274,6 +277,18 @@ int32_t DragServer::RotateDragWindowSync(CallingContext &context, MessageParcel return env_->GetDragManager().RotateDragWindowSync(param.rsTransaction_); } +int32_t DragServer::SetDragWindowScreenId(CallingContext &context, MessageParcel &data, MessageParcel &reply) +{ + SetDragWindowScreenIdParam param {}; + + if (!param.Unmarshalling(data)) { + FI_HILOGE("SetDragWindowScreenId::Unmarshalling fail"); + return RET_ERR; + } + env_->GetDragManager().SetDragWindowScreenId(param.displayId_, param.screenId_); + return RET_OK; +} + int32_t DragServer::GetDragTargetPid(CallingContext &context, MessageParcel &data, MessageParcel &reply) { int32_t targetPid = env_->GetDragManager().GetDragTargetPid(); diff --git a/intention/frameworks/client/include/intention_manager.h b/intention/frameworks/client/include/intention_manager.h index 3edc66798..600efd9ac 100644 --- a/intention/frameworks/client/include/intention_manager.h +++ b/intention/frameworks/client/include/intention_manager.h @@ -81,6 +81,7 @@ public: int32_t GetExtraInfo(std::string &extraInfo); int32_t AddPrivilege(); int32_t EraseMouseIcon(); + int32_t SetDragWindowScreenId(uint64_t displayId, uint64_t screenId); private: void InitClient(); diff --git a/intention/frameworks/client/src/intention_manager.cpp b/intention/frameworks/client/src/intention_manager.cpp index 4fdf2c6bb..0849716da 100644 --- a/intention/frameworks/client/src/intention_manager.cpp +++ b/intention/frameworks/client/src/intention_manager.cpp @@ -441,6 +441,12 @@ int32_t IntentionManager::RotateDragWindowSync(const std::shared_ptr &summarys) { CALL_DEBUG_ENTER; diff --git a/intention/prototype/include/i_drag_manager.h b/intention/prototype/include/i_drag_manager.h index 560834271..c74905dbe 100644 --- a/intention/prototype/include/i_drag_manager.h +++ b/intention/prototype/include/i_drag_manager.h @@ -69,6 +69,7 @@ public: virtual int32_t EnterTextEditorArea(bool enable) = 0; virtual int32_t AddPrivilege(int32_t tokenId) = 0; virtual int32_t EraseMouseIcon() = 0; + virtual void SetDragWindowScreenId(uint64_t displayId, uint64_t screenId) = 0; }; } // namespace DeviceStatus } // namespace Msdp diff --git a/interfaces/innerkits/interaction/include/interaction_manager.h b/interfaces/innerkits/interaction/include/interaction_manager.h index ab6e44864..04f5af1b6 100644 --- a/interfaces/innerkits/interaction/include/interaction_manager.h +++ b/interfaces/innerkits/interaction/include/interaction_manager.h @@ -341,6 +341,8 @@ public: int32_t EraseMouseIcon(); + int32_t SetDragWindowScreenId(uint64_t displayId, uint64_t screenId); + private: InteractionManager() = default; DISALLOW_COPY_AND_MOVE(InteractionManager); diff --git a/interfaces/innerkits/libdevicestatus_client_map b/interfaces/innerkits/libdevicestatus_client_map index f5ce65b0a..eb55dc970 100644 --- a/interfaces/innerkits/libdevicestatus_client_map +++ b/interfaces/innerkits/libdevicestatus_client_map @@ -68,6 +68,7 @@ "OHOS::Msdp::DeviceStatus::InteractionManager::GetExtraInfo(std::__h::basic_string, std::__h::allocator>&)"; "OHOS::Msdp::DeviceStatus::InteractionManager::AddPrivilege()"; "OHOS::Msdp::DeviceStatus::InteractionManager::EraseMouseIcon()"; + "OHOS::Msdp::DeviceStatus::InteractionManager::SetDragWindowScreenId(unsigned long long, unsigned long long)"; }; local: *; diff --git a/services/interaction/drag/include/drag_manager.h b/services/interaction/drag/include/drag_manager.h index 0054aaf17..22d048f17 100644 --- a/services/interaction/drag/include/drag_manager.h +++ b/services/interaction/drag/include/drag_manager.h @@ -83,6 +83,7 @@ public: int32_t AddPrivilege(int32_t tokenId) override; int32_t EraseMouseIcon() override; int32_t RotateDragWindow(Rosen::Rotation rotation) override; + void SetDragWindowScreenId(uint64_t displayId, uint64_t screenId) override; #ifdef OHOS_DRAG_ENABLE_INTERCEPTOR class InterceptorConsumer : public MMI::IInputEventConsumer { public: @@ -157,6 +158,8 @@ private: bool isControlMultiScreenVisible_ = false; sptr displayAbilityStatusChange_ { nullptr }; sptr appStateObserverStatusChange_ { nullptr }; + uint64_t displayId_ { 0 }; + uint64_t screenId_ { 0 }; }; } // namespace DeviceStatus } // namespace Msdp diff --git a/services/interaction/drag/src/drag_manager.cpp b/services/interaction/drag/src/drag_manager.cpp index 06b94ed80..e877a9c60 100644 --- a/services/interaction/drag/src/drag_manager.cpp +++ b/services/interaction/drag/src/drag_manager.cpp @@ -40,7 +40,6 @@ namespace DeviceStatus { namespace { constexpr int32_t TIMEOUT_MS { 3000 }; constexpr int32_t INTERVAL_MS { 500 }; -constexpr uint64_t FOLD_SCREEN_ID { 5 }; std::atomic g_startFilterTime { -1 }; const std::string DRAG_STYLE_DEFAULT {"DEFAULT"}; const std::string DRAG_STYLE_FORBIDDEN {"FORBIDDEN"}; @@ -774,9 +773,8 @@ int32_t DragManager::OnStartDrag() } dragDrawing_.SetScreenId(dragData.displayId); if (Rosen::DisplayManager::GetInstance().IsFoldable() && !isHicarOrSuperLauncher) { - Rosen::FoldDisplayMode foldMode = Rosen::DisplayManager::GetInstance().GetFoldDisplayMode(); - if (foldMode == Rosen::FoldDisplayMode::MAIN) { - dragDrawing_.SetScreenId(FOLD_SCREEN_ID); + if (static_cast(dragData.displayId) == displayId_) { + dragDrawing_.SetScreenId(screenId_); } } int32_t ret = dragDrawing_.Init(dragData, context_); @@ -1030,6 +1028,13 @@ int32_t DragManager::RotateDragWindowSync(const std::shared_ptr keyEvent) { CHKPV(keyEvent);