Merge "Added UIThreadLoader to GLIB framework" into devel/master
[platform/core/uifw/dali-adaptor.git] / dali / internal / drag-and-drop / tizen-wayland / drag-and-drop-impl-ecore-wl2.h
1 #ifndef DALI_INTERNAL_DRAG_AND_DROP_ECORE_WL2_H
2 #define DALI_INTERNAL_DRAG_AND_DROP_ECORE_WL2_H
3
4 /*
5  * Copyright (c) 2023 Samsung Electronics Co., Ltd.
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  *
19  */
20
21 // INTERNAL INCLUDES
22 #include <dali/internal/drag-and-drop/common/drag-and-drop-impl.h>
23 #include <dali/internal/system/linux/dali-ecore.h>
24
25 namespace Dali
26 {
27 class DragAndDrop;
28
29 namespace Internal
30 {
31 namespace Adaptor
32 {
33 struct DropTarget
34 {
35   Dali::Actor                            target;
36   Dali::DragAndDrop::DragAndDropFunction callback;
37   bool                                   inside;
38   int                                    parentWindowId;
39 };
40
41 struct DropWindowTarget
42 {
43   Dali::Window                            target;
44   Dali::DragAndDrop::DragAndDropFunction  callback;
45   bool                                    inside;
46   int                                     windowId;
47 };
48
49 /**
50  * DragAndDrop Implementation
51  */
52 class DragAndDropEcoreWl : public Dali::Internal::Adaptor::DragAndDrop,
53                            public Dali::ConnectionTracker
54 {
55 public:
56   /**
57    * Constructor
58    */
59   DragAndDropEcoreWl();
60
61   /**
62    * Destructor
63    */
64   ~DragAndDropEcoreWl() override;
65
66   /**
67    * @copydoc Dali::DragAndDrop::StartDragAndDrop()
68    */
69   bool StartDragAndDrop(Dali::Actor source, Dali::Window shadowWindow, const Dali::DragAndDrop::DragData& data, Dali::DragAndDrop::SourceFunction callback) override;
70
71   /**
72    * @copydoc Dali::DragAndDrop::AddListener()
73    */
74   bool AddListener(Dali::Actor target, Dali::DragAndDrop::DragAndDropFunction callback) override;
75
76   /**
77    * @copydoc Dali::DragAndDrop::AddListener()
78    */
79   bool AddListener(Dali::Window target, Dali::DragAndDrop::DragAndDropFunction callback) override;
80
81   /**
82    * @copydoc Dali::DragAndDrop::RemoveListener()
83    */
84   bool RemoveListener(Dali::Actor target) override;
85
86   /**
87    * @copydoc Dali::DragAndDrop::RemoveListener()
88    */
89   bool RemoveListener(Dali::Window target) override;
90
91   /**
92    * @copydoc Dali::DragAndDrop::SendData()
93    */
94   void SendData(void* event) override;
95
96   /**
97    * @copydoc Dali::DragAndDrop::ReceiveData()
98    */
99   void ReceiveData(void* event) override;
100
101   /**
102    * @copydoc Dali::DragAndDrop::CalculateDragEvent()
103    */
104   bool CalculateDragEvent(void* event) override;
105
106   /**
107    * @copydoc Dali::DragAndDrop::CalculateViewRegion()
108    */
109   bool CalculateViewRegion(void* event) override;
110
111   /**
112    * @brief Call drag source events.
113    */
114   void CallSourceEvent(Dali::DragAndDrop::SourceEventType type);
115
116   /**
117    * @brief Reset drop targets.
118    */
119   void ResetDropTargets();
120
121 private:
122   /**
123    * @brief Callback function to check whether listening target is scene on.
124    * Note that This signal will be called only if AddListener target is not scene on.
125    */
126   void DropTargetSceneOn(Dali::Actor target);
127
128   /**
129    * @brief Recalculate cursor position by orientation.
130    *
131    * @param[in] x The x value of given position
132    * @param[in] y The y value of given position
133    * @param[in] window The window instance
134    * @return The recalculated position by orientation
135    */
136   Vector2 RecalculatePositionByOrientation(int x, int y, Dali::Window window);
137
138 private:
139   DragAndDropEcoreWl(const DragAndDropEcoreWl&) = delete;
140   DragAndDropEcoreWl& operator=(DragAndDropEcoreWl&) = delete;
141   DragAndDropEcoreWl(DragAndDropEcoreWl&&)           = delete;
142   DragAndDropEcoreWl& operator=(DragAndDropEcoreWl&&) = delete;
143
144 private:
145   Dali::Window                      mDragWindow;
146   uint32_t                          mSerial{std::numeric_limits<uint32_t>::max()};
147   Ecore_Event_Handler*              mSendHandler{nullptr};
148   Ecore_Event_Handler*              mSourceEndHandler{nullptr};
149   Ecore_Event_Handler*              mSourceDropHandler{nullptr};
150   Ecore_Event_Handler*              mReceiveHandler{nullptr};
151   Ecore_Event_Handler*              mMotionHandler{nullptr};
152   Ecore_Event_Handler*              mDropHandler{nullptr};
153   Ecore_Event_Handler*              mEnterHandler{nullptr};
154   Ecore_Event_Handler*              mLeaveHandler{nullptr};
155   int                               mTargetIndex{-1};
156   int                               mWindowTargetIndex{-1};
157   std::string                       mMimeType;
158   std::string                       mData;
159   int                               mDataSize{0};
160   Dali::Vector2                     mPosition;
161   Dali::Vector2                     mWindowPosition;
162   Dali::DragAndDrop::SourceFunction mSourceCallback{nullptr};
163   std::vector<DropTarget>           mDropTargets;
164   std::vector<DropWindowTarget>     mDropWindowTargets;
165 }; // class DragAndDropEcoreWl
166
167 } // namespace Adaptor
168
169 } // namespace Internal
170
171 } // namespace Dali
172
173 #endif // DALI_INTERNAL_DRAG_AND_DROP_ECORE_WL2_H