Set focus for each window 81/208581/26
authorSunghyun kim <scholb.kim@samsung.com>
Wed, 26 Jun 2019 06:54:03 +0000 (15:54 +0900)
committerSunghyun kim <scholb.kim@samsung.com>
Fri, 6 Sep 2019 07:39:33 +0000 (16:39 +0900)
In multi-window, focus manager must remember the focus currently set for each window.
For this reason, i added the patch that can get focus actor per Window.

Change-Id: Iffa35f30e3f994ed919673a79c6909a978ff7148

automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-scene-holder.cpp
automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-window-impl.h
automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-window.cpp
automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-window.h
automated-tests/src/dali-toolkit/utc-Dali-KeyboardFocusManager.cpp
dali-toolkit/internal/focus-manager/keyboard-focus-manager-impl.cpp
dali-toolkit/internal/focus-manager/keyboard-focus-manager-impl.h

index 7aec884..bfc1315 100644 (file)
@@ -66,7 +66,7 @@ void SceneHolder::Add( Dali::Actor actor )
 
 void SceneHolder::Remove( Dali::Actor actor )
 {
 
 void SceneHolder::Remove( Dali::Actor actor )
 {
-  mScene.Add( actor );
+  mScene.Remove( actor );
 }
 
 Dali::Layer SceneHolder::GetRootLayer() const
 }
 
 Dali::Layer SceneHolder::GetRootLayer() const
index 64b0a40..1615e62 100644 (file)
@@ -40,10 +40,10 @@ namespace Adaptor
 class Window : public SceneHolder
 {
 public:
 class Window : public SceneHolder
 {
 public:
-
   Window( const PositionSize& positionSize );
   virtual ~Window() = default;
   static Window* New(const PositionSize& positionSize, const std::string& name, const std::string& className, bool isTransparent);
   Window( const PositionSize& positionSize );
   virtual ~Window() = default;
   static Window* New(const PositionSize& positionSize, const std::string& name, const std::string& className, bool isTransparent);
+  FocusChangeSignalType mFocusChangeSignal;
 };
 
 } // namespace Adaptor
 };
 
 } // namespace Adaptor
index 1424f1a..9849f60 100644 (file)
@@ -125,6 +125,41 @@ Integration::RenderSurface& Window::GetRenderSurface()
   return GetImplementation( *this ).GetRenderSurface();
 }
 
   return GetImplementation( *this ).GetRenderSurface();
 }
 
+void Window::Add( Actor actor )
+{
+  GetImplementation( *this ).Add( actor );
+}
+
+void Window::Remove( Actor actor )
+{
+  GetImplementation( *this ).Remove( actor );
+}
+
+Dali::Layer Window::GetRootLayer() const
+{
+  return GetImplementation( *this ).GetRootLayer();
+}
+
+void Window::SetBackgroundColor( const Vector4& color )
+{
+  GetImplementation( *this ).SetBackgroundColor( color );
+}
+
+Vector4 Window::GetBackgroundColor() const
+{
+  return GetImplementation( *this ).GetBackgroundColor();
+}
+
+void Window::Raise()
+{
+  GetImplementation( *this ).mFocusChangeSignal.Emit(*this, true);
+}
+
+FocusChangeSignalType& Window::FocusChangeSignal()
+{
+  return GetImplementation( *this ).mFocusChangeSignal;
+}
+
 namespace DevelWindow
 {
 
 namespace DevelWindow
 {
 
@@ -140,6 +175,16 @@ Window Get( Actor actor )
   return Dali::Window( windowImpl );
 }
 
   return Dali::Window( windowImpl );
 }
 
+Window DownCast( BaseHandle handle )
+{
+  Internal::Adaptor::Window* windowImpl = nullptr;
+  if ( Dali::Adaptor::IsAvailable() )
+  {
+    windowImpl = dynamic_cast<Dali::Internal::Adaptor::Window*>( handle.GetObjectPtr());
+  }
+  return Dali::Window( windowImpl );
+}
+
 EventProcessingFinishedSignalType& EventProcessingFinishedSignal( Window window )
 {
   return GetImplementation( window ).GetScene().EventProcessingFinishedSignal();
 EventProcessingFinishedSignalType& EventProcessingFinishedSignal( Window window )
 {
   return GetImplementation( window ).GetScene().EventProcessingFinishedSignal();
@@ -164,6 +209,7 @@ WheelEventSignalType& WheelEventSignal( Window window )
 {
   return GetImplementation( window ).WheelEventSignal();
 }
 {
   return GetImplementation( window ).WheelEventSignal();
 }
+
 } // namespace DevelWindow
 
 } // Dali
 } // namespace DevelWindow
 
 } // Dali
