#include <dali/integration-api/scene-holder-impl.h>
// EXTERNAL HEADERS
+#include <sys/time.h>
#include <dali/public-api/actors/actor.h>
#include <dali/public-api/actors/layer.h>
+#include <dali/integration-api/debug.h>
+#include <dali/integration-api/events/key-event-integ.h>
+#include <dali/integration-api/events/touch-event-integ.h>
+#include <dali/integration-api/events/hover-event-integ.h>
+#include <dali/integration-api/events/wheel-event-integ.h>
// INTERNAL HEADERS
#include <dali/internal/adaptor/common/adaptor-impl.h>
#include <dali/internal/adaptor/common/lifecycle-observer.h>
+#include <dali/internal/input/common/key-impl.h>
+#include <dali/internal/input/common/physical-keyboard-impl.h>
namespace Dali
{
namespace Adaptor
{
+namespace
+{
+
+#if defined(DEBUG_ENABLED)
+Integration::Log::Filter* gTouchEventLogFilter = Integration::Log::Filter::New(Debug::NoLogging, false, "LOG_ADAPTOR_EVENTS_TOUCH");
+#endif
+
+// Copied from x server
+static uint32_t GetCurrentMilliSeconds(void)
+{
+ struct timeval tv;
+
+ struct timespec tp;
+ static clockid_t clockid;
+
+ if (!clockid)
+ {
+#ifdef CLOCK_MONOTONIC_COARSE
+ if (clock_getres(CLOCK_MONOTONIC_COARSE, &tp) == 0 &&
+ (tp.tv_nsec / 1000) <= 1000 && clock_gettime(CLOCK_MONOTONIC_COARSE, &tp) == 0)
+ {
+ clockid = CLOCK_MONOTONIC_COARSE;
+ }
+ else
+#endif
+ if (clock_gettime(CLOCK_MONOTONIC, &tp) == 0)
+ {
+ clockid = CLOCK_MONOTONIC;
+ }
+ else
+ {
+ clockid = ~0L;
+ }
+ }
+ if (clockid != ~0L && clock_gettime(clockid, &tp) == 0)
+ {
+ return static_cast<uint32_t>( (tp.tv_sec * 1000 ) + (tp.tv_nsec / 1000000L) );
+ }
+
+ gettimeofday(&tv, NULL);
+ return static_cast<uint32_t>( (tv.tv_sec * 1000 ) + (tv.tv_usec / 1000) );
+}
+
+} // unnamed namespace
+
uint32_t SceneHolder::mSceneHolderCounter = 0;
class SceneHolder::SceneHolderLifeCycleObserver : public LifeCycleObserver
void SceneHolder::Pause()
{
+ Reset();
+
OnPause();
}
void SceneHolder::Resume()
{
+ Reset();
+
OnResume();
}
+void SceneHolder::FeedTouchPoint( Dali::Integration::Point& point, int timeStamp )
+{
+ if( timeStamp < 1 )
+ {
+ timeStamp = GetCurrentMilliSeconds();
+ }
+
+ RecalculateTouchPosition( 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 )
+ {
+ mScene.QueueEvent( touchEvent );
+ }
+
+ if( type == Integration::TouchEventCombiner::DispatchHover || type == Integration::TouchEventCombiner::DispatchBoth )
+ {
+ mScene.QueueEvent( hoverEvent );
+ }
+
+ // Next the events are processed with a single call into Core
+ mAdaptor->ProcessCoreEvents();
+ }
+}
+
+void SceneHolder::FeedWheelEvent( Dali::Integration::WheelEvent& wheelEvent )
+{
+ mScene.QueueEvent( wheelEvent );
+ mAdaptor->ProcessCoreEvents();
+}
+
+void SceneHolder::FeedKeyEvent( Dali::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.
+ mScene.QueueEvent( keyEvent );
+ mAdaptor->ProcessCoreEvents();
+}
+
+void SceneHolder::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
+ mScene.QueueEvent( event );
+
+ // Next the events are processed with a single call into Core
+ mAdaptor->ProcessCoreEvents();
+}
+
+
}// Adaptor
}// Internal
#include <dali/public-api/object/base-object.h>
#include <dali/public-api/common/intrusive-ptr.h>
#include <dali/integration-api/scene.h>
+#include <dali/integration-api/events/key-event-integ.h>
+#include <dali/integration-api/events/point.h>
+#include <dali/integration-api/events/touch-event-combiner.h>
// INTERNAL INCLUDES
-
#ifdef DALI_ADAPTOR_COMPILATION
#include <dali/integration-api/render-surface-interface.h>
#include <dali/integration-api/scene-holder.h>
{
class Scene;
+struct Point;
+struct KeyEvent;
+struct WheelEvent;
}
*/
void Resume();
-public: // The following methods can be overridden if required
-
/**
- * @brief Returns whether the Scene is visible or not.
- * @return True if the Scene is visible, false otherwise.
+ * @copydoc Dali::Integration::SceneHolder::FeedTouchPoint
*/
- virtual bool IsVisible() const;
-
-public: // The following methods must be overridden
+ void FeedTouchPoint( Dali::Integration::Point& point, int timeStamp );
/**
- * @copydoc Dali::Integration::SceneHolder::GetNativeHandle
+ * @copydoc Dali::Integration::SceneHolder::FeedWheelEvent
*/
- virtual Dali::Any GetNativeHandle() const = 0;
+ void FeedWheelEvent( Dali::Integration::WheelEvent& wheelEvent );
/**
- * @copydoc Dali::Integration::SceneHolder::FeedTouchPoint
+ * @copydoc Dali::Integration::SceneHolder::FeedKeyEvent
*/
- virtual void FeedTouchPoint( Dali::TouchPoint& point, int timeStamp ) = 0;
+ void FeedKeyEvent( Dali::Integration::KeyEvent& keyEvent );
+
+public: // The following methods can be overridden if required
/**
- * @copydoc Dali::Integration::SceneHolder::FeedWheelEvent
+ * @brief Returns whether the Scene is visible or not.
+ * @return True if the Scene is visible, false otherwise.
*/
- virtual void FeedWheelEvent( Dali::WheelEvent& wheelEvent ) = 0;
+ virtual bool IsVisible() const;
+
+public: // The following methods must be overridden
/**
- * @copydoc Dali::Integration::SceneHolder::FeedKeyEvent
+ * @copydoc Dali::Integration::SceneHolder::GetNativeHandle
*/
- virtual void FeedKeyEvent( Dali::KeyEvent& keyEvent ) = 0;
+ virtual Dali::Any GetNativeHandle() const = 0;
protected:
*/
virtual void OnResume() {};
+ /**
+ * Recalculate the touch position if required
+ * @param[in,out] point The touch point
+ */
+ virtual void RecalculateTouchPosition( Integration::Point& point ) {};
+
+private:
+
+ /**
+ * Resets the event handling.
+ */
+ void Reset();
+
private:
static uint32_t mSceneHolderCounter; ///< A counter to track the SceneHolder creation
std::unique_ptr< Dali::RenderSurfaceInterface > mSurface; ///< The window rendering surface
Adaptor* mAdaptor; ///< The adaptor
+ Dali::Integration::TouchEventCombiner mCombiner; ///< Combines multi-touch events.
+
bool mAdaptorStarted:1; ///< Whether the adaptor has started or not
bool mVisible:1; ///< Whether the scene is visible or not
};
// CLASS HEADER
#include <dali/integration-api/scene-holder.h>
+// EXTERNAL INCLUDES
+#include <dali/public-api/events/wheel-event.h>
+#include <dali/integration-api/events/key-event-integ.h>
+#include <dali/integration-api/events/touch-event-integ.h>
+#include <dali/integration-api/events/wheel-event-integ.h>
+
// INTERNAL INCLUDES
#include <dali/public-api/actors/layer.h>
#include <dali/integration-api/scene-holder-impl.h>
void SceneHolder::FeedTouchPoint( Dali::TouchPoint& point, int timeStamp )
{
- GetImplementation(*this).FeedTouchPoint( point, timeStamp );
+ Integration::Point convertedPoint( point );
+ GetImplementation(*this).FeedTouchPoint( convertedPoint, timeStamp );
}
void SceneHolder::FeedWheelEvent( Dali::WheelEvent& wheelEvent )
{
- GetImplementation(*this).FeedWheelEvent( wheelEvent );
+ Integration::WheelEvent event( static_cast< Integration::WheelEvent::Type >(wheelEvent.type), wheelEvent.direction, wheelEvent.modifiers, wheelEvent.point, wheelEvent.z, wheelEvent.timeStamp );
+ GetImplementation(*this).FeedWheelEvent( event );
}
void SceneHolder::FeedKeyEvent( Dali::KeyEvent& keyEvent )
{
- GetImplementation(*this).FeedKeyEvent( keyEvent );
+ Integration::KeyEvent convertedEvent( keyEvent );
+ GetImplementation(*this).FeedKeyEvent( convertedEvent );
}
}// Integration
#include <dali/integration-api/context-notifier.h>
#include <dali/integration-api/profiling.h>
#include <dali/integration-api/input-options.h>
+#include <dali/integration-api/events/key-event-integ.h>
#include <dali/integration-api/events/touch-event-integ.h>
+#include <dali/integration-api/events/wheel-event-integ.h>
#include <dali/integration-api/processor-interface.h>
// INTERNAL INCLUDES
void Adaptor::FeedTouchPoint( TouchPoint& point, int timeStamp )
{
- mWindows.front()->FeedTouchPoint( point, timeStamp );
+ Integration::Point convertedPoint( point );
+ mWindows.front()->FeedTouchPoint( convertedPoint, timeStamp );
}
void Adaptor::FeedWheelEvent( WheelEvent& wheelEvent )
{
- mWindows.front()->FeedWheelEvent( wheelEvent );
+ Integration::WheelEvent event( static_cast< Integration::WheelEvent::Type >(wheelEvent.type), wheelEvent.direction, wheelEvent.modifiers, wheelEvent.point, wheelEvent.z, wheelEvent.timeStamp );
+ mWindows.front()->FeedWheelEvent( event );
}
void Adaptor::FeedKeyEvent( KeyEvent& keyEvent )
{
- mWindows.front()->FeedKeyEvent( keyEvent );
+ Integration::KeyEvent convertedEvent( keyEvent );
+ mWindows.front()->FeedKeyEvent( convertedEvent );
}
void Adaptor::ReplaceSurface( Dali::Integration::SceneHolder window, Dali::RenderSurfaceInterface& newSurface )
return mLanguageChangedSignal;
}
-private: // From Dali::Internal::Adaptor::CoreEventInterface
+public: // From Dali::Internal::Adaptor::CoreEventInterface
/**
- * @copydoc Dali::Internal::Adaptor::CoreEventInterface::QueueCoreEvent()
+ * @copydoc Dali::Internal::Adaptor:CoreEventInterface:::ProcessCoreEvents()
*/
- virtual void QueueCoreEvent(const Dali::Integration::Event& event);
+ virtual void ProcessCoreEvents();
+
+private: // From Dali::Internal::Adaptor::CoreEventInterface
/**
- * @copydoc Dali::Internal::Adaptor:CoreEventInterface:::ProcessCoreEvents()
+ * @copydoc Dali::Internal::Adaptor::CoreEventInterface::QueueCoreEvent()
*/
- virtual void ProcessCoreEvents();
+ virtual void QueueCoreEvent(const Dali::Integration::Event& event);
private: // From Dali::Integration::RenderController
#include <dali/devel-api/adaptor-framework/singleton-service.h>
#include <dali/internal/adaptor/common/framework.h>
-#include <dali/internal/window-system/common/window-impl.h>
#include <dali/internal/system/common/environment-options.h>
#include <dali/internal/adaptor/common/adaptor-builder-impl.h>
// CLASS HEADER
#include <dali/internal/adaptor/tizen-wayland/tizen-wearable/watch-application-impl.h>
+
+// INTERNAL INCLUDES
+#include <dali/internal/adaptor/common/adaptor-impl.h>
#include <dali/internal/system/common/environment-variables.h>
namespace Dali
#include <dali/integration-api/events/touch-event-integ.h>
#include <dali/integration-api/events/hover-event-integ.h>
#include <dali/integration-api/events/wheel-event-integ.h>
-#include <dali/integration-api/scene.h>
// INTERNAL INCLUDES
#include <dali/internal/clipboard/common/clipboard-impl.h>
-#include <dali/internal/input/common/key-impl.h>
-#include <dali/internal/input/common/physical-keyboard-impl.h>
#include <dali/internal/styling/common/style-monitor-impl.h>
#include <dali/internal/window-system/common/window-render-surface.h>
#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
{
}
} // unnamed namespace
+#endif
-EventHandler::EventHandler( Dali::Integration::Scene scene, CoreEventInterface& coreEventInterface, DamageObserver& damageObserver )
-: mScene( scene ),
- mCoreEventInterface( coreEventInterface ),
- mStyleMonitor( StyleMonitor::Get() ),
+EventHandler::EventHandler( WindowRenderSurface* surface, DamageObserver& damageObserver )
+: mStyleMonitor( StyleMonitor::Get() ),
mDamageObserver( damageObserver ),
- mRotationObserver( NULL ),
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* >( scene.GetSurface() );
- 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 );
{
}
-void EventHandler::SendEvent( Integration::Point& point, uint32_t 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 )
- {
- mScene.QueueEvent( touchEvent );
- }
-
- if( type == Integration::TouchEventCombiner::DispatchHover || type == Integration::TouchEventCombiner::DispatchBoth )
- {
- mScene.QueueEvent( 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.
- mScene.QueueEvent( 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 );
-
- mScene.QueueEvent( event );
- mCoreEventInterface.ProcessCoreEvents();
-}
-
void EventHandler::SendEvent( StyleChange::Type styleChange )
{
DALI_ASSERT_DEBUG( mStyleMonitor && "StyleMonitor Not Available" );
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, uint32_t 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 )
-{
- mScene.QueueEvent( 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
- mScene.QueueEvent( 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::SetRotationObserver( RotationObserver* observer )
-{
- mRotationObserver = observer;
}
void EventHandler::OnTouchEvent( Integration::Point& point, uint32_t 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 )
}
}
+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 );
#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 = static_cast<float>( mWindowWidth ) - position.y;
- convertedPosition.y = position.x;
- break;
- }
- case 180:
- {
- convertedPosition.x = static_cast<float>( mWindowWidth ) - position.x;
- convertedPosition.y = static_cast<float>( mWindowHeight ) - position.y;
- break;
- }
- case 270:
- {
- convertedPosition.x = position.y;
- convertedPosition.y = static_cast<float>( 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
#include <cstdint> // uint32_t
#include <dali/public-api/common/intrusive-ptr.h>
-#include <dali/integration-api/events/key-event-integ.h>
-#include <dali/integration-api/events/point.h>
-#include <dali/integration-api/events/touch-event-combiner.h>
#include <dali/devel-api/adaptor-framework/clipboard.h>
#include <dali/devel-api/adaptor-framework/style-monitor.h>
// INTERNAL INCLUDES
#include <dali/internal/accessibility/common/accessibility-adaptor-impl.h>
#include <dali/internal/clipboard/common/clipboard-event-notifier-impl.h>
-#include <dali/internal/system/common/core-event-interface.h>
#include <dali/internal/window-system/common/damage-observer.h>
-#include <dali/internal/window-system/common/rotation-observer.h>
#include <dali/internal/window-system/common/window-base.h>
namespace Dali
namespace Integration
{
-class RenderSurface;
-class Scene;
+struct Point;
+struct KeyEvent;
+struct WheelEvent;
+
}
namespace Internal
namespace Adaptor
{
-class GestureManager;
class StyleMonitor;
+class WindowRenderSurface;
/**
* The Event Handler class is responsible for setting up receiving of Ecore events and then converts them
public:
/**
- * Constructor.
- * @param[in] scene The scene where events will be sent to.
- * @param[in] coreEventInterface Used to send events to Core.
- * @param[in] damageObserver The damage observer (to pass damage events to).
+ * The observer can be overridden in order to listen to the events.
*/
- EventHandler( Dali::Integration::Scene scene, CoreEventInterface& coreEventInterface, DamageObserver& damageObserver );
+ class Observer
+ {
+ public:
- /**
- * Destructor.
- */
- ~EventHandler();
+ /**
+ * Deriving classes should override this to be notified when we receive a touch point event.
+ * @param[in] point The touch point
+ * @param[in] timeStamp The time stamp
+ */
+ virtual void OnTouchPoint( Dali::Integration::Point& point, int timeStamp ) = 0;
- /**
- * Feed (Send) touch event to core and gesture manager
- * @param[in] touchEvent The touch event holding the touch point information.
- */
- void FeedTouchPoint( TouchPoint& point, uint32_t timeStamp );
+ /**
+ * Deriving classes should override this to be notified when we receive a wheel event.
+ * @param[in] wheelEvent The wheel event
+ */
+ virtual void OnWheelEvent( Dali::Integration::WheelEvent& wheelEvent ) = 0;
- /**
- * Feed (Send) wheel event to core and gesture manager
- * @param[in] wheelEvent The wheel event
- */
- void FeedWheelEvent( WheelEvent& wheelEvent );
+ /**
+ * Deriving classes should override this to be notified when we receive a key event.
+ * @param[in] keyEvent The key event holding the key information.
+ */
+ virtual void OnKeyEvent( Dali::Integration::KeyEvent& keyEvent ) = 0;
+
+ /**
+ * Deriving classes should override this to be notified when the window is rotated.
+ * @param[in] rotation The rotation event.
+ */
+ virtual void OnRotation( const RotationEvent& rotation ) = 0;
+
+ protected:
+
+ /**
+ * Protected Constructor.
+ */
+ Observer() {}
+
+ /**
+ * Protected virtual destructor.
+ */
+ virtual ~Observer() {}
+ };
+
+public:
/**
- * Feed (Send) key event to core
- * @param[in] keyEvent The key event holding the key information.
+ * Constructor.
+ * @param[in] surface The render surface of the window.
+ * @param[in] damageObserver The damage observer (to pass damage events to).
*/
- void FeedKeyEvent( KeyEvent& keyEvent );
+ EventHandler( WindowRenderSurface* surface, DamageObserver& damageObserver );
/**
- * Feed (Send) an event to core
- * @param[in] event The event information.
+ * Destructor.
*/
- void FeedEvent( Integration::Event& event );
+ ~EventHandler();
/**
* Called when the adaptor is paused.
void Resume();
/**
- * Set the rotation observer (note, some adaptors may not have a rotation observer)
- * @param[in] observer The rotation observer
- */
- void SetRotationObserver( RotationObserver* observer );
-
-private:
-
- /**
- * Send touch event to core.
- * @param[in] point The touch point information.
- * @param[in] timeStamp The time the touch occurred.
+ * Adds an observer so that we can observe the events.
+ * @param[in] observer The observer.
*/
- void SendEvent(Integration::Point& point, uint32_t timeStamp);
+ void AddObserver( Observer& observer );
/**
- * Send key event to core.
- * @param[in] keyEvent The KeyEvent to send.
+ * Removes the observer from the EventHandler.
+ * @param[in] observer The observer to remove.
+ * @note Observers should remove themselves when they are destroyed.
*/
- void SendEvent(Integration::KeyEvent& keyEvent);
+ void RemoveObserver( Observer& observer );
- /**
- * Send wheel event to core.
- * @param[in] wheelEvent The wheel event
- */
- void SendWheelEvent( WheelEvent& wheelEvent );
+private:
/**
* Send a style change event to the style monitor.
void SendEvent( const DamageArea& area );
/**
- * Inform rotation observer of rotation prepare event
- * @param[in] rotation The rotation event
- */
- void SendRotationPrepareEvent( const RotationEvent& rotation );
-
- /**
- * Inform rotation observer of rotation prepare event
- */
- void SendRotationRequestEvent();
-
- /**
- * Resets the event handler.
- * Called when the adaptor is paused or resumed.
- */
- void Reset();
-
- /**
* Called when a touch event is received.
*/
void OnTouchEvent( Integration::Point& point, uint32_t timeStamp );
void OnFocusChanged( bool focusIn );
/**
+ * Called when the window is rotated.
+ * @param[in] event The rotation event
+ */
+ void OnRotation( const RotationEvent& event );
+
+ /**
* Called when the window is damaged.
*/
void OnWindowDamaged( const DamageArea& area );
private:
- /**
- * Convert touch event position
- */
- void ConvertTouchPosition( Integration::Point& point );
-
-private:
-
// Undefined
EventHandler( const EventHandler& eventHandler );
private:
- Dali::Integration::Scene mScene; ///< The scene the event handler is created for.
- CoreEventInterface& mCoreEventInterface; ///< Used to send events to Core.
- Dali::Integration::TouchEventCombiner mCombiner; ///< Combines multi-touch events.
Dali::StyleMonitor mStyleMonitor; ///< Handle to the style monitor, set on construction, to send font size and font change events to.
DamageObserver& mDamageObserver; ///< Reference to the DamageObserver, set on construction, to sent damage events to.
- RotationObserver* mRotationObserver; ///< Pointer to rotation observer, if present.
Dali::AccessibilityAdaptor mAccessibilityAdaptor; ///< Pointer to the accessibility adaptor
Dali::ClipboardEventNotifier mClipboardEventNotifier; ///< Pointer to the clipboard event notifier
Dali::Clipboard mClipboard;///< Pointer to the clipboard
- int mRotationAngle;
- int mWindowWidth;
- int mWindowHeight;
+ using ObserverContainer = std::vector<Observer*>;
+ ObserverContainer mObservers; ///< A list of event observer pointers
bool mPaused; ///< The paused state of the adaptor.
};
/*
- * Copyright (c) 2017 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.
return mChangedSignal;
}
-void Orientation::OnRotationPrepare( const RotationEvent& rotation )
+void Orientation::OnOrientationChange( const RotationEvent& rotation )
{
mOrientation = rotation.angle;
mWindowWidth = rotation.width;
mWindowHeight = rotation.height;
-}
-void Orientation::OnRotationRequest()
-{
// Emit signal
if( !mChangedSignal.Empty() )
{
Dali::Orientation handle( this );
mChangedSignal.Emit( handle );
}
-
- if( mWindow != NULL )
- {
- mWindow->RotationDone( mOrientation, mWindowWidth, mWindowHeight );
- }
}
} // namespace Adaptor
// INTERNAL INCLUDES
#include <dali/devel-api/adaptor-framework/orientation.h>
-#include <dali/internal/window-system/common/rotation-observer.h>
+#include <dali/internal/window-system/common/rotation-event.h>
namespace Dali
{
typedef IntrusivePtr<Orientation> OrientationPtr;
-class Orientation : public BaseObject, public RotationObserver
+class Orientation : public BaseObject
{
public:
*/
float GetRadians() const;
+ /**
+ * Called by the Window when orientation is changed
+ * @param[in] rotation The rotation event
+ */
+ void OnOrientationChange( const RotationEvent& rotation );
+
public: // Signals
/**
OrientationSignalType& ChangedSignal();
private:
- /**
- * @copydoc Dali::Internal::Adaptor::RotationObserver::OnRotationPrepare()
- */
- virtual void OnRotationPrepare( const RotationEvent& rotation );
-
- /**
- * @copydoc Dali::Internal::Adaptor::RotationObserver::OnRotationRequest()
- */
- virtual void OnRotationRequest( );
// Undefined
Orientation(const Orientation&);
Orientation& operator=(Orientation&);
private:
- /**
- * Signals and sends event of orientation change.
- */
- void EmitOrientationChange();
-
-private:
Window* mWindow;
-#ifndef DALI_INTERNAL_ROTATION_OBSERVER_H
-#define DALI_INTERNAL_ROTATION_OBSERVER_H
+#ifndef DALI_INTERNAL_ROTATION_EVENT_H
+#define DALI_INTERNAL_ROTATION_EVENT_H
/*
* Copyright (c) 2019 Samsung Electronics Co., Ltd.
int height; ///< new window height
};
-
-/**
- * The RotationObserver can be overridden in order to listen to rotation events.
- */
-class RotationObserver
-{
-public:
-
- /**
- * Deriving classes should override this to be notified when we receive a RotationPrepare event.
- * @param[in] area The area that has been rotationd.
- */
- virtual void OnRotationPrepare( const RotationEvent& rotation ) = 0;
-
- /**
- * Deriving classes should override this to be notifed when a RotationRequest event is received
- */
- virtual void OnRotationRequest( ) = 0;
-
-protected:
-
- /**
- * Protected Constructor.
- */
- RotationObserver()
- {
- }
-
- /**
- * Protected virtual destructor.
- */
- virtual ~RotationObserver()
- {
- }
-};
-
} // namespace Adaptor
} // namespace Internal
} // namespace Dali
-#endif // DALI_INTERNAL_ROTATION_OBSERVER_H
+#endif // DALI_INTERNAL_ROTATION_EVENT_H
*
*/
-// INTERNAL INCLUDES
-#include <dali/public-api/adaptor-framework/window.h>
-#include <dali/public-api/adaptor-framework/key-grab.h>
-#include <dali/public-api/adaptor-framework/style-change.h>
-#include <dali/internal/window-system/common/damage-observer.h>
-#include <dali/internal/window-system/common/rotation-observer.h>
-#include <dali/internal/graphics/gles/egl-implementation.h>
-
// EXTERNAL INCLUDES
#include <dali/integration-api/events/key-event-integ.h>
#include <dali/integration-api/events/point.h>
#include <vector>
#include <cstdint>
+// INTERNAL INCLUDES
+#include <dali/public-api/adaptor-framework/window.h>
+#include <dali/public-api/adaptor-framework/key-grab.h>
+#include <dali/public-api/adaptor-framework/style-change.h>
+#include <dali/internal/window-system/common/damage-observer.h>
+#include <dali/internal/window-system/common/rotation-event.h>
+#include <dali/internal/graphics/gles/egl-implementation.h>
+
namespace Dali
{
namespace Internal
#include <dali/public-api/render-tasks/render-task-list.h>
#include <dali/public-api/rendering/frame-buffer.h>
#include <dali/devel-api/adaptor-framework/orientation.h>
+#include <dali/integration-api/events/touch-event-integ.h>
#ifdef DALI_ADAPTOR_COMPILATION
#include <dali/integration-api/render-surface-interface.h>
mResizeEnabled( false ),
mType( Dali::Window::NORMAL ),
mPreferredOrientation( Dali::Window::PORTRAIT ),
+ mRotationAngle( 0 ),
+ mWindowWidth( 0 ),
+ mWindowHeight( 0 ),
mFocusChangedSignal(),
mResizedSignal(),
mDeleteRequestSignal()
{
if ( mEventHandler )
{
- mEventHandler->SetRotationObserver( nullptr );
+ mEventHandler->RemoveObserver( *this );
}
}
void Window::OnAdaptorSet(Dali::Adaptor& adaptor)
{
- mEventHandler = EventHandlerPtr(new EventHandler( mScene, *mAdaptor, *mAdaptor ) );
-
- // TODO: Orientation should be passed into the constructor of EventHandler
- if( mOrientation )
- {
- SetRotationObserver( &(*mOrientation) );
- }
+ mEventHandler = EventHandlerPtr(new EventHandler( mWindowSurface, *mAdaptor ) );
+ mEventHandler->AddObserver( *this );
}
void Window::OnSurfaceSet( Dali::RenderSurfaceInterface* surface )
return mWindowBase->UngrabKeyList( key, result );
}
-void Window::RotationDone( int orientation, int width, int height )
-{
- mWindowSurface->RequestRotation( orientation, width, height );
-
- mAdaptor->SurfaceResizePrepare( mSurface.get(), Adaptor::SurfaceSize( width, height ) );
-
- // Emit signal
- mResizedSignal.Emit( Dali::Window::WindowSize( width, height ) );
-
- mAdaptor->SurfaceResizeComplete( mSurface.get(), Adaptor::SurfaceSize( width, height ) );
-}
-
void Window::OnIconifyChanged( bool iconified )
{
if( iconified )
mDeleteRequestSignal.Emit();
}
-void Window::FeedTouchPoint( TouchPoint& point, int timeStamp )
+void Window::OnTouchPoint( Dali::Integration::Point& point, int timeStamp )
{
- if( mEventHandler )
- {
- mEventHandler->FeedTouchPoint( point, timeStamp );
- }
+ FeedTouchPoint( point, timeStamp );
}
-void Window::FeedWheelEvent( WheelEvent& wheelEvent )
+void Window::OnWheelEvent( Dali::Integration::WheelEvent& wheelEvent )
{
- if( mEventHandler )
- {
- mEventHandler->FeedWheelEvent( wheelEvent );
- }
+ FeedWheelEvent( wheelEvent );
}
-void Window::FeedKeyEvent( KeyEvent& keyEvent )
+void Window::OnKeyEvent( Dali::Integration::KeyEvent& keyEvent )
{
- if( mEventHandler )
- {
- mEventHandler->FeedKeyEvent( keyEvent );
- }
+ FeedKeyEvent( keyEvent );
+}
+
+void Window::OnRotation( const RotationEvent& rotation )
+{
+ mRotationAngle = rotation.angle;
+ mWindowWidth = rotation.width;
+ mWindowHeight = rotation.height;
+
+ // Notify that the orientation is changed
+ mOrientation->OnOrientationChange( rotation );
+
+ mWindowSurface->RequestRotation( mRotationAngle, mWindowWidth, mWindowHeight );
+
+ mAdaptor->SurfaceResizePrepare( mSurface.get(), Adaptor::SurfaceSize( mRotationAngle, mWindowHeight ) );
+
+ // Emit signal
+ mResizedSignal.Emit( Dali::Window::WindowSize( mRotationAngle, mWindowHeight ) );
+
+ mAdaptor->SurfaceResizeComplete( mSurface.get(), Adaptor::SurfaceSize( mRotationAngle, mWindowHeight ) );
}
void Window::OnPause()
}
}
-bool Window::SetRotationObserver( RotationObserver* observer )
+void Window::RecalculateTouchPosition( Integration::Point& point )
{
- if( mEventHandler )
+ Vector2 position = point.GetScreenPosition();
+ Vector2 convertedPosition;
+
+ switch( mRotationAngle )
{
- mEventHandler->SetRotationObserver( observer );
- return true;
+ case 90:
+ {
+ convertedPosition.x = static_cast<float>( mWindowWidth ) - position.y;
+ convertedPosition.y = position.x;
+ break;
+ }
+ case 180:
+ {
+ convertedPosition.x = static_cast<float>( mWindowWidth ) - position.x;
+ convertedPosition.y = static_cast<float>( mWindowHeight ) - position.y;
+ break;
+ }
+ case 270:
+ {
+ convertedPosition.x = position.y;
+ convertedPosition.y = static_cast<float>( mWindowHeight ) - position.x;
+ break;
+ }
+ default:
+ {
+ convertedPosition = position;
+ break;
+ }
}
- return false;
+ point.SetScreenPosition( convertedPosition );
}
Dali::Window Window::Get( Dali::Actor actor )
#include <dali/public-api/adaptor-framework/window.h>
#include <dali/public-api/adaptor-framework/key-grab.h>
#include <dali/devel-api/adaptor-framework/window-devel.h>
+#include <dali/internal/window-system/common/event-handler.h>
namespace Dali
{
{
namespace Adaptor
{
-class EventHandler;
class Orientation;
-class RotationObserver;
class WindowRenderSurface;
class WindowBase;
/**
* Window provides a surface to render onto with orientation & indicator properties.
*/
-class Window : public Dali::Internal::Adaptor::SceneHolder, public ConnectionTracker
+class Window : public Dali::Internal::Adaptor::SceneHolder, public EventHandler::Observer, public ConnectionTracker
{
public:
typedef Dali::Window::IndicatorSignalType IndicatorSignalType;
bool UngrabKeyList( const Dali::Vector< Dali::KEY >& key, Dali::Vector< bool >& result );
/**
- * Called from Orientation after the Change signal has been sent
- */
- void RotationDone( int orientation, int width, int height );
-
- /**
- * Set the rotation observer (note, some adaptors may not have a rotation observer)
- * @param[in] observer The rotation observer
- * @return If the rotation observer is set
- */
- bool SetRotationObserver( RotationObserver* observer );
-
- /**
* @copydoc Dali::DevelWindow::Get()
*/
static Dali::Window Get( Dali::Actor actor );
private: // Dali::Internal::Adaptor::SceneHolder
/**
- * @copydoc Dali::Internal::Adaptor::SceneHolder::FeedTouchPoint
+ * @copydoc Dali::Internal::Adaptor::SceneHolder::OnAdaptorSet
*/
- void FeedTouchPoint( TouchPoint& point, int timeStamp ) override;
+ void OnAdaptorSet( Dali::Adaptor& adaptor ) override;
/**
- * @copydoc Dali::Internal::Adaptor::SceneHolder::FeedWheelEvent
+ * @copydoc Dali::Internal::Adaptor::SceneHolder::OnSurfaceSet
*/
- void FeedWheelEvent( WheelEvent& wheelEvent ) override;
+ void OnSurfaceSet( Dali::RenderSurfaceInterface* surface ) override;
/**
- * @copydoc Dali::Internal::Adaptor::SceneHolder::FeedKeyEvent
+ * @copydoc Dali::Internal::Adaptor::SceneHolder::OnPause
*/
- void FeedKeyEvent( KeyEvent& keyEvent ) override;
+ void OnPause() override;
/**
- * @copydoc Dali::Internal::Adaptor::SceneHolder::OnAdaptorSet
+ * @copydoc Dali::Internal::Adaptor::SceneHolder::OnResume
*/
- void OnAdaptorSet( Dali::Adaptor& adaptor ) override;
+ void OnResume() override;
/**
- * @copydoc Dali::Internal::Adaptor::SceneHolder::OnSurfaceSet
+ * @copydoc Dali::Internal::Adaptor::SceneHolder::RecalculateTouchPosition
*/
- void OnSurfaceSet( Dali::RenderSurfaceInterface* surface ) override;
+ void RecalculateTouchPosition( Integration::Point& point ) override;
+
+private: // Dali::Internal::Adaptor::EventHandler::Observer
/**
- * @copydoc Dali::Internal::Adaptor::SceneHolder::OnPause
+ * @copydoc Dali::Internal::Adaptor::EventHandler::Observer::OnTouchPoint
*/
- void OnPause() override;
+ void OnTouchPoint( Dali::Integration::Point& point, int timeStamp ) override;
/**
- * @copydoc Dali::Internal::Adaptor::SceneHolder::OnResume
+ * @copydoc Dali::Internal::Adaptor::EventHandler::Observer::OnWheelEvent
*/
- void OnResume() override;
+ void OnWheelEvent( Dali::Integration::WheelEvent& wheelEvent ) override;
+
+ /**
+ * @copydoc Dali::Internal::Adaptor::EventHandler::Observer::OnKeyEvent
+ */
+ void OnKeyEvent( Dali::Integration::KeyEvent& keyEvent ) override;
+
+ /**
+ * @copydoc Dali::Internal::Adaptor::EventHandler::Observer::OnRotation
+ */
+ void OnRotation( const RotationEvent& rotation ) override;
public: // Signals
std::vector<Dali::Window::WindowOrientation> mAvailableOrientations;
Dali::Window::WindowOrientation mPreferredOrientation;
+ int mRotationAngle; ///< The angle of the rotation
+ int mWindowWidth; ///< The width of the window
+ int mWindowHeight; ///< The height of the window
+
EventHandlerPtr mEventHandler; ///< The window events handler
// Signals
// INTERNAL INCLUDES
#include <dali/public-api/actors/actor.h>
-#include <dali/internal/adaptor/common/adaptor-impl.h>
#include <dali/internal/window-system/common/window-impl.h>
#include <dali/internal/window-system/common/orientation-impl.h>