Add event handling support for multiple windows. 54/194554/14
authorAnton Obzhirov <a.obzhirov@samsung.com>
Fri, 30 Nov 2018 17:43:44 +0000 (17:43 +0000)
committerAnton Obzhirov <a.obzhirov@samsung.com>
Mon, 11 Mar 2019 16:56:36 +0000 (16:56 +0000)
Change-Id: Id146f0223d3df8e02e7cf7f1497c480b184bcd6e

22 files changed:
dali/devel-api/adaptor-framework/window-devel.cpp
dali/devel-api/adaptor-framework/window-devel.h
dali/integration-api/adaptor.h
dali/internal/accessibility/common/accessibility-adaptor-impl.cpp
dali/internal/accessibility/common/accessibility-gesture-detector.h
dali/internal/adaptor/common/adaptor-impl.cpp
dali/internal/adaptor/common/adaptor-impl.h
dali/internal/adaptor/common/adaptor.cpp
dali/internal/adaptor/common/application-impl.cpp
dali/internal/adaptor/tizen-wayland/adaptor-impl-tizen.cpp
dali/internal/input/common/gesture-detector.h
dali/internal/input/common/gesture-manager.cpp
dali/internal/input/common/gesture-manager.h
dali/internal/input/common/long-press-gesture-detector.cpp
dali/internal/input/common/pinch-gesture-detector.cpp
dali/internal/input/common/tap-gesture-detector.cpp
dali/internal/window-system/common/event-handler.cpp
dali/internal/window-system/common/event-handler.h
dali/internal/window-system/common/orientation-impl.cpp
dali/internal/window-system/common/orientation-impl.h
dali/internal/window-system/common/window-impl.cpp
dali/internal/window-system/common/window-impl.h

index a2a1246..2093d7c 100644 (file)
  *
  */
 
+// EXTERNAL INCLUDES
+#include <dali/public-api/events/key-event.h>
+#include <dali/public-api/events/touch-event.h>
+#include <dali/public-api/events/wheel-event.h>
+
 // INTERNAL INCLUDES
 #include <dali/devel-api/adaptor-framework/window-devel.h>
 #include <dali/internal/window-system/common/window-impl.h>
@@ -65,6 +70,26 @@ Dali::Layer GetLayer( Window window, uint32_t depth )
   return GetImplementation( window ).GetLayer( depth );
 }
 
+EventProcessingFinishedSignalType& EventProcessingFinishedSignal( Window window )
+{
+  return GetImplementation( window ).EventProcessingFinishedSignal();
+}
+
+KeyEventSignalType& KeyEventSignal( Window window )
+{
+  return GetImplementation( window ).KeyEventSignal();
+}
+
+TouchSignalType& TouchSignal( Window window )
+{
+  return GetImplementation( window ).TouchSignal();
+}
+
+WheelEventSignalType& WheelEventSignal( Window window )
+{
+  return GetImplementation( window ).WheelEventSignal();
+}
+
 } // namespace DevelWindow
 
 } // namespace Dali