index 3fac48d..f261051 100644 (file)
@@ -44,6 +44,9 @@ class Window;
 }
 }
 
 }
 }
 
+class Window;
+typedef Signal< void (Window,bool) > FocusChangeSignalType;
+
 class Window : public BaseHandle
 {
 public:
 class Window : public BaseHandle
 {
 public:
@@ -58,6 +61,13 @@ public:
 
   Integration::Scene GetScene();
   Integration::RenderSurface& GetRenderSurface();
 
   Integration::Scene GetScene();
   Integration::RenderSurface& GetRenderSurface();
+  void Add( Dali::Actor actor );
+  void Remove( Dali::Actor actor );
+  Dali::Layer GetRootLayer() const;
+  void SetBackgroundColor( const Vector4& color );
+  Vector4 GetBackgroundColor() const;
+  void Raise();
+  FocusChangeSignalType& FocusChangeSignal();
 
 public:
   explicit Window( Internal::Adaptor::Window* window );
 
 public:
   explicit Window( Internal::Adaptor::Window* window );
@@ -75,6 +85,7 @@ typedef Signal< void (const TouchData&) > TouchSignalType;
 typedef Signal< void (const WheelEvent&) > WheelEventSignalType;
 
 Dali::Window Get( Actor actor );
 typedef Signal< void (const WheelEvent&) > WheelEventSignalType;
 
 Dali::Window Get( Actor actor );
+Dali::Window DownCast(  BaseHandle handle );
 
 EventProcessingFinishedSignalType& EventProcessingFinishedSignal( Window window );
 KeyEventSignalType& KeyEventSignal( Dali::Window window );
 
 EventProcessingFinishedSignalType& EventProcessingFinishedSignal( Window window );
 KeyEventSignalType& KeyEventSignal( Dali::Window window );
index 0f1d493..a759616 100755 (executable)
@@ -1579,4 +1579,40 @@ int UtcDaliKeyboardFocusManagerCheckConsumedKeyEvent(void)
   END_TEST;
 }
 
   END_TEST;
 }
 
+int UtcDaliKeyboardFocusManagerFocusPerWindow(void)
+{
+  ToolkitTestApplication application;
+
+  tet_infoline( "Ensure Memory focus actors for each window ");
+  KeyboardFocusManager manager = KeyboardFocusManager::Get();
+  DALI_TEST_CHECK( ! manager.GetCurrentFocusActor() );
+
+  Window firstWindow = Window::New(PositionSize(0,0,300,500) ,"", false);
+  DALI_TEST_CHECK( firstWindow );
+  Control first = Control::New();
+  first.SetKeyboardFocusable(true);
+  firstWindow.Add(first);
+
+  Window secondWindow = Window::New(PositionSize(0,0,400,600) ,"", false);
+  DALI_TEST_CHECK( secondWindow );
+  Control second = Control::New();
+  second.SetKeyboardFocusable(true);
+  secondWindow.Add( second );
+
+  DALI_TEST_CHECK(manager.SetCurrentFocusActor(first) == true);
+  DALI_TEST_CHECK(manager.GetCurrentFocusActor() == first);
+
+  DALI_TEST_CHECK(manager.SetCurrentFocusActor(second) == true);
+  DALI_TEST_CHECK(manager.GetCurrentFocusActor() == second);
+  firstWindow.Raise();
+  DALI_TEST_CHECK(manager.GetCurrentFocusActor() == first);
+
+  secondWindow.Remove( second );
+  secondWindow.Raise();
+  DALI_TEST_CHECK(manager.GetCurrentFocusActor() != second);
+
+  secondWindow.Reset();
+  END_TEST;
+}
+
 
 
index bba7702..18bd7a0 100644 (file)
@@ -122,15 +122,16 @@ KeyboardFocusManager::KeyboardFocusManager()
   mFocusedActorEnterKeySignal(),
   mCurrentFocusActor(),
   mFocusIndicatorActor(),
   mFocusedActorEnterKeySignal(),
   mCurrentFocusActor(),
   mFocusIndicatorActor(),
