Revert "[Tizen](ATSPI) squashed implementation"
[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/devel-api/adaptor-framework/clipboard.h>
26 #include <dali/devel-api/adaptor-framework/style-monitor.h>
27
28 // INTERNAL INCLUDES
29 #include <dali/internal/accessibility/common/accessibility-adaptor-impl.h>
30 #include <dali/internal/clipboard/common/clipboard-event-notifier-impl.h>
31 #include <dali/internal/window-system/common/damage-observer.h>
32 #include <dali/internal/window-system/common/window-base.h>
33
34 namespace Dali
35 {
36
37 namespace Integration
38 {
39
40 struct Point;
41 struct KeyEvent;
42 struct WheelEvent;
43
44 }
45
46 namespace Internal
47 {
48
49 namespace Adaptor
50 {
51
52 class StyleMonitor;
53 class WindowRenderSurface;
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, public Dali::RefObject
62 {
63 public:
64
65   /**
66    * The observer can be overridden in order to listen to the events.
67    */
68   class Observer
69   {
70   public:
71
72     /**
73      * Deriving classes should override this to be notified when we receive a touch point event.
74      * @param[in] point The touch point
75      * @param[in] timeStamp The time stamp
76      */
77     virtual void OnTouchPoint( Dali::Integration::Point& point, int timeStamp ) = 0;
78
79     /**
80      * Deriving classes should override this to be notified when we receive a wheel event.
81      * @param[in] wheelEvent The wheel event
82      */
83     virtual void OnWheelEvent( Dali::Integration::WheelEvent& wheelEvent ) = 0;
84
85     /**
86      * Deriving classes should override this to be notified when we receive a key event.
87      * @param[in] keyEvent The key event holding the key information.
88      */
89     virtual void OnKeyEvent( Dali::Integration::KeyEvent& keyEvent ) = 0;
90
91     /**
92      * Deriving classes should override this to be notified when the window is rotated.
93      * @param[in] rotation The rotation event.
94      */
95     virtual void OnRotation( const RotationEvent& rotation ) = 0;
96
97   protected:
98
99     /**
100      * Protected Constructor.
101      */
102     Observer() {}
103
104     /**
105      * Protected virtual destructor.
106      */
107     virtual ~Observer() {}
108   };
109
110 public:
111
112   /**
113    * Constructor.
114    * @param[in]  surface                  The render surface of the window.
115    * @param[in]  damageObserver           The damage observer (to pass damage events to).
116    */
117   EventHandler( WindowRenderSurface* surface, DamageObserver& damageObserver );
118
119   /**
120    * Destructor.
121    */
122   ~EventHandler();
123
124   /**
125    * Called when the adaptor is paused.
126    */
127   void Pause();
128
129   /**
130    * Called when the adaptor is resumed (from pause).
131    */
132   void Resume();
133
134   /**
135    * Adds an observer so that we can observe the events.
136    * @param[in] observer The observer.
137    */
138   void AddObserver( Observer& observer );
139
140   /**
141    * Removes the observer from the EventHandler.
142    * @param[in] observer The observer to remove.
143    * @note Observers should remove themselves when they are destroyed.
144    */
145   void RemoveObserver( Observer& observer );
146
147 private:
148
149   /**
150    * Send a style change event to the style monitor.
151    * @param[in]  styleChange  The style that has changed.
152    */
153   void SendEvent( StyleChange::Type styleChange );
154
155   /**
156    * Send a window damage event to the observer.
157    * @param[in]  area  Damaged area.
158    */
159   void SendEvent( const DamageArea& area );
160
161   /**
162    * Called when a touch event is received.
163    */
164   void OnTouchEvent( Integration::Point& point, uint32_t timeStamp );
165
166   /**
167    * Called when a mouse wheel is received.
168    */
169   void OnWheelEvent( WheelEvent& wheelEvent );
170
171   /**
172    * Called when a key event is received.
173    */
174   void OnKeyEvent( Integration::KeyEvent& keyEvent );
175
176   /**
177    * Called when the window focus is changed.
178    */
179   void OnFocusChanged( bool focusIn );
180
181   /**
182    * Called when the window is rotated.
183    * @param[in] event The rotation event
184    */
185   void OnRotation( const RotationEvent& event );
186
187   /**
188    * Called when the window is damaged.
189    */
190   void OnWindowDamaged( const DamageArea& area );
191
192   /**
193    * Called when the source window notifies us the content in clipboard is selected.
194    */
195   void OnSelectionDataSend( void* event );
196
197   /**
198    * Called when the source window sends us about the selected content.
199    */
200   void OnSelectionDataReceived( void* event );
201
202   /**
203    * Called when the style is changed.
204    */
205   void OnStyleChanged( StyleChange::Type styleChange );
206
207   /**
208    * Called when Ecore ElDBus accessibility event is received.
209    */
210   void OnAccessibilityNotification( const WindowBase::AccessibilityInfo& info );
211
212 private:
213
214   // Undefined
215   EventHandler( const EventHandler& eventHandler );
216
217   // Undefined
218   EventHandler& operator=( const EventHandler& eventHandler );
219
220 private:
221
222   Dali::StyleMonitor mStyleMonitor; ///< Handle to the style monitor, set on construction, to send font size and font change events to.
223   DamageObserver& mDamageObserver; ///< Reference to the DamageObserver, set on construction, to sent damage events to.
224
225   Dali::AccessibilityAdaptor mAccessibilityAdaptor; ///< Pointer to the accessibility adaptor
226   Dali::ClipboardEventNotifier mClipboardEventNotifier; ///< Pointer to the clipboard event notifier
227   Dali::Clipboard mClipboard;///< Pointer to the clipboard
228
229   using ObserverContainer = std::vector<Observer*>;
230   ObserverContainer mObservers;   ///< A list of event observer pointers
231
232   bool mPaused; ///< The paused state of the adaptor.
233 };
234
235 } // namespace Adaptor
236
237 } // namespace Internal
238
239 } // namespace Dali
240
241 #endif // DALI_INTERNAL_EVENT_HANDLER_H