Merge branch 'tizen' into devel/new_mesh
[platform/core/uifw/dali-adaptor.git] / adaptors / x11 / window-impl-x.cpp
index aac604c..dca0fb1 100644 (file)
 #include <dali/integration-api/system-overlay.h>
 #include <dali/public-api/render-tasks/render-task.h>
 #include <dali/public-api/render-tasks/render-task-list.h>
-#include <orientation.h>
 
 // INTERNAL HEADERS
 #include <window-render-surface.h>
 #include <drag-and-drop-detector-impl.h>
 #include <indicator-impl.h>
 #include <window-visibility-observer.h>
+#include <orientation.h>
 #include <orientation-impl.h>
 
 namespace
@@ -75,11 +75,15 @@ struct Window::EventHandler
     }
     DALI_ASSERT_ALWAYS( mEcoreWindow != 0 && "There is no ecore x window");
 
+#ifndef DALI_PROFILE_UBUNTU
     // set property on window to get deiconify approve client message
     unsigned int tmp = 1;
     ecore_x_window_prop_card32_set(mEcoreWindow,
                              ECORE_X_ATOM_E_DEICONIFY_APPROVE,
                              &tmp, 1);
+#endif // DALI_PROFILE_UBUNTU
+
+    ecore_x_input_multi_select( mEcoreWindow );
   }
 
   /**
@@ -156,6 +160,7 @@ struct Window::EventHandler
   static Eina_Bool EcoreEventClientMessage( void* data, int type, void* event )
   {
     Eina_Bool handled( ECORE_CALLBACK_PASS_ON );
+#ifndef DALI_PROFILE_UBUNTU
     Ecore_X_Event_Client_Message* clientMessageEvent( (Ecore_X_Event_Client_Message*)event );
     EventHandler* handler( (EventHandler*)data );
 
@@ -180,6 +185,7 @@ struct Window::EventHandler
         }
       }
     }
+#endif // DALI_PROFILE_UBUNTU
 
     return handled;
   }
@@ -236,28 +242,6 @@ RenderSurface* Window::GetSurface()
   return mSurface;
 }
 
-void Window::SetIndicatorStyle( Dali::Window::IndicatorStyle style )
-{
-  mIndicatorStyle = style;
-}
-
-void Window::ShowIndicator( bool show )
-{
-  DALI_LOG_TRACE_METHOD_FMT( gWindowLogFilter, "%s\n", show?"SHOW":"HIDE" );
-  DALI_ASSERT_DEBUG(mOverlay);
-
-  if(show)
-  {
-    mIndicatorVisible = Dali::Window::VISIBLE;
-  }
-  else
-  {
-    mIndicatorVisible = Dali::Window::INVISIBLE;
-  }
-
-  DoShowIndicator( mIndicatorOrientation );
-}
-
 void Window::ShowIndicator( Dali::Window::IndicatorVisibleMode visibleMode )
 {
   DALI_LOG_TRACE_METHOD_FMT( gWindowLogFilter, "visible : %d\n", visibleMode );
@@ -283,7 +267,7 @@ void Window::ShowIndicator( Dali::Window::IndicatorVisibleMode visibleMode )
 #if defined(DALI_PROFILE_MOBILE)
     else if ( mIndicatorOpacityMode == Dali::Window::TRANSPARENT )
     {
-      ecore_x_e_illume_indicator_opacity_set(xWinId, ECORE_X_ILLUME_INDICATOR_BG_TRANSPARENT);
+      ecore_x_e_illume_indicator_opacity_set(xWinId, ECORE_X_ILLUME_INDICATOR_OPAQUE);
     }
 #endif
   }
@@ -328,8 +312,7 @@ void Window::SetClass(std::string name, std::string klass)
 
 Window::Window()
 : mSurface(NULL),
-  mIndicatorStyle(Dali::Window::CHANGEABLE_COLOR),
-  mIndicatorVisible(Dali::Window::VISIBLE),
+  mIndicatorVisible(Dali::Window::INVISIBLE),
   mIndicatorIsShown(false),
   mShowRotatedIndicatorOnClose(false),
   mStarted(false),
@@ -340,7 +323,9 @@ Window::Window()
   mNextIndicatorOrientation(Dali::Window::PORTRAIT),
   mIndicatorOpacityMode(Dali::Window::OPAQUE),
   mOverlay(NULL),
-  mAdaptor(NULL)
+  mAdaptor(NULL),
+  mEventHandler(NULL),
+  mPreferredOrientation(Dali::Window::PORTRAIT)
 {
 }
 
@@ -348,7 +333,17 @@ Window::~Window()
 {
   delete mEventHandler;
 
-  if ( mAdaptor )
+  if( mIndicator )
+  {
+    mOverlay->Remove( mIndicator->GetActor() );
+    Dali::RenderTaskList taskList = mOverlay->GetOverlayRenderTasks();
+    Dali::RenderTask indicatorTask = taskList.GetTask(0);
+    mOverlay->GetOverlayRenderTasks().RemoveTask(indicatorTask);
+    mIndicator->Close();
+    delete mIndicator;
+  }
+
+  if( mAdaptor )
   {
     mAdaptor->RemoveObserver( *this );
     mAdaptor->SetDragAndDropDetector( NULL );
@@ -362,8 +357,11 @@ void Window::Initialize(const PositionSize& windowPosition, const std::string& n
 {
   // create an X11 window by default
   Any surface;
-  Any display;
-  mSurface = new ECore::WindowRenderSurface( windowPosition, surface, display, name, mIsTransparent );
+  ECore::WindowRenderSurface* windowSurface = new ECore::WindowRenderSurface( windowPosition, surface, name, mIsTransparent );
+  windowSurface->Map();
+
+  mSurface = windowSurface;
+
   mOrientation = Orientation::New(this);
 
   // create event handler for X11 window
@@ -376,7 +374,7 @@ void Window::DoShowIndicator( Dali::Window::WindowOrientation lastOrientation )
   {
     if( mIndicatorVisible != Dali::Window::INVISIBLE )
     {
-      mIndicator = new Indicator( mAdaptor, mIndicatorOrientation, mIndicatorStyle, this );
+      mIndicator = new Indicator( mAdaptor, mIndicatorOrientation, this );
       mIndicator->SetOpacityMode( mIndicatorOpacityMode );
       Dali::Actor actor = mIndicator->GetActor();
       SetIndicatorActorRotation();
@@ -454,6 +452,7 @@ void Window::IndicatorTypeChanged(Indicator::Type type)
   ECore::WindowRenderSurface* x11Window = dynamic_cast< ECore::WindowRenderSurface * >( mSurface );
   if( x11Window )
   {
+#ifndef DALI_PROFILE_UBUNTU
     Ecore_X_Window win = x11Window->GetXWindow();
     switch(type)
     {
@@ -469,6 +468,7 @@ void Window::IndicatorTypeChanged(Indicator::Type type)
       default:
         break;
     }
+#endif // DALI_PROFILE_UBUNTU
   }
 }
 
@@ -486,6 +486,11 @@ void Window::IndicatorClosed( Indicator* indicator )
   }
 }
 
+void Window::IndicatorVisibilityChanged(bool isVisible)
+{
+  mIndicatorVisibilityChangedSignal.Emit(isVisible);
+}
+
 void Window::SetIndicatorActorRotation()
 {
   DALI_LOG_TRACE_METHOD( gWindowLogFilter );
@@ -497,22 +502,22 @@ void Window::SetIndicatorActorRotation()
     case Dali::Window::PORTRAIT:
       actor.SetParentOrigin( ParentOrigin::TOP_CENTER );
       actor.SetAnchorPoint(  AnchorPoint::TOP_CENTER );
-      actor.SetRotation( Degree(0), Vector3::ZAXIS );
+      actor.SetOrientation( Degree(0), Vector3::ZAXIS );
       break;
     case Dali::Window::PORTRAIT_INVERSE:
       actor.SetParentOrigin( ParentOrigin::BOTTOM_CENTER );
       actor.SetAnchorPoint(  AnchorPoint::TOP_CENTER );
-      actor.SetRotation( Degree(180), Vector3::ZAXIS );
+      actor.SetOrientation( Degree(180), Vector3::ZAXIS );
       break;
     case Dali::Window::LANDSCAPE:
       actor.SetParentOrigin( ParentOrigin::CENTER_LEFT );
       actor.SetAnchorPoint(  AnchorPoint::TOP_CENTER );
-      actor.SetRotation( Degree(270), Vector3::ZAXIS );
+      actor.SetOrientation( Degree(270), Vector3::ZAXIS );
       break;
     case Dali::Window::LANDSCAPE_INVERSE:
       actor.SetParentOrigin( ParentOrigin::CENTER_RIGHT );
       actor.SetAnchorPoint(  AnchorPoint::TOP_CENTER );
-      actor.SetRotation( Degree(90), Vector3::ZAXIS );
+      actor.SetOrientation( Degree(90), Vector3::ZAXIS );
       break;
   }
 }
@@ -552,9 +557,21 @@ Dali::DragAndDropDetector Window::GetDragAndDropDetector() const
   return mDragAndDropDetector;
 }
 
+Dali::Any Window::GetNativeHandle() const
+{
+  if(mEventHandler)
+  {
+    return mEventHandler->mEcoreWindow;
+  }
+  else
+  {
+    return Dali::Any();
+  }
+}
+
 void Window::OnStart()
 {
-  DoShowIndicator( mIndicatorOrientation );
+  ShowIndicator( mIndicatorVisible );
 }
 
 void Window::OnPause()
@@ -588,11 +605,6 @@ void Window::OnDestroy()
   mAdaptor = NULL;
 }
 
-OrientationPtr Window::GetOrientation()
-{
-  return mOrientation;
-}
-
 void Window::AddAvailableOrientation(Dali::Window::WindowOrientation orientation)
 {
   bool found = false;
@@ -635,6 +647,7 @@ void Window::SetAvailableOrientations(const std::vector<Dali::Window::WindowOrie
   ECore::WindowRenderSurface* x11Window = dynamic_cast< ECore::WindowRenderSurface * >( mSurface );
   if( x11Window )
   {
+#ifndef DALI_PROFILE_UBUNTU
     Ecore_X_Window ecoreWindow = x11Window->GetXWindow();
     if( ! mWMRotationAppSet )
     {
@@ -648,7 +661,7 @@ void Window::SetAvailableOrientations(const std::vector<Dali::Window::WindowOrie
       rotations[i] = static_cast<int>(mAvailableOrientations[i]);
     }
     ecore_x_e_window_rotation_available_rotations_set(ecoreWindow, rotations, mAvailableOrientations.size() );
-
+#endif // DALI_PROFILE_UBUNTU
   }
 }
 
@@ -664,6 +677,7 @@ void Window::SetPreferredOrientation(Dali::Window::WindowOrientation orientation
   ECore::WindowRenderSurface* x11Window = dynamic_cast< ECore::WindowRenderSurface * >( mSurface );
   if( x11Window )
   {
+#ifndef DALI_PROFILE_UBUNTU
     Ecore_X_Window ecoreWindow = x11Window->GetXWindow();
 
     if( ! mWMRotationAppSet )
@@ -673,6 +687,7 @@ void Window::SetPreferredOrientation(Dali::Window::WindowOrientation orientation
     }
 
     ecore_x_e_window_rotation_preferred_rotation_set(ecoreWindow, orientation);
+#endif // DALI_PROFILE_UBUNTU
   }
 }
 
@@ -687,6 +702,7 @@ void Window::RotationDone( int orientation, int width, int height )
   ECore::WindowRenderSurface* x11Window = dynamic_cast< ECore::WindowRenderSurface * >( mSurface );
   if( x11Window )
   {
+#ifndef DALI_PROFILE_UBUNTU
     Ecore_X_Window ecoreWindow = x11Window->GetXWindow();
     Ecore_X_Window root = ecore_x_window_root_get(ecoreWindow);
 
@@ -704,6 +720,7 @@ void Window::RotationDone( int orientation, int width, int height )
     ecore_x_window_prop_property_set( ecoreWindow,
                                      ECORE_X_ATOM_E_ILLUME_ROTATE_WINDOW_ANGLE,
                                      ECORE_X_ATOM_CARDINAL, 32, &angles, 2 );
+#endif // DALI_PROFILE_UBUNTU
   }
 }