index eec41b7..90a8f7b 100644 (file)
 
 namespace Dali
 {
+class KeyEvent;
+class TouchData;
+class WheelEvent;
 
 namespace DevelWindow
 {
 
+typedef Signal< void () > EventProcessingFinishedSignalType;       ///< Event Processing finished signal type
+
+typedef Signal< void (const KeyEvent&) > KeyEventSignalType;       ///< Key event signal type
+
+typedef Signal< void (const TouchData&) > TouchSignalType;         ///< Touch signal type
+
+typedef Signal< void (const WheelEvent&) > WheelEventSignalType;   ///< Touched signal type
+
 /**
  * @brief Sets position and size of the window. This API guarantees that both moving and resizing of window will appear on the screen at once.
  *
@@ -99,6 +110,55 @@ DALI_ADAPTOR_API uint32_t GetLayerCount( Window window );
  */
 DALI_ADAPTOR_API Dali::Layer GetLayer( Window window, uint32_t depth );
 
+/**
+ * @brief This signal is emitted just after the event processing is finished.
+ *
+ * @param[in] window The window instance
+ * @return The signal to connect to
+ */
+DALI_ADAPTOR_API EventProcessingFinishedSignalType& EventProcessingFinishedSignal( Window window );
+
+/**
+ * @brief This signal is emitted when key event is received.
+ *
+ * A callback of the following type may be connected:
+ * @code
+ *   void YourCallbackName(const KeyEvent& event);
+ * @endcode
+ * @param[in] window The window instance
+ * @return The signal to connect to
+ */
+DALI_ADAPTOR_API KeyEventSignalType& KeyEventSignal( Window window );
+
+/**
+ * @brief This signal is emitted when the screen is touched and when the touch ends
+ * (i.e. the down & up touch events only).
+ *
+ * If there are multiple touch points, then this will be emitted when the first touch occurs and
+ * then when the last finger is lifted.
+ * An interrupted event will also be emitted (if it occurs).
+ * A callback of the following type may be connected:
+ * @code
+ *   void YourCallbackName( TouchData event );
+ * @endcode
+ *
+ * @param[in] window The window instance
+ * @return The touch signal to connect to
+ * @note Motion events are not emitted.
+ */
+DALI_ADAPTOR_API TouchSignalType& TouchSignal( Window window );
+
+/**
+ * @brief This signal is emitted when wheel event is received.
+ *
+ * A callback of the following type may be connected:
+ * @code
+ *   void YourCallbackName(const WheelEvent& event);
+ * @endcode
+ * @param[in] window The window instance
+ * @return The signal to connect to
+ */
+DALI_ADAPTOR_API WheelEventSignalType& WheelEventSignal( Window window );
 
 } // namespace DevelWindow
 
index 04f9429..8b5e658 100755 (executable)
@@ -137,21 +137,21 @@ public:
   /**
    * @brief Create a new adaptor using render surface.
    *
-   * @param[in] nativeWindow native window handle
+   * @param[in] window The window to draw onto
    * @param[in] surface The surface to draw onto
    * @return a reference to the adaptor handle
    */
-  static Adaptor& New( Any nativeWindow, const Dali::RenderSurfaceInterface& surface );
+  static Adaptor& New( Window window, const Dali::RenderSurfaceInterface& surface );
 
   /**
    * @brief Create a new adaptor using render surface.
    *
-   * @param[in] nativeWindow native window handle
+   * @param[in] window The window to draw onto
    * @param[in] surface The surface to draw onto
    * @param[in] configuration The context loss configuration.
    * @return a reference to the adaptor handle
    */
-  static Adaptor& New( Any nativeWindow, const Dali::RenderSurfaceInterface& surface, Configuration::ContextLoss configuration = Configuration::APPLICATION_DOES_NOT_HANDLE_CONTEXT_LOSS);
+  static Adaptor& New( Window window, const Dali::RenderSurfaceInterface& surface, Configuration::ContextLoss configuration = Configuration::APPLICATION_DOES_NOT_HANDLE_CONTEXT_LOSS);
 
   /**
    * @brief Virtual Destructor.
@@ -218,10 +218,10 @@ public:
   /**
    * @brief Replaces the rendering surface
    *
-   * @param[in] nativeWindow native window handle
+   * @param[in] window The window to replace the surface for
    * @param[in] surface to use
    */
-  void ReplaceSurface( Any nativeWindow, Dali::RenderSurfaceInterface& surface );
+  void ReplaceSurface( Window window, Dali::RenderSurfaceInterface& surface );
 
   /**
    * @brief Get the render surface the adaptor is using to render to.
index 678f13a..728fd87 100644 (file)
@@ -26,6 +26,7 @@
 #include <dali/integration-api/events/gesture-requests.h>
 
 // INTERNAL INCLUDES
+#include <dali/internal/adaptor/common/adaptor-impl.h>
 #include <dali/internal/system/common/system-settings.h>
 
 namespace Dali
index 4ae4b39..90d23e3 100644 (file)
@@ -22,7 +22,6 @@
 
 // INTERNAL INCLUDES
 #include <dali/internal/input/common/pan-gesture-detector-base.h>
-#include <dali/internal/adaptor/common/adaptor-impl.h>
 #include <dali/devel-api/adaptor-framework/accessibility-gesture-handler.h>
 
 namespace Dali
@@ -79,7 +78,7 @@ private:
   bool mPanning;    ///< Keep track of panning state, when panning is occuring, this is true.
 };
 
-typedef IntrusivePtr<AccessibilityGestureDetector> AccessibilityGestureDetectorPtr;
+using AccessibilityGestureDetectorPtr = Dali::IntrusivePtr<AccessibilityGestureDetector>;
 
 } // namespace Adaptor
 
index e8683a5..fe220af 100755 (executable)
@@ -82,11 +82,10 @@ namespace
 thread_local Adaptor* gThreadLocalAdaptor = NULL; // raw thread specific pointer to allow Adaptor::Get
 } // unnamed namespace
 
-
-Dali::Adaptor* Adaptor::New( Any nativeWindow, Dali::RenderSurfaceInterface *surface, Dali::Configuration::ContextLoss configuration, EnvironmentOptions* environmentOptions )
+Dali::Adaptor* Adaptor::New( Dali::Window window, Dali::RenderSurfaceInterface *surface, Dali::Configuration::ContextLoss configuration, EnvironmentOptions* environmentOptions )
 {
   Dali::Adaptor* adaptor = new Dali::Adaptor;
-  Adaptor* impl = new Adaptor( nativeWindow, *adaptor, surface, environmentOptions );
+  Adaptor* impl = new Adaptor( window, *adaptor, surface, environmentOptions );
   adaptor->mImpl = impl;
 
   Dali::Internal::Adaptor::AdaptorBuilder* mAdaptorBuilder = new AdaptorBuilder();
@@ -100,18 +99,16 @@ Dali::Adaptor* Adaptor::New( Any nativeWindow, Dali::RenderSurfaceInterface *sur
 
 Dali::Adaptor* Adaptor::New( Dali::Window window, Dali::Configuration::ContextLoss configuration, EnvironmentOptions* environmentOptions )
 {
-  Any winId = window.GetNativeHandle();
-
   Window& windowImpl = Dali::GetImplementation( window );
-  Dali::Adaptor* adaptor = New( winId, windowImpl.GetSurface(), configuration, environmentOptions );
+  Dali::Adaptor* adaptor = New( window, windowImpl.GetSurface(), configuration, environmentOptions );
   windowImpl.SetAdaptor( *adaptor );
   return adaptor;
 }
 
-Dali::Adaptor* Adaptor::New( GraphicsFactory& graphicsFactory, Any nativeWindow, Dali::RenderSurfaceInterface *surface, Dali::Configuration::ContextLoss configuration, EnvironmentOptions* environmentOptions )
+Dali::Adaptor* Adaptor::New( GraphicsFactory& graphicsFactory, Dali::Window window, Dali::RenderSurfaceInterface *surface, Dali::Configuration::ContextLoss configuration, EnvironmentOptions* environmentOptions )
 {
   Dali::Adaptor* adaptor = new Dali::Adaptor; // Public adaptor
-  Adaptor* impl = new Adaptor( nativeWindow, *adaptor, surface, environmentOptions ); // Impl adaptor
+  Adaptor* impl = new Adaptor( window, *adaptor, surface, environmentOptions ); // Impl adaptor
   adaptor->mImpl = impl;
 
   impl->Initialize( graphicsFactory, configuration );
@@ -121,10 +118,8 @@ Dali::Adaptor* Adaptor::New( GraphicsFactory& graphicsFactory, Any nativeWindow,
 
 Dali::Adaptor* Adaptor::New( GraphicsFactory& graphicsFactory, Dali::Window window, Dali::Configuration::ContextLoss configuration, EnvironmentOptions* environmentOptions )
 {
-  Any winId = window.GetNativeHandle();
-
   Window& windowImpl = Dali::GetImplementation( window );
-  Dali::Adaptor* adaptor = New( graphicsFactory, winId, windowImpl.GetSurface(), configuration, environmentOptions );
+  Dali::Adaptor* adaptor = New( graphicsFactory, window, windowImpl.GetSurface(), configuration, environmentOptions );
   windowImpl.SetAdaptor( *adaptor );
   return adaptor;
 } // Called first
@@ -160,13 +155,11 @@ void Adaptor::Initialize( GraphicsFactory& graphicsFactory, Dali::Configuration:
 
   mCallbackManager = CallbackManager::New();
 
-  WindowPane defaultWindow = mWindowFrame.front();
+  WindowPtr defaultWindow = mWindows.front();
 
-  DALI_ASSERT_DEBUG( defaultWindow.surface && "Surface not initialized" );
+  DALI_ASSERT_DEBUG( defaultWindow->GetSurface() && "Surface not initialized" );
 
-  PositionSize size = defaultWindow.surface->GetPositionSize();
-
-  defaultWindow.surface->SetAdaptor(*this);
+  PositionSize size = defaultWindow->GetSurface()->GetPositionSize();
 
   mGestureManager = new GestureManager(*this, Vector2(size.width, size.height), mCallbackManager, *mEnvironmentOptions);
 
@@ -191,6 +184,8 @@ void Adaptor::Initialize( GraphicsFactory& graphicsFactory, Dali::Configuration:
                                   mGraphics->GetDepthBufferRequired(),
                                   mGraphics->GetStencilBufferRequired() );
 
+  defaultWindow->SetAdaptor( *this );
+
   const unsigned int timeInterval = mEnvironmentOptions->GetObjectProfilerInterval();
   if( 0u < timeInterval )
   {
@@ -201,7 +196,7 @@ void Adaptor::Initialize( GraphicsFactory& graphicsFactory, Dali::Configuration:
 
   mVSyncMonitor = new VSyncMonitor;
 
-  mDisplayConnection = Dali::DisplayConnection::New( *mGraphics, defaultWindow.surface->GetSurfaceType() );
+  mDisplayConnection = Dali::DisplayConnection::New( *mGraphics, defaultWindow->GetSurface()->GetSurfaceType() );
 
   mThreadController = new ThreadController( *this, *mEnvironmentOptions );
 
@@ -291,9 +286,11 @@ Adaptor::~Adaptor()
     (*iter)->OnDestroy();
   }
 
+  // Clear out all the handles to Windows
+  mWindows.clear();
+
   delete mThreadController; // this will shutdown render thread, which will call Core::ContextDestroyed before exit
   delete mVSyncMonitor;
-  delete mEventHandler;
   delete mObjectProfiler;
 
   delete mCore;
@@ -331,28 +328,25 @@ void Adaptor::Start()
   // Start the callback manager
   mCallbackManager->Start();
 
-  WindowPane defaultWindow = mWindowFrame.front();
-
-  // Create event handler
-  mEventHandler = new EventHandler( defaultWindow.surface, *this, *mGestureManager, *this, mDragAndDropDetector );
+  WindowPtr defaultWindow = mWindows.front();
 
   if( mDeferredRotationObserver != NULL )
   {
-    mEventHandler->SetRotationObserver(mDeferredRotationObserver);
+    defaultWindow->SetRotationObserver( mDeferredRotationObserver );
     mDeferredRotationObserver = NULL;
   }
 
   unsigned int dpiHor, dpiVer;
   dpiHor = dpiVer = 0;
 
-  defaultWindow.surface->GetDpi( dpiHor, dpiVer );
+  defaultWindow->GetSurface()->GetDpi( dpiHor, dpiVer );
 
   // set the DPI value for font rendering
   FontClient fontClient = FontClient::Get();
   fontClient.SetDpi( dpiHor, dpiVer );
 
   // Tell the core the size of the surface just before we start the render-thread
-  mCore->SurfaceResized( defaultWindow.surface );
+  mCore->SurfaceResized( defaultWindow->GetSurface() );
 
   // Initialize the thread controller
   mThreadController->Initialize();
@@ -380,10 +374,10 @@ void Adaptor::Pause()
       (*iter)->OnPause();
     }
 
-    // Reset the event handler when adaptor paused
-    if( mEventHandler )
+    // Pause all windows event handlers when adaptor paused
+    for( WindowPtr window : mWindows )
     {
-      mEventHandler->Pause();
+      window->Pause();
     }
 
     mThreadController->Pause();
@@ -408,10 +402,10 @@ void Adaptor::Resume()
   {
     mState = RUNNING;
 
-    // Reset the event handler when adaptor resumed
-    if( mEventHandler )
+    // Reset the event handlers when adaptor resumed
+    for( WindowPtr window : mWindows )
     {
-      mEventHandler->Resume();
+      window->Resume();
     }
 
     // Inform observers that we have resumed.
@@ -447,13 +441,10 @@ void Adaptor::Stop()
 
     mThreadController->Stop();
 
-    // Clear out all the handles to Windows
-    mWindowFrame.clear();
-
     // Delete the TTS player
-    for(int i =0; i < Dali::TtsPlayer::MODE_NUM; i++)
+    for( int i =0; i < Dali::TtsPlayer::MODE_NUM; i++ )
     {
-      if(mTtsPlayers[i])
+      if( mTtsPlayers[i] )
       {
         mTtsPlayers[i].Reset();
       }
@@ -462,9 +453,6 @@ void Adaptor::Stop()
     // Destroy the image loader plugin
     Internal::Adaptor::ImageLoaderPluginProxy::Destroy();
 
-    delete mEventHandler;
-    mEventHandler = NULL;
-
     delete mNotificationTrigger;
     mNotificationTrigger = NULL;
 
@@ -491,64 +479,57 @@ void Adaptor::ContextRegained()
 
 void Adaptor::FeedTouchPoint( TouchPoint& point, int timeStamp )
 {
-  mEventHandler->FeedTouchPoint( point, timeStamp );
+  mWindows.front()->FeedTouchPoint( point, timeStamp );
 }
 
 void Adaptor::FeedWheelEvent( WheelEvent& wheelEvent )
 {
-  mEventHandler->FeedWheelEvent( wheelEvent );
+  mWindows.front()->FeedWheelEvent( wheelEvent );
 }
 
 void Adaptor::FeedKeyEvent( KeyEvent& keyEvent )
 {
-  mEventHandler->FeedKeyEvent( keyEvent );
+  mWindows.front()->FeedKeyEvent( keyEvent );
 }
 
-void Adaptor::ReplaceSurface( Any nativeWindow, Dali::RenderSurfaceInterface& newSurface )
+void Adaptor::ReplaceSurface( Dali::Window window, Dali::RenderSurfaceInterface& newSurface )
 {
-  // Let the core know the surface size has changed
-  mCore->SurfaceResized( &newSurface );
-
-  mResizedSignal.Emit( mAdaptor );
-
-  WindowPane newDefaultWindow;
-  newDefaultWindow.nativeWindow = nativeWindow;
-  newDefaultWindow.surface = &newSurface;
-  newDefaultWindow.surface->SetAdaptor(*this);
-
-  WindowPane oldDefaultWindow = mWindowFrame.front();
+  Window* windowImpl = &Dali::GetImplementation( window );
+  for( WindowPtr windowPtr : mWindows )
+  {
+    if( windowPtr.Get() == windowImpl ) // the window is not deleted
+    {
+      // Let the core know the surface size has changed
+      mCore->SurfaceResized( &newSurface );
 
-  // Update WindowFrame
-  std::vector<WindowPane>::iterator iter = mWindowFrame.begin();
-  iter = mWindowFrame.insert( iter, newDefaultWindow );
+      mResizedSignal.Emit( mAdaptor );
 
-  // Flush the event queue to give the update-render thread chance
-  // to start processing messages for new camera setup etc as soon as possible
-  ProcessCoreEvents();
+      windowImpl->SetSurface( static_cast<WindowRenderSurface*>( &newSurface ) );
 
-  // This method blocks until the render thread has completed the replace.
-  mThreadController->ReplaceSurface( newDefaultWindow.surface );
+      // Flush the event queue to give the update-render thread chance
+      // to start processing messages for new camera setup etc as soon as possible
+      ProcessCoreEvents();
 
-  // Must delete the old Window only after the render thread has completed the replace
-  oldDefaultWindow.surface->DestroySurface();
-  oldDefaultWindow.surface = nullptr;
+      // This method blocks until the render thread has completed the replace.
+      mThreadController->ReplaceSurface( &newSurface );
+      break;
+    }
+  }
 }
 
 Dali::RenderSurfaceInterface& Adaptor::GetSurface() const
 {
-  WindowPane defaultWindow = mWindowFrame.front();
-  return *(defaultWindow.surface);
+  return *mWindows.front()->GetSurface();
 }
 
 void Adaptor::ReleaseSurfaceLock()
 {
-  WindowPane defaultWindow = mWindowFrame.front();
-  defaultWindow.surface->ReleaseLock();
+  mWindows.front()->GetSurface()->ReleaseLock();
 }
 
 Dali::TtsPlayer Adaptor::GetTtsPlayer(Dali::TtsPlayer::Mode mode)
 {
-  if(!mTtsPlayers[mode])
+  if( !mTtsPlayers[mode] )
   {
     // Create the TTS player when it needed, because it can reduce launching time.
     mTtsPlayers[mode] = TtsPlayer::New(mode);
@@ -585,28 +566,19 @@ bool Adaptor::AddWindow( Dali::Window* childWindow, const std::string& childWind
   Window& windowImpl = Dali::GetImplementation( *childWindow );
   windowImpl.SetAdaptor( Get() );
 
-  // This is any Window that is not the main (default) one
-  WindowPane additionalWindow;
-  additionalWindow.instance = childWindow;
-  additionalWindow.window_name = childWindowName;
-  additionalWindow.class_name = childWindowClassName;
-  additionalWindow.window_mode = childWindowMode;
-  additionalWindow.surface = windowImpl.GetSurface();
-  additionalWindow.id = windowImpl.GetId();
-
-  // Add the new Window to the Frame - the order is not important
-  mWindowFrame.push_back( additionalWindow );
-
+  // Add the new Window to the container - the order is not important
+  mWindows.push_back( WindowPtr( &windowImpl ) );
   return true;
 }
 
 bool Adaptor::RemoveWindow( Dali::Window* childWindow )
 {
-  for ( WindowFrames::iterator iter = mWindowFrame.begin(); iter != mWindowFrame.end(); ++iter )
+  Window& windowImpl = Dali::GetImplementation( *childWindow );
+  for ( WindowContainer::iterator iter = mWindows.begin(); iter != mWindows.end(); ++iter )
   {
-    if( iter->instance == childWindow )
+    if( *iter == &windowImpl )
     {
-      mWindowFrame.erase( iter );
+      mWindows.erase( iter );
       return true;
     }
   }
@@ -616,11 +588,11 @@ bool Adaptor::RemoveWindow( Dali::Window* childWindow )
 
 bool Adaptor::RemoveWindow( std::string childWindowName )
 {
-  for ( WindowFrames::iterator iter = mWindowFrame.begin(); iter != mWindowFrame.end(); ++iter )
+  for ( WindowContainer::iterator iter = mWindows.begin(); iter != mWindows.end(); ++iter )
   {
-    if( iter->window_name == childWindowName )
+    if( ( *iter )->GetName() == childWindowName )
     {
-      mWindowFrame.erase( iter );
+      mWindows.erase( iter );
       return true;
     }
   }
@@ -630,11 +602,11 @@ bool Adaptor::RemoveWindow( std::string childWindowName )
 
 bool Adaptor::RemoveWindow( Window* childWindow )
 {
-  for ( WindowFrames::iterator iter = mWindowFrame.begin(); iter != mWindowFrame.end(); ++iter )
+  for ( WindowContainer::iterator iter = mWindows.begin(); iter != mWindows.end(); ++iter )
   {
-    if( iter->id == childWindow->GetId() )
+    if( ( *iter )->GetId() == childWindow->GetId() )
     {
-      mWindowFrame.erase( iter );
+      mWindows.erase( iter );
       return true;
     }
   }
@@ -707,15 +679,12 @@ SocketFactoryInterface& Adaptor::GetSocketFactoryInterface()
 
 Dali::RenderSurfaceInterface* Adaptor::GetRenderSurfaceInterface()
 {
-  if( !mWindowFrame.empty())
-  {
-    WindowPane defaultWindow = mWindowFrame.front();
-    return defaultWindow.surface;
-  }
-  else
+  if( !mWindows.empty() )
   {
-    return nullptr;
+    return mWindows.front()->GetSurface();
   }
+
+  return nullptr;
 }
 
 VSyncMonitorInterface* Adaptor::GetVSyncMonitorInterface()
@@ -747,20 +716,12 @@ Integration::PlatformAbstraction& Adaptor::GetPlatformAbstraction() const
 void Adaptor::SetDragAndDropDetector( DragAndDropDetectorPtr detector )
 {
   mDragAndDropDetector = detector;
-
-  if ( mEventHandler )
-  {
-    mEventHandler->SetDragAndDropDetector( detector );
-  }
 }
 
 void Adaptor::SetRotationObserver( RotationObserver* observer )
 {
-  if( mEventHandler )
-  {
-    mEventHandler->SetRotationObserver( observer );
-  }
-  else if( mState == READY )
+  WindowPtr defaultWindow = mWindows.front();
+  if( !defaultWindow->SetRotationObserver( observer ) && mState == READY )
   {
     // Set once event handler exists
     mDeferredRotationObserver = observer;
@@ -769,7 +730,7 @@ void Adaptor::SetRotationObserver( RotationObserver* observer )
 
 void Adaptor::DestroyTtsPlayer(Dali::TtsPlayer::Mode mode)
 {
-  if(mTtsPlayers[mode])
+  if( mTtsPlayers[mode] )
   {
     mTtsPlayers[mode].Reset();
   }
@@ -785,8 +746,7 @@ void Adaptor::SetMinimumPinchDistance(float distance)
 
 Any Adaptor::GetNativeWindowHandle()
 {
-  WindowPane defaultWindow = mWindowFrame.front();
-  return defaultWindow.nativeWindow;
+  return mWindows.front()->GetNativeHandle();
 }
 
 Any Adaptor::GetGraphicsDisplay()
@@ -1012,7 +972,7 @@ bool Adaptor::ProcessCoreEventsFromIdle()
   return false;
 }
 
-Adaptor::Adaptor(Any nativeWindow, Dali::Adaptor& adaptor, Dali::RenderSurfaceInterface* surface, EnvironmentOptions* environmentOptions)
+Adaptor::Adaptor(Dali::Window window, Dali::Adaptor& adaptor, Dali::RenderSurfaceInterface* surface, EnvironmentOptions* environmentOptions)
 : mResizedSignal(),
   mLanguageChangedSignal(),
   mAdaptor( adaptor ),
@@ -1022,9 +982,8 @@ Adaptor::Adaptor(Any nativeWindow, Dali::Adaptor& adaptor, Dali::RenderSurfaceIn
   mVSyncMonitor( nullptr ),
   mGraphics( nullptr ),
   mDisplayConnection( nullptr ),
-  mWindowFrame(),
+  mWindows(),
   mPlatformAbstraction( nullptr ),
-  mEventHandler( nullptr ),
   mCallbackManager( nullptr ),
   mNotificationOnIdleInstalled( false ),
   mNotificationTrigger( nullptr ),
@@ -1046,14 +1005,7 @@ Adaptor::Adaptor(Any nativeWindow, Dali::Adaptor& adaptor, Dali::RenderSurfaceIn
   mUseRemoteSurface( false )
 {
   DALI_ASSERT_ALWAYS( !IsAvailable() && "Cannot create more than one Adaptor per thread" );
-
-  WindowPane defaultWindow;
-  defaultWindow.nativeWindow = nativeWindow;
-  defaultWindow.surface = surface;
-  defaultWindow.id = 0;
-
-  std::vector<WindowPane>::iterator iter = mWindowFrame.begin();
-  iter = mWindowFrame.insert( iter, defaultWindow );
+  mWindows.insert( mWindows.begin(), WindowPtr( &Dali::GetImplementation( window ) ) );
 
   gThreadLocalAdaptor = this;
 }
index 428680c..b3d6181 100755 (executable)
@@ -28,6 +28,7 @@
 
 // INTERNAL INCLUDES
 #include <dali/integration-api/adaptor.h>
+#include <dali/integration-api/scene.h>
 #include <dali/public-api/adaptor-framework/tts-player.h>
 #include <dali/devel-api/adaptor-framework/clipboard.h>
 
@@ -39,6 +40,7 @@
 #include <dali/internal/system/common/core-event-interface.h>
 #include <dali/internal/input/common/drag-and-drop-detector-impl.h>
 #include <dali/internal/window-system/common/damage-observer.h>
+#include <dali/internal/window-system/common/window-impl.h>
 #include <dali/internal/window-system/common/window-visibility-observer.h>
 #include <dali/internal/system/common/kernel-trace.h>
 #include <dali/internal/system/common/system-trace.h>
@@ -66,7 +68,6 @@ namespace Adaptor
 {
 class DisplayConnection;
 class GraphicsFactory;
-class EventHandler;
 class GestureManager;
 class GlImplementation;
 class GlSyncImplementation;
@@ -98,21 +99,21 @@ public:
 
   /**
    * Creates a New Adaptor
-   * @param[in]  nativeWindow        Native window handle
+   * @param[in]  window              The window handle
    * @param[in]  surface             A render surface can be one of the following
    *                                  - Pixmap, adaptor will use existing Pixmap to draw on to
    *                                  - Window, adaptor will use existing Window to draw on to
    * @param[in]  configuration       The context loss configuration ( to choose resource discard policy )
    * @param[in]  environmentOptions  A pointer to the environment options. If NULL then one is created.
    */
-  static Dali::Adaptor* New( Any nativeWindow,
+  static Dali::Adaptor* New( Dali::Window window,
                              Dali::RenderSurfaceInterface* surface,
                              Dali::Configuration::ContextLoss configuration,
                              EnvironmentOptions* environmentOptions );
 
   /**
    * Creates a New Adaptor
-   * @param[in]  nativeWindow        native window handle
+   * @param[in]  window              The window handle
    * @param[in]  configuration       The context loss configuration ( to choose resource discard policy )
    * @param[in]  environmentOptions  A pointer to the environment options. If NULL then one is created.
    */
@@ -123,7 +124,7 @@ public:
   /**
    * Creates a New Adaptor
    * @param[in]  graphicsFactory     A factory that creates the graphics interface
-   * @param[in]  nativeWindow        Native window handle
+   * @param[in]  window              The window handle
    * @param[in]  surface             A render surface can be one of the following
    *                                  - Pixmap, adaptor will use existing Pixmap to draw on to
    *                                  - Window, adaptor will use existing Window to draw on to
@@ -131,7 +132,7 @@ public:
    * @param[in]  environmentOptions  A pointer to the environment options. If NULL then one is created.
    */
   static Dali::Adaptor* New( GraphicsFactory& graphicsFactory,
-                             Any nativeWindow,
+                             Dali::Window window,
                              Dali::RenderSurfaceInterface* surface,
                              Dali::Configuration::ContextLoss configuration,
                              EnvironmentOptions* environmentOptions );
@@ -139,7 +140,7 @@ public:
   /**
    * Creates a New Adaptor
    * @param[in]  graphicsFactory     A factory that creates the graphics interface
-   * @param[in]  nativeWindow        native window handle
+   * @param[in]  window              The window handle
    * @param[in]  configuration       The context loss configuration ( to choose resource discard policy )
    * @param[in]  environmentOptions  A pointer to the environment options. If NULL then one is created.
    */
@@ -224,7 +225,7 @@ public: // AdaptorInternalServices implementation
   /**
    * @copydoc AdaptorInterface::ReplaceSurface()
    */
-  virtual void ReplaceSurface( Any nativeWindow, Dali::RenderSurfaceInterface& surface );
+  virtual void ReplaceSurface( Dali::Window window, Dali::RenderSurfaceInterface& surface );
 
   /**
    * @copydoc Dali::Adaptor::GetSurface()
@@ -511,6 +512,15 @@ public: // Signals
     return mLanguageChangedSignal;
   }
 
+  /**
+   * Gets the gesture manager.
+   * @return The GestureManager
+   */
+  GestureManager* GetGestureManager() const
+  {
+    return mGestureManager;
+  }
+
 private: // From Dali::Internal::Adaptor::CoreEventInterface
 
   /**
@@ -609,14 +619,14 @@ private:
 
   /**
    * Constructor
-   * @param[in]  nativeWindow native window handle
+   * @param[in]  window       window handle
    * @param[in]  adaptor      The public adaptor
    * @param[in]  surface      A render surface can be one of the following
    *                          - Pixmap, adaptor will use existing Pixmap to draw on to
    *                          - Window, adaptor will use existing Window to draw on to
    * @param[in]  environmentOptions  A pointer to the environment options. If NULL then one is created.
    */
-  Adaptor( Any nativeWindow, Dali::Adaptor& adaptor, Dali::RenderSurfaceInterface* surface, EnvironmentOptions* environmentOptions );
+  Adaptor( Dali::Window window, Dali::Adaptor& adaptor, Dali::RenderSurfaceInterface* surface, EnvironmentOptions* environmentOptions );
 
 private: // Types
 
@@ -629,21 +639,9 @@ private: // Types
     STOPPED,             ///< Adaptor has been stopped.
   };
 
-  // A structure to encapsulate each Window instance for the Adaptor to track them
-  typedef struct WindowPane
-  {
-    Dali::Window*  instance;     ///< Window object
-    std::string    window_name;  ///< Name (title)_of the window
-    std::string    class_name;   ///< Class name that the window belongs to
-    bool           window_mode;  ///< Display mode of the window
-    Any            nativeWindow; ///< window identifier
-    uint32_t       id;           ///< unique Window ID
-    Dali::RenderSurfaceInterface* surface;      ///< The surface the Window is bound to
-  } WindowPane;
-
-  typedef std::vector<WindowPane> WindowFrames;
-
-  typedef std::vector<LifeCycleObserver*>  ObserverContainer;
+  using WindowPtr = IntrusivePtr< Window >;
+  using WindowContainer = std::vector<WindowPtr>;
+  using ObserverContainer = std::vector<LifeCycleObserver*>;
 
 private: // Data
 
@@ -658,11 +656,10 @@ private: // Data
 
   GraphicsInterface*                    mGraphics;                    ///< Graphics interface
   Dali::DisplayConnection*              mDisplayConnection;           ///< Display connection
-  WindowFrames                          mWindowFrame;                 ///< A container of all the Windows that are currently created
+  WindowContainer                       mWindows;                     ///< A container of all the Windows that are currently created
 
   TizenPlatform::TizenPlatformAbstraction* mPlatformAbstraction;      ///< Platform abstraction
 
-  EventHandler*                         mEventHandler;                ///< event handler
   CallbackManager*                      mCallbackManager;             ///< Used to install callbacks
   bool                                  mNotificationOnIdleInstalled; ///< whether the idle handler is installed to send an notification event
   TriggerEventInterface*                mNotificationTrigger;         ///< Notification event trigger
index 66b28ee..82382d8 100755 (executable)
@@ -41,15 +41,15 @@ Adaptor& Adaptor::New( Window window, Configuration::ContextLoss configuration )
   return *adaptor;
 }
 
