[dali_1.4.49] Merge branch 'devel/master'
[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 configure event is recevied.
95    */
96   void OnConfiguration( void* data, int type, void* event );
97
98   /**
99    * @brief Called when a touch down is received.
100    */
101   void OnMouseButtonDown( void* data, int type, void* event );
102
103   /**
104    * @brief Called when a touch up is received.
105    */
106   void OnMouseButtonUp( void* data, int type, void* event );
107
108   /**
109    * @brief Called when a touch motion is received.
110    */
111   void OnMouseButtonMove( void* data, int type, void* event );
112
113   /**
114    * @brief Called when a touch is canceled.
115    */
116   void OnMouseButtonCancel( void* data, int type, void* event );
117
118   /**
119    * @brief Called when a mouse wheel is received.
120    */
121   void OnMouseWheel( void* data, int type, void* event );
122
123   /**
124    * @brief Called when a detent rotation event is recevied.
125    */
126   void OnDetentRotation( void* data, int type, void* event );
127
128   /**
129    * @brief Called when a key down is received.
130    */
131   void OnKeyDown( void* data, int type, void* event );
132
133   /**
134    * @brief Called when a key up is received.
135    */
136   void OnKeyUp( void* data, int type, void* event );
137
138   /**
139    * @brief Called when the source window notifies us the content in clipboard is selected.
140    */
141   void OnDataSend( void* data, int type, void* event );
142
143   /**
144    * @brief Called when the source window sends us about the selected content.
145    */
146   void OnDataReceive( 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   /**
159    * @brief Called when a transition effect-start/end event is received.
160    */
161   void OnTransitionEffectEvent( DevelWindow::EffectState state, DevelWindow::EffectType type );
162
163 #ifdef DALI_ELDBUS_AVAILABLE
164   /**
165    * @brief Called when Ecore ElDBus accessibility event is received.
166    */
167   void OnEcoreElDBusAccessibilityNotification( void* context, const Eldbus_Message* message );
168 #endif
169
170   /**
171    * @brief RegistryGlobalCallback
172    */
173   void RegistryGlobalCallback( void* data, struct wl_registry *registry, uint32_t name, const char* interface, uint32_t version );
174
175   /**
176    * @brief RegistryGlobalCallbackRemove
177    */
178   void RegistryGlobalCallbackRemove( void* data, struct wl_registry* registry, uint32_t id );
179
180   /**
181    * @brief TizenPolicyNotificationChangeDone
182    */
183   void TizenPolicyNotificationChangeDone(void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, int32_t level, uint32_t state );
184
185   /**
186    * @brief TizenPolicyScreenModeChangeDone
187    */
188   void TizenPolicyScreenModeChangeDone( void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, uint32_t mode, uint32_t state );
189
190   /**
191    * @brief DisplayPolicyBrightnessChangeDone
192    */
193   void DisplayPolicyBrightnessChangeDone( void* data, struct tizen_display_policy *displayPolicy, struct wl_surface* surface, int32_t brightness, uint32_t state );
194
195 public:
196
197   /**
198    * @copydoc Dali::Internal::Adaptor::WindowBase::GetNativeWindow()
199    */
200   virtual Any GetNativeWindow() override;
201
202   /**
203    * @copydoc Dali::Internal::Adaptor::WindowBase::GetNativeWindowId()
204    */
205   virtual int GetNativeWindowId() override;
206
207   /**
208    * @copydoc Dali::Internal::Adaptor::WindowBase::CreateEglWindow()
209    */
210   virtual EGLNativeWindowType CreateEglWindow( int width, int height ) override;
211
212   /**
213    * @copydoc Dali::Internal::Adaptor::WindowBase::DestroyEglWindow()
214    */
215   virtual void DestroyEglWindow() override;
216
217   /**
218    * @copydoc Dali::Internal::Adaptor::WindowBase::SetEglWindowRotation()
219    */
220   virtual void SetEglWindowRotation( int angle ) override;
221
222   /**
223    * @copydoc Dali::Internal::Adaptor::WindowBase::SetEglWindowBufferTransform()
224    */
225   virtual void SetEglWindowBufferTransform( int angle ) override;
226
227   /**
228    * @copydoc Dali::Internal::Adaptor::WindowBase::SetEglWindowTransform()
229    */
230   virtual void SetEglWindowTransform( int angle ) override;
231
232   /**
233    * @copydoc Dali::Internal::Adaptor::WindowBase::ResizeEglWindow()
234    */
235   virtual void ResizeEglWindow( PositionSize positionSize ) override;
236
237   /**
238    * @copydoc Dali::Internal::Adaptor::WindowBase::IsEglWindowRotationSupported()
239    */
240   virtual bool IsEglWindowRotationSupported() override;
241
242   /**
243    * @copydoc Dali::Internal::Adaptor::WindowBase::Move()
244    */
245   virtual void Move( PositionSize positionSize ) override;
246
247   /**
248    * @copydoc Dali::Internal::Adaptor::WindowBase::Resize()
249    */
250   virtual void Resize( PositionSize positionSize ) override;
251
252   /**
253    * @copydoc Dali::Internal::Adaptor::WindowBase::MoveResize()
254    */
255   virtual void MoveResize( PositionSize positionSize ) override;
256
257   /**
258    * @copydoc Dali::Internal::Adaptor::WindowBase::SetClass()
259    */
260   virtual void SetClass( const std::string& name, const std::string& className ) override;
261
262   /**
263    * @copydoc Dali::Internal::Adaptor::WindowBase::Raise()
264    */
265   virtual void Raise() override;
266
267   /**
268    * @copydoc Dali::Internal::Adaptor::WindowBase::Lower()
269    */
270   virtual void Lower() override;
271
272   /**
273    * @copydoc Dali::Internal::Adaptor::WindowBase::Activate()
274    */
275   virtual void Activate() override;
276
277   /**
278    * @copydoc Dali::Internal::Adaptor::WindowBase::SetAvailableAnlges()
279    */
280   virtual void SetAvailableAnlges( const std::vector< int >& angles ) override;
281
282   /**
283    * @copydoc Dali::Internal::Adaptor::WindowBase::SetPreferredAngle()
284    */
285   virtual void SetPreferredAngle( int angle ) override;
286
287   /**
288    * @copydoc Dali::Internal::Adaptor::WindowBase::SetAcceptFocus()
289    */
290   virtual void SetAcceptFocus( bool accept ) override;
291
292   /**
293    * @copydoc Dali::Internal::Adaptor::WindowBase::Show()
294    */
295   virtual void Show() override;
296
297   /**
298    * @copydoc Dali::Internal::Adaptor::WindowBase::Hide()
299    */
300   virtual void Hide() override;
301
302   /**
303    * @copydoc Dali::Internal::Adaptor::WindowBase::GetSupportedAuxiliaryHintCount()
304    */
305   virtual unsigned int GetSupportedAuxiliaryHintCount() const override;
306
307   /**
308    * @copydoc Dali::Internal::Adaptor::WindowBase::GetSupportedAuxiliaryHint()
309    */
310   virtual std::string GetSupportedAuxiliaryHint( unsigned int index ) const override;
311
312   /**
313    * @copydoc Dali::Internal::Adaptor::WindowBase::AddAuxiliaryHint()
314    */
315   virtual unsigned int AddAuxiliaryHint( const std::string& hint, const std::string& value ) override;
316
317   /**
318    * @copydoc Dali::Internal::Adaptor::WindowBase::RemoveAuxiliaryHint()
319    */
320   virtual bool RemoveAuxiliaryHint( unsigned int id ) override;
321
322   /**
323    * @copydoc Dali::Internal::Adaptor::WindowBase::SetAuxiliaryHintValue()
324    */
325   virtual bool SetAuxiliaryHintValue( unsigned int id, const std::string& value ) override;
326
327   /**
328    * @copydoc Dali::Internal::Adaptor::WindowBase::GetAuxiliaryHintValue()
329    */
330   virtual std::string GetAuxiliaryHintValue( unsigned int id ) const override;
331
332   /**
333    * @copydoc Dali::Internal::Adaptor::WindowBase::GetAuxiliaryHintId()
334    */
335   virtual unsigned int GetAuxiliaryHintId( const std::string& hint ) const override;
336
337   /**
338    * @copydoc Dali::Internal::Adaptor::WindowBase::SetInputRegion()
339    */
340   virtual void SetInputRegion( const Rect< int >& inputRegion ) override;
341
342   /**
343    * @copydoc Dali::Internal::Adaptor::WindowBase::SetType()
344    */
345   virtual void SetType( Dali::Window::Type type ) override;
346
347   /**
348    * @copydoc Dali::Internal::Adaptor::WindowBase::SetNotificationLevel()
349    */
350   virtual bool SetNotificationLevel( Dali::Window::NotificationLevel::Type level ) override;
351
352   /**
353    * @copydoc Dali::Internal::Adaptor::WindowBase::GetNotificationLevel()
354    */
355   virtual Dali::Window::NotificationLevel::Type GetNotificationLevel() const override;
356
357   /**
358    * @copydoc Dali::Internal::Adaptor::WindowBase::SetOpaqueState()
359    */
360   virtual void SetOpaqueState( bool opaque ) override;
361
362   /**
363    * @copydoc Dali::Internal::Adaptor::WindowBase::SetScreenOffMode()
364    */
365   virtual bool SetScreenOffMode(Dali::Window::ScreenOffMode::Type screenOffMode) override;
366
367   /**
368    * @copydoc Dali::Internal::Adaptor::WindowBase::GetScreenOffMode()
369    */
370   virtual Dali::Window::ScreenOffMode::Type GetScreenOffMode() const override;
371
372   /**
373    * @copydoc Dali::Internal::Adaptor::WindowBase::SetBrightness()
374    */
375   virtual bool SetBrightness( int brightness ) override;
376
377   /**
378    * @copydoc Dali::Internal::Adaptor::WindowBase::GetBrightness()
379    */
380   virtual int GetBrightness() const override;
381
382   /**
383    * @copydoc Dali::Internal::Adaptor::WindowBase::GrabKey()
384    */
385   virtual bool GrabKey( Dali::KEY key, KeyGrab::KeyGrabMode grabMode ) override;
386
387   /**
388    * @copydoc Dali::Internal::Adaptor::WindowBase::UngrabKey()
389    */
390   virtual bool UngrabKey( Dali::KEY key ) override;
391
392   /**
393    * @copydoc Dali::Internal::Adaptor::WindowBase::GrabKeyList()
394    */
395   virtual bool GrabKeyList( const Dali::Vector< Dali::KEY >& key, const Dali::Vector< KeyGrab::KeyGrabMode >& grabMode, Dali::Vector< bool >& result ) override;
396
397   /**
398    * @copydoc Dali::Internal::Adaptor::WindowBase::UngrabKeyList()
399    */
400   virtual bool UngrabKeyList( const Dali::Vector< Dali::KEY >& key, Dali::Vector< bool >& result ) override;
401
402   /**
403    * @copydoc Dali::Internal::Adaptor::WindowBase::GetDpi()
404    */
405   virtual void GetDpi( unsigned int& dpiHorizontal, unsigned int& dpiVertical ) override;
406
407   /**
408    * @copydoc Dali::Internal::Adaptor::WindowBase::GetScreenRotationAngle()
409    */
410   virtual int GetScreenRotationAngle() override;
411
412   /**
413    * @copydoc Dali::Internal::Adaptor::WindowBase::SetWindowRotationAngle()
414    */
415   virtual void SetWindowRotationAngle( int degree ) override;
416
417   /**
418    * @copydoc Dali::Internal::Adaptor::WindowBase::WindowRotationCompleted()
419    */
420   virtual void WindowRotationCompleted( int degree, int width, int height ) override;
421
422   /**
423    * @copydoc Dali::Internal::Adaptor::WindowBase::SetTransparency()
424    */
425   virtual void SetTransparency( bool transparent ) override;
426
427   /**
428    * @copydoc Dali::Internal::Adaptor::WindowBase::SetParent()
429    */
430   virtual void SetParent( WindowBase* parentWinBase ) override;
431
432 private:
433
434   /**
435    * Second stage initialization
436    */
437   void Initialize( PositionSize positionSize, Any surface, bool isTransparent );
438
439   /**
440    * Initialize Ecore ElDBus
441    */
442   void InitializeEcoreElDBus();
443
444   /**
445    * @brief Create window
446    */
447   void CreateWindow( PositionSize positionSize );
448
449 protected:
450
451   // Undefined
452   WindowBaseEcoreWl2(const WindowBaseEcoreWl2&) = delete;
453
454   // Undefined
455   WindowBaseEcoreWl2& operator=(const WindowBaseEcoreWl2& rhs) = delete;
456
457 private:
458
459   typedef std::vector< std::pair< std::string, std::string > > AuxiliaryHints;
460
461   Dali::Vector< Ecore_Event_Handler* > mEcoreEventHandler;
462
463   Ecore_Wl2_Window*                    mEcoreWindow;
464   wl_surface*                          mWlSurface;
465   wl_egl_window*                       mEglWindow;
466   wl_display*                          mDisplay;
467   wl_event_queue*                      mEventQueue;
468   tizen_policy*                        mTizenPolicy;
469   tizen_display_policy*                mTizenDisplayPolicy;
470
471   std::vector< std::string >           mSupportedAuxiliaryHints;
472   AuxiliaryHints                       mAuxiliaryHints;
473
474   int                                  mNotificationLevel;
475   uint32_t                             mNotificationChangeState;
476   bool                                 mNotificationLevelChangeDone;
477
478   int                                  mScreenOffMode;
479   uint32_t                             mScreenOffModeChangeState;
480   bool                                 mScreenOffModeChangeDone;
481
482   int                                  mBrightness;
483   uint32_t                             mBrightnessChangeState;
484   bool                                 mBrightnessChangeDone;
485
486   bool                                 mOwnSurface;
487
488   volatile uint32_t                    mMoveResizeSerial;
489   uint32_t                             mLastSubmittedMoveResizeSerial;
490
491 #ifdef DALI_ELDBUS_AVAILABLE
492   Eldbus_Connection*                   mSystemConnection;
493 #endif // DALI_ELDBUS_AVAILABLE
494 };
495
496 } // namespace Adaptor
497
498 } // namespace internal
499
500 } // namespace Dali
501
502 #endif // DALI_INTERNAL_WINDOWSYSTEM_TIZENWAYLAND_WINDOW_BASE_ECORE_WL2_H