[AT-SPI] Squashed implementation
[platform/core/uifw/dali-adaptor.git] / dali / internal / adaptor / common / adaptor-impl.cpp
old mode 100644 (file)
new mode 100755 (executable)
index c496606..502ec75
@@ -29,6 +29,7 @@
 #include <dali/public-api/object/object-registry.h>
 #include <dali/public-api/events/wheel-event.h>
 #include <dali/devel-api/actors/actor-devel.h>
+#include <dali/devel-api/common/stage.h>
 #include <dali/integration-api/debug.h>
 #include <dali/integration-api/core.h>
 #include <dali/integration-api/context-notifier.h>
@@ -54,7 +55,6 @@
 
 #include <dali/internal/system/common/callback-manager.h>
 #include <dali/internal/accessibility/common/tts-player-impl.h>
-#include <dali/internal/accessibility/common/accessibility-adaptor-impl.h>
 #include <dali/internal/window-system/common/event-handler.h>
 #include <dali/internal/graphics/gles/gl-proxy-implementation.h>
 #include <dali/internal/graphics/gles/gl-implementation.h>
@@ -67,6 +67,7 @@
 #include <dali/internal/window-system/common/window-impl.h>
 #include <dali/internal/window-system/common/window-render-surface.h>
 
+#include <dali/devel-api/adaptor-framework/accessibility-impl.h>
 #include <dali/internal/system/common/logging.h>
 
 #include <dali/internal/system/common/locale-utils.h>
@@ -96,49 +97,49 @@ thread_local Adaptor* gThreadLocalAdaptor = NULL; // raw thread specific pointer
 
 } // unnamed namespace
 
-Dali::Adaptor* Adaptor::New( Dali::Integration::SceneHolder window, Dali::RenderSurfaceInterface *surface, Dali::Configuration::ContextLoss configuration, EnvironmentOptions* environmentOptions )
+Dali::Adaptor* Adaptor::New( Dali::Integration::SceneHolder window, Dali::RenderSurfaceInterface *surface, EnvironmentOptions* environmentOptions, ThreadMode threadMode )
 {
   Dali::Adaptor* adaptor = new Dali::Adaptor;
-  Adaptor* impl = new Adaptor( window, *adaptor, surface, environmentOptions );
+  Adaptor* impl = new Adaptor( window, *adaptor, surface, environmentOptions, threadMode );
   adaptor->mImpl = impl;
 
   Dali::Internal::Adaptor::AdaptorBuilder* mAdaptorBuilder = new AdaptorBuilder();
   auto graphicsFactory = mAdaptorBuilder->GetGraphicsFactory();
 
-  impl->Initialize( graphicsFactory, configuration );
+  impl->Initialize( graphicsFactory );
   delete mAdaptorBuilder; // Not needed anymore as the graphics interface has now been created
 
   return adaptor;
 }
 
-Dali::Adaptor* Adaptor::New( Dali::Integration::SceneHolder window, Dali::Configuration::ContextLoss configuration, EnvironmentOptions* environmentOptions )
+Dali::Adaptor* Adaptor::New( Dali::Integration::SceneHolder window, EnvironmentOptions* environmentOptions )
 {
   Internal::Adaptor::SceneHolder& windowImpl = Dali::GetImplementation( window );
-  Dali::Adaptor* adaptor = New( window, windowImpl.GetSurface(), configuration, environmentOptions );
+  Dali::Adaptor* adaptor = New( window, windowImpl.GetSurface(), environmentOptions, ThreadMode::NORMAL );
   windowImpl.SetAdaptor( *adaptor );
   return adaptor;
 }
 