-Adaptor& Adaptor::New( Any nativeWindow, const Dali::RenderSurfaceInterface& surface )
+Adaptor& Adaptor::New( Window window, const Dali::RenderSurfaceInterface& surface )
 {
-  return New( nativeWindow, surface, Configuration::APPLICATION_DOES_NOT_HANDLE_CONTEXT_LOSS );
+  return New( window, surface, Configuration::APPLICATION_DOES_NOT_HANDLE_CONTEXT_LOSS );
 }
 
-Adaptor& Adaptor::New( Any nativeWindow, const Dali::RenderSurfaceInterface& surface, Configuration::ContextLoss configuration )
+Adaptor& Adaptor::New( Window window, const Dali::RenderSurfaceInterface& surface, Configuration::ContextLoss configuration )
 {
   Dali::RenderSurfaceInterface* pSurface = const_cast<Dali::RenderSurfaceInterface *>(&surface);
-  Adaptor* adaptor = Internal::Adaptor::Adaptor::New( nativeWindow, pSurface, configuration, NULL );
+  Adaptor* adaptor = Internal::Adaptor::Adaptor::New( window, pSurface, configuration, NULL );
   return *adaptor;
 }
 
@@ -88,9 +88,9 @@ void Adaptor::RemoveIdle( CallbackBase* callback )
   mImpl->RemoveIdle( callback );
 }
 
