Revert "[Tizen] keygrab & ecore-wl-window-handle c# binding"
[platform/core/uifw/dali-adaptor.git] / adaptors / wayland / window-impl-wl.cpp
index b5ceec9..631681f 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -19,9 +19,6 @@
 #include "window-impl.h"
 
 // EXTERNAL HEADERS
-#include <Ecore.h>
-#include <Ecore_Wayland.h>
-
 #include <dali/integration-api/core.h>
 #include <dali/integration-api/system-overlay.h>
 #include <dali/public-api/render-tasks/render-task.h>
 #include <orientation.h>
 
 // INTERNAL HEADERS
-#include <window-render-surface.h>
+#include "render-surface/render-surface-wl.h"
 #include <drag-and-drop-detector-impl.h>
-#include <indicator-impl.h>
 #include <window-visibility-observer.h>
 #include <orientation-impl.h>
 
-namespace
-{
-const float INDICATOR_ANIMATION_DURATION( 0.18f ); // 180 milli seconds
-const float INDICATOR_SHOW_Y_POSITION( 0.0f );
-const float INDICATOR_HIDE_Y_POSITION( -52.0f );
-}
+
 
 namespace Dali
 {
@@ -52,63 +43,16 @@ namespace Adaptor
 Debug::Filter* gWindowLogFilter = Debug::Filter::New(Debug::Concise, false, "LOG_WINDOW");
 #endif
 
-/**
- * TODO: Abstract Window class out and move this into a window implementation for Ecore
- */
 struct Window::EventHandler
 {
-  /**
-   * Constructor
-   * @param[in]  window  A pointer to the window class.
-   */
-  EventHandler( Window* window )
-  : mWindow( window ),
-    mEcoreWindow( 0 )
-  {
-  }
-
-  /**
-   * Destructor
-   */
-  ~EventHandler()
-  {
-    if ( mWindowPropertyHandler )
-    {
-      ecore_event_handler_del( mWindowPropertyHandler );
-    }
-    if ( mClientMessagehandler )
-    {
-      ecore_event_handler_del( mClientMessagehandler );
-    }
-  }
-
-  // Static methods
-
-  /// Called when the window properties are changed.
-  static Eina_Bool EcoreEventWindowPropertyChanged( void* data, int type, void* event )
-  {
-    return EINA_FALSE;
-  }
-
-  /// Called when the window properties are changed.
-  static Eina_Bool EcoreEventClientMessage( void* data, int type, void* event )
-  {
-    return EINA_FALSE;
-  }
-
-  // Data
-  Window* mWindow;
-  Ecore_Event_Handler* mWindowPropertyHandler;
-  Ecore_Event_Handler* mClientMessagehandler;
-  Ecore_Wl_Window* mEcoreWindow;
+  // place holder
 };
 
-
-Window* Window::New(const PositionSize& posSize, const std::string& name, bool isTransparent)
+Window* Window::New(const PositionSize& posSize, const std::string& name, const std::string& className, bool isTransparent)
 {
   Window* window = new Window();
   window->mIsTransparent = isTransparent;
-  window->Initialize(posSize, name);
+  window->Initialize(posSize, name, className);
   return window;
 }
 
@@ -132,15 +76,7 @@ void Window::SetAdaptor(Dali::Adaptor& adaptor)
   mDragAndDropDetector = DragAndDropDetector::New();
   mAdaptor->SetDragAndDropDetector( &GetImplementation( mDragAndDropDetector ) );
 
-  if( mOrientation )
-  {
-    mOrientation->SetAdaptor(adaptor);
-  }
 
-  if( mIndicator != NULL )
-  {
-    mIndicator->SetAdaptor(mAdaptor);
-  }
 }
 
 RenderSurface* Window::GetSurface()
@@ -148,34 +84,17 @@ RenderSurface* Window::GetSurface()
   return mSurface;
 }
 