-Dali::Adaptor* Adaptor::New( GraphicsFactory& graphicsFactory, Dali::Integration::SceneHolder window, Dali::RenderSurfaceInterface *surface, Dali::Configuration::ContextLoss configuration, EnvironmentOptions* environmentOptions )
+Dali::Adaptor* Adaptor::New( GraphicsFactory& graphicsFactory, Dali::Integration::SceneHolder window, Dali::RenderSurfaceInterface *surface, EnvironmentOptions* environmentOptions, ThreadMode threadMode )
 {
   Dali::Adaptor* adaptor = new Dali::Adaptor; // Public adaptor
-  Adaptor* impl = new Adaptor( window, *adaptor, surface, environmentOptions ); // Impl adaptor
+  Adaptor* impl = new Adaptor( window, *adaptor, surface, environmentOptions, threadMode ); // Impl adaptor
   adaptor->mImpl = impl;
 
-  impl->Initialize( graphicsFactory, configuration );
+  impl->Initialize( graphicsFactory );
 
   return adaptor;
 } // Called second
 
-Dali::Adaptor* Adaptor::New( GraphicsFactory& graphicsFactory, Dali::Integration::SceneHolder window, Dali::Configuration::ContextLoss configuration, EnvironmentOptions* environmentOptions )
+Dali::Adaptor* Adaptor::New( GraphicsFactory& graphicsFactory, Dali::Integration::SceneHolder window, EnvironmentOptions* environmentOptions )
 {
   Internal::Adaptor::SceneHolder& windowImpl = Dali::GetImplementation( window );
-  Dali::Adaptor* adaptor = New( graphicsFactory, window, windowImpl.GetSurface(), configuration, environmentOptions );
+  Dali::Adaptor* adaptor = New( graphicsFactory, window, windowImpl.GetSurface(), environmentOptions, ThreadMode::NORMAL );
   windowImpl.SetAdaptor( *adaptor );
   return adaptor;
 } // Called first
 
-void Adaptor::Initialize( GraphicsFactory& graphicsFactory, Dali::Configuration::ContextLoss configuration )
+void Adaptor::Initialize( GraphicsFactory& graphicsFactory )
 {
   // all threads here (event, update, and render) will send their logs to TIZEN Platform's LogMessage handler.
   Dali::Integration::Log::LogFunction logFunction( Dali::TizenPlatform::LogMessage );
@@ -320,10 +321,36 @@ void Adaptor::Initialize( GraphicsFactory& graphicsFactory, Dali::Configuration:
   }
 
   mConfigurationManager = Utils::MakeUnique<ConfigurationManager>( systemCachePath, eglGraphics, mThreadController );
+
+  auto appName = GetApplicationPackageName();
+  auto bridge = Accessibility::Bridge::GetCurrentBridge();
+  bridge->SetApplicationName( appName );
+  bridge->Initialize();
+  Dali::Stage::GetCurrent().KeyEventSignal().Connect( &accessibilityObserver, &AccessibilityObserver::OnAccessibleKeyEvent );
+}
+
+void Adaptor::AccessibilityObserver::OnAccessibleKeyEvent( const Dali::KeyEvent& event )
+{
+  Accessibility::KeyEventType type;
+  if( event.GetState() == Dali::KeyEvent::DOWN )
+  {
+    type = Accessibility::KeyEventType::KEY_PRESSED;
+  }
+  else if( event.GetState() == Dali::KeyEvent::UP )
+  {
+    type = Accessibility::KeyEventType::KEY_RELEASED;
+  }
+  else
+  {
+    return;
+  }
+  Dali::Accessibility::Bridge::GetCurrentBridge()->Emit( type, event.GetKeyCode(), event.GetKeyName(), event.GetTime(), !event.GetKeyString().empty() );
 }
 
 Adaptor::~Adaptor()
 {
+  Accessibility::Bridge::GetCurrentBridge()->Terminate();
+
   // Ensure stop status
   Stop();
 
@@ -560,9 +587,9 @@ void Adaptor::FeedWheelEvent( Dali::WheelEvent& wheelEvent )
   mWindows.front()->FeedWheelEvent( event );
 }
 
-void Adaptor::FeedKeyEvent( KeyEvent& keyEvent )
+void Adaptor::FeedKeyEvent( Dali::KeyEvent& keyEvent )
 {
-  Integration::KeyEvent convertedEvent( keyEvent );
+  Integration::KeyEvent convertedEvent( keyEvent.GetKeyName(), keyEvent.GetLogicalKey(), keyEvent.GetKeyString(), keyEvent.GetKeyCode(), keyEvent.GetKeyModifier(), keyEvent.GetTime(), static_cast< Integration::KeyEvent::State >( keyEvent.GetState() ), keyEvent.GetCompose(), keyEvent.GetDeviceName(), keyEvent.GetDeviceClass(), keyEvent.GetDeviceSubclass() );
   mWindows.front()->FeedKeyEvent( convertedEvent );
 }
 
