Use existing callback ID for recurring callbacks
[platform/core/uifw/dali-adaptor.git] / dali / internal / window-system / common / window-base.h
1 #ifndef DALI_INTERNAL_WINDOWSYSTEM_COMMON_WINDOW_BASE_H
2 #define DALI_INTERNAL_WINDOWSYSTEM_COMMON_WINDOW_BASE_H
3
4 /*
5  * Copyright (c) 2020 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/wheel-event-integ.h>
25 #include <string>
26 #include <vector>
27 #include <cstdint>
28
29 // INTERNAL INCLUDES
30 #include <dali/public-api/adaptor-framework/window.h>
31 #include <dali/public-api/adaptor-framework/key-grab.h>
32 #include <dali/public-api/adaptor-framework/style-change.h>
33 #include <dali/devel-api/adaptor-framework/window-devel.h>
34 #include <dali/internal/window-system/common/damage-observer.h>
35 #include <dali/internal/window-system/common/rotation-event.h>
36 #include <dali/internal/graphics/gles/egl-implementation.h>
37
38 namespace Dali
39 {
40 namespace Internal
41 {
42 namespace Adaptor
43 {
44
45 /**
46  * WindowBase interface
47  */
48 class WindowBase
49 {
50 public:
51
52   /**
53    * @brief Struct used to retrieve accessibility information
54    */
55   struct AccessibilityInfo
56   {
57     int gestureValue;
58     int startX;
59     int startY;
60     int endX;
61     int endY;
62     int state;
63     int eventTime;
64   };
65
66   // Window
67   typedef Signal< void ( bool ) > IconifySignalType;
68   typedef Signal< void ( bool ) > FocusSignalType;
69   typedef Signal< void ( ) > OutputSignalType;
70   typedef Signal< void ( ) > DeleteSignalType;
71   typedef Signal< void ( const DamageArea& ) > DamageSignalType;
72   typedef Signal< void ( const RotationEvent& ) > RotationSignalType;
73   typedef Signal< void ( DevelWindow::EffectState, DevelWindow::EffectType ) > TransitionEffectEventSignalType;
74   typedef Signal< void ( ) > KeyboardRepeatSettingsChangedSignalType;
75   typedef Signal< void ( ) > WindowRedrawRequestSignalType;
76
77   // Input events
78   typedef Signal< void ( Integration::Point&, uint32_t ) > TouchEventSignalType;
79   typedef Signal< void ( Integration::WheelEvent& ) > WheelEventSignalType;
80   typedef Signal< void( Integration::KeyEvent& ) > KeyEventSignalType;
81
82   // Clipboard
83   typedef Signal< void ( void* ) > SelectionSignalType;
84
85   // Accessibility
86   typedef Signal< void ( StyleChange::Type ) > StyleSignalType;
87   typedef Signal< void ( const AccessibilityInfo& ) > AccessibilitySignalType;
88
89   /**
90    * @brief Default constructor
91    */
92   WindowBase();
93
94   /**
95    * @brief Destructor
96    */
97   virtual ~WindowBase();
98
99 public:
100
101   /**
102    * @brief Get the native window handle
103    * @return The native window handle
104    */
105   virtual Any GetNativeWindow() = 0;
106
107   /**
108    * @brief Get the native window id
109    * @return The native window id
110    */
111   virtual int GetNativeWindowId() = 0;
112
113   /**
114    * @brief Create the egl window
115    */
116   virtual EGLNativeWindowType CreateEglWindow( int width, int height ) = 0;
117
118   /**
119    * @brief Destroy the egl window
120    */
121   virtual void DestroyEglWindow() = 0;
122
123   /**
124    * @brief Set the egl window rotation
125    */
126   virtual void SetEglWindowRotation( int angle ) = 0;
127
128   /**
129    * @brief Set the egl window buffer transform
130    */
131   virtual void SetEglWindowBufferTransform( int angle ) = 0;
132
133   /**
134    * @brief Set the egl window transform
135    */
136   virtual void SetEglWindowTransform( int angle ) = 0;
137
138   /**
139    * @brief Resize the egl window
140    */
141   virtual void ResizeEglWindow( Dali::PositionSize positionSize ) = 0;
142
143   /**
144    * @brief Returns whether the egl window support rotation or not
145    */
146   virtual bool IsEglWindowRotationSupported() = 0;
147
148   /**
149    * @brief Move the window
150    */
151   virtual void Move( Dali::PositionSize positionSize ) = 0;
152
153   /**
154    * @brief Resize the window
155    */
156   virtual void Resize( Dali::PositionSize positionSize ) = 0;
157
158   /**
159    * @brief Move and resize the window
160    */
161   virtual void MoveResize( Dali::PositionSize positionSize ) = 0;
162
163   /**
164    * @copydoc Dali::Window::SetClass()
165    */
166   virtual void SetClass( const std::string& name, const std::string& className ) = 0;
167
168   /**
169    * @copydoc Dali::Window::Raise()
170    */
171   virtual void Raise() = 0;
172
173   /**
174    * @copydoc Dali::Window::Lower()
175    */
176   virtual void Lower() = 0;
177
178   /**
179    * @copydoc Dali::Window::Activate()
180    */
181   virtual void Activate() = 0;
182
183   /**
184    * @copydoc Dali::Window::SetAvailableOrientations()
185    */
186   virtual void SetAvailableAnlges( const std::vector< int >& angles ) = 0;
187
188   /**
189    * @copydoc Dali::Window::SetPreferredOrientation()
190    */
191   virtual void SetPreferredAngle( int angle ) = 0;
192
193   /**
194    * @copydoc Dali::Window::SetAcceptFocus()
195    */
196   virtual void SetAcceptFocus( bool accept ) = 0;
197
198   /**
199    * @copydoc Dali::Window::Show()
200    */
201   virtual void Show() = 0;
202
203   /**
204    * @copydoc Dali::Window::Hide()
205    */
206   virtual void Hide() = 0;
207
208   /**
209    * @copydoc Dali::Window::GetSupportedAuxiliaryHintCount()
210    */
211   virtual unsigned int GetSupportedAuxiliaryHintCount() const = 0;
212
213   /**
214    * @copydoc Dali::Window::GetSupportedAuxiliaryHint()
215    */
216   virtual std::string GetSupportedAuxiliaryHint( unsigned int index ) const = 0;
217
218   /**
219    * @copydoc Dali::Window::AddAuxiliaryHint()
220    */
221   virtual unsigned int AddAuxiliaryHint( const std::string& hint, const std::string& value ) = 0;
222
223   /**
224    * @copydoc Dali::Window::RemoveAuxiliaryHint()
225    */
226   virtual bool RemoveAuxiliaryHint( unsigned int id ) = 0;
227
228   /**
229    * @copydoc Dali::Window::SetAuxiliaryHintValue()
230    */
231   virtual bool SetAuxiliaryHintValue( unsigned int id, const std::string& value ) = 0;
232
233   /**
234    * @copydoc Dali::Window::GetAuxiliaryHintValue()
235    */
236   virtual std::string GetAuxiliaryHintValue( unsigned int id ) const = 0;
237
238   /**
239    * @copydoc Dali::Window::GetAuxiliaryHintId()
240    */
241   virtual unsigned int GetAuxiliaryHintId( const std::string& hint ) const = 0;
242
243   /**
244    * @copydoc Dali::Window::SetInputRegion()
245    */
246   virtual void SetInputRegion( const Rect< int >& inputRegion ) = 0;
247
248   /**
249    * @copydoc Dali::Window::SetType()
250    */
251   virtual void SetType( Dali::Window::Type type ) = 0;
252
253   /**
254    * @copydoc Dali::Window::SetNotificationLevel()
255    */
256   virtual bool SetNotificationLevel( Dali::Window::NotificationLevel::Type level ) = 0;
257
258   /**
259    * @copydoc Dali::Window::GetNotificationLevel()
260    */
261   virtual Dali::Window::NotificationLevel::Type GetNotificationLevel() const = 0;
262
263   /**
264    * @copydoc Dali::Window::SetOpaqueState()
265    */
266   virtual void SetOpaqueState( bool opaque ) = 0;
267
268   /**
269    * @copydoc Dali::Window::SetScreenOffMode()
270    */
271   virtual bool SetScreenOffMode(Dali::Window::ScreenOffMode::Type screenOffMode) = 0;
272
273   /**
274    * @copydoc Dali::Window::GetScreenOffMode()
275    */
276   virtual Dali::Window::ScreenOffMode::Type GetScreenOffMode() const = 0;
277
278   /**
279    * @copydoc Dali::Window::SetBrightness()
280    */
281   virtual bool SetBrightness( int brightness ) = 0;
282
283   /**
284    * @copydoc Dali::Window::GetBrightness()
285    */
286   virtual int GetBrightness() const = 0;
287
288   /**
289    * @copydoc Dali::KeyGrab::GrabKey()
290    */
291   virtual bool GrabKey( Dali::KEY key, KeyGrab::KeyGrabMode grabMode ) = 0;
292
293   /**
294    * @copydoc Dali::KeyGrab::UngrabKey()
295    */
296   virtual bool UngrabKey( Dali::KEY key ) = 0;
297
298   /**
299    * @copydoc Dali::KeyGrab::GrabKeyList()
300    */
301   virtual bool GrabKeyList( const Dali::Vector< Dali::KEY >& key, const Dali::Vector< KeyGrab::KeyGrabMode >& grabMode, Dali::Vector< bool >& result ) = 0;
302
303   /**
304    * @copydoc Dali::KeyGrab::UngrabKeyList()
305    */
306   virtual bool UngrabKeyList( const Dali::Vector< Dali::KEY >& key, Dali::Vector< bool >& result ) = 0;
307
308   /**
309    * @brief Get DPI
310    * @param[out] dpiHorizontal set to the horizontal dpi
311    * @param[out] dpiVertical set to the vertical dpi
312    */
313   virtual void GetDpi( unsigned int& dpiHorizontal, unsigned int& dpiVertical ) = 0;
314
315   /**
316    * @brief Get the screen rotation angle of the window
317    */
318   virtual int GetScreenRotationAngle() = 0;
319
320   /**
321    * @brief Set the rotation angle of the window
322    */
323   virtual void SetWindowRotationAngle( int degree ) = 0;
324
325   /**
326    * @brief Inform the window rotation is completed
327    */
328   virtual void WindowRotationCompleted( int degree, int width, int height ) = 0;
329
330   /**
331    * @copydoc Dali::Window::SetTransparency()
332    */
333   virtual void SetTransparency( bool transparent ) = 0;
334
335   /**
336    * @copydoc Dali::Window::SetParent()
337    */
338   virtual void SetParent( WindowBase* parentWinBase ) = 0;
339
340   /**
341    * @brief Create a sync fence that can tell the frame is rendered by the graphics driver.
342    * @return The file descriptor that tells when it is rendered.
343    */
344   virtual int CreateFrameRenderedSyncFence() = 0;
345
346   /**
347    * @brief Create a sync fence that can tell the frame is presented by the display server.
348    * @return The file descriptor that tells when it is presented.
349    */
350   virtual int CreateFramePresentedSyncFence() = 0;
351
352   // Signals
353
354   /**
355    * @brief This signal is emitted when the window becomes iconified or deiconified.
356    */
357    IconifySignalType& IconifyChangedSignal();
358
359   /**
360    * @brief This signal is emitted when the window focus is changed.
361    */
362   FocusSignalType& FocusChangedSignal();
363
364   /**
365    * @brief This signal is emitted when the output is transformed.
366    */
367   OutputSignalType& OutputTransformedSignal();
368
369   /**
370    * @brief This signal is emitted when the window receives a delete request.
371    */
372   DeleteSignalType& DeleteRequestSignal();
373
374   /**
375    * @brief This signal is emitted when the window is damaged.
376    */
377   DamageSignalType& WindowDamagedSignal();
378
379   /**
380    * @brief This signal is emitted when a rotation event is recevied.
381    */
382   RotationSignalType& RotationSignal();
383
384   /**
385    * @brief This signal is emitted when a touch event is received.
386    */
387   TouchEventSignalType& TouchEventSignal();
388
389   /**
390    * @brief This signal is emitted when a mouse wheel is received.
391    */
392   WheelEventSignalType& WheelEventSignal();
393
394   /**
395    * @brief This signal is emitted when a key event is received.
396    */
397   KeyEventSignalType& KeyEventSignal();
398
399   /**
400    * @brief This signal is emitted when the source window notifies us the content in clipboard is selected.
401    */
402   SelectionSignalType& SelectionDataSendSignal();
403
404   /**
405    * @brief This signal is emitted when the source window sends us about the selected content.
406    */
407   SelectionSignalType& SelectionDataReceivedSignal();
408
409   /**
410    * @brief This signal is emitted when the style is changed.
411    */
412   StyleSignalType& StyleChangedSignal();
413
414   /**
415    * @brief This signal is emitted when an accessibility event is received.
416    */
417   AccessibilitySignalType& AccessibilitySignal();
418
419   /**
420    * @brief This signal is emitted when window's transition animation is started or ended.
421    */
422   TransitionEffectEventSignalType& TransitionEffectEventSignal();
423
424   /**
425    * @brief This signal is emitted when the keyboard repeat is changed.
426    */
427   KeyboardRepeatSettingsChangedSignalType& KeyboardRepeatSettingsChangedSignal();
428
429   /**
430    * @brief This signal is emitted when the window redraw is requested.
431    */
432   WindowRedrawRequestSignalType& WindowRedrawRequestSignal();
433
434 protected:
435
436   // Undefined
437   WindowBase(const WindowBase&) = delete;
438
439   // Undefined
440   WindowBase& operator=(const WindowBase& rhs) = delete;
441
442 protected:
443
444   IconifySignalType                       mIconifyChangedSignal;
445   FocusSignalType                         mFocusChangedSignal;
446   OutputSignalType                        mOutputTransformedSignal;
447   DeleteSignalType                        mDeleteRequestSignal;
448   DamageSignalType                        mWindowDamagedSignal;
449   RotationSignalType                      mRotationSignal;
450   TouchEventSignalType                    mTouchEventSignal;
451   WheelEventSignalType                    mWheelEventSignal;
452   KeyEventSignalType                      mKeyEventSignal;
453   SelectionSignalType                     mSelectionDataSendSignal;
454   SelectionSignalType                     mSelectionDataReceivedSignal;
455   StyleSignalType                         mStyleChangedSignal;
456   AccessibilitySignalType                 mAccessibilitySignal;
457   TransitionEffectEventSignalType         mTransitionEffectEventSignal;
458   KeyboardRepeatSettingsChangedSignalType mKeyboardRepeatSettingsChangedSignal;
459   WindowRedrawRequestSignalType           mWindowRedrawRequestSignal;
460 };
461
462 } // namespace Adaptor
463
464 } // namespace internal
465
466 } // namespace Dali
467
468 #endif // DALI_INTERNAL_WINDOWSYSTEM_COMMON_WINDOW_BASE_H