Remove StereoMode
[platform/core/uifw/dali-adaptor.git] / dali / internal / window-system / tizen-wayland / ecore-wl2 / window-base-ecore-wl2.h
1 #ifndef DALI_INTERNAL_WINDOWSYSTEM_TIZENWAYLAND_WINDOW_BASE_ECORE_WL2_H
2 #define DALI_INTERNAL_WINDOWSYSTEM_TIZENWAYLAND_WINDOW_BASE_ECORE_WL2_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 // INTERNAL INCLUDES
22 #include <dali/internal/window-system/common/window-base.h>
23
24 // EXTERNAL HEADERS
25 #include <Ecore.h>
26 #include <Ecore_Wl2.h>
27 #include <tizen-extension-client-protocol.h>
28 #include <wayland-egl.h>
29
30 #ifdef DALI_ELDBUS_AVAILABLE
31 #include <Eldbus.h>
32 #endif
33
34 namespace Dali
35 {
36 namespace Internal
37 {
38 namespace Adaptor
39 {
40
41 class WindowRenderSurface;
42 class WindowRenderSurfaceEcoreWl2;
43
44 /**
45  * WindowBaseEcoreWl2 class provides an WindowBase Ecore-Wayland2 implementation.
46  */
47 class WindowBaseEcoreWl2 : public WindowBase
48 {
49 public:
50
51   /**
52    * @brief Constructor
53    */
54   WindowBaseEcoreWl2( PositionSize positionSize, Any surface, bool isTransparent );
55
56   /**
57    * @brief Destructor
58    */
59   virtual ~WindowBaseEcoreWl2();
60
61 public:
62
63   /**
64    * @brief Called when the window iconify state is changed.
65    */
66   Eina_Bool OnIconifyStateChanged( void* data, int type, void* event );
67
68   /**
69    * @brief Called when the window gains focus.
70    */
71   Eina_Bool OnFocusIn( void* data, int type, void* event );
72
73   /**
74    * @brief Called when the window loses focus.
75    */
76   Eina_Bool OnFocusOut( void* data, int type, void* event );
77
78   /**
79    * @brief Called when the output is transformed.
80    */
81   Eina_Bool OnOutputTransform( void* data, int type, void* event );
82
83   /**
84    * @brief Called when the output transform should be ignored.
85    */
86   Eina_Bool OnIgnoreOutputTransform( void* data, int type, void* event );
87
88   /**
89    * @brief Called when a rotation event is recevied.
90    */
91   void OnRotation( void* data, int type, void* event );
92
93   /**
94    * @brief Called when a touch down is received.
95    */
96   void OnMouseButtonDown( void* data, int type, void* event );
97
98   /**
99    * @brief Called when a touch up is received.
100    */
101   void OnMouseButtonUp( void* data, int type, void* event );
102
103   /**
104    * @brief Called when a touch motion is received.
105    */
106   void OnMouseButtonMove( void* data, int type, void* event );
107
108   /**
109    * @brief Called when a touch is canceled.
110    */
111   void OnMouseButtonCancel( void* data, int type, void* event );
112
113   /**
114    * @brief Called when a mouse wheel is received.
115    */
116   void OnMouseWheel( void* data, int type, void* event );
117
118   /**
119    * @brief Called when a detent rotation event is recevied.
120    */
121   void OnDetentRotation( void* data, int type, void* event );
122
123   /**
124    * @brief Called when a key down is received.
125    */
126   void OnKeyDown( void* data, int type, void* event );
127
128   /**
129    * @brief Called when a key up is received.
130    */
131   void OnKeyUp( void* data, int type, void* event );
132
133   /**
134    * @brief Called when the source window notifies us the content in clipboard is selected.
135    */
136   void OnDataSend( void* data, int type, void* event );
137
138   /**
139    * @brief Called when the source window sends us about the selected content.
140    */
141   void OnDataReceive( void* data, int type, void* event );
142
143   /**
144    * @brief Called when the indicator event is received.
145    */
146   void OnIndicatorFlicked( void* data, int type, void* event );
147
148   /**
149    * @brief Called when a font name is changed.
150    */
151   void OnFontNameChanged();
152
153   /**
154    * @brief Called when a font size is changed.
155    */
156   void OnFontSizeChanged();
157
158 #ifdef DALI_ELDBUS_AVAILABLE
159   /**
160    * @brief Called when Ecore ElDBus accessibility event is received.
161    */
162   void OnEcoreElDBusAccessibilityNotification( void* context, const Eldbus_Message* message );
163 #endif
164
165   /**
166    * @brief RegistryGlobalCallback
167    */
168   void RegistryGlobalCallback( void* data, struct wl_registry *registry, uint32_t name, const char* interface, uint32_t version );
169
170   /**
171    * @brief RegistryGlobalCallbackRemove
172    */
173   void RegistryGlobalCallbackRemove( void* data, struct wl_registry* registry, uint32_t id );
174
175   /**
176    * @brief TizenPolicyNotificationChangeDone
177    */
178   void TizenPolicyNotificationChangeDone(void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, int32_t level, uint32_t state );
179
180   /**
181    * @brief TizenPolicyScreenModeChangeDone
182    */
183   void TizenPolicyScreenModeChangeDone( void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, uint32_t mode, uint32_t state );
184
185   /**
186    * @brief DisplayPolicyBrightnessChangeDone
187    */
188   void DisplayPolicyBrightnessChangeDone( void* data, struct tizen_display_policy *displayPolicy, struct wl_surface* surface, int32_t brightness, uint32_t state );
189
190 public:
191
192   /**
193    * @copydoc Dali::Internal::Adaptor::WindowBase::GetNativeWindow()
194    */
195   virtual Any GetNativeWindow() override;
196
197   /**
198    * @copydoc Dali::Internal::Adaptor::WindowBase::GetNativeWindowId()
199    */
200   virtual int GetNativeWindowId() override;
201
202   /**
203    * @copydoc Dali::Internal::Adaptor::WindowBase::CreateEglWindow()
204    */
205   virtual EGLNativeWindowType CreateEglWindow( int width, int height ) override;
206
207   /**
208    * @copydoc Dali::Internal::Adaptor::WindowBase::DestroyEglWindow()
209    */
210   virtual void DestroyEglWindow() override;
211
212   /**
213    * @copydoc Dali::Internal::Adaptor::WindowBase::SetEglWindowRotation()
214    */
215   virtual void SetEglWindowRotation( int angle ) override;
216
217   /**
218    * @copydoc Dali::Internal::Adaptor::WindowBase::SetEglWindowBufferTransform()
219    */
220   virtual void SetEglWindowBufferTransform( int angle ) override;
221
222   /**
223    * @copydoc Dali::Internal::Adaptor::WindowBase::SetEglWindowTransform()
224    */
225   virtual void SetEglWindowTransform( int angle ) override;
226
227   /**
228    * @copydoc Dali::Internal::Adaptor::WindowBase::ResizeEglWindow()
229    */
230   virtual void ResizeEglWindow( PositionSize positionSize ) override;
231
232   /**
233    * @copydoc Dali::Internal::Adaptor::WindowBase::IsEglWindowRotationSupported()
234    */
235   virtual bool IsEglWindowRotationSupported() override;
236
237   /**
238    * @copydoc Dali::Internal::Adaptor::WindowBase::Move()
239    */
240   virtual void Move( PositionSize positionSize ) override;
241
242   /**
243    * @copydoc Dali::Internal::Adaptor::WindowBase::Resize()
244    */
245   virtual void Resize( PositionSize positionSize ) override;
246
247   /**
248    * @copydoc Dali::Internal::Adaptor::WindowBase::MoveResize()
249    */
250   virtual void MoveResize( PositionSize positionSize ) override;
251
252   /**
253    * @copydoc Dali::Internal::Adaptor::WindowBase::ShowIndicator()
254    */
255   virtual void ShowIndicator( Dali::Window::IndicatorVisibleMode visibleMode, Dali::Window::IndicatorBgOpacity opacityMode ) override;
256
257   /**
258    * @copydoc Dali::Internal::Adaptor::WindowBase::SetIndicatorProperties()
259    */
260   virtual void SetIndicatorProperties( bool isShow, Dali::Window::WindowOrientation lastOrientation ) override;
261
262   /**
263    * @copydoc Dali::Internal::Adaptor::WindowBase::IndicatorTypeChanged()
264    */
265   virtual void IndicatorTypeChanged( IndicatorInterface::Type type ) override;
266
267   /**
268    * @copydoc Dali::Internal::Adaptor::WindowBase::SetClass()
269    */
270   virtual void SetClass( const std::string& name, const std::string& className ) override;
271
272   /**
273    * @copydoc Dali::Internal::Adaptor::WindowBase::Raise()
274    */
275   virtual void Raise() override;
276
277   /**
278    * @copydoc Dali::Internal::Adaptor::WindowBase::Lower()
279    */
280   virtual void Lower() override;
281
282   /**
283    * @copydoc Dali::Internal::Adaptor::WindowBase::Activate()
284    */
285   virtual void Activate() override;
286
287   /**
288    * @copydoc Dali::Internal::Adaptor::WindowBase::SetAvailableOrientations()
289    */
290   virtual void SetAvailableOrientations( const std::vector< Dali::Window::WindowOrientation >& orientations ) override;
291
292   /**
293    * @copydoc Dali::Internal::Adaptor::WindowBase::SetPreferredOrientation()
294    */
295   virtual void SetPreferredOrientation( Dali::Window::WindowOrientation orientation ) override;
296
297   /**
298    * @copydoc Dali::Internal::Adaptor::WindowBase::SetAcceptFocus()
299    */
300   virtual void SetAcceptFocus( bool accept ) override;
301
302   /**
303    * @copydoc Dali::Internal::Adaptor::WindowBase::Show()
304    */
305   virtual void Show() override;
306
307   /**
308    * @copydoc Dali::Internal::Adaptor::WindowBase::Hide()
309    */
310   virtual void Hide() override;
311
312   /**
313    * @copydoc Dali::Internal::Adaptor::WindowBase::GetSupportedAuxiliaryHintCount()
314    */
315   virtual unsigned int GetSupportedAuxiliaryHintCount() const override;
316
317   /**
318    * @copydoc Dali::Internal::Adaptor::WindowBase::GetSupportedAuxiliaryHint()
319    */
320   virtual std::string GetSupportedAuxiliaryHint( unsigned int index ) const override;
321
322   /**
323    * @copydoc Dali::Internal::Adaptor::WindowBase::AddAuxiliaryHint()
324    */
325   virtual unsigned int AddAuxiliaryHint( const std::string& hint, const std::string& value ) override;
326
327   /**
328    * @copydoc Dali::Internal::Adaptor::WindowBase::RemoveAuxiliaryHint()
329    */
330   virtual bool RemoveAuxiliaryHint( unsigned int id ) override;
331
332   /**
333    * @copydoc Dali::Internal::Adaptor::WindowBase::SetAuxiliaryHintValue()
334    */
335   virtual bool SetAuxiliaryHintValue( unsigned int id, const std::string& value ) override;
336
337   /**
338    * @copydoc Dali::Internal::Adaptor::WindowBase::GetAuxiliaryHintValue()
339    */
340   virtual std::string GetAuxiliaryHintValue( unsigned int id ) const override;
341
342   /**
343    * @copydoc Dali::Internal::Adaptor::WindowBase::GetAuxiliaryHintId()
344    */
345   virtual unsigned int GetAuxiliaryHintId( const std::string& hint ) const override;
346
347   /**
348    * @copydoc Dali::Internal::Adaptor::WindowBase::SetInputRegion()
349    */
350   virtual void SetInputRegion( const Rect< int >& inputRegion ) override;
351
352   /**
353    * @copydoc Dali::Internal::Adaptor::WindowBase::SetType()
354    */
355   virtual void SetType( Dali::Window::Type type ) override;
356
357   /**
358    * @copydoc Dali::Internal::Adaptor::WindowBase::SetNotificationLevel()
359    */
360   virtual bool SetNotificationLevel( Dali::Window::NotificationLevel::Type level ) override;
361
362   /**
363    * @copydoc Dali::Internal::Adaptor::WindowBase::GetNotificationLevel()
364    */
365   virtual Dali::Window::NotificationLevel::Type GetNotificationLevel() const override;
366
367   /**
368    * @copydoc Dali::Internal::Adaptor::WindowBase::SetOpaqueState()
369    */
370   virtual void SetOpaqueState( bool opaque ) override;
371
372   /**
373    * @copydoc Dali::Internal::Adaptor::WindowBase::SetScreenOffMode()
374    */
375   virtual bool SetScreenOffMode(Dali::Window::ScreenOffMode::Type screenOffMode) override;
376
377   /**
378    * @copydoc Dali::Internal::Adaptor::WindowBase::GetScreenOffMode()
379    */
380   virtual Dali::Window::ScreenOffMode::Type GetScreenOffMode() const override;
381
382   /**
383    * @copydoc Dali::Internal::Adaptor::WindowBase::SetBrightness()
384    */
385   virtual bool SetBrightness( int brightness ) override;
386
387   /**
388    * @copydoc Dali::Internal::Adaptor::WindowBase::GetBrightness()
389    */
390   virtual int GetBrightness() const override;
391
392   /**
393    * @copydoc Dali::Internal::Adaptor::WindowBase::GrabKey()
394    */
395   virtual bool GrabKey( Dali::KEY key, KeyGrab::KeyGrabMode grabMode ) override;
396
397   /**
398    * @copydoc Dali::Internal::Adaptor::WindowBase::UngrabKey()
399    */
400   virtual bool UngrabKey( Dali::KEY key ) override;
401
402   /**
403    * @copydoc Dali::Internal::Adaptor::WindowBase::GrabKeyList()
404    */
405   virtual bool GrabKeyList( const Dali::Vector< Dali::KEY >& key, const Dali::Vector< KeyGrab::KeyGrabMode >& grabMode, Dali::Vector< bool >& result ) override;
406
407   /**
408    * @copydoc Dali::Internal::Adaptor::WindowBase::UngrabKeyList()
409    */
410   virtual bool UngrabKeyList( const Dali::Vector< Dali::KEY >& key, Dali::Vector< bool >& result ) override;
411
412   /**
413    * @copydoc Dali::Internal::Adaptor::WindowBase::GetDpi()
414    */
415   virtual void GetDpi( unsigned int& dpiHorizontal, unsigned int& dpiVertical ) override;
416
417   /**
418    * @copydoc Dali::Internal::Adaptor::WindowBase::GetScreenRotationAngle()
419    */
420   virtual int GetScreenRotationAngle() override;
421
422   /**
423    * @copydoc Dali::Internal::Adaptor::WindowBase::SetWindowRotationAngle()
424    */
425   virtual void SetWindowRotationAngle( int degree ) override;
426
427   /**
428    * @copydoc Dali::Internal::Adaptor::WindowBase::WindowRotationCompleted()
429    */
430   virtual void WindowRotationCompleted( int degree, int width, int height ) override;
431
432   /**
433    * @copydoc Dali::Internal::Adaptor::WindowBase::SetTransparency()
434    */
435   virtual void SetTransparency( bool transparent ) override;
436
437 private:
438
439   /**
440    * Second stage initialization
441    */
442   void Initialize( PositionSize positionSize, Any surface, bool isTransparent );
443
444   /**
445    * Initialize Ecore ElDBus
446    */
447   void InitializeEcoreElDBus();
448
449   /**
450    * @brief Create window
451    */
452   void CreateWindow( PositionSize positionSize );
453
454 protected:
455
456   // Undefined
457   WindowBaseEcoreWl2(const WindowBaseEcoreWl2&) = delete;
458
459   // Undefined
460   WindowBaseEcoreWl2& operator=(const WindowBaseEcoreWl2& rhs) = delete;
461
462 private:
463
464   typedef std::vector< std::pair< std::string, std::string > > AuxiliaryHints;
465
466   Dali::Vector< Ecore_Event_Handler* > mEcoreEventHandler;
467
468   Ecore_Wl2_Window*                    mEcoreWindow;
469   wl_surface*                          mWlSurface;
470   wl_egl_window*                       mEglWindow;
471   wl_display*                          mDisplay;
472   wl_event_queue*                      mEventQueue;
473   tizen_policy*                        mTizenPolicy;
474   tizen_display_policy*                mTizenDisplayPolicy;
475
476   std::vector< std::string >           mSupportedAuxiliaryHints;
477   AuxiliaryHints                       mAuxiliaryHints;
478
479   int                                  mNotificationLevel;
480   uint32_t                             mNotificationChangeState;
481   bool                                 mNotificationLevelChangeDone;
482
483   int                                  mScreenOffMode;
484   uint32_t                             mScreenOffModeChangeState;
485   bool                                 mScreenOffModeChangeDone;
486
487   int                                  mBrightness;
488   uint32_t                             mBrightnessChangeState;
489   bool                                 mBrightnessChangeDone;
490
491   bool                                 mOwnSurface;
492
493 #ifdef DALI_ELDBUS_AVAILABLE
494   Eldbus_Connection*                   mSystemConnection;
495 #endif // DALI_ELDBUS_AVAILABLE
496 };
497
498 } // namespace Adaptor
499
500 } // namespace internal
501
502 } // namespace Dali
503
504 #endif // DALI_INTERNAL_WINDOWSYSTEM_TIZENWAYLAND_WINDOW_BASE_ECORE_WL2_H