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