libuv support for dali-adaptor for running in Node.JS
[platform/core/uifw/dali-adaptor.git] / adaptors / x11 / window-impl-x.cpp
index f5530b6..b189872 100644 (file)
@@ -63,8 +63,8 @@ struct Window::EventHandler
    */
   EventHandler( Window* window )
   : mWindow( window ),
-    mWindowPropertyHandler( ecore_event_handler_add( ECORE_X_EVENT_WINDOW_PROPERTY,  EcoreEventWindowPropertyChanged, this ) ),
-    mClientMessagehandler( ecore_event_handler_add( ECORE_X_EVENT_CLIENT_MESSAGE,  EcoreEventClientMessage, this ) ),
+    mWindowPropertyHandler( NULL ),
+    mClientMessagehandler( NULL ),
     mEcoreWindow( 0 )
   {
     // store ecore window handle
@@ -82,6 +82,14 @@ struct Window::EventHandler
                              ECORE_X_ATOM_E_DEICONIFY_APPROVE,
                              &tmp, 1);
 #endif // DALI_PROFILE_UBUNTU
+
+    if( mWindow->mEcoreEventHander )
+    {
+      ecore_x_input_multi_select( mEcoreWindow );
+      mWindowPropertyHandler=  ecore_event_handler_add( ECORE_X_EVENT_WINDOW_PROPERTY,  EcoreEventWindowPropertyChanged, this );
+      mClientMessagehandler =  ecore_event_handler_add( ECORE_X_EVENT_CLIENT_MESSAGE,  EcoreEventClientMessage, this );
+    }
+
   }
 
   /**
@@ -240,11 +248,6 @@ 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 );
@@ -315,13 +318,13 @@ void Window::SetClass(std::string name, std::string klass)
 
 Window::Window()
 : mSurface(NULL),
-  mIndicatorStyle(Dali::Window::CHANGEABLE_COLOR),
   mIndicatorVisible(Dali::Window::INVISIBLE),
   mIndicatorIsShown(false),
   mShowRotatedIndicatorOnClose(false),
   mStarted(false),
   mIsTransparent(false),
   mWMRotationAppSet(false),
+  mEcoreEventHander(true),
   mIndicator(NULL),
   mIndicatorOrientation(Dali::Window::PORTRAIT),
   mNextIndicatorOrientation(Dali::Window::PORTRAIT),
@@ -331,6 +334,17 @@ Window::Window()
   mEventHandler(NULL),
   mPreferredOrientation(Dali::Window::PORTRAIT)
 {
+
+  // Detect if we're not running in a ecore main loop (e.g. libuv).
+  // Typically ecore_x_init is called by app_efl_main->elm_init
+  // but if we're not using app_efl_main then we have to call it ourselves
+  // This is a hack until we create a pure X Window class
+  if( ecore_x_display_get() == NULL )
+  {
+    mEcoreEventHander = false;
+    ecore_x_init (NULL); //  internally calls _ecore_x_input_init
+  }
+
 }
 
 Window::~Window()
@@ -361,8 +375,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
@@ -375,7 +392,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();
@@ -606,11 +623,6 @@ void Window::OnDestroy()
   mAdaptor = NULL;
 }
 
-OrientationPtr Window::GetOrientation()
-{
-  return mOrientation;
-}
-
 void Window::AddAvailableOrientation(Dali::Window::WindowOrientation orientation)
 {
   bool found = false;