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