[Tizen] Add a flag to check whether it is forced to enable
[platform/core/uifw/dali-adaptor.git] / dali / internal / window-system / common / event-handler.cpp
index 25fc86f..8bdec19 100755 (executable)
@@ -56,6 +56,9 @@ Integration::Log::Filter* gSelectionEventLogFilter = Integration::Log::Filter::N
 namespace
 {
 
+static constexpr auto QUICKPANEL_TYPE_SYSTEM_DEFAULT = 1;
+static constexpr auto QUICKPANEL_TYPE_APPS_MENU = 3;
+
 // Copied from x server
 static uint32_t GetCurrentMilliSeconds(void)
 {
@@ -104,16 +107,24 @@ EventHandler::EventHandler( WindowBase* windowBase, DamageObserver& damageObserv
   mPaused( false )
 {
   // Connect signals
-  windowBase->WindowDamagedSignal().Connect( this, &EventHandler::OnWindowDamaged );
-  windowBase->FocusChangedSignal().Connect( this, &EventHandler::OnFocusChanged );
-  windowBase->RotationSignal().Connect( this, &EventHandler::OnRotation );
-  windowBase->TouchEventSignal().Connect( this, &EventHandler::OnTouchEvent );
-  windowBase->WheelEventSignal().Connect( this, &EventHandler::OnWheelEvent );
-  windowBase->KeyEventSignal().Connect( this, &EventHandler::OnKeyEvent );
-  windowBase->SelectionDataSendSignal().Connect( this, &EventHandler::OnSelectionDataSend );
-  windowBase->SelectionDataReceivedSignal().Connect( this, &EventHandler::OnSelectionDataReceived );
-  windowBase->StyleChangedSignal().Connect( this, &EventHandler::OnStyleChanged );
-  windowBase->AccessibilitySignal().Connect( this, &EventHandler::OnAccessibilityNotification );
+  if( windowBase )
+  {
+    windowBase->WindowDamagedSignal().Connect( this, &EventHandler::OnWindowDamaged );
+    windowBase->FocusChangedSignal().Connect( this, &EventHandler::OnFocusChanged );
+    windowBase->RotationSignal().Connect( this, &EventHandler::OnRotation );
+    windowBase->TouchEventSignal().Connect( this, &EventHandler::OnTouchEvent );
+    windowBase->WheelEventSignal().Connect( this, &EventHandler::OnWheelEvent );
+    windowBase->KeyEventSignal().Connect( this, &EventHandler::OnKeyEvent );
+    windowBase->SelectionDataSendSignal().Connect( this, &EventHandler::OnSelectionDataSend );
+    windowBase->SelectionDataReceivedSignal().Connect( this, &EventHandler::OnSelectionDataReceived );
+    windowBase->StyleChangedSignal().Connect( this, &EventHandler::OnStyleChanged );
+    windowBase->AccessibilitySignal().Connect( this, &EventHandler::OnAccessibilityNotification );
+    windowBase->QuickPanelSignal().Connect( this, &EventHandler::OnAccessibilityQuickpanelChanged );
+  }
+  else
+  {
+    DALI_LOG_ERROR("WindowBase is invalid!!!\n");
+  }
 }
 
 EventHandler::~EventHandler()
@@ -260,6 +271,18 @@ void EventHandler::OnAccessibilityNotification( const WindowBase::AccessibilityI
     return;
   }
 
+  if( !accessibilityAdaptor->IsEnabled() )
+  {
+    DALI_LOG_ERROR( "The current dali accessibility is not available. \n" );
+    return;
+  }
+
+  if( ( info.quickpanelInfo & ( 1 << QUICKPANEL_TYPE_SYSTEM_DEFAULT ) ) && ( info.quickpanelInfo & ( 1 << QUICKPANEL_TYPE_APPS_MENU ) ) )
+  {
+    DALI_LOG_ERROR("Quickpanel is top now, so all dali apps should be stopped \n");
+    return;
+  }
+
   // Create a touch point object.
   PointState::Type touchPointState( PointState::DOWN );
   if( info.state == 0 )
@@ -493,6 +516,57 @@ void EventHandler::OnAccessibilityNotification( const WindowBase::AccessibilityI
 #endif
 }
 
+void EventHandler::OnAccessibilityQuickpanelChanged( const unsigned char& info )
+{
+#ifdef DALI_ELDBUS_AVAILABLE
+  if( mPaused )
+  {
+    return;
+  }
+
+  if( !mAccessibilityAdaptor )
+  {
+    DALI_LOG_ERROR( "Invalid accessibility adaptor\n" );
+    return;
+  }
+
+  AccessibilityAdaptor* accessibilityAdaptor( &AccessibilityAdaptor::GetImplementation( mAccessibilityAdaptor ) );
+  if( !accessibilityAdaptor )
+  {
+    DALI_LOG_ERROR( "Cannot access accessibility adaptor\n" );
+    return;
+  }
+
+  if( ( ( info & ( 1 << QUICKPANEL_TYPE_SYSTEM_DEFAULT ) ) && ( info & ( 1 << QUICKPANEL_TYPE_APPS_MENU ) ) ) || // Both QuickPanel and Apps are shown
+      ( info & ( 1 << QUICKPANEL_TYPE_SYSTEM_DEFAULT ) ) ) // QuickPanel is shown
+  {
+    // dali apps should be disabled.
+    DALI_LOG_INFO( gSelectionEventLogFilter, Debug::General, "OnAccessibilityQuickpanelChanged: Quickpanel show -> DisableAccessibility \n" );
+    accessibilityAdaptor->DisableAccessibility();
+  }
+  else if( info & ( 1 << QUICKPANEL_TYPE_APPS_MENU ) ) // Only Apps menu (dali application) is shown
+  {
+    if( !accessibilityAdaptor->IsForcedEnable() ) // It is not in case of that an application controls the accessibility status itself
+    {
+      DALI_LOG_INFO( gSelectionEventLogFilter, Debug::General, "OnAccessibilityQuickpanelChanged: Only Apps show, but not forced dali -> DisableAccessibility \n" );
+      accessibilityAdaptor->DisableAccessibility();
+    }
+    else
+    {
+      DALI_LOG_INFO( gSelectionEventLogFilter, Debug::General, "OnAccessibilityQuickpanelChanged: Only Apps show and it is a forced dali -> EnableAccessibility \n" );
+      accessibilityAdaptor->EnableAccessibility();
+    }
+  }
+  else
+  {
+    DALI_LOG_INFO( gSelectionEventLogFilter, Debug::General, "OnAccessibilityQuickpanelChanged: Nothing shows -> EnableAccessibility \n" );
+    // dali app should be enabled.
+    accessibilityAdaptor->EnableAccessibility();
+  }
+
+#endif
+}
+
 void EventHandler::AddObserver( Observer& observer )
 {
   ObserverContainer::iterator match ( find(mObservers.begin(), mObservers.end(), &observer) );