18125f82539e4cc3585f83d3e5ba4647d2b78122
[platform/core/uifw/dali-adaptor.git] / dali / internal / window-system / common / event-handler.h
1 #ifndef __DALI_INTERNAL_EVENT_HANDLER_H__
2 #define __DALI_INTERNAL_EVENT_HANDLER_H__
3
4 /*
5  * Copyright (c) 2018 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 // EXTERNAL INCLUDES
22 #include <dali/integration-api/events/key-event-integ.h>
23 #include <dali/integration-api/events/point.h>
24 #include <dali/integration-api/events/touch-event-combiner.h>
25 #include <dali/devel-api/adaptor-framework/style-monitor.h>
26
27 // INTERNAL INCLUDES
28 #include <dali/internal/window-system/common/damage-observer.h>
29 #include <dali/internal/input/common/drag-and-drop-detector-impl.h>
30 #include <dali/internal/accessibility/common/accessibility-adaptor-impl.h>
31 #include <dali/internal/clipboard/common/clipboard-event-notifier-impl.h>
32 #include <dali/internal/window-system/common/rotation-observer.h>
33 #include <dali/internal/window-system/common/window-base.h>
34
35 namespace Dali
36 {
37
38 class RenderSurface;
39
40 namespace Internal
41 {
42
43 namespace Adaptor
44 {
45
46 class CoreEventInterface;
47 class GestureManager;
48 class StyleMonitor;
49
50 /**
51  * The Event Handler class is responsible for setting up receiving of Ecore events and then converts them
52  * to TouchEvents when it does receive them.
53  *
54  * These TouchEvents are then passed on to Core.
55  */
56 class EventHandler : public ConnectionTracker
57 {
58 public:
59
60   /**
61    * Constructor.
62    * @param[in]  surface                  The surface where events will be sent to.
63    * @param[in]  coreEventInterface       Used to send events to Core.
64    * @param[in]  gestureManager           The Gesture Manager.
65    * @param[in]  damageObserver           The damage observer (to pass damage events to).
66    * @param[in]  dndDetector              The Drag & Drop listener (to pass DnD events to).
67    */
68   EventHandler( RenderSurface* surface, CoreEventInterface& coreEventInterface, GestureManager& gestureManager, DamageObserver& damageObserver, DragAndDropDetectorPtr dndDetector );
69
70   /**
71    * Destructor.
72    */
73   ~EventHandler();
74
75   /**
76    * Feed (Send) touch event to core and gesture manager
77    * @param[in] touchEvent  The touch event holding the touch point information.
78    */
79   void FeedTouchPoint( TouchPoint& point, int timeStamp );
80
81   /**
82    * Feed (Send) wheel event to core and gesture manager
83    * @param[in]  wheelEvent The wheel event
84    */
85   void FeedWheelEvent( WheelEvent& wheelEvent );
86
87   /**
88    * Feed (Send) key event to core
89    * @param[in] keyEvent The key event holding the key information.
90    */
91   void FeedKeyEvent( KeyEvent& keyEvent );
92
93   /**
94    * Feed (Send) an event to core
95    * @param[in] event  The event information.
96    */
97   void FeedEvent( Integration::Event& event );
98
99   /**
100    * Called when the adaptor is paused.
101    */
102   void Pause();
103
104   /**
105    * Called when the adaptor is resumed (from pause).
106    */
107   void Resume();
108
109   /**
110    * Sets the Drag & Drop detector.
111    * @param[in]  detector  An intrusive pointer to the Drag & Drop listener to set. To unset pass in NULL.
112    */
113   void SetDragAndDropDetector( DragAndDropDetectorPtr detector );
114
115   /**
116    * Set the rotation observer (note, some adaptors may not have a rotation observer)
117    * @param[in] observer The rotation observer
118    */
119   void SetRotationObserver( RotationObserver* observer );
120
121 private:
122
123   /**
124    * Send touch event to core.
125    * @param[in]  point      The touch point information.
126    * @param[in]  timeStamp  The time the touch occurred.
127    */
128   void SendEvent(Integration::Point& point, unsigned long timeStamp);
129
130   /**
131    * Send key event to core.
132    * @param[in]  keyEvent The KeyEvent to send.
133    */
134   void SendEvent(Integration::KeyEvent& keyEvent);
135
136   /**
137    * Send wheel event to core.
138    * @param[in]  wheelEvent The wheel event
139    */
140   void SendWheelEvent( WheelEvent& wheelEvent );
141
142   /**
143    * Send a style change event to the style monitor.
144    * @param[in]  styleChange  The style that has changed.
145    */
146   void SendEvent( StyleChange::Type styleChange );
147
148   /**
149    * Send a window damage event to the observer.
150    * @param[in]  area  Damaged area.
151    */
152   void SendEvent( const DamageArea& area );
153
154   /**
155    * Inform rotation observer of rotation prepare event
156    * @param[in] rotation The rotation event
157    */
158   void SendRotationPrepareEvent( const RotationEvent& rotation );
159
160   /**
161    * Inform rotation observer of rotation prepare event
162    */
163   void SendRotationRequestEvent();
164
165   /**
166    * Resets the event handler.
167    * Called when the adaptor is paused or resumed.
168    */
169   void Reset();
170
171   /**
172    * Called when a touch event is received.
173    */
174   void OnTouchEvent( Integration::Point& point, unsigned long timeStamp );
175
176   /**
177    * Called when a mouse wheel is received.
178    */
179   void OnWheelEvent( WheelEvent& wheelEvent );
180
181   /**
182    * Called when a key event is received.
183    */
184   void OnKeyEvent( Integration::KeyEvent& keyEvent );
185
186   /**
187    * Called when the window focus is changed.
188    */
189   void OnFocusChanged( bool focusIn );
190
191   /**
192    * Called when the window is damaged.
193    */
194   void OnWindowDamaged( const DamageArea& area );
195
196   /**
197    * Called when the source window notifies us the content in clipboard is selected.
198    */
199   void OnSelectionDataSend( void* event );
200
201   /**
202    * Called when the source window sends us about the selected content.
203    */
204   void OnSelectionDataReceived( void* event );
205
206   /**
207    * Called when the style is changed.
208    */
209   void OnStyleChanged( StyleChange::Type styleChange );
210
211   /**
212    * Called when Ecore ElDBus accessibility event is received.
213    */
214   void OnAccessibilityNotification( const WindowBase::AccessibilityInfo& info );
215
216 private:
217
218   /**
219    * Convert touch event position
220    */
221   void ConvertTouchPosition( Integration::Point& point );
222
223 private:
224
225   // Undefined
226   EventHandler( const EventHandler& eventHandler );
227
228   // Undefined
229   EventHandler& operator=( const EventHandler& eventHandler );
230
231 private:
232
233   CoreEventInterface& mCoreEventInterface; ///< Used to send events to Core.
234   Dali::Integration::TouchEventCombiner mCombiner; ///< Combines multi-touch events.
235   GestureManager& mGestureManager; ///< Reference to the GestureManager, set on construction, to send touch events to for analysis.
236   Dali::StyleMonitor mStyleMonitor; ///< Handle to the style monitor, set on construction, to send font size and font change events to.
237   DamageObserver& mDamageObserver; ///< Reference to the DamageObserver, set on construction, to sent damage events to.
238   RotationObserver* mRotationObserver; ///< Pointer to rotation observer, if present.
239
240   DragAndDropDetectorPtr mDragAndDropDetector; ///< Pointer to the drag & drop detector, to send Drag & Drop events to.
241   Dali::AccessibilityAdaptor mAccessibilityAdaptor; ///< Pointer to the accessibility adaptor
242   Dali::ClipboardEventNotifier mClipboardEventNotifier; ///< Pointer to the clipboard event notifier
243   Dali::Clipboard mClipboard;///< Pointer to the clipboard
244
245   int mRotationAngle;
246   int mWindowWidth;
247   int mWindowHeight;
248
249   bool mPaused; ///< The paused state of the adaptor.
250 };
251
252 } // namespace Adaptor
253
254 } // namespace Internal
255
256 } // namespace Dali
257
258 #endif // __DALI_INTERNAL_EVENT_HANDLER_H__