-void Adaptor::ReplaceSurface( Any nativeWindow, Dali::RenderSurfaceInterface& surface )
+void Adaptor::ReplaceSurface( Window window, Dali::RenderSurfaceInterface& surface )
 {
-  mImpl->ReplaceSurface(nativeWindow, surface);
+  mImpl->ReplaceSurface( window, surface );
 }
 
 Adaptor::AdaptorSignalType& Adaptor::ResizedSignal()
index f728657..0cf2228 100755 (executable)
@@ -29,7 +29,9 @@
 #include <dali/internal/adaptor/common/lifecycle-controller-impl.h>
 #include <dali/internal/window-system/common/window-impl.h>
 #include <dali/internal/window-system/common/window-render-surface.h>
+#include <dali/internal/window-system/common/render-surface-factory.h>
 
+// To disable a macro with the same name from one of OpenGL headers
 #undef Status
 
 namespace Dali
@@ -396,15 +398,12 @@ float Application::GetStereoBase() const
 
 void Application::ReplaceWindow( const PositionSize& positionSize, const std::string& name )
 {
-  Dali::Window newWindow = Dali::Window::New( positionSize, name, mMainWindowMode == Dali::Application::TRANSPARENT );
-  Window& windowImpl = GetImplementation(newWindow);
-  windowImpl.SetAdaptor(*mAdaptor);
+  Any surface;
+  auto renderSurfaceFactory = Dali::Internal::Adaptor::GetRenderSurfaceFactory();
+  std::unique_ptr<Internal::Adaptor::WindowRenderSurface> renderSurface =
+      renderSurfaceFactory->CreateWindowRenderSurface( positionSize, surface, false );
 
-  Internal::Adaptor::WindowRenderSurface* renderSurface = windowImpl.GetSurface();
-
-  Any nativeWindow = newWindow.GetNativeHandle();
-  Internal::Adaptor::Adaptor::GetImplementation( *mAdaptor ).ReplaceSurface(nativeWindow, *renderSurface);
-  mMainWindow = newWindow;
+  Internal::Adaptor::Adaptor::GetImplementation( *mAdaptor ).ReplaceSurface( mMainWindow, *renderSurface.release() );
   mWindowPositionSize = positionSize;
 }
 
