/*
- * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2020 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
#include <cstring>
#include <sys/time.h>
-#include <dali/public-api/events/touch-point.h>
+#include <dali/devel-api/events/touch-point.h>
#include <dali/public-api/events/key-event.h>
#include <dali/public-api/events/wheel-event.h>
#include <dali/integration-api/debug.h>
} // unnamed namespace
#endif
-#if 0 and defined DALI_ELDBUS_AVAILABLE
+#ifdef DALI_ELDBUS_AVAILABLE
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)
{
} // unnamed namespace
#endif
-EventHandler::EventHandler( WindowRenderSurface* surface, DamageObserver& damageObserver )
+EventHandler::EventHandler( WindowBase* windowBase, DamageObserver& damageObserver )
: mStyleMonitor( StyleMonitor::Get() ),
mDamageObserver( damageObserver ),
+ mAccessibilityAdaptor( AccessibilityAdaptor::Get() ),
mClipboardEventNotifier( ClipboardEventNotifier::Get() ),
mClipboard( Clipboard::Get() ),
mPaused( false )
{
- if( surface )
+ // Connect signals
+ if( windowBase )
{
- WindowBase* windowBase = surface->GetWindowBase();
-
- // Connect signals
windowBase->WindowDamagedSignal().Connect( this, &EventHandler::OnWindowDamaged );
windowBase->FocusChangedSignal().Connect( this, &EventHandler::OnFocusChanged );
windowBase->RotationSignal().Connect( this, &EventHandler::OnRotation );
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");
}
}
}
}
-void EventHandler::OnWheelEvent( WheelEvent& wheelEvent )
+void EventHandler::OnWheelEvent( Integration::WheelEvent& wheelEvent )
{
- Integration::WheelEvent event( static_cast< Integration::WheelEvent::Type >(wheelEvent.type), wheelEvent.direction, wheelEvent.modifiers, wheelEvent.point, wheelEvent.z, wheelEvent.timeStamp );
-
for ( ObserverContainer::iterator iter = mObservers.begin(), endIter = mObservers.end(); iter != endIter; ++iter )
{
- (*iter)->OnWheelEvent( event );
+ (*iter)->OnWheelEvent( wheelEvent );
}
}
SendEvent( styleChange );
}
+void EventHandler::OnAccessibilityNotification( const WindowBase::AccessibilityInfo& 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.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 )
+ {
+ touchPointState = PointState::DOWN; // Mouse down.
+ }
+ else if( info.state == 1 )
+ {
+ touchPointState = PointState::MOTION; // Mouse move.
+ }
+ else if( info.state == 2 )
+ {
+ touchPointState = PointState::UP; // Mouse up.
+ }
+ else
+ {
+ touchPointState = PointState::INTERRUPTED; // Error.
+ }
+
+ // Send touch event to accessibility adaptor.
+ TouchPoint point( 0, touchPointState, static_cast< float >( info.startX ), static_cast< float >( info.startY ) );
+
+ // Perform actions based on received gestures.
+ // Note: This is seperated from the reading so we can have other input readers without changing the below code.
+ switch( info.gestureValue )
+ {
+ case 0: // OneFingerHover
+ {
+ // Focus, read out.
+ accessibilityAdaptor->HandleActionReadEvent( static_cast< unsigned int >( info.startX ), static_cast< unsigned int >( info.startY ), true /* allow read again */ );
+ break;
+ }
+ case 1: // TwoFingersHover
+ {
+ // In accessibility mode, scroll action should be handled when the currently focused actor is contained in scrollable control
+ accessibilityAdaptor->HandleActionScrollEvent( point, GetCurrentMilliSeconds() );
+ break;
+ }
+ case 2: // ThreeFingersHover
+ {
+ // Read from top item on screen continuously.
+ accessibilityAdaptor->HandleActionReadFromTopEvent();
+ break;
+ }
+ case 3: // OneFingerFlickLeft
+ {
+ // Move to previous item.
+ accessibilityAdaptor->HandleActionReadPreviousEvent();
+ break;
+ }
+ case 4: // OneFingerFlickRight
+ {
+ // Move to next item.
+ accessibilityAdaptor->HandleActionReadNextEvent();
+ break;
+ }
+ case 5: // OneFingerFlickUp
+ {
+ // Move to previous item.
+ accessibilityAdaptor->HandleActionPreviousEvent();
+ break;
+ }
+ case 6: // OneFingerFlickDown
+ {
+ // Move to next item.
+ accessibilityAdaptor->HandleActionNextEvent();
+ break;
+ }
+ case 7: // TwoFingersFlickUp
+ {
+ // Scroll up the list.
+ accessibilityAdaptor->HandleActionScrollUpEvent();
+ break;
+ }
+ case 8: // TwoFingersFlickDown
+ {
+ // Scroll down the list.
+ accessibilityAdaptor->HandleActionScrollDownEvent();
+ break;
+ }
+ case 9: // TwoFingersFlickLeft
+ {
+ // Scroll left to the previous page
+ accessibilityAdaptor->HandleActionPageLeftEvent();
+ break;
+ }
+ case 10: // TwoFingersFlickRight
+ {
+ // Scroll right to the next page
+ accessibilityAdaptor->HandleActionPageRightEvent();
+ break;
+ }
+ case 11: // ThreeFingersFlickLeft
+ {
+ // Not exist yet
+ break;
+ }
+ case 12: // ThreeFingersFlickRight
+ {
+ // Not exist yet
+ break;
+ }
+ case 13: // ThreeFingersFlickUp
+ {
+ // Not exist yet
+ break;
+ }
+ case 14: // ThreeFingersFlickDown
+ {
+ // Not exist yet
+ break;
+ }
+ case 15: // OneFingerSingleTap
+ {
+ // Focus, read out.
+ accessibilityAdaptor->HandleActionReadEvent( static_cast< unsigned int >( info.startX ), static_cast< unsigned int >( info.startY ), true /* allow read again */ );
+ break;
+ }
+ case 16: // OneFingerDoubleTap
+ {
+ // Activate selected item / active edit mode.
+ accessibilityAdaptor->HandleActionActivateEvent();
+ break;
+ }
+ case 17: // OneFingerTripleTap
+ {
+ // Zoom
+ accessibilityAdaptor->HandleActionZoomEvent();
+ break;
+ }
+ case 18: // TwoFingersSingleTap
+ {
+ // Pause/Resume current speech
+ accessibilityAdaptor->HandleActionReadPauseResumeEvent();
+ break;
+ }
+ case 19: // TwoFingersDoubleTap
+ {
+ // Start/Stop current action
+ accessibilityAdaptor->HandleActionStartStopEvent();
+ break;
+ }
+ case 20: // TwoFingersTripleTap
+ {
+ // Read information from indicator
+ // Not supported
+ break;
+ }
+ case 21: // ThreeFingersSingleTap
+ {
+ // Read from top item on screen continuously.
+ accessibilityAdaptor->HandleActionReadFromTopEvent();
+ break;
+ }
+ case 22: // ThreeFingersDoubleTap
+ {
+ // Read from next item continuously.
+ accessibilityAdaptor->HandleActionReadFromNextEvent();
+ break;
+ }
+ case 23: // ThreeFingersTripleTap
+ {
+ // Not exist yet
+ break;
+ }
+ case 24: // OneFingerFlickLeftReturn
+ {
+ // Scroll up to the previous page
+ accessibilityAdaptor->HandleActionPageUpEvent();
+ break;
+ }
+ case 25: // OneFingerFlickRightReturn
+ {
+ // Scroll down to the next page
+ accessibilityAdaptor->HandleActionPageDownEvent();
+ break;
+ }
+ case 26: // OneFingerFlickUpReturn
+ {
+ // Move to the first item on screen
+ accessibilityAdaptor->HandleActionMoveToFirstEvent();
+ break;
+ }
+ case 27: // OneFingerFlickDownReturn
+ {
+ // Move to the last item on screen
+ accessibilityAdaptor->HandleActionMoveToLastEvent();
+ break;
+ }
+ case 28: // TwoFingersFlickLeftReturn
+ {
+ // Not exist yet
+ break;
+ }
+ case 29: // TwoFingersFlickRightReturn
+ {
+ // Not exist yet
+ break;
+ }
+ case 30: // TwoFingersFlickUpReturn
+ {
+ // Not exist yet
+ break;
+ }
+ case 31: // TwoFingersFlickDownReturn
+ {
+ // Not exist yet
+ break;
+ }
+ case 32: // ThreeFingersFlickLeftReturn
+ {
+ // Not exist yet
+ break;
+ }
+ case 33: // ThreeFingersFlickRightReturn
+ {
+ // Not exist yet
+ break;
+ }
+ case 34: // ThreeFingersFlickUpReturn
+ {
+ // Not exist yet
+ break;
+ }
+ case 35: // ThreeFingersFlickDownReturn
+ {
+ // Not exist yet
+ break;
+ }
+ }
+#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_APPS_MENU ) ) || // Only Apps menu (dali application) is shown
+ ( info & ( 1 << QUICKPANEL_TYPE_SYSTEM_DEFAULT ) ) ) // QuickPanel is shown
+ {
+ // dali apps should be disabled.
+ accessibilityAdaptor->DisableAccessibility();
+ }
+ else
+ {
+ // dali app should be enabled.
+ accessibilityAdaptor->EnableAccessibility();
+ }
+
+#endif
+}
+
void EventHandler::AddObserver( Observer& observer )
{
ObserverContainer::iterator match ( find(mObservers.begin(), mObservers.end(), &observer) );