X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=adaptors%2Fecore%2Fcommon%2Fecore-indicator-impl.cpp;h=c5e6ba062b9a3acc6dbfdfb3924f5ca8145770d7;hb=749c5cd9253d9a5202c30118418d3a8a63913d75;hp=d0bda155086cc149d60bda4e1961cf931b014f90;hpb=fd068ee647a4f30c60e2fa83cddcc2a9287200b1;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 d0bda15..c5e6ba0 100644 --- a/adaptors/ecore/common/ecore-indicator-impl.cpp +++ b/adaptors/ecore/common/ecore-indicator-impl.cpp @@ -21,6 +21,11 @@ // EXTERNAL INCLUDES #include #include +#ifdef WAYLAND +#include +#else +#include +#endif #include #include @@ -32,8 +37,6 @@ #include #include #include -#include -#include #include #include @@ -148,6 +151,8 @@ const char* INDICATOR_SERVICE_NAME("elm_indicator"); // Copied from ecore_evas_extn_engine.h +#define NBUF 2 + enum // opcodes { OP_RESIZE, @@ -175,7 +180,8 @@ enum // opcodes OP_EV_KEY_DOWN, OP_EV_HOLD, OP_MSG_PARENT, - OP_MSG + OP_MSG, + OP_PIXMAP_REF, }; // Copied from elm_conform.c @@ -285,6 +291,107 @@ namespace Adaptor Debug::Filter* gIndicatorLogFilter = Debug::Filter::New(Debug::Concise, false, "LOG_INDICATOR"); #endif +// Impl to hide EFL implementation. + +struct Indicator::Impl +{ + enum // operation mode + { + INDICATOR_HIDE, + INDICATOR_STAY_WITH_DURATION + }; + + /** + * Constructor + */ + Impl(Indicator* indicator) + : mIndicator(indicator), + mEcoreEventHandler(NULL) + { +#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 + } + + /** + * Destructor + */ + ~Impl() + { + if ( mEcoreEventHandler ) + { + ecore_event_handler_del(mEcoreEventHandler); + } + } + + static void SetIndicatorVisibility( void* data, int operation ) + { + Indicator::Impl* indicatorImpl((Indicator::Impl*)data); + + if ( indicatorImpl == NULL || indicatorImpl->mIndicator == NULL) + { + return; + } + if ( operation == INDICATOR_STAY_WITH_DURATION ) + { + // if indicator is not showing, INDICATOR_FLICK_DONE is given + if( indicatorImpl->mIndicator->mVisible == Dali::Window::AUTO && + !indicatorImpl->mIndicator->mIsShowing ) + { + indicatorImpl->mIndicator->ShowIndicator( AUTO_INDICATOR_STAY_DURATION ); + } + } + else if( operation == INDICATOR_HIDE ) + { + if( indicatorImpl->mIndicator->mVisible == Dali::Window::AUTO && + indicatorImpl->mIndicator->mIsShowing ) + { + indicatorImpl->mIndicator->ShowIndicator( HIDE_NOW ); + } + } + } +#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; +}; Indicator::LockFile::LockFile(const std::string filename) : mFilename(filename), @@ -392,6 +499,8 @@ Indicator::Indicator( Adaptor* adaptor, Dali::Window::WindowOrientation orientat mIsShowing( true ), mIsAnimationPlaying( false ), mCurrentSharedFile( 0 ), + mSharedBufferType( BUFFER_TYPE_SHM ), + mImpl( NULL ), mBackgroundVisible( false ) { mIndicatorContentActor = Dali::Actor::New(); @@ -429,10 +538,19 @@ Indicator::Indicator( Adaptor* adaptor, Dali::Window::WindowOrientation orientat } // hide the indicator by default mIndicatorActor.SetVisible( false ); + + // create impl to handle ecore event + mImpl = new Impl(this); } Indicator::~Indicator() { + if(mImpl) + { + delete mImpl; + mImpl = NULL; + } + if(mEventActor) { mEventActor.TouchedSignal().Disconnect( this, &Indicator::OnTouched ); @@ -541,9 +659,22 @@ void Indicator::SetVisible( Dali::Window::IndicatorVisibleMode visibleMode, bool { UpdateImageData( mCurrentSharedFile ); } - if ( visibleMode != Dali::Window::INVISIBLE ) + + if ( visibleMode == Dali::Window::INVISIBLE ) + { + if (mServerConnection) + { + mServerConnection->SendEvent( OP_HIDE, NULL, 0 ); + } + } + else { mIndicatorActor.SetVisible( true ); + + if( mServerConnection ) + { + mServerConnection->SendEvent( OP_SHOW, NULL, 0 ); + } } mVisible = visibleMode; @@ -566,6 +697,10 @@ void Indicator::SetVisible( Dali::Window::IndicatorVisibleMode visibleMode, bool ShowIndicator( HIDE_NOW ); } } + else + { + mIsShowing = false; + } } } @@ -620,6 +755,7 @@ bool Indicator::OnTouched(Dali::Actor indicator, const Dali::TouchEvent& touchEv break; case Dali::PointState::UP: + case Dali::PointState::INTERRUPTED: { IpcDataEvMouseUp ipcUp( touchEvent.time ); mServerConnection->SendEvent( OP_EV_MOUSE_UP, &ipcUp, sizeof(ipcUp) ); @@ -814,6 +950,11 @@ void Indicator::LoadSharedImage( Ecore_Ipc_Event_Server_Data *epcEvent ) // epcEvent->ref_to == sys // epcEvent->response == buffer num + if ( mSharedBufferType != BUFFER_TYPE_SHM ) + { + return ; + } + int n = epcEvent->response; if( n >= 0 && n < SHARED_FILE_NUMBER ) @@ -846,19 +987,7 @@ void Indicator::LoadSharedImage( Ecore_Ipc_Event_Server_Data *epcEvent ) } CreateNewImage( n ); - - if( CheckVisibleState() ) - { - // set default indicator type (enable the quick panel) - OnIndicatorTypeChanged( INDICATOR_TYPE_1 ); - } - else - { - // set default indicator type (disable the quick panel) - OnIndicatorTypeChanged( INDICATOR_TYPE_2 ); - } - - SetVisible(mVisible, true); + UpdateVisibility(); } } } @@ -867,38 +996,43 @@ void Indicator::LoadPixmapImage( Ecore_Ipc_Event_Server_Data *epcEvent ) { DALI_LOG_TRACE_METHOD( gIndicatorLogFilter ); - // epcEvent->ref == w - // epcEvent->ref_to == h - // epcEvent->response == alpha - // epcEvent->data = pixmap id + // epcEvent->ref == pixmap id + // epcEvent->ref_to == type + // epcEvent->response == buffer num - if( ( epcEvent->data ) && - (epcEvent->size >= (int)sizeof(PixmapId)) ) + if( (epcEvent->ref > 0) && (epcEvent->ref_to > 0) ) { + mSharedBufferType = (BufferType)(epcEvent->ref_to); + ClearSharedFileInfo(); - if( (epcEvent->ref > 0) && (epcEvent->ref_to > 0) ) - { - mImageWidth = epcEvent->ref; - mImageHeight = epcEvent->ref_to; + mPixmap = static_cast(epcEvent->ref); + DALI_LOG_INFO( gIndicatorLogFilter, Debug::General, "mPixmap [%x]", mPixmap); - mPixmap = *(static_cast(epcEvent->data)); - CreateNewPixmapImage(); + CreateNewPixmapImage(); + UpdateVisibility(); + } +} - if( CheckVisibleState() ) - { - // set default indicator type (enable the quick panel) - OnIndicatorTypeChanged( INDICATOR_TYPE_1 ); - } - else - { - // set default indicator type (disable the quick panel) - OnIndicatorTypeChanged( INDICATOR_TYPE_2 ); - } +void Indicator::UpdateVisibility() +{ + if( CheckVisibleState() ) + { + // set default indicator type (enable the quick panel) + OnIndicatorTypeChanged( INDICATOR_TYPE_1 ); + } + else + { + // set default indicator type (disable the quick panel) + OnIndicatorTypeChanged( INDICATOR_TYPE_2 ); + } - SetVisible(mVisible, true); - } + if( !mIsShowing ) + { + mIndicatorContentActor.SetPosition( 0.0f, -mImageHeight, 0.0f ); } + + SetVisible(mVisible, true); } void Indicator::UpdateImageData( int bufferNumber ) @@ -1203,6 +1337,12 @@ void Indicator::DataReceived( void* event ) LoadSharedImage( epcEvent ); break; } + case OP_PIXMAP_REF: + { + DALI_LOG_INFO( gIndicatorLogFilter, Debug::General, "Indicator client received: OP_PIXMAP_REF\n" ); + LoadPixmapImage( epcEvent ); + break; + } case OP_RESIZE: { DALI_LOG_INFO( gIndicatorLogFilter, Debug::General, "Indicator client received: OP_RESIZE\n" ); @@ -1244,7 +1384,7 @@ void Indicator::DataReceived( void* event ) if (msgDataSize != (int)sizeof(IpcIndicatorDataAnimation)) { - DALI_LOG_ERROR("Message data is incorrect"); + DALI_LOG_ERROR("Message data is incorrect\n"); break; } @@ -1256,7 +1396,6 @@ void Indicator::DataReceived( void* event ) } break; } - } } break; @@ -1281,7 +1420,8 @@ bool Indicator::CheckVisibleState() { if( mOrientation == Dali::Window::LANDSCAPE || mOrientation == Dali::Window::LANDSCAPE_INVERSE - || (mVisible != Dali::Window::VISIBLE) ) + || (mVisible == Dali::Window::INVISIBLE) + || (mVisible == Dali::Window::AUTO && !mIsShowing) ) { return false; } @@ -1332,6 +1472,8 @@ void Indicator::ShowIndicator(float duration) } else { + mIndicatorAnimation.Clear(); + if( EqualsZero(duration) ) { mIndicatorAnimation.AnimateTo( Property( mIndicatorContentActor, Dali::Actor::Property::POSITION ), Vector3(0, -mImageHeight, 0), Dali::AlphaFunction::EASE_OUT ); @@ -1396,17 +1538,16 @@ void Indicator::OnAnimationFinished(Dali::Animation& animation) { mIsAnimationPlaying = false; // once animation is finished and indicator is hidden, take it off stage - if( !mIsShowing ) + if( mObserver != NULL ) { - if( mObserver != NULL ) - { - mObserver->IndicatorVisibilityChanged( mIsShowing ); // is showing? - } + mObserver->IndicatorVisibilityChanged( mIsShowing ); // is showing? } } void Indicator::OnPan( Dali::Actor actor, const Dali::PanGesture& gesture ) { + return ; + if( mServerConnection ) { switch( gesture.state ) @@ -1470,7 +1611,11 @@ void Indicator::OnStageTouched(const Dali::TouchEvent& touchEvent) { case Dali::PointState::DOWN: { - ShowIndicator( HIDE_NOW ); + // if touch point is inside the indicator, indicator is not hidden + if( mImageHeight < int(touchPoint.screen.y) ) + { + ShowIndicator( HIDE_NOW ); + } break; }