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