@@ -653,6 +680,9 @@ bool Adaptor::AddWindow( Dali::Integration::SceneHolder childWindow )
   Internal::Adaptor::SceneHolder& windowImpl = Dali::GetImplementation( childWindow );
   windowImpl.SetAdaptor( Get() );
 
+  // ChildWindow is set to the layout direction of the default window.
+  windowImpl.GetRootLayer().SetProperty( Dali::Actor::Property::LAYOUT_DIRECTION, mRootLayoutDirection );
+
   // Add the new Window to the container - the order is not important
   mWindows.push_back( &windowImpl );
 
@@ -934,6 +964,8 @@ void Adaptor::RequestProcessEventsOnIdle( bool forceProcess )
 
 void Adaptor::OnWindowShown()
 {
+  Dali::Accessibility::Bridge::GetCurrentBridge()->ApplicationShown();
+
   if( PAUSED_WHILE_HIDDEN == mState )
   {
     // Adaptor can now be resumed
@@ -964,6 +996,8 @@ void Adaptor::OnWindowShown()
 
 void Adaptor::OnWindowHidden()
 {
+  Dali::Accessibility::Bridge::GetCurrentBridge()->ApplicationHidden();
+
   if( RUNNING == mState || READY == mState )
   {
     bool allWindowsHidden = true;
@@ -1174,7 +1208,7 @@ Dali::ObjectRegistry Adaptor::GetObjectRegistry() const
   return registry;
 }
 
-Adaptor::Adaptor(Dali::Integration::SceneHolder window, Dali::Adaptor& adaptor, Dali::RenderSurfaceInterface* surface, EnvironmentOptions* environmentOptions)
+Adaptor::Adaptor(Dali::Integration::SceneHolder window, Dali::Adaptor& adaptor, Dali::RenderSurfaceInterface* surface, EnvironmentOptions* environmentOptions, ThreadMode threadMode )
 : mResizedSignal(),
   mLanguageChangedSignal(),
   mWindowCreatedSignal(),
@@ -1200,9 +1234,10 @@ Adaptor::Adaptor(Dali::Integration::SceneHolder window, Dali::Adaptor& adaptor,
   mSystemTracer(),
   mObjectProfiler( nullptr ),
   mSocketFactory(),
-  mThreadMode( ThreadMode::NORMAL ),
+  mThreadMode( threadMode ),
   mEnvironmentOptionsOwned( environmentOptions ? false : true /* If not provided then we own the object */ ),
-  mUseRemoteSurface( false )
+  mUseRemoteSurface( false ),
+  mRootLayoutDirection( Dali::LayoutDirection::LEFT_TO_RIGHT )
 {
   DALI_ASSERT_ALWAYS( !IsAvailable() && "Cannot create more than one Adaptor per thread" );
   mWindows.insert( mWindows.begin(), &Dali::GetImplementation( window ) );
@@ -1212,11 +1247,11 @@ Adaptor::Adaptor(Dali::Integration::SceneHolder window, Dali::Adaptor& adaptor,
 
 void Adaptor::SetRootLayoutDirection( std::string locale )
 {
+  mRootLayoutDirection = static_cast< LayoutDirection::Type >( Internal::Adaptor::Locale::GetDirection( std::string( locale ) ) );
   for ( auto& window : mWindows )
   {
     Dali::Actor root = window->GetRootLayer();
-    root.SetProperty( Dali::Actor::Property::LAYOUT_DIRECTION,
-                      static_cast< LayoutDirection::Type >( Internal::Adaptor::Locale::GetDirection( std::string( locale ) ) ) );
+    root.SetProperty( Dali::Actor::Property::LAYOUT_DIRECTION, mRootLayoutDirection );
   }
 }