[Tizen] Add screen and client rotation itself function
[platform/core/uifw/dali-adaptor.git] / dali / internal / window-system / tizen-wayland / ecore-wl2 / window-base-ecore-wl2.h
index a5bf2b2..dbf7734 100644 (file)
 #include <Ecore.h>
 #include <Ecore_Wl2.h>
 #include <tizen-extension-client-protocol.h>
+#include <wayland-egl.h>
+#include <xkbcommon/xkbcommon.h>
+
+#ifdef DALI_ELDBUS_AVAILABLE
+#include <Eldbus.h>
+#endif
 
 namespace Dali
 {
@@ -46,7 +52,7 @@ public:
   /**
    * @brief Constructor
    */
-  WindowBaseEcoreWl2( Window* window, WindowRenderSurface* windowRenderSurface );
+  WindowBaseEcoreWl2( PositionSize positionSize, Any surface, bool isTransparent );
 
   /**
    * @brief Destructor
@@ -81,6 +87,103 @@ public:
   Eina_Bool OnIgnoreOutputTransform( void* data, int type, void* event );
 
   /**
+   * @brief Called when a rotation event is recevied.
+   */
+  void OnRotation( void* data, int type, void* event );
+
+  /**
+   * @brief Called when a configure event is recevied.
+   */
+  void OnConfiguration( void* data, int type, void* event );
+
+  /**
+   * @brief Called when a touch down is received.
+   */
+  void OnMouseButtonDown( void* data, int type, void* event );
+
+  /**
+   * @brief Called when a touch up is received.
+   */
+  void OnMouseButtonUp( void* data, int type, void* event );
+
+  /**
+   * @brief Called when a touch motion is received.
+   */
+  void OnMouseButtonMove( void* data, int type, void* event );
+
+  /**
+   * @brief Called when a touch is canceled.
+   */
+  void OnMouseButtonCancel( void* data, int type, void* event );
+
+  /**
+   * @brief Called when a mouse wheel is received.
+   */
+  void OnMouseWheel( void* data, int type, void* event );
+
+  /**
+   * @brief Called when a detent rotation event is recevied.
+   */
+  void OnDetentRotation( void* data, int type, void* event );
+
+  /**
+   * @brief Called when a key down is received.
+   */
+  void OnKeyDown( void* data, int type, void* event );
+
+  /**
+   * @brief Called when a key up is received.
+   */
+  void OnKeyUp( void* data, int type, void* event );
+
+  /**
+   * @brief Called when the source window notifies us the content in clipboard is selected.
+   */
+  void OnDataSend( void* data, int type, void* event );
+
+  /**
+   * @brief Called when the source window sends us about the selected content.
+   */
+  void OnDataReceive( void* data, int type, void* event );
+
+  /**
+   * @brief Called when a font name is changed.
+   */
+  void OnFontNameChanged();
+
+  /**
+   * @brief Called when a font size is changed.
+   */
+  void OnFontSizeChanged();
+
+  /**
+   * @brief Called when a transition effect-start/end event is received.
+   */
+  void OnTransitionEffectEvent( DevelWindow::EffectState state, DevelWindow::EffectType type );
+
+  /**
+   * @brief Called when a keyboard repeat event is changed.
+   */
+  void OnKeyboardRepeatSettingsChanged();
+
+  /**
+   * @brief Called when a window redraw is requested.
+   */
+  void OnEcoreEventWindowRedrawRequest();
+
+#ifdef DALI_ELDBUS_AVAILABLE
+  /**
+   * @brief Called when Ecore ElDBus accessibility event is received.
+   */
+  void OnEcoreElDBusAccessibilityNotification( void* context, const Eldbus_Message* message );
+#endif
+
+  /**
+   * @brief Called when a keymap is changed.
+   */
+  void KeymapChanged(void *data, int type, void *event);
+
+  /**
    * @brief RegistryGlobalCallback
    */
   void RegistryGlobalCallback( void* data, struct wl_registry *registry, uint32_t name, const char* interface, uint32_t version );
@@ -105,172 +208,286 @@ public:
    */
   void DisplayPolicyBrightnessChangeDone( void* data, struct tizen_display_policy *displayPolicy, struct wl_surface* surface, int32_t brightness, uint32_t state );
 
+
+  /**
+   * @brief Gets the key code by keyName.
+   */
+  void GetKeyCode( std::string keyName, int32_t& keyCode );
+
 public:
 
   /**
-   * @copydoc Dali::Internal::Adaptor::WindowBase::Initialize()
+   * @copydoc Dali::Internal::Adaptor::WindowBase::GetNativeWindow()
    */
-  virtual void Initialize() override;
+  Any GetNativeWindow() override;
 
   /**
-   * @copydoc Dali::Internal::Adaptor::WindowBase::ShowIndicator()
+   * @copydoc Dali::Internal::Adaptor::WindowBase::GetNativeWindowId()
    */
-  virtual void ShowIndicator( Dali::Window::IndicatorVisibleMode visibleMode, Dali::Window::IndicatorBgOpacity opacityMode ) override;
+  int GetNativeWindowId() override;
 
   /**
-   * @copydoc Dali::Internal::Adaptor::WindowBase::SetIndicatorProperties()
+   * @copydoc Dali::Internal::Adaptor::WindowBase::CreateEglWindow()
    */
-  virtual void SetIndicatorProperties( bool isShow, Dali::Window::WindowOrientation lastOrientation ) override;
+  EGLNativeWindowType CreateEglWindow( int width, int height ) override;
 
   /**
-   * @copydoc Dali::Internal::Adaptor::WindowBase::IndicatorTypeChanged()
+   * @copydoc Dali::Internal::Adaptor::WindowBase::DestroyEglWindow()
    */
-  virtual void IndicatorTypeChanged( IndicatorInterface::Type type ) override;
+  void DestroyEglWindow() override;
+
+  /**
+   * @copydoc Dali::Internal::Adaptor::WindowBase::SetEglWindowRotation()
+   */
+  void SetEglWindowRotation( int angle ) override;
+
+  /**
+   * @copydoc Dali::Internal::Adaptor::WindowBase::SetEglWindowBufferTransform()
+   */
+  void SetEglWindowBufferTransform( int angle ) override;
+
+  /**
+   * @copydoc Dali::Internal::Adaptor::WindowBase::SetEglWindowTransform()
+   */
+  void SetEglWindowTransform( int angle ) override;
+
+  /**
+   * @copydoc Dali::Internal::Adaptor::WindowBase::ResizeEglWindow()
+   */
+  void ResizeEglWindow( PositionSize positionSize ) override;
+
+  /**
+   * @copydoc Dali::Internal::Adaptor::WindowBase::IsEglWindowRotationSupported()
+   */
+  bool IsEglWindowRotationSupported() override;
+
+  /**
+   * @copydoc Dali::Internal::Adaptor::WindowBase::Move()
+   */
+  void Move( PositionSize positionSize ) override;
+
+  /**
+   * @copydoc Dali::Internal::Adaptor::WindowBase::Resize()
+   */
+  void Resize( PositionSize positionSize ) override;
+
+  /**
+   * @copydoc Dali::Internal::Adaptor::WindowBase::MoveResize()
+   */
+  void MoveResize( PositionSize positionSize ) override;
 
   /**
    * @copydoc Dali::Internal::Adaptor::WindowBase::SetClass()
    */
-  virtual void SetClass( std::string name, std::string className ) override;
+  void SetClass( const std::string& name, const std::string& className ) override;
 
   /**
    * @copydoc Dali::Internal::Adaptor::WindowBase::Raise()
    */
-  virtual void Raise() override;
+  void Raise() override;
 
   /**
    * @copydoc Dali::Internal::Adaptor::WindowBase::Lower()
    */
-  virtual void Lower() override;
+  void Lower() override;
 
   /**
    * @copydoc Dali::Internal::Adaptor::WindowBase::Activate()
    */
-  virtual void Activate() override;
+  void Activate() override;
 
   /**
-   * @copydoc Dali::Internal::Adaptor::WindowBase::SetAvailableOrientations()
+   * @copydoc Dali::Internal::Adaptor::WindowBase::SetAvailableAnlges()
    */
-  virtual void SetAvailableOrientations( const std::vector< Dali::Window::WindowOrientation >& orientations ) override;
+  void SetAvailableAnlges( const std::vector< int >& angles ) override;
 
   /**
-   * @copydoc Dali::Internal::Adaptor::WindowBase::SetPreferredOrientation()
+   * @copydoc Dali::Internal::Adaptor::WindowBase::SetPreferredAngle()
    */
-  virtual void SetPreferredOrientation( Dali::Window::WindowOrientation orientation ) override;
+  void SetPreferredAngle( int angle ) override;
 
   /**
    * @copydoc Dali::Internal::Adaptor::WindowBase::SetAcceptFocus()
    */
-  virtual void SetAcceptFocus( bool accept ) override;
+  void SetAcceptFocus( bool accept ) override;
 
   /**
    * @copydoc Dali::Internal::Adaptor::WindowBase::Show()
    */
-  virtual void Show() override;
+  void Show() override;
 
   /**
    * @copydoc Dali::Internal::Adaptor::WindowBase::Hide()
    */
-  virtual void Hide() override;
+  void Hide() override;
 
   /**
    * @copydoc Dali::Internal::Adaptor::WindowBase::GetSupportedAuxiliaryHintCount()
    */
-  virtual unsigned int GetSupportedAuxiliaryHintCount() const override;
+  unsigned int GetSupportedAuxiliaryHintCount() const override;
 
   /**
    * @copydoc Dali::Internal::Adaptor::WindowBase::GetSupportedAuxiliaryHint()
    */
-  virtual std::string GetSupportedAuxiliaryHint( unsigned int index ) const override;
+  std::string GetSupportedAuxiliaryHint( unsigned int index ) const override;
 
   /**
    * @copydoc Dali::Internal::Adaptor::WindowBase::AddAuxiliaryHint()
    */
-  virtual unsigned int AddAuxiliaryHint( const std::string& hint, const std::string& value ) override;
+  unsigned int AddAuxiliaryHint( const std::string& hint, const std::string& value ) override;
 
   /**
    * @copydoc Dali::Internal::Adaptor::WindowBase::RemoveAuxiliaryHint()
    */
-  virtual bool RemoveAuxiliaryHint( unsigned int id ) override;
+  bool RemoveAuxiliaryHint( unsigned int id ) override;
 
   /**
    * @copydoc Dali::Internal::Adaptor::WindowBase::SetAuxiliaryHintValue()
    */
-  virtual bool SetAuxiliaryHintValue( unsigned int id, const std::string& value ) override;
+  bool SetAuxiliaryHintValue( unsigned int id, const std::string& value ) override;
 
   /**
    * @copydoc Dali::Internal::Adaptor::WindowBase::GetAuxiliaryHintValue()
    */
-  virtual std::string GetAuxiliaryHintValue( unsigned int id ) const override;
+  std::string GetAuxiliaryHintValue( unsigned int id ) const override;
 
   /**
    * @copydoc Dali::Internal::Adaptor::WindowBase::GetAuxiliaryHintId()
    */
-  virtual unsigned int GetAuxiliaryHintId( const std::string& hint ) const override;
+  unsigned int GetAuxiliaryHintId( const std::string& hint ) const override;
 
   /**
    * @copydoc Dali::Internal::Adaptor::WindowBase::SetInputRegion()
    */
-  virtual void SetInputRegion( const Rect< int >& inputRegion ) override;
+  void SetInputRegion( const Rect< int >& inputRegion ) override;
 
   /**
    * @copydoc Dali::Internal::Adaptor::WindowBase::SetType()
    */
-  virtual void SetType( Dali::Window::Type type ) override;
+  void SetType( Dali::Window::Type type ) override;
 
   /**
    * @copydoc Dali::Internal::Adaptor::WindowBase::SetNotificationLevel()
    */
-  virtual bool SetNotificationLevel( Dali::Window::NotificationLevel::Type level ) override;
+  bool SetNotificationLevel( Dali::Window::NotificationLevel::Type level ) override;
 
   /**
    * @copydoc Dali::Internal::Adaptor::WindowBase::GetNotificationLevel()
    */
-  virtual Dali::Window::NotificationLevel::Type GetNotificationLevel() const override;
+  Dali::Window::NotificationLevel::Type GetNotificationLevel() const override;
 
   /**
    * @copydoc Dali::Internal::Adaptor::WindowBase::SetOpaqueState()
    */
-  virtual void SetOpaqueState( bool opaque ) override;
+  void SetOpaqueState( bool opaque ) override;
 
   /**
    * @copydoc Dali::Internal::Adaptor::WindowBase::SetScreenOffMode()
    */
-  virtual bool SetScreenOffMode(Dali::Window::ScreenOffMode::Type screenOffMode) override;
+  bool SetScreenOffMode(Dali::Window::ScreenOffMode::Type screenOffMode) override;
 
   /**
    * @copydoc Dali::Internal::Adaptor::WindowBase::GetScreenOffMode()
    */
-  virtual Dali::Window::ScreenOffMode::Type GetScreenOffMode() const override;
+  Dali::Window::ScreenOffMode::Type GetScreenOffMode() const override;
 
   /**
    * @copydoc Dali::Internal::Adaptor::WindowBase::SetBrightness()
    */
-  virtual bool SetBrightness( int brightness ) override;
+  bool SetBrightness( int brightness ) override;
 
   /**
    * @copydoc Dali::Internal::Adaptor::WindowBase::GetBrightness()
    */
-  virtual int GetBrightness() const override;
+  int GetBrightness() const override;
 
   /**
    * @copydoc Dali::Internal::Adaptor::WindowBase::GrabKey()
    */
-  virtual bool GrabKey( Dali::KEY key, KeyGrab::KeyGrabMode grabMode ) override;
+  bool GrabKey( Dali::KEY key, KeyGrab::KeyGrabMode grabMode ) override;
 
   /**
    * @copydoc Dali::Internal::Adaptor::WindowBase::UngrabKey()
    */
-  virtual bool UngrabKey( Dali::KEY key ) override;
+  bool UngrabKey( Dali::KEY key ) override;
 
   /**
    * @copydoc Dali::Internal::Adaptor::WindowBase::GrabKeyList()
    */
-  virtual bool GrabKeyList( const Dali::Vector< Dali::KEY >& key, const Dali::Vector< KeyGrab::KeyGrabMode >& grabMode, Dali::Vector< bool >& result ) override;
+  bool GrabKeyList( const Dali::Vector< Dali::KEY >& key, const Dali::Vector< KeyGrab::KeyGrabMode >& grabMode, Dali::Vector< bool >& result ) override;
 
   /**
    * @copydoc Dali::Internal::Adaptor::WindowBase::UngrabKeyList()
    */
-  virtual bool UngrabKeyList( const Dali::Vector< Dali::KEY >& key, Dali::Vector< bool >& result ) override;
+  bool UngrabKeyList( const Dali::Vector< Dali::KEY >& key, Dali::Vector< bool >& result ) override;
+
+  /**
+   * @copydoc Dali::Internal::Adaptor::WindowBase::GetDpi()
+   */
+  void GetDpi( unsigned int& dpiHorizontal, unsigned int& dpiVertical ) override;
+
+  /**
+   * @brief Return the orientation of the surface.
+   * @return The orientation
+   */
+  virtual int GetOrientation() const override;
+
+  /**
+   * @copydoc Dali::Internal::Adaptor::WindowBase::GetScreenRotationAngle()
+   */
+  int GetScreenRotationAngle() override;
+
+  /**
+   * @copydoc Dali::Internal::Adaptor::WindowBase::SetWindowRotationAngle()
+   */
+  void SetWindowRotationAngle( int degree ) override;
+
+  /**
+   * @copydoc Dali::Internal::Adaptor::WindowBase::GetWindowRotationAngle()
+   */
+  virtual int GetWindowRotationAngle() override;
+
+  /**
+   * @copydoc Dali::Internal::Adaptor::WindowBase::WindowRotationCompleted()
+   */
+  void WindowRotationCompleted( int degree, int width, int height ) override;
+
+  /**
+   * @copydoc Dali::Internal::Adaptor::WindowBase::SetTransparency()
+   */
+  void SetTransparency( bool transparent ) override;
+
+  /**
+   * @copydoc Dali::Internal::Adaptor::WindowBase::SetParent()
+   */
+  void SetParent( WindowBase* parentWinBase ) override;
+
+  /**
+   * @copydoc  Dali::Internal::Adaptor::WindowBase::CreateFrameRenderedSyncFence()
+   */
+  int CreateFrameRenderedSyncFence() override;
+
+  /**
+   * @copydoc  Dali::Internal::Adaptor::WindowBase::CreateFramePresentedSyncFence()
+   */
+  int CreateFramePresentedSyncFence() override;
+
+private:
+
+  /**
+   * Second stage initialization
+   */
+  void Initialize( PositionSize positionSize, Any surface, bool isTransparent );
+
+  /**
+   * Initialize Ecore ElDBus
+   */
+  void InitializeEcoreElDBus();
+
+  /**
+   * @brief Create window
+   */
+  void CreateWindow( PositionSize positionSize );
 
 protected:
 
@@ -286,13 +503,14 @@ private:
 
   Dali::Vector< Ecore_Event_Handler* > mEcoreEventHandler;
 
-  Window*                              mWindow;
-  WindowRenderSurfaceEcoreWl2*         mWindowSurface;
   Ecore_Wl2_Window*                    mEcoreWindow;
+  wl_surface*                          mWlSurface;
+  wl_egl_window*                       mEglWindow;
   wl_display*                          mDisplay;
   wl_event_queue*                      mEventQueue;
   tizen_policy*                        mTizenPolicy;
   tizen_display_policy*                mTizenDisplayPolicy;
+  xkb_keymap*                          mKeyMap;
 
   std::vector< std::string >           mSupportedAuxiliaryHints;
   AuxiliaryHints                       mAuxiliaryHints;
@@ -308,6 +526,21 @@ private:
   int                                  mBrightness;
   uint32_t                             mBrightnessChangeState;
   bool                                 mBrightnessChangeDone;
+
+  bool                                 mVisible:1;
+  Dali::PositionSize                   mWindowPositionSize;
+
+  bool                                 mOwnSurface;
+
+  volatile uint32_t                    mMoveResizeSerial;
+  uint32_t                             mLastSubmittedMoveResizeSerial;
+
+  int                                  mWindowRotationAngle;
+  int                                  mScreenRotationAngle;
+  int                                  mSupportedPreProtation;
+#ifdef DALI_ELDBUS_AVAILABLE
+  Eldbus_Connection*                   mSystemConnection;
+#endif // DALI_ELDBUS_AVAILABLE
 };
 
 } // namespace Adaptor