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