X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali%2Finternal%2Fwindow-system%2Fcommon%2Fevent-handler.cpp;h=99f1796ce6a4bd39756aa2b906e39b14dcf342d9;hb=15cb030e9396d29dab2de0bd298c1daf810bcf5f;hp=c9eaa315459775ef3604a778885f9b8165a73c33;hpb=4b32c2ff33adaa23f8ae600380d7d7c246c1a9ad;p=platform%2Fcore%2Fuifw%2Fdali-adaptor.git diff --git a/dali/internal/window-system/common/event-handler.cpp b/dali/internal/window-system/common/event-handler.cpp index c9eaa31..99f1796 100755 --- a/dali/internal/window-system/common/event-handler.cpp +++ b/dali/internal/window-system/common/event-handler.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018 Samsung Electronics Co., Ltd. + * Copyright (c) 2019 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. @@ -32,10 +32,7 @@ #include // INTERNAL INCLUDES -#include #include -#include -#include #include #include @@ -51,16 +48,16 @@ namespace Adaptor #if defined(DEBUG_ENABLED) namespace { -Integration::Log::Filter* gTouchEventLogFilter = Integration::Log::Filter::New(Debug::NoLogging, false, "LOG_ADAPTOR_EVENTS_TOUCH"); Integration::Log::Filter* gSelectionEventLogFilter = Integration::Log::Filter::New(Debug::NoLogging, false, "LOG_ADAPTOR_EVENTS_SELECTION"); } // unnamed namespace #endif +#ifdef DALI_ELDBUS_AVAILABLE namespace { // Copied from x server -static unsigned int GetCurrentMilliSeconds(void) +static uint32_t GetCurrentMilliSeconds(void) { struct timeval tv; @@ -88,40 +85,32 @@ static unsigned int GetCurrentMilliSeconds(void) } if (clockid != ~0L && clock_gettime(clockid, &tp) == 0) { - return (tp.tv_sec * 1000) + (tp.tv_nsec / 1000000L); + return static_cast( (tp.tv_sec * 1000 ) + (tp.tv_nsec / 1000000L) ); } gettimeofday(&tv, NULL); - return (tv.tv_sec * 1000) + (tv.tv_usec / 1000); + return static_cast( (tv.tv_sec * 1000 ) + (tv.tv_usec / 1000) ); } } // unnamed namespace +#endif -EventHandler::EventHandler( RenderSurface* surface, CoreEventInterface& coreEventInterface, GestureManager& gestureManager, DamageObserver& damageObserver, DragAndDropDetectorPtr dndDetector ) -: mCoreEventInterface( coreEventInterface ), - mGestureManager( gestureManager ), - mStyleMonitor( StyleMonitor::Get() ), +EventHandler::EventHandler( WindowRenderSurface* surface, DamageObserver& damageObserver ) +: mStyleMonitor( StyleMonitor::Get() ), mDamageObserver( damageObserver ), - mRotationObserver( NULL ), - mDragAndDropDetector( dndDetector ), mAccessibilityAdaptor( AccessibilityAdaptor::Get() ), mClipboardEventNotifier( ClipboardEventNotifier::Get() ), mClipboard( Clipboard::Get() ), - mRotationAngle( 0 ), - mWindowWidth( 0 ), - mWindowHeight( 0 ), mPaused( false ) { - // this code only works with the WindowRenderSurface so need to downcast - WindowRenderSurface* windowRenderSurface = static_cast< WindowRenderSurface* >( surface ); - if( windowRenderSurface ) + if( surface ) { - WindowBase* windowBase = windowRenderSurface->GetWindowBase(); + WindowBase* windowBase = surface->GetWindowBase(); // Connect signals windowBase->WindowDamagedSignal().Connect( this, &EventHandler::OnWindowDamaged ); windowBase->FocusChangedSignal().Connect( this, &EventHandler::OnFocusChanged ); - windowBase->RotationSignal().Connect( this, &EventHandler::SendRotationPrepareEvent ); + windowBase->RotationSignal().Connect( this, &EventHandler::OnRotation ); windowBase->TouchEventSignal().Connect( this, &EventHandler::OnTouchEvent ); windowBase->WheelEventSignal().Connect( this, &EventHandler::OnWheelEvent ); windowBase->KeyEventSignal().Connect( this, &EventHandler::OnKeyEvent ); @@ -134,64 +123,6 @@ EventHandler::EventHandler( RenderSurface* surface, CoreEventInterface& coreEven EventHandler::~EventHandler() { - mGestureManager.Stop(); -} - -void EventHandler::SendEvent(Integration::Point& point, unsigned long timeStamp) -{ - if(timeStamp < 1) - { - timeStamp = GetCurrentMilliSeconds(); - } - - ConvertTouchPosition( point ); - - Integration::TouchEvent touchEvent; - Integration::HoverEvent hoverEvent; - Integration::TouchEventCombiner::EventDispatchType type = mCombiner.GetNextTouchEvent(point, timeStamp, touchEvent, hoverEvent); - 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); - - // First the touch and/or hover event & related gesture events are queued - if(type == Integration::TouchEventCombiner::DispatchTouch || type == Integration::TouchEventCombiner::DispatchBoth) - { - mCoreEventInterface.QueueCoreEvent( touchEvent ); - mGestureManager.SendEvent(touchEvent); - } - - if(type == Integration::TouchEventCombiner::DispatchHover || type == Integration::TouchEventCombiner::DispatchBoth) - { - mCoreEventInterface.QueueCoreEvent( hoverEvent ); - } - - // Next the events are processed with a single call into Core - mCoreEventInterface.ProcessCoreEvents(); - } -} - -void EventHandler::SendEvent(Integration::KeyEvent& keyEvent) -{ - Dali::PhysicalKeyboard physicalKeyboard = PhysicalKeyboard::Get(); - if ( physicalKeyboard ) - { - if ( ! KeyLookup::IsDeviceButton( keyEvent.keyName.c_str() ) ) - { - GetImplementation( physicalKeyboard ).KeyReceived( keyEvent.time > 1 ); - } - } - - // Create send KeyEvent to Core. - mCoreEventInterface.QueueCoreEvent( keyEvent ); - mCoreEventInterface.ProcessCoreEvents(); -} - -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 ); - mCoreEventInterface.ProcessCoreEvents(); } void EventHandler::SendEvent( StyleChange::Type styleChange ) @@ -205,100 +136,40 @@ void EventHandler::SendEvent( const DamageArea& area ) mDamageObserver.OnDamaged( area ); } -void EventHandler::SendRotationPrepareEvent( const RotationEvent& event ) -{ - if( mRotationObserver != NULL ) - { - mRotationAngle = event.angle; - mWindowWidth = event.width; - mWindowHeight = event.height; - - mRotationObserver->OnRotationPrepare( event ); - mRotationObserver->OnRotationRequest(); - } -} - -void EventHandler::SendRotationRequestEvent( ) -{ - // No need to separate event into prepare and request -} - -void EventHandler::FeedTouchPoint( TouchPoint& point, int timeStamp) -{ - Integration::Point convertedPoint( point ); - SendEvent(convertedPoint, timeStamp); -} - -void EventHandler::FeedWheelEvent( WheelEvent& wheelEvent ) -{ - SendWheelEvent( wheelEvent ); -} - -void EventHandler::FeedKeyEvent( KeyEvent& event ) -{ - Integration::KeyEvent convertedEvent( event ); - SendEvent( convertedEvent ); -} - -void EventHandler::FeedEvent( Integration::Event& event ) -{ - mCoreEventInterface.QueueCoreEvent( event ); - mCoreEventInterface.ProcessCoreEvents(); -} - -void EventHandler::Reset() -{ - mCombiner.Reset(); - - // Any touch listeners should be told of the interruption. - Integration::TouchEvent event; - Integration::Point point; - point.SetState( PointState::INTERRUPTED ); - event.AddPoint( point ); - - // First the touch event & related gesture events are queued - mCoreEventInterface.QueueCoreEvent( event ); - mGestureManager.SendEvent( event ); - - // Next the events are processed with a single call into Core - mCoreEventInterface.ProcessCoreEvents(); -} - void EventHandler::Pause() { mPaused = true; - Reset(); } void EventHandler::Resume() { mPaused = false; - Reset(); } -void EventHandler::SetDragAndDropDetector( DragAndDropDetectorPtr detector ) +void EventHandler::OnTouchEvent( Integration::Point& point, uint32_t timeStamp ) { - mDragAndDropDetector = detector; -} - -void EventHandler::SetRotationObserver( RotationObserver* observer ) -{ - mRotationObserver = observer; -} - -void EventHandler::OnTouchEvent( Integration::Point& point, unsigned long timeStamp ) -{ - SendEvent( point, timeStamp ); + for ( ObserverContainer::iterator iter = mObservers.begin(), endIter = mObservers.end(); iter != endIter; ++iter ) + { + (*iter)->OnTouchPoint( point, timeStamp ); + } } void EventHandler::OnWheelEvent( WheelEvent& wheelEvent ) { - SendWheelEvent( 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 ); + } } void EventHandler::OnKeyEvent( Integration::KeyEvent& keyEvent ) { - SendEvent( keyEvent ); + for ( ObserverContainer::iterator iter = mObservers.begin(), endIter = mObservers.end(); iter != endIter; ++iter ) + { + (*iter)->OnKeyEvent( keyEvent ); + } } void EventHandler::OnFocusChanged( bool focusIn ) @@ -324,6 +195,14 @@ void EventHandler::OnFocusChanged( bool focusIn ) } } +void EventHandler::OnRotation( const RotationEvent& event ) +{ + for ( ObserverContainer::iterator iter = mObservers.begin(), endIter = mObservers.end(); iter != endIter; ++iter ) + { + (*iter)->OnRotation( event ); + } +} + void EventHandler::OnWindowDamaged( const DamageArea& area ) { SendEvent( area ); @@ -533,7 +412,7 @@ void EventHandler::OnAccessibilityNotification( const WindowBase::AccessibilityI case 20: // TwoFingersTripleTap { // Read information from indicator - accessibilityAdaptor->HandleActionReadIndicatorInformationEvent(); + // Not supported break; } case 21: // ThreeFingersSingleTap @@ -621,39 +500,24 @@ void EventHandler::OnAccessibilityNotification( const WindowBase::AccessibilityI #endif } -void EventHandler::ConvertTouchPosition( Integration::Point& point ) +void EventHandler::AddObserver( Observer& observer ) { - Vector2 position = point.GetScreenPosition(); - Vector2 convertedPosition; + ObserverContainer::iterator match ( find(mObservers.begin(), mObservers.end(), &observer) ); - switch( mRotationAngle ) + if ( match == mObservers.end() ) { - case 90: - { - convertedPosition.x = mWindowWidth - position.y; - convertedPosition.y = position.x; - break; - } - case 180: - { - convertedPosition.x = mWindowWidth - position.x; - convertedPosition.y = mWindowHeight - position.y; - break; - } - case 270: - { - convertedPosition.x = position.y; - convertedPosition.y = mWindowHeight - position.x; - break; - } - default: - { - convertedPosition = position; - break; - } + mObservers.push_back( &observer ); } +} + +void EventHandler::RemoveObserver( Observer& observer ) +{ + ObserverContainer::iterator match ( find(mObservers.begin(), mObservers.end(), &observer) ); - point.SetScreenPosition( convertedPosition ); + if ( match != mObservers.end() ) + { + mObservers.erase( match ); + } } } // namespace Adaptor