index 5f0f953..029a86f 100644 (file)
@@ -112,12 +112,11 @@ void Adaptor::SurfaceInitialized()
   // Use strdup() in app_get_id(), so need to free memory
   if( appId )
   {
-    WindowPane defaultWindow = mWindowFrame.front();
 #ifdef ECORE_WAYLAND2
-    Ecore_Wl2_Window* ecoreWlWindow = AnyCast< Ecore_Wl2_Window* >( defaultWindow.nativeWindow );
+    Ecore_Wl2_Window* ecoreWlWindow = AnyCast< Ecore_Wl2_Window* >( mWindows.front()->GetNativeHandle() );
     screen_connector_provider_remote_enable( appId, ecore_wl2_window_surface_get( ecoreWlWindow ) );
 #else
-    Ecore_Wl_Window* ecoreWlWindow = AnyCast< Ecore_Wl_Window* >( defaultWindow.nativeWindow );
+    Ecore_Wl_Window* ecoreWlWindow = AnyCast< Ecore_Wl_Window* >( mWindows.front()->GetNativeHandle() );
     screen_connector_provider_remote_enable( appId, ecore_wl_window_surface_get( ecoreWlWindow ) );
 #endif
     free( appId );
index d7ccf67..d4e3ab7 100644 (file)
@@ -23,6 +23,7 @@
 #include <dali/public-api/events/gesture.h>
 #include <dali/public-api/math/vector2.h>
 #include <dali/public-api/object/ref-object.h>
+#include <dali/integration-api/scene.h>
 
 namespace Dali
 {
@@ -69,6 +70,12 @@ public:
    */
   Gesture::Type GetType() const { return mType; }
 
+  void SendEvent(Integration::Scene& scene, const Integration::TouchEvent& event)
+  {
+    mScene = &scene;
+    SendEvent(event);
+  }
+
 protected:
 
   /**
@@ -77,7 +84,7 @@ protected:
    * @param[in]  detectorType  The type of gesture detector.
    */
   GestureDetector(Vector2 screenSize, Gesture::Type detectorType)
-  : mScreenSize(screenSize), mType(detectorType) {}
+  : mScreenSize(screenSize), mType(detectorType), mScene(nullptr) {}
 
   /**
    * Virtual destructor.
@@ -88,6 +95,7 @@ protected:
 
   Vector2 mScreenSize;
   Gesture::Type mType;
+  Integration::Scene* mScene;
 };
 
 typedef IntrusivePtr<GestureDetector> GestureDetectorPtr;
index 18484c6..80da679 100644 (file)
@@ -111,7 +111,7 @@ GestureManager::~GestureManager()
   DALI_LOG_INFO( gLogFilter, Debug::Verbose, "Destroying GestureManager\n" );
 }
 
-void GestureManager::SendEvent(const Integration::TouchEvent& event)
+void GestureManager::SendEvent(Integration::Scene& scene, const Integration::TouchEvent& event)
 {
   if (mRunning)
   {
@@ -125,7 +125,7 @@ void GestureManager::SendEvent(const Integration::TouchEvent& event)
     // Send the event to all gesture detectors.
     for ( GestureDetectorContainer::iterator iter = detectors.begin(), endIter = detectors.end(); iter != endIter; ++iter )
     {
-      (*iter)->SendEvent(event);
+      (*iter)->SendEvent(scene, event);
     }
     DALI_LOG_INFO( gLogFilter, Debug::Verbose, "SendEvent: END\n" );
   }
index e50bdf0..5d2d287 100644 (file)
@@ -74,7 +74,7 @@ public:
    * Used by the event handler to send touch events to the Gesture Manager.
    * @param[in]  event  The latest touch event.
    */
-  void SendEvent(const Integration::TouchEvent& event);
+  void SendEvent(Integration::Scene& scene, const Integration::TouchEvent& event);
 
   /**
    * Used by the event handler to stop the GestureManager detection.
index 4d0b028..7fc75fe 100644 (file)
@@ -232,7 +232,10 @@ void LongPressGestureDetector::EmitGesture(Gesture::State state)
       longPress.time += GetSystemValue();
     }
 
-    mCoreEventInterface.QueueCoreEvent(longPress);
+    if( mScene )
+    {
+      mScene->QueueEvent( longPress );
+    }
   }
 }
 
index 82a2b5a..baeaaa0 100644 (file)
@@ -246,7 +246,10 @@ void PinchGestureDetector::SendPinch(Gesture::State state, const Integration::To
 
   gesture.time = currentEvent.time;
 
-  mCoreEventInterface.QueueCoreEvent(gesture);
+  if( mScene )
+  {
+    mScene->QueueEvent(gesture);
+  }
 }
 
 } // namespace Adaptor
index 38bae6f..320f3ce 100644 (file)
@@ -186,7 +186,10 @@ void TapGestureDetector::EmitPossibleState( const Integration::TouchEvent& event
   Integration::TapGestureEvent tapEvent( Gesture::Possible );
   tapEvent.point = mTouchPosition;
   tapEvent.time = event.time;
-  mCoreEventInterface.QueueCoreEvent(tapEvent);
+  if( mScene )
+  {
+    mScene->QueueEvent( tapEvent );
+  }
 }
 
 
@@ -230,7 +233,10 @@ void TapGestureDetector::EmitTap( unsigned int time, Integration::TapGestureEven
   event.numberOfTaps = mTapsRegistered;
   event.point = mTouchPosition;
   event.time = time;
-  mCoreEventInterface.QueueCoreEvent(event);
+  if( mScene )
+  {
+    mScene->QueueEvent( event );
+  }
 }
 
 } // namespace Adaptor
index 7cc82b6..692c1b4 100755 (executable)
@@ -30,6 +30,7 @@
 #include <dali/integration-api/events/touch-event-integ.h>
 #include <dali/integration-api/events/hover-event-integ.h>
 #include <dali/integration-api/events/wheel-event-integ.h>
+#include <dali/integration-api/scene.h>
 
 // INTERNAL INCLUDES
 #include <dali/internal/input/common/gesture-manager.h>
@@ -97,13 +98,13 @@ static unsigned int GetCurrentMilliSeconds(void)
 
 } // unnamed namespace
 
-EventHandler::EventHandler( Integration::RenderSurface* surface, CoreEventInterface& coreEventInterface, GestureManager& gestureManager, DamageObserver& damageObserver, DragAndDropDetectorPtr dndDetector )
-: mCoreEventInterface( coreEventInterface ),
+EventHandler::EventHandler( Dali::Integration::Scene scene, CoreEventInterface& coreEventInterface, GestureManager& gestureManager, DamageObserver& damageObserver )
+: mScene( scene ),
+  mCoreEventInterface( coreEventInterface ),
   mGestureManager( gestureManager ),
   mStyleMonitor( StyleMonitor::Get() ),
   mDamageObserver( damageObserver ),
   mRotationObserver( NULL ),
-  mDragAndDropDetector( dndDetector ),
   mAccessibilityAdaptor( AccessibilityAdaptor::Get() ),
   mClipboardEventNotifier( ClipboardEventNotifier::Get() ),
   mClipboard( Clipboard::Get() ),
@@ -113,7 +114,7 @@ EventHandler::EventHandler( Integration::RenderSurface* surface, CoreEventInterf
   mPaused( false )
 {
   // this code only works with the WindowRenderSurface so need to downcast
-  WindowRenderSurface* windowRenderSurface = static_cast< WindowRenderSurface* >( surface );
+  WindowRenderSurface* windowRenderSurface = static_cast< WindowRenderSurface* >( scene.GetSurface() );
   if( windowRenderSurface )
   {
     WindowBase* windowBase = windowRenderSurface->GetWindowBase();
@@ -137,9 +138,9 @@ EventHandler::~EventHandler()
   mGestureManager.Stop();
 }
 
-void EventHandler::SendEvent(Integration::Point& point, unsigned long timeStamp)
+void EventHandler::SendEvent( Integration::Point& point, unsigned long timeStamp )
 {
-  if(timeStamp < 1)
+  if( timeStamp < 1 )
   {
     timeStamp = GetCurrentMilliSeconds();
   }
@@ -149,20 +150,19 @@ void EventHandler::SendEvent(Integration::Point& point, unsigned long timeStamp)
   Integration::TouchEvent touchEvent;
   Integration::HoverEvent hoverEvent;
   Integration::TouchEventCombiner::EventDispatchType type = mCombiner.GetNextTouchEvent(point, timeStamp, touchEvent, hoverEvent);
-  if(type != Integration::TouchEventCombiner::DispatchNone )
+  if( type != Integration::TouchEventCombiner::DispatchNone )
   {
-    DALI_LOG_INFO(gTouchEventLogFilter, Debug::General, "%d: Device %d: Button state %d (%.2f, %.2f)\n", timeStamp, point.GetDeviceId(), point.GetState(), point.GetScreenPosition().x, point.GetScreenPosition().y);
-
+    DALI_LOG_INFO( gTouchEventLogFilter, Debug::General, "%d: Device %d: Button state %d (%.2f, %.2f)\n", timeStamp, point.GetDeviceId(), point.GetState(), point.GetScreenPosition().x, point.GetScreenPosition().y );
     // First the touch and/or hover event & related gesture events are queued
-    if(type == Integration::TouchEventCombiner::DispatchTouch || type == Integration::TouchEventCombiner::DispatchBoth)
+    if( type == Integration::TouchEventCombiner::DispatchTouch || type == Integration::TouchEventCombiner::DispatchBoth )
     {
-      mCoreEventInterface.QueueCoreEvent( touchEvent );
-      mGestureManager.SendEvent(touchEvent);
+      mScene.QueueEvent( touchEvent );
+      mGestureManager.SendEvent( mScene, touchEvent );
     }
 
-    if(type == Integration::TouchEventCombiner::DispatchHover || type == Integration::TouchEventCombiner::DispatchBoth)
+    if( type == Integration::TouchEventCombiner::DispatchHover || type == Integration::TouchEventCombiner::DispatchBoth )
     {
-      mCoreEventInterface.QueueCoreEvent( hoverEvent );
+      mScene.QueueEvent( hoverEvent );
     }
 
     // Next the events are processed with a single call into Core
@@ -173,16 +173,16 @@ void EventHandler::SendEvent(Integration::Point& point, unsigned long timeStamp)
 void EventHandler::SendEvent(Integration::KeyEvent& keyEvent)
 {
   Dali::PhysicalKeyboard physicalKeyboard = PhysicalKeyboard::Get();
-  if ( physicalKeyboard )
+  if( physicalKeyboard )
   {
-    if ( ! KeyLookup::IsDeviceButton( keyEvent.keyName.c_str() ) )
+    if( ! KeyLookup::IsDeviceButton( keyEvent.keyName.c_str() ) )
     {
       GetImplementation( physicalKeyboard ).KeyReceived( keyEvent.time > 1 );
     }
   }
 
   // Create send KeyEvent to Core.
-  mCoreEventInterface.QueueCoreEvent( keyEvent );
+  mScene.QueueEvent( keyEvent );
   mCoreEventInterface.ProcessCoreEvents();
 }
 
@@ -190,7 +190,8 @@ void EventHandler::SendWheelEvent( WheelEvent& wheelEvent )
 {
   // Create WheelEvent and send to Core.
   Integration::WheelEvent event( static_cast< Integration::WheelEvent::Type >(wheelEvent.type), wheelEvent.direction, wheelEvent.modifiers, wheelEvent.point, wheelEvent.z, wheelEvent.timeStamp );
-  mCoreEventInterface.QueueCoreEvent( event );
+
+  mScene.QueueEvent( event );
   mCoreEventInterface.ProcessCoreEvents();
 }
 
@@ -226,7 +227,7 @@ void EventHandler::SendRotationRequestEvent( )
 void EventHandler::FeedTouchPoint( TouchPoint& point, int timeStamp)
 {
   Integration::Point convertedPoint( point );
-  SendEvent(convertedPoint, timeStamp);
+  SendEvent( convertedPoint, timeStamp );
 }
 
 void EventHandler::FeedWheelEvent( WheelEvent& wheelEvent )
@@ -242,7 +243,7 @@ void EventHandler::FeedKeyEvent( KeyEvent& event )
 
 void EventHandler::FeedEvent( Integration::Event& event )
 {
-  mCoreEventInterface.QueueCoreEvent( event );
+  mScene.QueueEvent( event );
   mCoreEventInterface.ProcessCoreEvents();
 }
 
@@ -257,8 +258,9 @@ void EventHandler::Reset()
   event.AddPoint( point );
 
   // First the touch event & related gesture events are queued
-  mCoreEventInterface.QueueCoreEvent( event );
-  mGestureManager.SendEvent( event );
+  mScene.QueueEvent( event );
+
+  mGestureManager.SendEvent( mScene, event );
 
   // Next the events are processed with a single call into Core
   mCoreEventInterface.ProcessCoreEvents();
@@ -276,11 +278,6 @@ void EventHandler::Resume()
   Reset();
 }
 
-void EventHandler::SetDragAndDropDetector( DragAndDropDetectorPtr detector )
-{
-  mDragAndDropDetector = detector;
-}
-
 void EventHandler::SetRotationObserver( RotationObserver* observer )
 {
   mRotationObserver = observer;
index be46842..d0f73e7 100755 (executable)
  */
 
 // EXTERNAL INCLUDES
+#include <dali/public-api/common/intrusive-ptr.h>
+
 #include <dali/integration-api/events/key-event-integ.h>
 #include <dali/integration-api/events/point.h>
 #include <dali/integration-api/events/touch-event-combiner.h>
+#include <dali/devel-api/adaptor-framework/clipboard.h>
 #include <dali/devel-api/adaptor-framework/style-monitor.h>
 
 // INTERNAL INCLUDES
-#include <dali/internal/window-system/common/damage-observer.h>
-#include <dali/internal/input/common/drag-and-drop-detector-impl.h>
 #include <dali/internal/accessibility/common/accessibility-adaptor-impl.h>
 #include <dali/internal/clipboard/common/clipboard-event-notifier-impl.h>
+#include <dali/internal/input/common/drag-and-drop-detector-impl.h>
+#include <dali/internal/system/common/core-event-interface.h>
+#include <dali/internal/window-system/common/damage-observer.h>
 #include <dali/internal/window-system/common/rotation-observer.h>
 #include <dali/internal/window-system/common/window-base.h>
 
@@ -39,7 +43,7 @@ namespace Integration
 {
 
 class RenderSurface;
-
+class Scene;
 }
 
 namespace Internal
@@ -48,7 +52,6 @@ namespace Internal
 namespace Adaptor
 {
 
-class CoreEventInterface;
 class GestureManager;
 class StyleMonitor;
 
@@ -58,19 +61,18 @@ class StyleMonitor;
  *
  * These TouchEvents are then passed on to Core.
  */
-class EventHandler : public ConnectionTracker
+class EventHandler : public ConnectionTracker, public Dali::RefObject
 {
 public:
 
   /**
    * Constructor.
-   * @param[in]  surface                  The surface where events will be sent to.
+   * @param[in]  scene                    The scene where events will be sent to.
    * @param[in]  coreEventInterface       Used to send events to Core.
    * @param[in]  gestureManager           The Gesture Manager.
    * @param[in]  damageObserver           The damage observer (to pass damage events to).
-   * @param[in]  dndDetector              The Drag & Drop listener (to pass DnD events to).
    */
-  EventHandler( Integration::RenderSurface* surface, CoreEventInterface& coreEventInterface, GestureManager& gestureManager, DamageObserver& damageObserver, DragAndDropDetectorPtr dndDetector );
+  EventHandler( Dali::Integration::Scene scene, CoreEventInterface& coreEventInterface, GestureManager& gestureManager, DamageObserver& damageObserver );
 
   /**
    * Destructor.
@@ -112,12 +114,6 @@ public:
   void Resume();
 
   /**
-   * Sets the Drag & Drop detector.
-   * @param[in]  detector  An intrusive pointer to the Drag & Drop listener to set. To unset pass in NULL.
-   */
-  void SetDragAndDropDetector( DragAndDropDetectorPtr detector );
-
-  /**
    * Set the rotation observer (note, some adaptors may not have a rotation observer)
    * @param[in] observer The rotation observer
    */
@@ -235,6 +231,7 @@ private:
 
 private:
 
+  Dali::Integration::Scene mScene; ///< The scene the event handler is created for.
   CoreEventInterface& mCoreEventInterface; ///< Used to send events to Core.
   Dali::Integration::TouchEventCombiner mCombiner; ///< Combines multi-touch events.
   GestureManager& mGestureManager; ///< Reference to the GestureManager, set on construction, to send touch events to for analysis.
@@ -242,7 +239,6 @@ private:
   DamageObserver& mDamageObserver; ///< Reference to the DamageObserver, set on construction, to sent damage events to.
   RotationObserver* mRotationObserver; ///< Pointer to rotation observer, if present.
 
-  DragAndDropDetectorPtr mDragAndDropDetector; ///< Pointer to the drag & drop detector, to send Drag & Drop events to.
   Dali::AccessibilityAdaptor mAccessibilityAdaptor; ///< Pointer to the accessibility adaptor
   Dali::ClipboardEventNotifier mClipboardEventNotifier; ///< Pointer to the clipboard event notifier
   Dali::Clipboard mClipboard;///< Pointer to the clipboard
index 88c10e0..0adbe85 100644 (file)
@@ -55,8 +55,12 @@ Orientation::~Orientation()
 
 void Orientation::SetAdaptor(Dali::Adaptor& adaptor)
 {
-  Adaptor& adaptorImpl = Adaptor::GetImplementation(adaptor);
-  adaptorImpl.SetRotationObserver(this);
+  SetAdaptor( Adaptor::GetImplementation( adaptor ) );
+}
+
+void Orientation::SetAdaptor(Adaptor& adaptor)
+{
+  adaptor.SetRotationObserver(this);
 }
 
 int Orientation::GetDegrees() const
index dec1c0c..e48ff0e 100644 (file)
@@ -36,6 +36,7 @@ namespace Internal
 
 namespace Adaptor
 {
+class Adaptor;
 class Window;
 class Orientation;
 
@@ -68,6 +69,12 @@ public:
   void SetAdaptor(Dali::Adaptor& adaptor);
 
   /**
+   * Set the adaptor for basic setup
+   * @param[in] adaptor The adaptor
+   */
+  void SetAdaptor(Adaptor& adaptor);
+
+  /**
    * Returns the actual orientation in degrees
    * @return The device's orientation
    */
index c57b275..bcbeae7 100644 (file)
 
 // INTERNAL HEADERS
 #include <dali/internal/input/common/drag-and-drop-detector-impl.h>
-#include <dali/internal/window-system/common/window-visibility-observer.h>
+#include <dali/internal/window-system/common/event-handler.h>
 #include <dali/internal/window-system/common/orientation-impl.h>
 #include <dali/internal/window-system/common/render-surface-factory.h>
 #include <dali/internal/window-system/common/window-factory.h>
 #include <dali/internal/window-system/common/window-base.h>
 #include <dali/internal/window-system/common/window-render-surface.h>
+#include <dali/internal/window-system/common/window-visibility-observer.h>
 
 namespace Dali
 {
@@ -69,6 +70,7 @@ Window::Window()
   mSurface( nullptr ),
   mWindowBase(),
   mStarted( false ),
+  mIsTransparent( false ),
   mIsFocusAcceptable( true ),
   mVisible( true ),
   mIconified( false ),
@@ -88,12 +90,12 @@ Window::~Window()
   if ( mAdaptor )
   {
     mAdaptor->RemoveObserver( *this );
-    mAdaptor->SetDragAndDropDetector( NULL );
     mAdaptor->RemoveWindow( this );
     mAdaptor = NULL;
   }
 
-  mSurface.reset( nullptr );
+  // Do we need to do it?
+  mEventHandler->SetRotationObserver( nullptr );
 }
 
 void Window::Initialize(const PositionSize& positionSize, const std::string& name, const std::string& className)
@@ -128,11 +130,21 @@ void Window::Initialize(const PositionSize& positionSize, const std::string& nam
 
 void Window::SetAdaptor(Dali::Adaptor& adaptor)
 {
-  DALI_ASSERT_ALWAYS( !mStarted && "Adaptor already started" );
+  Window::SetAdaptor( Internal::Adaptor::Adaptor::GetImplementation( adaptor ) );
+}
+
+void Window::SetAdaptor(Adaptor& adaptor)
+{
+  if( mStarted )
+  {
+    return;
+  }
+
   mStarted = true;
 
+  // Create scene for the window
   PositionSize positionSize = mSurface->GetPositionSize();
-  mScene = Dali::Integration::Scene::New( Vector2(positionSize.width, positionSize.height) );
+  mScene = Dali::Integration::Scene::New( Vector2( positionSize.width, positionSize.height ) );
   mScene.SetSurface( *mSurface.get() );
 
   unsigned int dpiHorizontal, dpiVertical;
@@ -141,28 +153,44 @@ void Window::SetAdaptor(Dali::Adaptor& adaptor)
   mSurface->GetDpi( dpiHorizontal, dpiVertical );
   mScene.SetDpi( Vector2( static_cast<float>( dpiHorizontal ), static_cast<float>( dpiVertical ) ) );
 
-  // Create one overlay for the main window only
-  Internal::Adaptor::Adaptor& adaptorImpl = Internal::Adaptor::Adaptor::GetImplementation(adaptor);
-  mAdaptor = &adaptorImpl;
+  // Add the window to the adaptor observers
+  mAdaptor = &adaptor;
   mAdaptor->AddObserver( *this );
 
   // Can only create the detector when we know the Core has been instantiated.
   mDragAndDropDetector = DragAndDropDetector::New();
-  mAdaptor->SetDragAndDropDetector( &GetImplementation( mDragAndDropDetector ) );
 
   if( mOrientation )
   {
-    mOrientation->SetAdaptor(adaptor);
+    mOrientation->SetAdaptor( adaptor );
   }
 
   mSurface->SetAdaptor( *mAdaptor );
+
+  mEventHandler = EventHandlerPtr(
+      new EventHandler( mScene, *mAdaptor, *mAdaptor->GetGestureManager(), *mAdaptor ) );
 }
 
-WindowRenderSurface* Window::GetSurface()
+WindowRenderSurface* Window::GetSurface() const
 {
   return mSurface.get();
 }
 
+void Window::SetSurface(WindowRenderSurface* surface)
+{
+  mSurface.reset( surface );
+
+  mScene.SetSurface( *mSurface.get() );
+
+  unsigned int dpiHorizontal, dpiVertical;
+  dpiHorizontal = dpiVertical = 0;
+
+  mSurface->GetDpi( dpiHorizontal, dpiVertical );
+  mScene.SetDpi( Vector2( static_cast<float>( dpiHorizontal ), static_cast<float>( dpiVertical ) ) );
+
+  mSurface->SetAdaptor( *mAdaptor );
+}
+
 void Window::ShowIndicator( Dali::Window::IndicatorVisibleMode visibleMode )
 {
 }
@@ -177,9 +205,21 @@ void Window::RotateIndicator( Dali::Window::WindowOrientation orientation )
 
 void Window::SetClass( std::string name, std::string className )
 {
+  mName = name;
+  mClassName = className;
   mWindowBase->SetClass( name, className );
 }
 
+std::string Window::GetName() const
+{
+  return mName;
+}
+
+std::string Window::GetClassName() const
+{
+  return mClassName;
+}
+
 void Window::Raise()
 {
   mWindowBase->Raise();
@@ -557,6 +597,11 @@ void Window::SetPositionSize( PositionSize positionSize )
   }
 }
 
+Dali::Layer Window::GetRootLayer()
+{
+  return mScene.GetRootLayer();
+}
+
 void Window::SetTransparency( bool transparent )
 {
   mSurface->SetTransparency( transparent );
@@ -665,6 +710,58 @@ uint32_t Window::GetId() const
   return mId;
 }
 
+void Window::FeedTouchPoint( TouchPoint& point, int timeStamp )
+{
+  if( mEventHandler )
+  {
+    mEventHandler->FeedTouchPoint( point, timeStamp );
+  }
+}
+
+void Window::FeedWheelEvent( WheelEvent& wheelEvent )
+{
+  if( mEventHandler )
+  {
+    mEventHandler->FeedWheelEvent( wheelEvent );
+  }
+}
+
+void Window::FeedKeyEvent( KeyEvent& keyEvent )
+{
+  if( mEventHandler )
+  {
+    mEventHandler->FeedKeyEvent( keyEvent );
+  }
+}
+
+void Window::Pause()
+{
+  if( mEventHandler )
+  {
+    mEventHandler->Pause();
+  }
+}
+
+void Window::Resume()
+{
+  if( mEventHandler )
+  {
+    mEventHandler->Resume();
+  }
+}
+
+bool Window::SetRotationObserver( RotationObserver* observer )
+{
+  if( mEventHandler )
+  {
+    mEventHandler->SetRotationObserver( observer );
+    return true;
+  }
+
+  return false;
+}
+
+
 } // Adaptor
 
 } // Internal
index eb7d873..414af24 100644 (file)
@@ -31,6 +31,7 @@
 #include <dali/public-api/adaptor-framework/window.h>
 #include <dali/public-api/adaptor-framework/key-grab.h>
 #include <dali/devel-api/adaptor-framework/drag-and-drop-detector.h>
+#include <dali/devel-api/adaptor-framework/window-devel.h>
 
 namespace Dali
 {
@@ -41,13 +42,16 @@ namespace Internal
 {
 namespace Adaptor
 {
+class EventHandler;
 class Orientation;
+class RotationObserver;
 class WindowRenderSurface;
 class WindowBase;
 
 class Window;
-typedef IntrusivePtr<Window> WindowPtr;
-typedef IntrusivePtr<Orientation> OrientationPtr;
+using WindowPtr = IntrusivePtr< Window >;
+using OrientationPtr = IntrusivePtr< Orientation >;
+using EventHandlerPtr = IntrusivePtr< EventHandler >;
 
 /**
  * Window provides a surface to render onto with orientation & indicator properties.
@@ -77,10 +81,22 @@ public:
   void SetAdaptor(Dali::Adaptor& adaptor);
 
   /**
+   * Pass the adaptor back to the overlay. This allows the window to access Core's overlay.
+   * @param[in] adaptor implementation An initialized adaptor implementation
+   */
+  void SetAdaptor(Adaptor& adaptor);
+
+  /**
    * Get the window surface
    * @return The render surface
    */
-  WindowRenderSurface* GetSurface();
+  WindowRenderSurface* GetSurface() const;
+
+  /**
+   * Set the window surface
+   * @param[in] surface The surface
+   */
+  void SetSurface(WindowRenderSurface* surface);
 
   /**
    * @copydoc Dali::Window::ShowIndicator()
@@ -103,6 +119,18 @@ public:
   void SetClass( std::string name, std::string className );
 
   /**
+   * @brief Gets the window name.
+   * @return The name of the window
+   */
+  std::string GetName() const;
+
+  /**
+   * @brief Gets the window class name.
+   * @return The class of the window
+   */
+  std::string GetClassName() const;
+
+  /**
    * @copydoc Dali::Window::Raise()
    */
   void Raise();
@@ -333,6 +361,11 @@ public:
   void SetPositionSize( PositionSize positionSize );
 
   /**
+   * @copydoc Dali::DevelWindow::GetRootLayer()
+   */
+  Dali::Layer GetRootLayer();
+
+  /**
    * @copydoc Dali::Window::SetTransparency()
    */
   void SetTransparency( bool transparent );
@@ -368,6 +401,41 @@ public:
    */
   uint32_t GetId() const;
 
+  /**
+   * Feed (Send) touch event to core and gesture manager
+   * @param[in] touchEvent  The touch event holding the touch point information.
+   */
+  void FeedTouchPoint( TouchPoint& point, int timeStamp );
+
+  /**
+   * Feed (Send) wheel event to core and gesture manager
+   * @param[in]  wheelEvent The wheel event
+   */
+  void FeedWheelEvent( WheelEvent& wheelEvent );
+
+  /**
+   * Feed (Send) key event to core
+   * @param[in] keyEvent The key event holding the key information.
+   */
+  void FeedKeyEvent( KeyEvent& keyEvent );
+
+  /**
+   * Called when the adaptor is paused.
+   */
+  void Pause();
+
+  /**
+   * Called when the adaptor is resumed (from pause).
+   */
+  void Resume();
+
+  /**
+   * Set the rotation observer (note, some adaptors may not have a rotation observer)
+   * @param[in] observer The rotation observer
+   * @return If the rotation observer is set
+   */
+  bool SetRotationObserver( RotationObserver* observer );
+
 private:
 
   /**
@@ -455,13 +523,35 @@ public: // Signals
    */
   SignalType& DeleteRequestSignal() { return mDeleteRequestSignal; }
 
+  /**
+   * @copydoc Dali::Window::SignalEventProcessingFinished()
+   */
+  Dali::DevelWindow::EventProcessingFinishedSignalType& EventProcessingFinishedSignal() { return mScene.EventProcessingFinishedSignal(); };
+
+  /**
+   * @copydoc Dali::Window::KeyEventSignal()
+   */
+  Dali::DevelWindow::KeyEventSignalType& KeyEventSignal() { return mScene.KeyEventSignal(); };
+
+  /**
+    * @copydoc Dali::Window::TouchSignal()
+    */
+  Dali::DevelWindow::TouchSignalType& TouchSignal() { return mScene.TouchSignal(); };
+
+  /**
+   * @copydoc Dali::Window::WheelEventSignal()
+   */
+  Dali::DevelWindow::WheelEventSignalType& WheelEventSignal() { return mScene.WheelEventSignal(); };
+
 private:
 
   static uint32_t                       mWindowCounter;    ///< A counter to track the window creation
   uint32_t                              mId;               ///< A unique ID to identify the window starting from 0
-  std::unique_ptr< WindowRenderSurface > mSurface;
+  std::unique_ptr< WindowRenderSurface >mSurface;          ///< The window rendering surface
   Dali::Integration::Scene              mScene;
   WindowBase*                           mWindowBase;
+  std::string                           mName;
+  std::string                           mClassName;
   bool                                  mStarted:1;
   bool                                  mIsTransparent:1;
   bool                                  mIsFocusAcceptable:1;
@@ -477,13 +567,17 @@ private:
   std::vector<Dali::Window::WindowOrientation> mAvailableOrientations;
   Dali::Window::WindowOrientation              mPreferredOrientation;
 
+  EventHandlerPtr                       mEventHandler;      ///< The window events handler
+
   Vector4                               mBackgroundColor;
 
   // Signals
-  IndicatorSignalType mIndicatorVisibilityChangedSignal;
-  FocusSignalType     mFocusChangedSignal;
-  ResizedSignalType   mResizedSignal;
-  SignalType          mDeleteRequestSignal;
+  IndicatorSignalType                   mIndicatorVisibilityChangedSignal;
+  FocusSignalType                       mFocusChangedSignal;
+  ResizedSignalType                     mResizedSignal;
+  SignalType                            mDeleteRequestSignal;
+
+
 };
 
 } // namespace Adaptor