-void Window::SetIndicatorStyle( Dali::Window::IndicatorStyle style )
-{
-  mIndicatorStyle = style;
-}
-
 void Window::ShowIndicator( Dali::Window::IndicatorVisibleMode visibleMode )
 {
-  DALI_LOG_TRACE_METHOD_FMT( gWindowLogFilter, "visible : %d\n", visibleMode );
-  DALI_ASSERT_DEBUG(mOverlay);
 
-  DoShowIndicator( mIndicatorOrientation );
 }
 
 void Window::RotateIndicator(Dali::Window::WindowOrientation orientation)
 {
-  DALI_LOG_TRACE_METHOD_FMT( gWindowLogFilter, "Orientation: %d\n", orientation );
-
-  DoRotateIndicator( orientation );
 }
 
 void Window::SetIndicatorBgOpacity( Dali::Window::IndicatorBgOpacity opacityMode )
 {
-  mIndicatorOpacityMode = opacityMode;
-
-  if( mIndicator != NULL )
-  {
-    mIndicator->SetOpacityMode( opacityMode );
-  }
 }
 
 void Window::SetClass(std::string name, std::string klass)
@@ -183,33 +102,34 @@ void Window::SetClass(std::string name, std::string klass)
 }
 
 Window::Window()
-: mSurface(NULL),
-  mIndicatorStyle(Dali::Window::CHANGEABLE_COLOR),
-  mIndicatorVisible(Dali::Window::VISIBLE),
-  mIndicatorIsShown(false),
-  mShowRotatedIndicatorOnClose(false),
-  mStarted(false),
-  mIsTransparent(false),
-  mWMRotationAppSet(false),
-  mIndicator(NULL),
-  mIndicatorOrientation(Dali::Window::PORTRAIT),
-  mNextIndicatorOrientation(Dali::Window::PORTRAIT),
-  mIndicatorOpacityMode(Dali::Window::OPAQUE),
-  mOverlay(NULL),
-  mAdaptor(NULL)
-{
+: mSurface( NULL ),
+  mIndicatorVisible( Dali::Window::VISIBLE ),
+  mIndicatorIsShown( false ),
+  mShowRotatedIndicatorOnClose( false ),
+  mStarted( false ),
+  mIsTransparent( false ),
+  mWMRotationAppSet( false ),
+  mIsFocusAcceptable( true ),
+  mVisible( true ),
+  mOpaqueState( false ),
+  mIndicator( NULL ),
+  mIndicatorOrientation( Dali::Window::PORTRAIT ),
+  mNextIndicatorOrientation( Dali::Window::PORTRAIT ),
+  mIndicatorOpacityMode( Dali::Window::OPAQUE ),
+  mOverlay( NULL ),
+  mAdaptor( NULL ),
+  mType( Dali::DevelWindow::NORMAL ),
+  mPreferredOrientation( Dali::Window::PORTRAIT ),
+  mSupportedAuxiliaryHints(),
+  mAuxiliaryHints()
+{
+  mEventHandler = NULL;
 }
 
 Window::~Window()
 {
   delete mEventHandler;
 
-  if( mIndicator )
-  {
-    mIndicator->Close();
-    delete mIndicator;
-  }
-
   if ( mAdaptor )
   {
     mAdaptor->RemoveObserver( *this );
@@ -220,133 +140,49 @@ Window::~Window()
   delete mSurface;
 }
 
-void Window::Initialize(const PositionSize& windowPosition, const std::string& name)
+void Window::Initialize(const PositionSize& windowPosition, const std::string& name, const std::string& className)
 {
   // create an Wayland window by default
   Any surface;
-  ECore::WindowRenderSurface* windowSurface = new ECore::WindowRenderSurface( windowPosition, surface, name, mIsTransparent );
-  windowSurface->Map();
+  Wayland::RenderSurface* windowSurface = new Wayland::RenderSurface( windowPosition, surface, name, mIsTransparent );
 
   mSurface = windowSurface;
 
   mOrientation = Orientation::New(this);
 
-  // create event handler for Wayland window
-  mEventHandler = new EventHandler( this );
 }
 
 void Window::DoShowIndicator( Dali::Window::WindowOrientation lastOrientation )
 {
-  if( mIndicator == NULL )
-  {
-    if( mIndicatorVisible != Dali::Window::INVISIBLE )
-    {
-      mIndicator = new Indicator( mAdaptor, mIndicatorOrientation, mIndicatorStyle, this );
-      mIndicator->SetOpacityMode( mIndicatorOpacityMode );
-      Dali::Actor actor = mIndicator->GetActor();
-      SetIndicatorActorRotation();
-      mOverlay->Add(actor);
-    }
-    // else don't create a hidden indicator
-  }
-  else // Already have indicator
-  {
-    if( mIndicatorVisible == Dali::Window::VISIBLE )
-    {
-      // If we are resuming, and rotation has changed,
-      if( mIndicatorIsShown == false && mIndicatorOrientation != mNextIndicatorOrientation )
-      {
-        // then close current indicator and open new one
-        mShowRotatedIndicatorOnClose = true;
-        mIndicator->Close(); // May synchronously call IndicatorClosed() callback & 1 level of recursion
-        // Don't show actor - will contain indicator for old orientation.
-      }
-    }
-  }
 
-  // set indicator visible mode
-  if( mIndicator != NULL )
-  {
-    mIndicator->SetVisible( mIndicatorVisible );
-  }
-
-  bool show = (mIndicatorVisible != Dali::Window::INVISIBLE );
-  SetIndicatorProperties( show, lastOrientation );
-  mIndicatorIsShown = show;
 }
 
 void Window::DoRotateIndicator( Dali::Window::WindowOrientation orientation )
 {
-  if( mIndicatorIsShown )
-  {
-    mShowRotatedIndicatorOnClose = true;
-    mNextIndicatorOrientation = orientation;
-    mIndicator->Close(); // May synchronously call IndicatorClosed() callback
-  }
-  else
-  {
-    // Save orientation for when the indicator is next shown
-    mShowRotatedIndicatorOnClose = false;
-    mNextIndicatorOrientation = orientation;
-  }
+
 }
 
 void Window::SetIndicatorProperties( bool isShow, Dali::Window::WindowOrientation lastOrientation )
 {
 }
 
-void Window::IndicatorTypeChanged(Indicator::Type type)
+void Window::IndicatorTypeChanged(IndicatorInterface::Type type)
 {
 }
 
-void Window::IndicatorClosed( Indicator* indicator )
+void Window::IndicatorClosed( IndicatorInterface* indicator )
 {
-  DALI_LOG_TRACE_METHOD( gWindowLogFilter );
 
-  if( mShowRotatedIndicatorOnClose )
-  {
-    Dali::Window::WindowOrientation currentOrientation = mIndicatorOrientation;
-    mIndicator->Open(mNextIndicatorOrientation);
-    mIndicatorOrientation = mNextIndicatorOrientation;
-    SetIndicatorActorRotation();
-    DoShowIndicator(currentOrientation);
-  }
 }
 
 void Window::IndicatorVisibilityChanged(bool isVisible)
 {
-  mIndicatorVisibilityChangedSignal.Emit(isVisible);
+
 }
 
 void Window::SetIndicatorActorRotation()
 {
-  DALI_LOG_TRACE_METHOD( gWindowLogFilter );
-  DALI_ASSERT_DEBUG( mIndicator != NULL );
 
-  Dali::Actor actor = mIndicator->GetActor();
-  switch( mIndicatorOrientation )
-  {
-    case Dali::Window::PORTRAIT:
-      actor.SetParentOrigin( ParentOrigin::TOP_CENTER );
-      actor.SetAnchorPoint(  AnchorPoint::TOP_CENTER );
-      actor.SetOrientation( Degree(0), Vector3::ZAXIS );
-      break;
-    case Dali::Window::PORTRAIT_INVERSE:
-      actor.SetParentOrigin( ParentOrigin::BOTTOM_CENTER );
-      actor.SetAnchorPoint(  AnchorPoint::TOP_CENTER );
-      actor.SetOrientation( Degree(180), Vector3::ZAXIS );
-      break;
-    case Dali::Window::LANDSCAPE:
-      actor.SetParentOrigin( ParentOrigin::CENTER_LEFT );
-      actor.SetAnchorPoint(  AnchorPoint::TOP_CENTER );
-      actor.SetOrientation( Degree(270), Vector3::ZAXIS );
-      break;
-    case Dali::Window::LANDSCAPE_INVERSE:
-      actor.SetParentOrigin( ParentOrigin::CENTER_RIGHT );
-      actor.SetAnchorPoint(  AnchorPoint::TOP_CENTER );
-      actor.SetOrientation( Degree(90), Vector3::ZAXIS );
-      break;
-  }
 }
 
 void Window::Raise()
@@ -368,19 +204,13 @@ Dali::DragAndDropDetector Window::GetDragAndDropDetector() const
 
 Dali::Any Window::GetNativeHandle() const
 {
-  if(mEventHandler)
-  {
-    return mEventHandler->mEcoreWindow;
-  }
-  else
-  {
-    return Dali::Any();
-  }
+  Wayland::RenderSurface* surface = static_cast<  Wayland::RenderSurface* >( mSurface );
+
+  return surface->GetWindow();
 }
 
 void Window::OnStart()
 {
-  DoShowIndicator( mIndicatorOrientation );
 }
 
 void Window::OnPause()
@@ -389,24 +219,10 @@ void Window::OnPause()
 
 void Window::OnResume()
 {
-  // resume indicator status
-  if( mIndicator != NULL )
-  {
-    // Restore own indicator opacity
-    // Send opacity mode to indicator service when app resumed
-    mIndicator->SetOpacityMode( mIndicatorOpacityMode );
-  }
 }
 
 void Window::OnStop()
 {
-  if( mIndicator )
-  {
-    mIndicator->Close();
-  }
-
-  delete mIndicator;
-  mIndicator = NULL;
 }
 
 void Window::OnDestroy()
@@ -414,11 +230,6 @@ void Window::OnDestroy()
   mAdaptor = NULL;
 }
 
-OrientationPtr Window::GetOrientation()
-{
-  return mOrientation;
-}
-
 void Window::AddAvailableOrientation(Dali::Window::WindowOrientation orientation)
 {
   bool found = false;
@@ -473,10 +284,124 @@ Dali::Window::WindowOrientation Window::GetPreferredOrientation()
   return mPreferredOrientation;
 }
 
+void Window::SetAcceptFocus( bool accept )
+{
+  mIsFocusAcceptable = accept;
+}
+
+bool Window::IsFocusAcceptable()
+{
+  return mIsFocusAcceptable;
+}
+
+void Window::Show()
+{
+  mVisible = true;
+}
+
+void Window::Hide()
+{
+  mVisible = false;
+}
+
+bool Window::IsVisible() const
+{
+  return mVisible;
+}
+
+
 void Window::RotationDone( int orientation, int width, int height )
 {
 }
 
+unsigned int Window::GetSupportedAuxiliaryHintCount()
+{
+  return 0;
+}
+
+std::string Window::GetSupportedAuxiliaryHint( unsigned int index )
+{
+  return std::string();
+}
+
+unsigned int Window::AddAuxiliaryHint( const std::string& hint, const std::string& value )
+{
+  return -1;
+}
+
+bool Window::RemoveAuxiliaryHint( unsigned int id )
+{
+  return false;
+}
+
+bool Window::SetAuxiliaryHintValue( unsigned int id, const std::string& value )
+{
+  return false;
+}
+
+std::string Window::GetAuxiliaryHintValue( unsigned int id ) const
+{
+  return std::string();
+}
+
+unsigned int Window::GetAuxiliaryHintId( const std::string& hint ) const
+{
+  return -1;
+}
+
+void Window::SetInputRegion( const Rect< int >& inputRegion )
+{
+}
+
+void Window::SetType( Dali::DevelWindow::Type type )
+{
+  mType = type;
+}
+
+Dali::DevelWindow::Type Window::GetType() const
+{
+  return mType;
+}
+
+bool Window::SetNotificationLevel( Dali::DevelWindow::NotificationLevel::Type level )
+{
+  return false;
+}
+
+Dali::DevelWindow::NotificationLevel::Type Window::GetNotificationLevel()
+{
+  return Dali::DevelWindow::NotificationLevel::NONE;
+}
+
+void Window::SetOpaqueState( bool opaque )
+{
+  mOpaqueState = opaque;
+}
+
+bool Window::IsOpaqueState()
+{
+  return mOpaqueState;
+}
+
+bool Window::SetScreenMode( Dali::DevelWindow::ScreenMode::Type screenMode )
+{
+  return false;
+}
+
+Dali::DevelWindow::ScreenMode::Type Window::GetScreenMode()
+{
+  return Dali::DevelWindow::ScreenMode::DEFAULT;
+}
+
+bool Window::SetBrightness( int brightness )
+{
+  return false;
+}
+
+int Window::GetBrightness()
+{
+  return 0;
+}
 
 } // Adaptor
 } // Internal