• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2023 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef DRAG_MANAGER_IMPL_H
17 #define DRAG_MANAGER_IMPL_H
18 
19 #include <functional>
20 #include <list>
21 #include <mutex>
22 #include <string>
23 
24 #include "client.h"
25 #include "devicestatus_client.h"
26 #include "devicestatus_define.h"
27 #include "drag_data.h"
28 #include "i_drag_listener.h"
29 #include "util.h"
30 
31 namespace OHOS {
32 namespace Msdp {
33 namespace DeviceStatus {
34 class DragManagerImpl  {
35 public:
36     DragManagerImpl() = default;
37     ~DragManagerImpl() = default;
38 
39     int32_t UpdateDragStyle(DragCursorStyle style);
40     int32_t GetDragTargetPid();
41     int32_t GetUdKey(std::string &udKey);
42     int32_t StartDrag(const DragData &dragData, std::function<void(const DragNotifyMsg&)> callback);
43     int32_t StopDrag(DragResult result, bool hasCustomAnimation);
44     int32_t OnNotifyResult(const StreamClient& client, NetPacket& pkt);
45     int32_t OnStateChangedMessage(const StreamClient& client, NetPacket& pkt);
46     int32_t AddDraglistener(DragListenerPtr listener);
47     int32_t RemoveDraglistener(DragListenerPtr listener);
48     int32_t SetDragWindowVisible(bool visible);
49     int32_t GetShadowOffset(int32_t& offsetX, int32_t& offsetY, int32_t& width, int32_t& height);
50     int32_t UpdateShadowPic(const ShadowInfo &shadowInfo);
51 
52 private:
53     std::mutex mtx_;
54     std::atomic_bool hasRegistered_ { false };
55     std::list<DragListenerPtr> dragListener_;
56     std::function<void(const DragNotifyMsg&)> stopCallback_ { nullptr };
57 };
58 } // namespace DeviceStatus
59 } // namespace Msdp
60 } // namespace OHOS
61 #endif // DRAG_MANAGER_IMPL_H
62