X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=adaptors%2Fecore%2Fcommon%2Fecore-indicator-impl.cpp;h=6eaefb9a93075064bfdcc05685ac42675f81e07c;hb=e83b0793131adcfc5b9a92239ba8403db5febb47;hp=b33cd12cea7900a1ad2c8ca4e709455cea49e106;hpb=615875ce81de0c2006a82c028c7279f0beb936e3;p=platform%2Fcore%2Fuifw%2Fdali-adaptor.git diff --git a/adaptors/ecore/common/ecore-indicator-impl.cpp b/adaptors/ecore/common/ecore-indicator-impl.cpp index b33cd12..6eaefb9 100644 --- a/adaptors/ecore/common/ecore-indicator-impl.cpp +++ b/adaptors/ecore/common/ecore-indicator-impl.cpp @@ -21,7 +21,9 @@ // EXTERNAL INCLUDES #include #include -#ifndef WAYLAND +#ifdef WAYLAND +#include +#else #include #endif @@ -32,11 +34,8 @@ #include #include -#include -#include +#include #include -#include -#include #include #include @@ -253,9 +252,9 @@ struct IpcDataEvMouseMove unsigned int timestamp; Evas_Event_Flags event_flags; - IpcDataEvMouseMove(const Dali::TouchPoint& touchPoint, unsigned long timestamp) - : x(static_cast(touchPoint.local.x)), - y(static_cast(touchPoint.local.y)), + IpcDataEvMouseMove(const Dali::TouchData& touchData, unsigned long timestamp) + : x(static_cast(touchData.GetLocalPosition( 0 ).x)), + y(static_cast(touchData.GetLocalPosition( 0 ).y)), flags(EVAS_BUTTON_NONE), mask(0), timestamp(static_cast(timestamp)), @@ -291,11 +290,15 @@ namespace Adaptor Debug::Filter* gIndicatorLogFilter = Debug::Filter::New(Debug::Concise, false, "LOG_INDICATOR"); #endif -#ifndef WAYLAND // Impl to hide EFL implementation. + struct Indicator::Impl { - // Construction & Destruction + enum // operation mode + { + INDICATOR_HIDE, + INDICATOR_STAY_WITH_DURATION + }; /** * Constructor @@ -304,8 +307,13 @@ struct Indicator::Impl : mIndicator(indicator), mEcoreEventHandler(NULL) { - // Register Client message events for quick panel state. +#if defined(DALI_PROFILE_MOBILE) +#if defined(WAYLAND) + mEcoreEventHandler = ecore_event_handler_add(ECORE_WL_EVENT_INDICATOR_FLICK, EcoreEventIndicator, this); +#else mEcoreEventHandler = ecore_event_handler_add(ECORE_X_EVENT_CLIENT_MESSAGE, EcoreEventClientMessage, this); +#endif +#endif // WAYLAND && DALI_PROFILE_MOBILE } /** @@ -313,24 +321,21 @@ struct Indicator::Impl */ ~Impl() { - ecore_event_handler_del(mEcoreEventHandler); + if ( mEcoreEventHandler ) + { + ecore_event_handler_del(mEcoreEventHandler); + } } - /** - * Called when the client messages (i.e. quick panel state) are received. - */ - static Eina_Bool EcoreEventClientMessage( void* data, int type, void* event ) + static void SetIndicatorVisibility( void* data, int operation ) { - Ecore_X_Event_Client_Message* clientMessageEvent((Ecore_X_Event_Client_Message*)event); Indicator::Impl* indicatorImpl((Indicator::Impl*)data); - if (clientMessageEvent == NULL || indicatorImpl == NULL || indicatorImpl->mIndicator == NULL) + if ( indicatorImpl == NULL || indicatorImpl->mIndicator == NULL) { - return ECORE_CALLBACK_PASS_ON; + return; } - -#ifndef DALI_PROFILE_UBUNTU - if (clientMessageEvent->message_type == ECORE_X_ATOM_E_INDICATOR_FLICK_DONE) + if ( operation == INDICATOR_STAY_WITH_DURATION ) { // if indicator is not showing, INDICATOR_FLICK_DONE is given if( indicatorImpl->mIndicator->mVisible == Dali::Window::AUTO && @@ -339,7 +344,7 @@ struct Indicator::Impl indicatorImpl->mIndicator->ShowIndicator( AUTO_INDICATOR_STAY_DURATION ); } } - else if( clientMessageEvent->message_type == ECORE_X_ATOM_E_MOVE_QUICKPANEL_STATE ) + else if( operation == INDICATOR_HIDE ) { if( indicatorImpl->mIndicator->mVisible == Dali::Window::AUTO && indicatorImpl->mIndicator->mIsShowing ) @@ -347,16 +352,45 @@ struct Indicator::Impl indicatorImpl->mIndicator->ShowIndicator( HIDE_NOW ); } } -#endif + } +#if defined(DALI_PROFILE_MOBILE) +#if defined(WAYLAND) + /** + * Called when the Ecore indicator event is received. + */ + static Eina_Bool EcoreEventIndicator( void* data, int type, void* event ) + { + SetIndicatorVisibility( data, INDICATOR_STAY_WITH_DURATION ); + return ECORE_CALLBACK_PASS_ON; + } +#else + /** + * Called when the client messages (i.e. quick panel state) are received. + */ + static Eina_Bool EcoreEventClientMessage( void* data, int type, void* event ) + { + Ecore_X_Event_Client_Message* clientMessageEvent((Ecore_X_Event_Client_Message*)event); + if ( clientMessageEvent != NULL ) + { + if (clientMessageEvent->message_type == ECORE_X_ATOM_E_INDICATOR_FLICK_DONE) + { + SetIndicatorVisibility( data, INDICATOR_STAY_WITH_DURATION ); + } + else if ( clientMessageEvent->message_type == ECORE_X_ATOM_E_MOVE_QUICKPANEL_STATE ) + { + SetIndicatorVisibility( data, INDICATOR_HIDE ); + } + } return ECORE_CALLBACK_PASS_ON; } +#endif +#endif // WAYLAND && DALI_PROFILE_MOBILE // Data Indicator* mIndicator; Ecore_Event_Handler* mEcoreEventHandler; }; -#endif Indicator::LockFile::LockFile(const std::string filename) : mFilename(filename), @@ -384,21 +418,27 @@ bool Indicator::LockFile::Lock() bool locked = false; if( mFileDescriptor > 0 ) { - if( lockf( mFileDescriptor, F_LOCK, 0 ) == 0 ) // Note, operation may block. + struct flock filelock; + + filelock.l_type = F_RDLCK; + filelock.l_whence = SEEK_SET; + filelock.l_start = 0; + filelock.l_len = 0; + if( fcntl( mFileDescriptor, F_SETLKW, &filelock ) == -1 ) { - locked = true; + mErrorThrown = true; + DALI_LOG_ERROR( "### Failed to lock with fd : %s ###\n", mFilename.c_str() ); } else { - if( errno == EBADF ) - { - // file descriptor is no longer valid or not writable - mFileDescriptor = 0; - mErrorThrown = true; - DALI_LOG_ERROR( "### Cannot lock indicator: bad file descriptor for %s ###\n", mFilename.c_str() ); - } + locked = true; } } + else + { + mErrorThrown = true; + DALI_LOG_ERROR( "### Invalid fd ###\n" ); + } return locked; } @@ -406,15 +446,17 @@ bool Indicator::LockFile::Lock() void Indicator::LockFile::Unlock() { DALI_LOG_TRACE_METHOD( gIndicatorLogFilter ); - if( lockf( mFileDescriptor, F_ULOCK, 0 ) != 0 ) + + struct flock filelock; + + filelock.l_type = F_UNLCK; + filelock.l_whence = SEEK_SET; + filelock.l_start = 0; + filelock.l_len = 0; + if (fcntl(mFileDescriptor, F_SETLKW, &filelock) == -1) { - if( errno == EBADF ) - { - // file descriptor is no longer valid or not writable - mFileDescriptor = 0; - mErrorThrown = true; - DALI_LOG_ERROR( "### Cannot unlock indicator: bad file descriptor for %s\n", mFilename.c_str() ); - } + mErrorThrown = true; + DALI_LOG_ERROR( "### Failed to lock with fd : %s ###\n", mFilename.c_str() ); } } @@ -466,7 +508,8 @@ Indicator::Indicator( Adaptor* adaptor, Dali::Window::WindowOrientation orientat mCurrentSharedFile( 0 ), mSharedBufferType( BUFFER_TYPE_SHM ), mImpl( NULL ), - mBackgroundVisible( false ) + mBackgroundVisible( false ), + mTopMargin( 0 ) { mIndicatorContentActor = Dali::Actor::New(); mIndicatorContentActor.SetParentOrigin( ParentOrigin::TOP_CENTER ); @@ -474,7 +517,7 @@ Indicator::Indicator( Adaptor* adaptor, Dali::Window::WindowOrientation orientat // Indicator image handles the touch event including "leave" mIndicatorContentActor.SetLeaveRequired( true ); - mIndicatorContentActor.TouchedSignal().Connect( this, &Indicator::OnTouched ); + mIndicatorContentActor.TouchSignal().Connect( this, &Indicator::OnTouched ); mIndicatorContentActor.SetColor( Color::BLACK ); mIndicatorActor = Dali::Actor::New(); @@ -504,25 +547,21 @@ Indicator::Indicator( Adaptor* adaptor, Dali::Window::WindowOrientation orientat // hide the indicator by default mIndicatorActor.SetVisible( false ); -#ifndef WAYLAND // create impl to handle ecore event mImpl = new Impl(this); -#endif } Indicator::~Indicator() { -#ifndef WAYLAND if(mImpl) { delete mImpl; mImpl = NULL; } -#endif if(mEventActor) { - mEventActor.TouchedSignal().Disconnect( this, &Indicator::OnTouched ); + mEventActor.TouchSignal().Disconnect( this, &Indicator::OnTouched ); } Disconnect(); } @@ -617,6 +656,7 @@ void Indicator::SetOpacityMode( Dali::Window::IndicatorBgOpacity mode ) mIndicatorContentActor.RemoveRenderer( mBackgroundRenderer ); mBackgroundVisible = false; } + UpdateTopMargin(); } void Indicator::SetVisible( Dali::Window::IndicatorVisibleMode visibleMode, bool forceUpdate ) @@ -647,6 +687,7 @@ void Indicator::SetVisible( Dali::Window::IndicatorVisibleMode visibleMode, bool } mVisible = visibleMode; + UpdateTopMargin(); if( mForegroundRenderer && mForegroundRenderer.GetTextures().GetTexture( 0u ) ) { @@ -690,21 +731,19 @@ bool Indicator::SendMessage( int messageDomain, int messageId, const void *data, } } -bool Indicator::OnTouched(Dali::Actor indicator, const Dali::TouchEvent& touchEvent) +bool Indicator::OnTouched(Dali::Actor indicator, const Dali::TouchData& touchData) { if( mServerConnection ) { - const TouchPoint& touchPoint = touchEvent.GetPoint( 0 ); - // Send touch event to indicator server when indicator is showing if( CheckVisibleState() || mIsShowing ) { - switch( touchPoint.state ) + switch( touchData.GetState( 0 ) ) { case Dali::PointState::DOWN: { - IpcDataEvMouseMove ipcMove( touchPoint, touchEvent.time ); - IpcDataEvMouseDown ipcDown( touchEvent.time ); + IpcDataEvMouseMove ipcMove( touchData, touchData.GetTime() ); + IpcDataEvMouseDown ipcDown( touchData.GetTime() ); mServerConnection->SendEvent( OP_EV_MOUSE_MOVE, &ipcMove, sizeof(ipcMove) ); mServerConnection->SendEvent( OP_EV_MOUSE_DOWN, &ipcDown, sizeof(ipcDown) ); @@ -718,14 +757,15 @@ bool Indicator::OnTouched(Dali::Actor indicator, const Dali::TouchEvent& touchEv case Dali::PointState::MOTION: { - IpcDataEvMouseMove ipcMove( touchPoint, touchEvent.time ); + IpcDataEvMouseMove ipcMove( touchData, touchData.GetTime() ); mServerConnection->SendEvent( OP_EV_MOUSE_MOVE, &ipcMove, sizeof(ipcMove) ); } break; case Dali::PointState::UP: + case Dali::PointState::INTERRUPTED: { - IpcDataEvMouseUp ipcUp( touchEvent.time ); + IpcDataEvMouseUp ipcUp( touchData.GetTime() ); mServerConnection->SendEvent( OP_EV_MOUSE_UP, &ipcUp, sizeof(ipcUp) ); if( mVisible == Dali::Window::AUTO ) @@ -736,11 +776,11 @@ bool Indicator::OnTouched(Dali::Actor indicator, const Dali::TouchEvent& touchEv } break; - case Dali::TouchPoint::Leave: + case Dali::PointState::LEAVE: { - IpcDataEvMouseMove ipcMove( touchPoint, touchEvent.time ); + IpcDataEvMouseMove ipcMove( touchData, touchData.GetTime() ); mServerConnection->SendEvent( OP_EV_MOUSE_MOVE, &ipcMove, sizeof(ipcMove) ); - IpcDataEvMouseUp ipcOut( touchEvent.time ); + IpcDataEvMouseUp ipcOut( touchData.GetTime() ); mServerConnection->SendEvent( OP_EV_MOUSE_OUT, &ipcOut, sizeof(ipcOut) ); } break; @@ -844,6 +884,7 @@ void Indicator::Resize( int width, int height ) mIndicatorContentActor.SetSize( mImageWidth, mImageHeight ); mIndicatorActor.SetSize( mImageWidth, mImageHeight ); mEventActor.SetSize(mImageWidth, mImageHeight); + UpdateTopMargin(); } } @@ -952,6 +993,8 @@ void Indicator::LoadSharedImage( Ecore_Ipc_Event_Server_Data *epcEvent ) if( mSharedFileInfo[n].mLock->RetrieveAndClearErrorStatus() ) { DALI_LOG_ERROR( "### Indicator error: Cannot open lock file %s ###\n", mSharedFileInfo[n].mLockFileName.c_str() ); + + return; } CreateNewImage( n ); @@ -982,6 +1025,16 @@ void Indicator::LoadPixmapImage( Ecore_Ipc_Event_Server_Data *epcEvent ) } } +void Indicator::UpdateTopMargin() +{ + int newMargin = (mVisible == Dali::Window::VISIBLE && mOpacityMode == Dali::Window::OPAQUE) ? mImageHeight : 0; + if (mTopMargin != newMargin) + { + mTopMargin = newMargin; + mAdaptor->IndicatorSizeChanged( mTopMargin ); + } +} + void Indicator::UpdateVisibility() { if( CheckVisibleState() ) @@ -1063,6 +1116,7 @@ void Indicator::CreateNewPixmapImage() mIndicatorContentActor.SetSize( mImageWidth, mImageHeight ); mIndicatorActor.SetSize( mImageWidth, mImageHeight ); mEventActor.SetSize( mImageWidth, mImageHeight ); + UpdateTopMargin(); } else { @@ -1276,7 +1330,7 @@ void Indicator::DataReceived( void* event ) DALI_LOG_INFO( gIndicatorLogFilter, Debug::General, "Indicator client received: OP_UPDATE\n" ); if( mIsShowing ) { - //mAdaptor->RequestUpdateOnce(); + mAdaptor->RequestUpdateOnce(); } break; } @@ -1284,7 +1338,7 @@ void Indicator::DataReceived( void* event ) { DALI_LOG_INFO( gIndicatorLogFilter, Debug::General, "Indicator client received: OP_UPDATE_DONE [%d]\n", epcEvent->response ); // epcEvent->response == display buffer # - //UpdateImageData( epcEvent->response ); + UpdateImageData( epcEvent->response ); break; } case OP_SHM_REF0: @@ -1476,7 +1530,7 @@ void Indicator::ShowIndicator(float duration) if( mVisible == Dali::Window::AUTO ) { // check the stage touch - Dali::Stage::GetCurrent().TouchedSignal().Connect( this, &Indicator::OnStageTouched ); + Dali::Stage::GetCurrent().TouchSignal().Connect( this, &Indicator::OnStageTouched ); } } else @@ -1489,7 +1543,7 @@ void Indicator::ShowIndicator(float duration) if( mVisible == Dali::Window::AUTO ) { // check the stage touch - Dali::Stage::GetCurrent().TouchedSignal().Disconnect( this, &Indicator::OnStageTouched ); + Dali::Stage::GetCurrent().TouchSignal().Disconnect( this, &Indicator::OnStageTouched ); } } } @@ -1568,19 +1622,17 @@ void Indicator::OnPan( Dali::Actor actor, const Dali::PanGesture& gesture ) } } -void Indicator::OnStageTouched(const Dali::TouchEvent& touchEvent) +void Indicator::OnStageTouched(const Dali::TouchData& touchData) { - const TouchPoint& touchPoint = touchEvent.GetPoint( 0 ); - // when stage is touched while indicator is showing temporary, hide it if( mIsShowing && ( CheckVisibleState() == false || mVisible == Dali::Window::AUTO ) ) { - switch( touchPoint.state ) + switch( touchData.GetState( 0 ) ) { case Dali::PointState::DOWN: { // if touch point is inside the indicator, indicator is not hidden - if( mImageHeight < int(touchPoint.screen.y) ) + if( mImageHeight < int(touchData.GetScreenPosition( 0 ).y) ) { ShowIndicator( HIDE_NOW ); }