Added UIThreadLoader to GLIB framework
[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 /**
42  * DragAndDrop Implementation
43  */
44 class DragAndDropEcoreWl : public Dali::Internal::Adaptor::DragAndDrop,
45                            public Dali::ConnectionTracker
46 {
47 public:
48   /**
49    * Constructor
50    */
51   DragAndDropEcoreWl();
52
53   /**
54    * Destructor
55    */
56   ~DragAndDropEcoreWl() override;
57
58   /**
59    * @copydoc Dali::DragAndDrop::StartDragAndDrop()
60    */
61   bool StartDragAndDrop(Dali::Actor source, Dali::Window shadowWindow, const Dali::DragAndDrop::DragData& data, Dali::DragAndDrop::SourceFunction callback) override;
62
63   /**
64    * @copydoc Dali::DragAndDrop::AddListener()
65    */
66   bool AddListener(Dali::Actor target, Dali::DragAndDrop::DragAndDropFunction callback) override;
67
68   /**
69    * @copydoc Dali::DragAndDrop::RemoveListener()
70    */
71   bool RemoveListener(Dali::Actor target) override;
72
73   /**
74    * @copydoc Dali::DragAndDrop::SendData()
75    */
76   void SendData(void* event) override;
77
78   /**
79    * @copydoc Dali::DragAndDrop::ReceiveData()
80    */
81   void ReceiveData(void* event) override;
82
83   /**
84    * @copydoc Dali::DragAndDrop::CalculateDragEvent()
85    */
86   bool CalculateDragEvent(void* event) override;
87
88   /**
89    * @copydoc Dali::DragAndDrop::CalculateViewRegion()
90    */
91   bool CalculateViewRegion(void* event) override;
92
93   /**
94    * @brief Call drag source events.
95    */
96   void CallSourceEvent(Dali::DragAndDrop::SourceEventType type);
97
98   /**
99    * @brief Reset drop targets.
100    */
101   void ResetDropTargets();
102
103 private:
104   /**
105    * @brief Callback function to check whether listening target is scene on.
106    * Note that This signal will be called only if AddListener target is not scene on.
107    */
108   void DropTargetSceneOn(Dali::Actor target);
109
110   /**
111    * @brief Recalculate cursor position by orientation.
112    *
113    * @param[in] x The x value of given position
114    * @param[in] y The y value of given position
115    * @param[in] window The window instance
116    * @return The recalculated position by orientation
117    */
118   Vector2 RecalculatePositionByOrientation(int x, int y, Dali::Window window);
119
120 private:
121   DragAndDropEcoreWl(const DragAndDropEcoreWl&) = delete;
122   DragAndDropEcoreWl& operator=(DragAndDropEcoreWl&) = delete;
123   DragAndDropEcoreWl(DragAndDropEcoreWl&&)           = delete;
124   DragAndDropEcoreWl& operator=(DragAndDropEcoreWl&&) = delete;
125
126 private:
127   Dali::Window                      mDragWindow;
128   uint32_t                          mSerial{0u};
129   Ecore_Event_Handler*              mSendHandler{nullptr};
130   Ecore_Event_Handler*              mSourceEndHandler{nullptr};
131   Ecore_Event_Handler*              mSourceDropHandler{nullptr};
132   Ecore_Event_Handler*              mReceiveHandler{nullptr};
133   Ecore_Event_Handler*              mMotionHandler{nullptr};
134   Ecore_Event_Handler*              mDropHandler{nullptr};
135   Ecore_Event_Handler*              mEnterHandler{nullptr};
136   Ecore_Event_Handler*              mLeaveHandler{nullptr};
137   int                               mTargetIndex{0};
138   std::string                       mMimeType;
139   std::string                       mData;
140   int                               mDataSize{0};
141   Dali::Vector2                     mPosition;
142   Dali::DragAndDrop::SourceFunction mSourceCallback{nullptr};
143   std::vector<DropTarget>           mDropTargets;
144 }; // class DragAndDropEcoreWl
145
146 } // namespace Adaptor
147
148 } // namespace Internal
149
150 } // namespace Dali
151
152 #endif // DALI_INTERNAL_DRAG_AND_DROP_ECORE_WL2_H