-  mIsFocusIndicatorShown( -1 ),
-  mFocusGroupLoopEnabled( false ),
-  mIsWaitingKeyboardFocusChangeCommit( false ),
-  mClearFocusOnTouch( true ),
-  mEnableFocusIndicator( true ),
-  mAlwaysShowIndicator( true ),
   mFocusHistory(),
   mSlotDelegate( this ),
   mFocusHistory(),
   mSlotDelegate( this ),
-  mCustomAlgorithmInterface(NULL)
+  mCustomAlgorithmInterface(NULL),
+  mCurrentFocusedWindow(),
+  mIsFocusIndicatorShown( UNKNOWN ),
+  mEnableFocusIndicator( ENABLE ),
+  mAlwaysShowIndicator( ALWAYS_SHOW ),
+  mFocusGroupLoopEnabled( false ),
+  mIsWaitingKeyboardFocusChangeCommit( false ),
+  mClearFocusOnTouch( true )
 {
   // TODO: Get FocusIndicatorEnable constant from stylesheet to set mIsFocusIndicatorShown.
 
 {
   // TODO: Get FocusIndicatorEnable constant from stylesheet to set mIsFocusIndicatorShown.
 
@@ -147,6 +148,11 @@ void KeyboardFocusManager::OnAdaptorInit()
     {
       ( *iter ).KeyEventSignal().Connect( mSlotDelegate, &KeyboardFocusManager::OnKeyEvent );
       ( *iter ).TouchSignal().Connect( mSlotDelegate, &KeyboardFocusManager::OnTouch );
     {
       ( *iter ).KeyEventSignal().Connect( mSlotDelegate, &KeyboardFocusManager::OnKeyEvent );
       ( *iter ).TouchSignal().Connect( mSlotDelegate, &KeyboardFocusManager::OnTouch );
+      Dali::Window window = DevelWindow::DownCast( *iter );
+      if( window )
+      {
+        window.FocusChangeSignal().Connect( mSlotDelegate, &KeyboardFocusManager::OnWindowFocusChanged);
+      }
     }
 
     // Get notified when any new scene holder is created afterwards
     }
 
     // Get notified when any new scene holder is created afterwards
@@ -158,6 +164,11 @@ void KeyboardFocusManager::OnSceneHolderCreated( Dali::Integration::SceneHolder&
 {
   sceneHolder.KeyEventSignal().Connect( mSlotDelegate, &KeyboardFocusManager::OnKeyEvent );
   sceneHolder.TouchSignal().Connect( mSlotDelegate, &KeyboardFocusManager::OnTouch );
 {
   sceneHolder.KeyEventSignal().Connect( mSlotDelegate, &KeyboardFocusManager::OnKeyEvent );
   sceneHolder.TouchSignal().Connect( mSlotDelegate, &KeyboardFocusManager::OnTouch );
+  Dali::Window window = DevelWindow::DownCast( sceneHolder );
+  if( window )
+  {
+    window.FocusChangeSignal().Connect( mSlotDelegate, &KeyboardFocusManager::OnWindowFocusChanged);
+  }
 }
 
 KeyboardFocusManager::~KeyboardFocusManager()
 }
 
 KeyboardFocusManager::~KeyboardFocusManager()
@@ -170,9 +181,9 @@ void KeyboardFocusManager::GetConfigurationFromStyleManger()
     if( styleManager )
     {
       Property::Map config = Toolkit::DevelStyleManager::GetConfigurations( styleManager );
     if( styleManager )
     {
       Property::Map config = Toolkit::DevelStyleManager::GetConfigurations( styleManager );
-      mAlwaysShowIndicator = config["alwaysShowFocus"].Get<bool>();
-      mIsFocusIndicatorShown = static_cast<int>(mAlwaysShowIndicator);
-      mClearFocusOnTouch = mIsFocusIndicatorShown ? false : true;
+      mAlwaysShowIndicator = config["alwaysShowFocus"].Get<bool>() ? ALWAYS_SHOW : NONE;
+      mIsFocusIndicatorShown = ( mAlwaysShowIndicator == ALWAYS_SHOW )? SHOW : HIDE;
+      mClearFocusOnTouch = ( mIsFocusIndicatorShown == SHOW ) ? false : true;
     }
 }
 
     }
 }
 
@@ -180,7 +191,7 @@ bool KeyboardFocusManager::SetCurrentFocusActor( Actor actor )
 {
   DALI_ASSERT_DEBUG( !mIsWaitingKeyboardFocusChangeCommit && "Calling this function in the PreFocusChangeSignal callback?" );
 
 {
   DALI_ASSERT_DEBUG( !mIsWaitingKeyboardFocusChangeCommit && "Calling this function in the PreFocusChangeSignal callback?" );
 
-  if( mIsFocusIndicatorShown == -1 )
+  if( mIsFocusIndicatorShown == UNKNOWN )
   {
     GetConfigurationFromStyleManger();
   }
   {
     GetConfigurationFromStyleManger();
   }
@@ -191,6 +202,16 @@ bool KeyboardFocusManager::SetCurrentFocusActor( Actor actor )
 bool KeyboardFocusManager::DoSetCurrentFocusActor( Actor actor )
 {
   bool success = false;
 bool KeyboardFocusManager::DoSetCurrentFocusActor( Actor actor )
 {
   bool success = false;
+  if( actor && actor.IsKeyboardFocusable() && actor.OnStage() )
+  {
+    Integration::SceneHolder currentWindow = Integration::SceneHolder::Get( actor );
+
+    if( currentWindow.GetRootLayer() != mCurrentFocusedWindow.GetHandle())
+    {
+      Layer rootLayer = currentWindow.GetRootLayer();
+      mCurrentFocusedWindow = rootLayer;
+    }
+  }
 
   Actor currentFocusedActor = GetCurrentFocusActor();
 
 
   Actor currentFocusedActor = GetCurrentFocusActor();
 
@@ -207,7 +228,7 @@ bool KeyboardFocusManager::DoSetCurrentFocusActor( Actor actor )
   // Check whether the actor is in the stage and is keyboard focusable.
   if( actor && actor.IsKeyboardFocusable() && actor.OnStage() )
   {
   // Check whether the actor is in the stage and is keyboard focusable.
   if( actor && actor.IsKeyboardFocusable() && actor.OnStage() )
   {
-    if( mIsFocusIndicatorShown && mEnableFocusIndicator )
+    if( ( mIsFocusIndicatorShown == SHOW ) && ( mEnableFocusIndicator == ENABLE ) )
     {
       actor.Add( GetFocusIndicatorActor() );
     }
     {
       actor.Add( GetFocusIndicatorActor() );
     }
@@ -231,6 +252,22 @@ bool KeyboardFocusManager::DoSetCurrentFocusActor( Actor actor )
     // Save the current focused actor
     mCurrentFocusActor = actor;
 
     // Save the current focused actor
     mCurrentFocusActor = actor;
 
+    bool focusedWindowFound = false;
+    for( unsigned int i = 0; i < mCurrentFocusActors.size(); i++ )
+    {
+      if( mCurrentFocusActors[i].first == mCurrentFocusedWindow )
+      {
+        mCurrentFocusActors[i].second = actor;
+        focusedWindowFound = true;
+        break;
+      }
+    }
+    if( !focusedWindowFound)
+    {
+      // A new window gains the focus, so store the focused actor in that window.
+      mCurrentFocusActors.push_back( std::pair< WeakHandle< Layer>, WeakHandle< Actor > >( mCurrentFocusedWindow , actor ));
+    }
+
     Toolkit::Control newlyFocusedControl = Toolkit::Control::DownCast(actor);
     if( newlyFocusedControl )
     {
     Toolkit::Control newlyFocusedControl = Toolkit::Control::DownCast(actor);
     if( newlyFocusedControl )
     {
@@ -262,16 +299,39 @@ bool KeyboardFocusManager::DoSetCurrentFocusActor( Actor actor )
 Actor KeyboardFocusManager::GetCurrentFocusActor()
 {
   Actor actor = mCurrentFocusActor.GetHandle();
 Actor KeyboardFocusManager::GetCurrentFocusActor()
 {
   Actor actor = mCurrentFocusActor.GetHandle();
+
   if( actor && ! actor.OnStage() )
   {
     // If the actor has been removed from the stage, then it should not be focused
   if( actor && ! actor.OnStage() )
   {
     // If the actor has been removed from the stage, then it should not be focused
-
     actor.Reset();
     mCurrentFocusActor.Reset();
   }
   return actor;
 }
 
     actor.Reset();
     mCurrentFocusActor.Reset();
   }
   return actor;
 }
 
+Actor KeyboardFocusManager::GetFocusActorFromCurrentWindow()
+{
+  Actor actor;
+  unsigned int index;
+  for( index = 0; index < mCurrentFocusActors.size(); index++ )
+  {
+    if( mCurrentFocusActors[index].first == mCurrentFocusedWindow )
+    {
+      actor = mCurrentFocusActors[index].second.GetHandle();
+      break;
+    }
+  }
+
+  if( actor && ! actor.OnStage() )
+  {
+    // If the actor has been removed from the window, then the window doesn't have any focused actor
+    actor.Reset();
+    mCurrentFocusActors.erase( mCurrentFocusActors.begin() + index );
+  }
+
+  return actor;
+}
+
 Actor KeyboardFocusManager::GetCurrentFocusGroup()
 {
   return GetFocusGroup(GetCurrentFocusActor());
 Actor KeyboardFocusManager::GetCurrentFocusGroup()
 {
   return GetFocusGroup(GetCurrentFocusActor());
@@ -593,7 +653,7 @@ void KeyboardFocusManager::ClearFocus()
   }
 
   mCurrentFocusActor.Reset();
   }
 
   mCurrentFocusActor.Reset();
-  mIsFocusIndicatorShown = static_cast<int>(mAlwaysShowIndicator);
+  mIsFocusIndicatorShown = ( mAlwaysShowIndicator == ALWAYS_SHOW ) ? SHOW : HIDE;
 }
 
 void KeyboardFocusManager::SetFocusGroupLoop(bool enabled)
 }
 
 void KeyboardFocusManager::SetFocusGroupLoop(bool enabled)
@@ -693,7 +753,7 @@ void KeyboardFocusManager::OnKeyEvent(const KeyEvent& event)
 
   std::string keyName = event.keyPressedName;
 
 
   std::string keyName = event.keyPressedName;
 
-  if( mIsFocusIndicatorShown == -1 )
+  if( mIsFocusIndicatorShown == UNKNOWN )
   {
     GetConfigurationFromStyleManger();
   }
   {
     GetConfigurationFromStyleManger();
   }
@@ -706,10 +766,10 @@ void KeyboardFocusManager::OnKeyEvent(const KeyEvent& event)
     {
       if(!isAccessibilityEnabled)
       {
     {
       if(!isAccessibilityEnabled)
       {
-        if(!mIsFocusIndicatorShown)
+        if(mIsFocusIndicatorShown == HIDE)
         {
           // Show focus indicator
         {
           // Show focus indicator
-          mIsFocusIndicatorShown = 1;
+          mIsFocusIndicatorShown = SHOW;
         }
         else
         {
         }
         else
         {
@@ -729,10 +789,10 @@ void KeyboardFocusManager::OnKeyEvent(const KeyEvent& event)
     {
       if(!isAccessibilityEnabled)
       {
     {
       if(!isAccessibilityEnabled)
       {
-        if(!mIsFocusIndicatorShown)
+        if( mIsFocusIndicatorShown == HIDE )
         {
           // Show focus indicator
         {
           // Show focus indicator
-          mIsFocusIndicatorShown = 1;
+          mIsFocusIndicatorShown = SHOW;
         }
         else
         {
         }
         else
         {
@@ -750,10 +810,10 @@ void KeyboardFocusManager::OnKeyEvent(const KeyEvent& event)
     }
     else if (keyName == "Up" && !isAccessibilityEnabled)
     {
     }
     else if (keyName == "Up" && !isAccessibilityEnabled)
     {
-      if(!mIsFocusIndicatorShown)
+      if( mIsFocusIndicatorShown == HIDE )
       {
         // Show focus indicator
       {
         // Show focus indicator
-        mIsFocusIndicatorShown = 1;
+        mIsFocusIndicatorShown = SHOW;
       }
       else
       {
       }
       else
       {
@@ -765,10 +825,10 @@ void KeyboardFocusManager::OnKeyEvent(const KeyEvent& event)
     }
     else if (keyName == "Down" && !isAccessibilityEnabled)
     {
     }
     else if (keyName == "Down" && !isAccessibilityEnabled)
     {
-      if(!mIsFocusIndicatorShown)
+      if( mIsFocusIndicatorShown == HIDE )
       {
         // Show focus indicator
       {
         // Show focus indicator
-        mIsFocusIndicatorShown = 1;
+        mIsFocusIndicatorShown = SHOW;
       }
       else
       {
       }
       else
       {
@@ -780,10 +840,10 @@ void KeyboardFocusManager::OnKeyEvent(const KeyEvent& event)
     }
     else if (keyName == "Prior" && !isAccessibilityEnabled)
     {
     }
     else if (keyName == "Prior" && !isAccessibilityEnabled)
     {
-      if(!mIsFocusIndicatorShown)
+      if( mIsFocusIndicatorShown == HIDE )
       {
         // Show focus indicator
       {
         // Show focus indicator
-        mIsFocusIndicatorShown = 1;
+        mIsFocusIndicatorShown = SHOW;
       }
       else
       {
       }
       else
       {
@@ -795,10 +855,10 @@ void KeyboardFocusManager::OnKeyEvent(const KeyEvent& event)
     }
     else if (keyName == "Next" && !isAccessibilityEnabled)
     {
     }
     else if (keyName == "Next" && !isAccessibilityEnabled)
     {
-      if(!mIsFocusIndicatorShown)
+      if( mIsFocusIndicatorShown == HIDE )
       {
         // Show focus indicator
       {
         // Show focus indicator
-        mIsFocusIndicatorShown = 1;
+        mIsFocusIndicatorShown = SHOW;
       }
       else
       {
       }
       else
       {
@@ -810,10 +870,10 @@ void KeyboardFocusManager::OnKeyEvent(const KeyEvent& event)
     }
     else if (keyName == "Tab" && !isAccessibilityEnabled)
     {
     }
     else if (keyName == "Tab" && !isAccessibilityEnabled)
     {
-      if(!mIsFocusIndicatorShown)
+      if( mIsFocusIndicatorShown == HIDE )
       {
         // Show focus indicator
       {
         // Show focus indicator
-        mIsFocusIndicatorShown = 1;
+        mIsFocusIndicatorShown = SHOW;
       }
       else
       {
       }
       else
       {
@@ -826,10 +886,10 @@ void KeyboardFocusManager::OnKeyEvent(const KeyEvent& event)
     }
     else if (keyName == "space" && !isAccessibilityEnabled)
     {
     }
     else if (keyName == "space" && !isAccessibilityEnabled)
     {
-      if(!mIsFocusIndicatorShown)
+      if( mIsFocusIndicatorShown == HIDE )
       {
         // Show focus indicator
       {
         // Show focus indicator
-        mIsFocusIndicatorShown = 1;
+        mIsFocusIndicatorShown = SHOW;
       }
 
       isFocusStartableKey = true;
       }
 
       isFocusStartableKey = true;
@@ -837,10 +897,10 @@ void KeyboardFocusManager::OnKeyEvent(const KeyEvent& event)
     else if (keyName == "" && !isAccessibilityEnabled)
     {
       // Check the fake key event for evas-plugin case
     else if (keyName == "" && !isAccessibilityEnabled)
     {
       // Check the fake key event for evas-plugin case
-      if(!mIsFocusIndicatorShown)
+      if( mIsFocusIndicatorShown == HIDE )
       {
         // Show focus indicator
       {
         // Show focus indicator
-        mIsFocusIndicatorShown = 1;
+        mIsFocusIndicatorShown = SHOW;
       }
 
       isFocusStartableKey = true;
       }
 
       isFocusStartableKey = true;
@@ -857,10 +917,10 @@ void KeyboardFocusManager::OnKeyEvent(const KeyEvent& event)
   {
     if (keyName == "Return")
     {
   {
     if (keyName == "Return")
     {
-      if(!mIsFocusIndicatorShown && !isAccessibilityEnabled)
+      if((mIsFocusIndicatorShown == HIDE) && !isAccessibilityEnabled)
       {
         // Show focus indicator
       {
         // Show focus indicator
-        mIsFocusIndicatorShown = 1;
+        mIsFocusIndicatorShown = SHOW;
       }
       else
       {
       }
       else
       {
@@ -885,12 +945,12 @@ void KeyboardFocusManager::OnKeyEvent(const KeyEvent& event)
     }
   }
 
     }
   }
 
-  if(isFocusStartableKey && mIsFocusIndicatorShown && !isAccessibilityEnabled)
+  if(isFocusStartableKey && ( mIsFocusIndicatorShown == SHOW ) && !isAccessibilityEnabled)
   {
     Actor actor = GetCurrentFocusActor();
     if( actor )
     {
   {
     Actor actor = GetCurrentFocusActor();
     if( actor )
     {
-      if( mEnableFocusIndicator )
+      if( mEnableFocusIndicator == ENABLE )
       {
         // Make sure the focused actor is highlighted
         actor.Add( GetFocusIndicatorActor() );
       {
         // Make sure the focused actor is highlighted
         actor.Add( GetFocusIndicatorActor() );
@@ -907,9 +967,9 @@ void KeyboardFocusManager::OnKeyEvent(const KeyEvent& event)
 
 void KeyboardFocusManager::OnTouch(const TouchData& touch)
 {
 
 void KeyboardFocusManager::OnTouch(const TouchData& touch)
 {
-  // if mIsFocusIndicatorShown is -1, it means Configuration is not loaded.
+  // if mIsFocusIndicatorShown is UNKNOWN, it means Configuration is not loaded.
   // Try to load configuration.
   // Try to load configuration.
-  if( mIsFocusIndicatorShown == -1 )
+  if( mIsFocusIndicatorShown == UNKNOWN )
   {
     GetConfigurationFromStyleManger();
   }
   {
     GetConfigurationFromStyleManger();
   }
@@ -923,6 +983,27 @@ void KeyboardFocusManager::OnTouch(const TouchData& touch)
   }
 }
 
   }
 }
 
+void KeyboardFocusManager::OnWindowFocusChanged(Window window, bool focusIn )
+{
+  if( focusIn && mCurrentFocusedWindow.GetHandle() != window.GetRootLayer() )
+  {
+    // Change Current Focused Window
+    Layer rootLayer = window.GetRootLayer();
+    mCurrentFocusedWindow = rootLayer;
+
+    // Get Current Focused Actor from window
+    Actor currentFocusedActor = GetFocusActorFromCurrentWindow();
+    SetCurrentFocusActor( currentFocusedActor );
+
+    if( currentFocusedActor && ( mEnableFocusIndicator == ENABLE ) )
+    {
+      // Make sure the focused actor is highlighted
+      currentFocusedActor.Add( GetFocusIndicatorActor() );
+      mIsFocusIndicatorShown = SHOW;
+    }
+  }
+}
+
 Toolkit::KeyboardFocusManager::PreFocusChangeSignalType& KeyboardFocusManager::PreFocusChangeSignal()
 {
   return mPreFocusChangeSignal;
 Toolkit::KeyboardFocusManager::PreFocusChangeSignalType& KeyboardFocusManager::PreFocusChangeSignal()
 {
   return mPreFocusChangeSignal;
@@ -987,12 +1068,13 @@ void KeyboardFocusManager::EnableFocusIndicator(bool enable)
     mFocusIndicatorActor.Unparent();
   }
 
     mFocusIndicatorActor.Unparent();
   }
 
-  mEnableFocusIndicator = enable;
+  mEnableFocusIndicator = enable? ENABLE : DISABLE;
+
 }
 
 bool KeyboardFocusManager::IsFocusIndicatorEnabled() const
 {
 }
 
 bool KeyboardFocusManager::IsFocusIndicatorEnabled() const
 {
-  return mEnableFocusIndicator;
+  return ( mEnableFocusIndicator == ENABLE );
 }
 
 } // namespace Internal
 }
 
 } // namespace Internal
index ff79634..176bfce 100644 (file)
@@ -26,6 +26,7 @@
 // INTERNAL INCLUDES
 #include <dali-toolkit/public-api/focus-manager/keyboard-focus-manager.h>
 #include <dali-toolkit/devel-api/focus-manager/keyboard-focus-manager-devel.h>
 // INTERNAL INCLUDES
 #include <dali-toolkit/public-api/focus-manager/keyboard-focus-manager.h>
 #include <dali-toolkit/devel-api/focus-manager/keyboard-focus-manager-devel.h>
+#include <dali/devel-api/adaptor-framework/window-devel.h>
 
 namespace Dali
 {
 
 namespace Dali
 {
@@ -52,6 +53,25 @@ public:
 
   typedef Toolkit::DevelKeyboardFocusManager::CustomAlgorithmInterface CustomAlgorithmInterface;
 
 
   typedef Toolkit::DevelKeyboardFocusManager::CustomAlgorithmInterface CustomAlgorithmInterface;
 
+  enum FocusIndicatorState
+  {
+    UNKNOWN = -1,   ///< Unknown state
+    HIDE = 0,          ///< FocusIndicator is hidden
+    SHOW = 1,          ///< FocusIndicator is shown
+  };
+
+  enum EnableFocusedIndicatorState
+  {
+    DISABLE = 0,          ///< FocusIndicator is disable
+    ENABLE = 1,          ///< FocusIndicator is enable
+  };
+
+  enum FocusedIndicatorModeState
+  {
+    NONE = 0,          ///< Set nothing
+    ALWAYS_SHOW = 1,          ///< FocusIndicator is always shown
+  };
+
   /**
    * @copydoc Toolkit::KeyboardFocusManager::Get
    */
   /**
    * @copydoc Toolkit::KeyboardFocusManager::Get
    */
@@ -260,7 +280,7 @@ private:
    * Callback for the key event when no actor in the stage has gained the key input focus
    * @param[in] event The KeyEvent event.
    */
    * Callback for the key event when no actor in the stage has gained the key input focus
    * @param[in] event The KeyEvent event.
    */
-  void OnKeyEvent(const KeyEvent& event);
+  void OnKeyEvent( const KeyEvent& event );
 
   /**
    * Callback for the touch event when the screen is touched and when the touch ends
 
   /**
    * Callback for the touch event when the screen is touched and when the touch ends
@@ -269,6 +289,18 @@ private:
    */
   void OnTouch( const TouchData& touch );
 
    */
   void OnTouch( const TouchData& touch );
 
+  /**
+   * Called when the window focus is changed.
+   * @param[in] window The window whose focus is changed
+   * @param[in] focusIn Whether the focus is in/out
+   */
+  void OnWindowFocusChanged( Window window, bool focusIn );
+
+  /**
+   * Get the focus Actor from current window
+   */
+  Actor GetFocusActorFromCurrentWindow();
+
 private:
 
   // Undefined
 private:
 
   // Undefined
@@ -287,24 +319,29 @@ private:
 
   Actor mFocusIndicatorActor; ///< The focus indicator actor shared by all the keyboard focusable actors for highlight
 
 
   Actor mFocusIndicatorActor; ///< The focus indicator actor shared by all the keyboard focusable actors for highlight
 
-  int mIsFocusIndicatorShown; ///< Whether indicator should be shown / hidden when getting focus. It could be enabled when keyboard focus feature is enabled and navigation keys or 'Tab' key are pressed.
+  FocusStack mFocusHistory; ///< Stack to contain pre-focused actor's BaseObject*
 
 
-  bool mFocusGroupLoopEnabled:1; ///< Whether the focus movement is looped within the same focus group
+  SlotDelegate< KeyboardFocusManager > mSlotDelegate;
 
 
-  bool mIsWaitingKeyboardFocusChangeCommit:1; /// A flag to indicate PreFocusChangeSignal emitted but the proposed focus actor is not commited by the application yet.
+  CustomAlgorithmInterface* mCustomAlgorithmInterface; ///< The user's (application / toolkit) implementation of CustomAlgorithmInterface
 
 
-  bool mClearFocusOnTouch:1; ///< Whether clear focus on touch.
+  typedef std::vector< std::pair< WeakHandle< Layer >, WeakHandle< Actor > > > FocusActorContainer;
 
 
-  bool mEnableFocusIndicator;  ///< Whether use focus indicator
+  FocusActorContainer mCurrentFocusActors; ///< A container of focused actors
 
 
-  bool mAlwaysShowIndicator; ///< Whether always show indicator. If true, the indicator would be directly shown when focused.
+  WeakHandle< Layer > mCurrentFocusedWindow; ///< A weak handle to the current focused window's root layer
 
 
-  FocusStack mFocusHistory; ///< Stack to contain pre-focused actor's BaseObject*
+  FocusIndicatorState mIsFocusIndicatorShown; ///< Whether indicator should be shown / hidden when getting focus. It could be enabled when keyboard focus feature is enabled and navigation keys or 'Tab' key are pressed.
 
 
-  SlotDelegate< KeyboardFocusManager > mSlotDelegate;
+  EnableFocusedIndicatorState mEnableFocusIndicator;  ///< Whether use focus indicator
 
 
-  CustomAlgorithmInterface* mCustomAlgorithmInterface; ///< The user's (application / toolkit) implementation of CustomAlgorithmInterface
+  FocusedIndicatorModeState mAlwaysShowIndicator; ///< Whether always show indicator. If true, the indicator would be directly shown when focused
 
 
+  bool mFocusGroupLoopEnabled:1; ///< Whether the focus movement is looped within the same focus group
+
+  bool mIsWaitingKeyboardFocusChangeCommit:1; /// A flag to indicate PreFocusChangeSignal emitted but the proposed focus actor is not commited by the application yet.
+
+  bool mClearFocusOnTouch:1; ///< Whether clear focus on touch.
 };
 
 } // namespace Internal
 };
 
 } // namespace Internal