Revert "[Tizen] Add screen and client rotation itself function"
[platform/core/uifw/dali-adaptor.git] / dali / internal / window-system / tizen-wayland / ecore-wl / window-base-ecore-wl.h
1 #ifndef DALI_INTERNAL_WINDOWSYSTEM_TIZENWAYLAND_WINDOW_BASE_ECORE_WL_H
2 #define DALI_INTERNAL_WINDOWSYSTEM_TIZENWAYLAND_WINDOW_BASE_ECORE_WL_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_Wayland.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 WindowRenderSurfaceEcoreWl;
43
44 /**
45  * WindowBaseEcoreWl class provides an WindowBase Ecore-Wayland implementation.
46  */
47 class WindowBaseEcoreWl : public WindowBase
48 {
49 public:
50
51   /**
52    * @brief Constructor
53    */
54   WindowBaseEcoreWl( PositionSize positionSize, Any surface, bool isTransparent );
55
56   /**
57    * @brief Destructor
58    */
59   virtual ~WindowBaseEcoreWl();
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 a font name is changed.
145    */
146   void OnFontNameChanged();
147
148   /**
149    * @brief Called when a font size is changed.
150    */
151   void OnFontSizeChanged();
152
153 #ifdef DALI_ELDBUS_AVAILABLE
154   /**
155    * @brief Called when Ecore ElDBus accessibility event is received.
156    */
157   void OnEcoreElDBusAccessibilityNotification( void* context, const Eldbus_Message* message );
158 #endif
159
160   /**
161    * @brief RegistryGlobalCallback
162    */
163   void RegistryGlobalCallback( void* data, struct wl_registry *registry, uint32_t name, const char* interface, uint32_t version );
164
165   /**
166    * @brief RegistryGlobalCallbackRemove
167    */
168   void RegistryGlobalCallbackRemove( void* data, struct wl_registry* registry, uint32_t id );
169
170   /**
171    * @brief TizenPolicyNotificationChangeDone
172    */
173   void TizenPolicyNotificationChangeDone(void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, int32_t level, uint32_t state );
174
175   /**
176    * @brief TizenPolicyScreenModeChangeDone
177    */
178   void TizenPolicyScreenModeChangeDone( void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, uint32_t mode, uint32_t state );
179
180   /**
181    * @brief DisplayPolicyBrightnessChangeDone
182    */
183   void DisplayPolicyBrightnessChangeDone( void* data, struct tizen_display_policy *displayPolicy, struct wl_surface* surface, int32_t brightness, uint32_t state );
184
185 public:
186
187   /**
188    * @copydoc Dali::Internal::Adaptor::WindowBase::GetNativeWindow()
189    */
190   virtual Any GetNativeWindow() override;
191
192   /**
193    * @copydoc Dali::Internal::Adaptor::WindowBase::GetNativeWindowId()
194    */
195   virtual int GetNativeWindowId() override;
196
197   /**
198    * @copydoc Dali::Internal::Adaptor::WindowBase::CreateEglWindow()
199    */
200   virtual EGLNativeWindowType CreateEglWindow( int width, int height ) override;
201
202   /**
203    * @copydoc Dali::Internal::Adaptor::WindowBase::DestroyEglWindow()
204    */
205   virtual void DestroyEglWindow() override;
206
207   /**
208    * @copydoc Dali::Internal::Adaptor::WindowBase::SetEglWindowRotation()
209    */
210   virtual void SetEglWindowRotation( int angle ) override;
211
212   /**
213    * @copydoc Dali::Internal::Adaptor::WindowBase::SetEglWindowBufferTransform()
214    */
215   virtual void SetEglWindowBufferTransform( int angle ) override;
216
217   /**
218    * @copydoc Dali::Internal::Adaptor::WindowBase::SetEglWindowTransform()
219    */
220   virtual void SetEglWindowTransform( int angle ) override;
221
222   /**
223    * @copydoc Dali::Internal::Adaptor::WindowBase::ResizeEglWindow()
224    */
225   virtual void ResizeEglWindow( PositionSize positionSize ) override;
226
227   /**
228    * @copydoc Dali::Internal::Adaptor::WindowBase::IsEglWindowRotationSupported()
229    */
230   virtual bool IsEglWindowRotationSupported() override;
231
232   /**
233    * @copydoc Dali::Internal::Adaptor::WindowBase::Move()
234    */
235   virtual void Move( PositionSize positionSize ) override;
236
237   /**
238    * @copydoc Dali::Internal::Adaptor::WindowBase::Resize()
239    */
240   virtual void Resize( PositionSize positionSize ) override;
241
242   /**
243    * @copydoc Dali::Internal::Adaptor::WindowBase::MoveResize()
244    */
245   virtual void MoveResize( PositionSize positionSize ) override;
246
247   /**
248    * @copydoc Dali::Internal::Adaptor::WindowBase::SetClass()
249    */
250   virtual void SetClass( const std::string& name, const std::string& className ) override;
251
252   /**
253    * @copydoc Dali::Internal::Adaptor::WindowBase::Raise()
254    */
255   virtual void Raise() override;
256
257   /**
258    * @copydoc Dali::Internal::Adaptor::WindowBase::Lower()
259    */
260   virtual void Lower() override;
261
262   /**
263    * @copydoc Dali::Internal::Adaptor::WindowBase::Activate()
264    */
265   virtual void Activate() override;
266
267   /**
268    * @copydoc Dali::Internal::Adaptor::WindowBase::SetAvailableAnlges()
269    */
270   virtual void SetAvailableAnlges( const std::vector< int >& angles ) override;
271
272   /**
273    * @copydoc Dali::Internal::Adaptor::WindowBase::SetPreferredAngle()
274    */
275   virtual void SetPreferredAngle( int angle ) override;
276
277   /**
278    * @copydoc Dali::Internal::Adaptor::WindowBase::SetAcceptFocus()
279    */
280   virtual void SetAcceptFocus( bool accept ) override;
281
282   /**
283    * @copydoc Dali::Internal::Adaptor::WindowBase::Show()
284    */
285   virtual void Show() override;
286
287   /**
288    * @copydoc Dali::Internal::Adaptor::WindowBase::Hide()
289    */
290   virtual void Hide() override;
291
292   /**
293    * @copydoc Dali::Internal::Adaptor::WindowBase::GetSupportedAuxiliaryHintCount()
294    */
295   virtual unsigned int GetSupportedAuxiliaryHintCount() const override;
296
297   /**
298    * @copydoc Dali::Internal::Adaptor::WindowBase::GetSupportedAuxiliaryHint()
299    */
300   virtual std::string GetSupportedAuxiliaryHint( unsigned int index ) const override;
301
302   /**
303    * @copydoc Dali::Internal::Adaptor::WindowBase::AddAuxiliaryHint()
304    */
305   virtual unsigned int AddAuxiliaryHint( const std::string& hint, const std::string& value ) override;
306
307   /**
308    * @copydoc Dali::Internal::Adaptor::WindowBase::RemoveAuxiliaryHint()
309    */
310   virtual bool RemoveAuxiliaryHint( unsigned int id ) override;
311
312   /**
313    * @copydoc Dali::Internal::Adaptor::WindowBase::SetAuxiliaryHintValue()
314    */
315   virtual bool SetAuxiliaryHintValue( unsigned int id, const std::string& value ) override;
316
317   /**
318    * @copydoc Dali::Internal::Adaptor::WindowBase::GetAuxiliaryHintValue()
319    */
320   virtual std::string GetAuxiliaryHintValue( unsigned int id ) const override;
321
322   /**
323    * @copydoc Dali::Internal::Adaptor::WindowBase::GetAuxiliaryHintId()
324    */
325   virtual unsigned int GetAuxiliaryHintId( const std::string& hint ) const override;
326
327   /**
328    * @copydoc Dali::Internal::Adaptor::WindowBase::SetInputRegion()
329    */
330   virtual void SetInputRegion( const Rect< int >& inputRegion ) override;
331
332   /**
333    * @copydoc Dali::Internal::Adaptor::WindowBase::SetType()
334    */
335   virtual void SetType( Dali::Window::Type type ) override;
336
337   /**
338    * @copydoc Dali::Internal::Adaptor::WindowBase::SetNotificationLevel()
339    */
340   virtual bool SetNotificationLevel( Dali::Window::NotificationLevel::Type level ) override;
341
342   /**
343    * @copydoc Dali::Internal::Adaptor::WindowBase::GetNotificationLevel()
344    */
345   virtual Dali::Window::NotificationLevel::Type GetNotificationLevel() const override;
346
347   /**
348    * @copydoc Dali::Internal::Adaptor::WindowBase::SetOpaqueState()
349    */
350   virtual void SetOpaqueState( bool opaque ) override;
351
352   /**
353    * @copydoc Dali::Internal::Adaptor::WindowBase::SetScreenOffMode()
354    */
355   virtual bool SetScreenOffMode(Dali::Window::ScreenOffMode::Type screenOffMode) override;
356
357   /**
358    * @copydoc Dali::Internal::Adaptor::WindowBase::GetScreenOffMode()
359    */
360   virtual Dali::Window::ScreenOffMode::Type GetScreenOffMode() const override;
361
362   /**
363    * @copydoc Dali::Internal::Adaptor::WindowBase::SetBrightness()
364    */
365   virtual bool SetBrightness( int brightness ) override;
366
367   /**
368    * @copydoc Dali::Internal::Adaptor::WindowBase::GetBrightness()
369    */
370   virtual int GetBrightness() const override;
371
372   /**
373    * @copydoc Dali::Internal::Adaptor::WindowBase::GrabKey()
374    */
375   virtual bool GrabKey( Dali::KEY key, KeyGrab::KeyGrabMode grabMode ) override;
376
377   /**
378    * @copydoc Dali::Internal::Adaptor::WindowBase::UngrabKey()
379    */
380   virtual bool UngrabKey( Dali::KEY key ) override;
381
382   /**
383    * @copydoc Dali::Internal::Adaptor::WindowBase::GrabKeyList()
384    */
385   virtual bool GrabKeyList( const Dali::Vector< Dali::KEY >& key, const Dali::Vector< KeyGrab::KeyGrabMode >& grabMode, Dali::Vector< bool >& result ) override;
386
387   /**
388    * @copydoc Dali::Internal::Adaptor::WindowBase::UngrabKeyList()
389    */
390   virtual bool UngrabKeyList( const Dali::Vector< Dali::KEY >& key, Dali::Vector< bool >& result ) override;
391
392   /**
393    * @copydoc Dali::Internal::Adaptor::WindowBase::GetDpi()
394    */
395   virtual void GetDpi( unsigned int& dpiHorizontal, unsigned int& dpiVertical ) override;
396
397   /**
398    * @copydoc Dali::Internal::Adaptor::WindowBase::GetScreenRotationAngle()
399    */
400   virtual int GetScreenRotationAngle() override;
401
402   /**
403    * @copydoc Dali::Internal::Adaptor::WindowBase::SetWindowRotationAngle()
404    */
405   virtual void SetWindowRotationAngle( int degree ) override;
406
407   /**
408    * @copydoc Dali::Internal::Adaptor::WindowBase::WindowRotationCompleted()
409    */
410   virtual void WindowRotationCompleted( int degree, int width, int height ) override;
411
412   /**
413    * @copydoc Dali::Internal::Adaptor::WindowBase::SetTransparency()
414    */
415   virtual void SetTransparency( bool transparent ) override;
416
417   /**
418    * @copydoc Dali::Internal::Adaptor::WindowBase::SetParent()
419    */
420   virtual void SetParent( WindowBase* parentWinBase ) override;
421
422 private:
423
424   /**
425    * Second stage initialization
426    */
427   void Initialize( PositionSize positionSize, Any surface, bool isTransparent );
428
429   /**
430    * Initialize Ecore ElDBus
431    */
432   void InitializeEcoreElDBus();
433
434   /**
435    * @brief Create window
436    */
437   void CreateWindow( PositionSize positionSize );
438
439 protected:
440
441   // Undefined
442   WindowBaseEcoreWl(const WindowBaseEcoreWl&) = delete;
443
444   // Undefined
445   WindowBaseEcoreWl& operator=(const WindowBaseEcoreWl& rhs) = delete;
446
447 private:
448
449   typedef std::vector< std::pair< std::string, std::string > > AuxiliaryHints;
450
451   Dali::Vector< Ecore_Event_Handler* > mEcoreEventHandler;
452
453   Ecore_Wl_Window*                     mEcoreWindow;
454   wl_surface*                          mWlSurface;
455   wl_egl_window*                       mEglWindow;
456   wl_display*                          mDisplay;
457   wl_event_queue*                      mEventQueue;
458   tizen_policy*                        mTizenPolicy;
459   tizen_display_policy*                mTizenDisplayPolicy;
460
461   std::vector< std::string >           mSupportedAuxiliaryHints;
462   AuxiliaryHints                       mAuxiliaryHints;
463
464   int                                  mNotificationLevel;
465   uint32_t                             mNotificationChangeState;
466   bool                                 mNotificationLevelChangeDone;
467
468   int                                  mScreenOffMode;
469   uint32_t                             mScreenOffModeChangeState;
470   bool                                 mScreenOffModeChangeDone;
471
472   int                                  mBrightness;
473   uint32_t                             mBrightnessChangeState;
474   bool                                 mBrightnessChangeDone;
475
476   bool                                 mOwnSurface;
477
478 #ifdef DALI_ELDBUS_AVAILABLE
479   Eldbus_Connection*                   mSystemConnection;
480 #endif // DALI_ELDBUS_AVAILABLE
481
482 };
483
484 } // namespace Adaptor
485
486 } // namespace internal
487
488 } // namespace Dali
489
490 #endif // DALI_INTERNAL_WINDOWSYSTEM_TIZENWAYLAND_WINDOW_BASE_ECORE_WL_H