[Tizen] Add rotation's values to winBase-wl2
[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 Called when a keymap is changed.
173    */
174   void KeymapChanged(void *data, int type, void *event);
175
176   /**
177    * @brief RegistryGlobalCallback
178    */
179   void RegistryGlobalCallback( void* data, struct wl_registry *registry, uint32_t name, const char* interface, uint32_t version );
180
181   /**
182    * @brief RegistryGlobalCallbackRemove
183    */
184   void RegistryGlobalCallbackRemove( void* data, struct wl_registry* registry, uint32_t id );
185
186   /**
187    * @brief TizenPolicyNotificationChangeDone
188    */
189   void TizenPolicyNotificationChangeDone(void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, int32_t level, uint32_t state );
190
191   /**
192    * @brief TizenPolicyScreenModeChangeDone
193    */
194   void TizenPolicyScreenModeChangeDone( void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, uint32_t mode, uint32_t state );
195
196   /**
197    * @brief DisplayPolicyBrightnessChangeDone
198    */
199   void DisplayPolicyBrightnessChangeDone( void* data, struct tizen_display_policy *displayPolicy, struct wl_surface* surface, int32_t brightness, uint32_t state );
200
201
202   /**
203    * @brief Gets the key code by keyName.
204    */
205   void GetKeyCode( std::string keyName, int32_t& keyCode );
206
207 public:
208
209   /**
210    * @copydoc Dali::Internal::Adaptor::WindowBase::GetNativeWindow()
211    */
212   virtual Any GetNativeWindow() override;
213
214   /**
215    * @copydoc Dali::Internal::Adaptor::WindowBase::GetNativeWindowId()
216    */
217   virtual int GetNativeWindowId() override;
218
219   /**
220    * @copydoc Dali::Internal::Adaptor::WindowBase::CreateEglWindow()
221    */
222   virtual EGLNativeWindowType CreateEglWindow( int width, int height ) override;
223
224   /**
225    * @copydoc Dali::Internal::Adaptor::WindowBase::DestroyEglWindow()
226    */
227   virtual void DestroyEglWindow() override;
228
229   /**
230    * @copydoc Dali::Internal::Adaptor::WindowBase::SetEglWindowRotation()
231    */
232   virtual void SetEglWindowRotation( int angle ) override;
233
234   /**
235    * @copydoc Dali::Internal::Adaptor::WindowBase::SetEglWindowBufferTransform()
236    */
237   virtual void SetEglWindowBufferTransform( int angle ) override;
238
239   /**
240    * @copydoc Dali::Internal::Adaptor::WindowBase::SetEglWindowTransform()
241    */
242   virtual void SetEglWindowTransform( int angle ) override;
243
244   /**
245    * @copydoc Dali::Internal::Adaptor::WindowBase::ResizeEglWindow()
246    */
247   virtual void ResizeEglWindow( PositionSize positionSize ) override;
248
249   /**
250    * @copydoc Dali::Internal::Adaptor::WindowBase::IsEglWindowRotationSupported()
251    */
252   virtual bool IsEglWindowRotationSupported() override;
253
254   /**
255    * @copydoc Dali::Internal::Adaptor::WindowBase::Move()
256    */
257   virtual void Move( PositionSize positionSize ) override;
258
259   /**
260    * @copydoc Dali::Internal::Adaptor::WindowBase::Resize()
261    */
262   virtual void Resize( PositionSize positionSize ) override;
263
264   /**
265    * @copydoc Dali::Internal::Adaptor::WindowBase::MoveResize()
266    */
267   virtual void MoveResize( PositionSize positionSize ) override;
268
269   /**
270    * @copydoc Dali::Internal::Adaptor::WindowBase::SetClass()
271    */
272   virtual void SetClass( const std::string& name, const std::string& className ) override;
273
274   /**
275    * @copydoc Dali::Internal::Adaptor::WindowBase::Raise()
276    */
277   virtual void Raise() override;
278
279   /**
280    * @copydoc Dali::Internal::Adaptor::WindowBase::Lower()
281    */
282   virtual void Lower() override;
283
284   /**
285    * @copydoc Dali::Internal::Adaptor::WindowBase::Activate()
286    */
287   virtual void Activate() override;
288
289   /**
290    * @copydoc Dali::Internal::Adaptor::WindowBase::SetAvailableAnlges()
291    */
292   virtual void SetAvailableAnlges( const std::vector< int >& angles ) override;
293
294   /**
295    * @copydoc Dali::Internal::Adaptor::WindowBase::SetPreferredAngle()
296    */
297   virtual void SetPreferredAngle( int angle ) override;
298
299   /**
300    * @copydoc Dali::Internal::Adaptor::WindowBase::SetAcceptFocus()
301    */
302   virtual void SetAcceptFocus( bool accept ) override;
303
304   /**
305    * @copydoc Dali::Internal::Adaptor::WindowBase::Show()
306    */
307   virtual void Show() override;
308
309   /**
310    * @copydoc Dali::Internal::Adaptor::WindowBase::Hide()
311    */
312   virtual void Hide() override;
313
314   /**
315    * @copydoc Dali::Internal::Adaptor::WindowBase::GetSupportedAuxiliaryHintCount()
316    */
317   virtual unsigned int GetSupportedAuxiliaryHintCount() const override;
318
319   /**
320    * @copydoc Dali::Internal::Adaptor::WindowBase::GetSupportedAuxiliaryHint()
321    */
322   virtual std::string GetSupportedAuxiliaryHint( unsigned int index ) const override;
323
324   /**
325    * @copydoc Dali::Internal::Adaptor::WindowBase::AddAuxiliaryHint()
326    */
327   virtual unsigned int AddAuxiliaryHint( const std::string& hint, const std::string& value ) override;
328
329   /**
330    * @copydoc Dali::Internal::Adaptor::WindowBase::RemoveAuxiliaryHint()
331    */
332   virtual bool RemoveAuxiliaryHint( unsigned int id ) override;
333
334   /**
335    * @copydoc Dali::Internal::Adaptor::WindowBase::SetAuxiliaryHintValue()
336    */
337   virtual bool SetAuxiliaryHintValue( unsigned int id, const std::string& value ) override;
338
339   /**
340    * @copydoc Dali::Internal::Adaptor::WindowBase::GetAuxiliaryHintValue()
341    */
342   virtual std::string GetAuxiliaryHintValue( unsigned int id ) const override;
343
344   /**
345    * @copydoc Dali::Internal::Adaptor::WindowBase::GetAuxiliaryHintId()
346    */
347   virtual unsigned int GetAuxiliaryHintId( const std::string& hint ) const override;
348
349   /**
350    * @copydoc Dali::Internal::Adaptor::WindowBase::SetInputRegion()
351    */
352   virtual void SetInputRegion( const Rect< int >& inputRegion ) override;
353
354   /**
355    * @copydoc Dali::Internal::Adaptor::WindowBase::SetType()
356    */
357   virtual void SetType( Dali::Window::Type type ) override;
358
359   /**
360    * @copydoc Dali::Internal::Adaptor::WindowBase::SetNotificationLevel()
361    */
362   virtual bool SetNotificationLevel( Dali::Window::NotificationLevel::Type level ) override;
363
364   /**
365    * @copydoc Dali::Internal::Adaptor::WindowBase::GetNotificationLevel()
366    */
367   virtual Dali::Window::NotificationLevel::Type GetNotificationLevel() const override;
368
369   /**
370    * @copydoc Dali::Internal::Adaptor::WindowBase::SetOpaqueState()
371    */
372   virtual void SetOpaqueState( bool opaque ) override;
373
374   /**
375    * @copydoc Dali::Internal::Adaptor::WindowBase::SetScreenOffMode()
376    */
377   virtual bool SetScreenOffMode(Dali::Window::ScreenOffMode::Type screenOffMode) override;
378
379   /**
380    * @copydoc Dali::Internal::Adaptor::WindowBase::GetScreenOffMode()
381    */
382   virtual Dali::Window::ScreenOffMode::Type GetScreenOffMode() const override;
383
384   /**
385    * @copydoc Dali::Internal::Adaptor::WindowBase::SetBrightness()
386    */
387   virtual bool SetBrightness( int brightness ) override;
388
389   /**
390    * @copydoc Dali::Internal::Adaptor::WindowBase::GetBrightness()
391    */
392   virtual int GetBrightness() const override;
393
394   /**
395    * @copydoc Dali::Internal::Adaptor::WindowBase::GrabKey()
396    */
397   virtual bool GrabKey( Dali::KEY key, KeyGrab::KeyGrabMode grabMode ) override;
398
399   /**
400    * @copydoc Dali::Internal::Adaptor::WindowBase::UngrabKey()
401    */
402   virtual bool UngrabKey( Dali::KEY key ) override;
403
404   /**
405    * @copydoc Dali::Internal::Adaptor::WindowBase::GrabKeyList()
406    */
407   virtual bool GrabKeyList( const Dali::Vector< Dali::KEY >& key, const Dali::Vector< KeyGrab::KeyGrabMode >& grabMode, Dali::Vector< bool >& result ) override;
408
409   /**
410    * @copydoc Dali::Internal::Adaptor::WindowBase::UngrabKeyList()
411    */
412   virtual bool UngrabKeyList( const Dali::Vector< Dali::KEY >& key, Dali::Vector< bool >& result ) override;
413
414   /**
415    * @copydoc Dali::Internal::Adaptor::WindowBase::GetDpi()
416    */
417   virtual void GetDpi( unsigned int& dpiHorizontal, unsigned int& dpiVertical ) override;
418
419   /**
420    * @brief Return the orientation of the surface.
421    * @return The orientation
422    */
423   virtual int GetOrientation() const override;
424
425   /**
426    * @copydoc Dali::Internal::Adaptor::WindowBase::GetScreenRotationAngle()
427    */
428   virtual int GetScreenRotationAngle() override;
429
430   /**
431    * @copydoc Dali::Internal::Adaptor::WindowBase::SetWindowRotationAngle()
432    */
433   virtual void SetWindowRotationAngle( int degree ) override;
434
435   /**
436    * @copydoc Dali::Internal::Adaptor::WindowBase::GetWindowRotationAngle()
437    */
438   virtual int GetWindowRotationAngle() override;
439
440   /**
441    * @copydoc Dali::Internal::Adaptor::WindowBase::WindowRotationCompleted()
442    */
443   virtual void WindowRotationCompleted( int degree, int width, int height ) override;
444
445   /**
446    * @copydoc Dali::Internal::Adaptor::WindowBase::SetTransparency()
447    */
448   virtual void SetTransparency( bool transparent ) override;
449
450   /**
451    * @copydoc Dali::Internal::Adaptor::WindowBase::SetParent()
452    */
453   virtual void SetParent( WindowBase* parentWinBase ) override;
454
455 private:
456
457   /**
458    * Second stage initialization
459    */
460   void Initialize( PositionSize positionSize, Any surface, bool isTransparent );
461
462   /**
463    * Initialize Ecore ElDBus
464    */
465   void InitializeEcoreElDBus();
466
467   /**
468    * @brief Create window
469    */
470   void CreateWindow( PositionSize positionSize );
471
472 protected:
473
474   // Undefined
475   WindowBaseEcoreWl2(const WindowBaseEcoreWl2&) = delete;
476
477   // Undefined
478   WindowBaseEcoreWl2& operator=(const WindowBaseEcoreWl2& rhs) = delete;
479
480 private:
481
482   typedef std::vector< std::pair< std::string, std::string > > AuxiliaryHints;
483
484   Dali::Vector< Ecore_Event_Handler* > mEcoreEventHandler;
485
486   Ecore_Wl2_Window*                    mEcoreWindow;
487   wl_surface*                          mWlSurface;
488   wl_egl_window*                       mEglWindow;
489   wl_display*                          mDisplay;
490   wl_event_queue*                      mEventQueue;
491   tizen_policy*                        mTizenPolicy;
492   tizen_display_policy*                mTizenDisplayPolicy;
493   xkb_keymap*                          mKeyMap;
494
495   std::vector< std::string >           mSupportedAuxiliaryHints;
496   AuxiliaryHints                       mAuxiliaryHints;
497
498   int                                  mNotificationLevel;
499   uint32_t                             mNotificationChangeState;
500   bool                                 mNotificationLevelChangeDone;
501
502   int                                  mScreenOffMode;
503   uint32_t                             mScreenOffModeChangeState;
504   bool                                 mScreenOffModeChangeDone;
505
506   int                                  mBrightness;
507   uint32_t                             mBrightnessChangeState;
508   bool                                 mBrightnessChangeDone;
509
510   bool                                 mOwnSurface;
511
512   volatile uint32_t                    mMoveResizeSerial;
513   uint32_t                             mLastSubmittedMoveResizeSerial;
514
515   int                                  mWindowRotationAngle;
516   int                                  mScreenRotationAngle;
517   int                                  mSupportedPreProtation;
518
519   // Temporary solution to fix window rotation and window hide
520   // It will be removed when EFL patch is completed.
521   int                                  mAvaiableWindowOrientations[4];
522 #ifdef DALI_ELDBUS_AVAILABLE
523   Eldbus_Connection*                   mSystemConnection;
524 #endif // DALI_ELDBUS_AVAILABLE
525 };
526
527 } // namespace Adaptor
528
529 } // namespace internal
530
531 } // namespace Dali
532
533 #endif // DALI_INTERNAL_WINDOWSYSTEM_TIZENWAYLAND_WINDOW_BASE_ECORE_WL2_H