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