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