X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali%2Finternal%2Fevent%2Fevents%2Fevent-processor.cpp;h=ff6007b13617fedc1ee679ad0cca993995e6fc8e;hb=4dff9e72216170bca91db1d28fd411dc4d4b07f8;hp=560b48a8b969448231d6fece8d6fa9580fc6e020;hpb=ebe1a7337f5b09ac1f7616fbc61a67a30dddabf2;p=platform%2Fcore%2Fuifw%2Fdali-core.git diff --git a/dali/internal/event/events/event-processor.cpp b/dali/internal/event/events/event-processor.cpp index 560b48a..ff6007b 100644 --- a/dali/internal/event/events/event-processor.cpp +++ b/dali/internal/event/events/event-processor.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 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. @@ -21,15 +21,10 @@ // INTERNAL INCLUDES #include #include -#include #include #include #include #include -#include -#include -#include -#include #include #include #include @@ -46,8 +41,7 @@ namespace // unnamed namespace { static const std::size_t MAX_MESSAGE_SIZE = std::max( sizeof(Integration::TouchEvent), - std::max( sizeof(Integration::KeyEvent), - std::max( sizeof(Integration::WheelEvent), sizeof(Integration::GestureEvent) ) ) ); + std::max( sizeof(Integration::KeyEvent), sizeof(Integration::WheelEvent) ) ); static const std::size_t INITIAL_MIN_CAPACITY = 4; @@ -55,12 +49,13 @@ static const std::size_t INITIAL_BUFFER_SIZE = MAX_MESSAGE_SIZE * INITIAL_MIN_CA } // unnamed namespace -EventProcessor::EventProcessor(Stage& stage, NotificationManager& /* notificationManager */, GestureEventProcessor& gestureEventProcessor) -: mTouchEventProcessor(stage), - mHoverEventProcessor(stage), - mGestureEventProcessor(gestureEventProcessor), - mKeyEventProcessor(stage), - mWheelEventProcessor(stage), +EventProcessor::EventProcessor( Scene& scene, GestureEventProcessor& gestureEventProcessor ) +: mScene( scene ), + mTouchEventProcessor( scene ), + mHoverEventProcessor( scene ), + mGestureEventProcessor( gestureEventProcessor ), + mKeyEventProcessor( scene ), + mWheelEventProcessor( scene ), mEventQueue0( INITIAL_BUFFER_SIZE ), mEventQueue1( INITIAL_BUFFER_SIZE ), mCurrentEventQueue( &mEventQueue0 ) @@ -93,7 +88,7 @@ void EventProcessor::QueueEvent( const Event& event ) typedef Integration::TouchEvent DerivedType; // Reserve some memory inside the message queue - unsigned int* slot = mCurrentEventQueue->ReserveMessageSlot( sizeof( DerivedType ) ); + uint32_t* slot = mCurrentEventQueue->ReserveMessageSlot( sizeof( DerivedType ) ); // Construct message in the message queue memory; note that delete should not be called on the return value new (slot) DerivedType( static_cast(event) ); @@ -103,10 +98,10 @@ void EventProcessor::QueueEvent( const Event& event ) case Event::Hover: { - typedef Integration::HoverEvent DerivedType; + using DerivedType = Integration::HoverEvent; // Reserve some memory inside the message queue - unsigned int* slot = mCurrentEventQueue->ReserveMessageSlot( sizeof( DerivedType ) ); + uint32_t* slot = mCurrentEventQueue->ReserveMessageSlot( sizeof( DerivedType ) ); // Construct message in the message queue memory; note that delete should not be called on the return value new (slot) DerivedType( static_cast(event) ); @@ -116,10 +111,10 @@ void EventProcessor::QueueEvent( const Event& event ) case Event::Key: { - typedef Integration::KeyEvent DerivedType; + using DerivedType = Integration::KeyEvent; // Reserve some memory inside the message queue - unsigned int* slot = mCurrentEventQueue->ReserveMessageSlot( sizeof( DerivedType ) ); + uint32_t* slot = mCurrentEventQueue->ReserveMessageSlot( sizeof( DerivedType ) ); // Construct message in the message queue memory; note that delete should not be called on the return value new (slot) DerivedType( static_cast(event) ); @@ -129,75 +124,10 @@ void EventProcessor::QueueEvent( const Event& event ) case Event::Wheel: { - typedef Integration::WheelEvent DerivedType; + using DerivedType = Integration::WheelEvent; // Reserve some memory inside the message queue - unsigned int* slot = mCurrentEventQueue->ReserveMessageSlot( sizeof( DerivedType ) ); - - // Construct message in the message queue memory; note that delete should not be called on the return value - new (slot) DerivedType( static_cast(event) ); - - break; - } - - case Event::Gesture: - { - QueueGestureEvent( static_cast(event) ); - break; - } - - } -} - -void EventProcessor::QueueGestureEvent(const Integration::GestureEvent& event) -{ - switch( event.gestureType ) - { - case Gesture::Pinch: - { - typedef Integration::PinchGestureEvent DerivedType; - - // Reserve some memory inside the message queue - unsigned int* slot = mCurrentEventQueue->ReserveMessageSlot( sizeof( DerivedType ) ); - - // Construct message in the message queue memory; note that delete should not be called on the return value - new (slot) DerivedType( static_cast(event) ); - - break; - } - - case Gesture::Pan: - { - typedef Integration::PanGestureEvent DerivedType; - - // Reserve some memory inside the message queue - unsigned int* slot = mCurrentEventQueue->ReserveMessageSlot( sizeof( DerivedType ) ); - - // Construct message in the message queue memory; note that delete should not be called on the return value - new (slot) DerivedType( static_cast(event) ); - - break; - } - - case Gesture::Tap: - { - typedef Integration::TapGestureEvent DerivedType; - - // Reserve some memory inside the message queue - unsigned int* slot = mCurrentEventQueue->ReserveMessageSlot( sizeof( DerivedType ) ); - - // Construct message in the message queue memory; note that delete should not be called on the return value - new (slot) DerivedType( static_cast(event) ); - - break; - } - - case Gesture::LongPress: - { - typedef Integration::LongPressGestureEvent DerivedType; - - // Reserve some memory inside the message queue - unsigned int* slot = mCurrentEventQueue->ReserveMessageSlot( sizeof( DerivedType ) ); + uint32_t* slot = mCurrentEventQueue->ReserveMessageSlot( sizeof( DerivedType ) ); // Construct message in the message queue memory; note that delete should not be called on the return value new (slot) DerivedType( static_cast(event) ); @@ -212,7 +142,7 @@ void EventProcessor::ProcessEvents() MessageBuffer* queueToProcess = mCurrentEventQueue; // Switch current queue; events can be added safely while iterating through the other queue. - mCurrentEventQueue = (&mEventQueue0 == mCurrentEventQueue) ? &mEventQueue1 : &mEventQueue0; + mCurrentEventQueue = ( &mEventQueue0 == mCurrentEventQueue ) ? &mEventQueue1 : &mEventQueue0; for( MessageBuffer::Iterator iter = queueToProcess->Begin(); iter.IsValid(); iter.Next() ) { @@ -222,7 +152,18 @@ void EventProcessor::ProcessEvents() { case Event::Touch: { - mTouchEventProcessor.ProcessTouchEvent( static_cast(*event) ); + Integration::TouchEvent& touchEvent = static_cast(*event); + const bool consumed = mTouchEventProcessor.ProcessTouchEvent( touchEvent ); + + // If touch is consumed, then gestures should be cancelled + // Do this by sending an interrupted event to the GestureEventProcessor + if( consumed ) + { + Integration::Point& point = touchEvent.GetPoint(0); + point.SetState( PointState::INTERRUPTED ); + } + + mGestureEventProcessor.ProcessTouchEvent(mScene, touchEvent); break; } @@ -243,13 +184,6 @@ void EventProcessor::ProcessEvents() mWheelEventProcessor.ProcessWheelEvent( static_cast(*event) ); break; } - - case Event::Gesture: - { - mGestureEventProcessor.ProcessGestureEvent( static_cast(*event) ); - break; - } - } // Call virtual destructor explictly; since delete will not be called after placement new event->~Event();