/*
- * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2018 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.
*/
// CLASS HEADER
-#include <dali/internal/window-system/common/ecore-indicator-impl.h>
+#include <dali/internal/window-system/tizen-wayland/indicator-impl-ecore-wl.h>
// EXTERNAL INCLUDES
// Ecore is littered with C style cast
#pragma GCC diagnostic ignored "-Wold-style-cast"
#include <Ecore.h>
#include <Evas.h>
-#ifdef WAYLAND
-#include <Ecore_Wayland.h>
+
+#ifdef ECORE_WAYLAND2
+#include <Ecore_Wl2.h>
#else
-#include <Ecore_X.h>
+#include <Ecore_Wayland.h>
#endif
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <fcntl.h>
-#include <errno.h>
-#include <iomanip>
-#include <fstream>
#include <dali/public-api/images/native-image.h>
-#include <dali/public-api/events/touch-event.h>
#include <dali/public-api/events/touch-point.h>
#include <dali/public-api/common/stage.h>
-#include <dali/public-api/images/buffer-image.h>
#include <dali/public-api/images/pixel.h>
#include <dali/integration-api/debug.h>
#include <dali/internal/accessibility/common/accessibility-adaptor-impl.h>
#include <dali/public-api/adaptor-framework/native-image-source.h>
-using Dali::Vector4;
-
#if defined(DEBUG_ENABLED)
#define STATE_DEBUG_STRING(state) (state==DISCONNECTED?"DISCONNECTED":state==CONNECTED?"CONNECTED":"UNKNOWN")
#endif
{
const float SLIDING_ANIMATION_DURATION( 0.2f ); // 200 milli seconds
-const float AUTO_INDICATOR_STAY_DURATION(3.0f); // 3 seconds
-const float SHOWING_DISTANCE_HEIGHT_RATE(0.34f); // 20 pixels
+const float AUTO_INDICATOR_STAY_DURATION( 3.0f ); // 3 seconds
enum
{
return quad;
}
-const float OPAQUE_THRESHOLD(0.99f);
-const float TRANSPARENT_THRESHOLD(0.05f);
-
// indicator service name
const char* INDICATOR_SERVICE_NAME("elm_indicator");
// Copied from ecore_evas_extn_engine.h
-#define NBUF 2
-
enum // opcodes
{
OP_RESIZE,
OP_EV_HOLD,
OP_MSG_PARENT,
OP_MSG,
- OP_PIXMAP_REF,
};
// Copied from elm_conform.c
const int MSG_ID_INDICATOR_TYPE( 0X1005 );
const int MSG_ID_INDICATOR_START_ANIMATION( 0X10006 );
-struct IpcDataUpdate
-{
- int x, w, y, h;
-};
-
struct IpcDataResize
{
int w, h;
// Impl to hide EFL implementation.
-struct Indicator::Impl
+struct IndicatorEcoreWl::Impl
{
enum // operation mode
{
/**
* Constructor
*/
- Impl(Indicator* indicator)
+ Impl(IndicatorEcoreWl* 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);
+#ifdef ECORE_WAYLAND2
+ mEcoreEventHandler = ecore_event_handler_add(ECORE_WL2_EVENT_INDICATOR_FLICK, EcoreEventIndicator, this);
#else
- mEcoreEventHandler = ecore_event_handler_add(ECORE_X_EVENT_CLIENT_MESSAGE, EcoreEventClientMessage, this);
+ mEcoreEventHandler = ecore_event_handler_add(ECORE_WL_EVENT_INDICATOR_FLICK, EcoreEventIndicator, this);
#endif
-#endif // WAYLAND && DALI_PROFILE_MOBILE
+#endif // DALI_PROFILE_MOBILE
}
/**
static void SetIndicatorVisibility( void* data, int operation )
{
- Indicator::Impl* indicatorImpl((Indicator::Impl*)data);
+ IndicatorEcoreWl::Impl* indicatorImpl((IndicatorEcoreWl::Impl*)data);
if ( indicatorImpl == NULL || indicatorImpl->mIndicator == NULL)
{
}
}
}
+
#if defined(DALI_PROFILE_MOBILE)
-#if defined(WAYLAND)
/**
* Called when the Ecore indicator event is received.
*/
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
+#endif // DALI_PROFILE_MOBILE
// Data
- Indicator* mIndicator;
+ IndicatorEcoreWl* mIndicator;
Ecore_Event_Handler* mEcoreEventHandler;
};
-Indicator::LockFile::LockFile(const std::string filename)
+IndicatorEcoreWl::LockFile::LockFile(const std::string filename)
: mFilename(filename),
mErrorThrown(false)
{
}
}
-Indicator::LockFile::~LockFile()
+IndicatorEcoreWl::LockFile::~LockFile()
{
// Closing file descriptor also unlocks file.
if( mFileDescriptor > 0 )
}
}
-bool Indicator::LockFile::Lock()
+bool IndicatorEcoreWl::LockFile::Lock()
{
DALI_LOG_TRACE_METHOD( gIndicatorLogFilter );
return locked;
}
-void Indicator::LockFile::Unlock()
+void IndicatorEcoreWl::LockFile::Unlock()
{
DALI_LOG_TRACE_METHOD( gIndicatorLogFilter );
}
}
-bool Indicator::LockFile::RetrieveAndClearErrorStatus()
+bool IndicatorEcoreWl::LockFile::RetrieveAndClearErrorStatus()
{
bool error = mErrorThrown;
mErrorThrown = false;
return error;
}
-Indicator::ScopedLock::ScopedLock(LockFile* lockFile)
+IndicatorEcoreWl::ScopedLock::ScopedLock(LockFile* lockFile)
: mLockFile(lockFile),
mLocked(false)
{
}
}
-Indicator::ScopedLock::~ScopedLock()
+IndicatorEcoreWl::ScopedLock::~ScopedLock()
{
if( mLockFile )
{
}
}
-bool Indicator::ScopedLock::IsLocked()
+bool IndicatorEcoreWl::ScopedLock::IsLocked()
{
return mLocked;
}
-Indicator::Indicator( Adaptor* adaptor, Dali::Window::WindowOrientation orientation, IndicatorInterface::Observer* observer )
-: mPixmap( 0 ),
- mGestureDeltaY( 0.0f ),
- mGestureDetected( false ),
- mConnection( this ),
+IndicatorEcoreWl::IndicatorEcoreWl( Adaptor* adaptor, Dali::Window::WindowOrientation orientation, IndicatorInterface::Observer* observer )
+: mConnection( this ),
mOpacityMode( Dali::Window::OPAQUE ),
mState( DISCONNECTED ),
mAdaptor(adaptor),
mIsShowing( true ),
mIsAnimationPlaying( false ),
mCurrentSharedFile( 0 ),
- mSharedBufferType( BUFFER_TYPE_SHM ),
mImpl( NULL ),
mBackgroundVisible( false ),
mTopMargin( 0 )
// Indicator image handles the touch event including "leave"
mIndicatorContentActor.SetLeaveRequired( true );
- mIndicatorContentActor.TouchSignal().Connect( this, &Indicator::OnTouch );
+ mIndicatorContentActor.TouchSignal().Connect( this, &IndicatorEcoreWl::OnTouch );
mIndicatorContentActor.SetColor( Color::BLACK );
mIndicatorActor = Dali::Actor::New();
// It can prevent the problem that scrollview gets pan gesture even indicator area is touched,
// since it consumes the pan gesture in advance.
mPanDetector = Dali::PanGestureDetector::New();
- mPanDetector.DetectedSignal().Connect( this, &Indicator::OnPan );
+ mPanDetector.DetectedSignal().Connect( this, &IndicatorEcoreWl::OnPan );
mPanDetector.Attach( mEventActor );
Open( orientation );
mImpl = new Impl(this);
}
-Indicator::~Indicator()
+IndicatorEcoreWl::~IndicatorEcoreWl()
{
if(mImpl)
{
if(mEventActor)
{
- mEventActor.TouchSignal().Disconnect( this, &Indicator::OnTouch );
+ mEventActor.TouchSignal().Disconnect( this, &IndicatorEcoreWl::OnTouch );
}
Disconnect();
}
-void Indicator::SetAdaptor(Adaptor* adaptor)
+void IndicatorEcoreWl::SetAdaptor(Adaptor* adaptor)
{
mAdaptor = adaptor;
mIndicatorBuffer->SetAdaptor( adaptor );
}
-Dali::Actor Indicator::GetActor()
+Dali::Actor IndicatorEcoreWl::GetActor()
{
return mIndicatorActor;
}
-void Indicator::Open( Dali::Window::WindowOrientation orientation )
+void IndicatorEcoreWl::Open( Dali::Window::WindowOrientation orientation )
{
DALI_LOG_TRACE_METHOD( gIndicatorLogFilter );
}
}
-void Indicator::Close()
+void IndicatorEcoreWl::Close()
{
DALI_LOG_TRACE_METHOD_FMT( gIndicatorLogFilter, "State: %s", STATE_DEBUG_STRING(mState) );
SetForegroundImage( emptyTexture );
}
-void Indicator::SetOpacityMode( Dali::Window::IndicatorBgOpacity mode )
+void IndicatorEcoreWl::SetOpacityMode( Dali::Window::IndicatorBgOpacity mode )
{
mOpacityMode = mode;
UpdateTopMargin();
}
-void Indicator::SetVisible( Dali::Window::IndicatorVisibleMode visibleMode, bool forceUpdate )
+void IndicatorEcoreWl::SetVisible( Dali::Window::IndicatorVisibleMode visibleMode, bool forceUpdate )
{
if ( visibleMode != mVisible || forceUpdate )
{
}
}
-bool Indicator::IsConnected()
+bool IndicatorEcoreWl::IsConnected()
{
return ( mState == CONNECTED );
}
-bool Indicator::SendMessage( int messageDomain, int messageId, const void *data, int size )
+bool IndicatorEcoreWl::SendMessage( int messageDomain, int messageId, const void *data, int size )
{
if(IsConnected())
{
}
}
-bool Indicator::OnTouch(Dali::Actor indicator, const Dali::TouchData& touchData)
+bool IndicatorEcoreWl::OnTouch(Dali::Actor indicator, const Dali::TouchData& touchData)
{
if( mServerConnection )
{
return false;
}
-bool Indicator::Connect()
+bool IndicatorEcoreWl::Connect()
{
DALI_LOG_TRACE_METHOD( gIndicatorLogFilter );
return connected;
}
-void Indicator::StartReconnectionTimer()
+void IndicatorEcoreWl::StartReconnectionTimer()
{
if( ! mReconnectTimer )
{
mReconnectTimer = Dali::Timer::New(1000);
mConnection.DisconnectAll();
- mReconnectTimer.TickSignal().Connect( mConnection, &Indicator::OnReconnectTimer );
+ mReconnectTimer.TickSignal().Connect( mConnection, &IndicatorEcoreWl::OnReconnectTimer );
}
mReconnectTimer.Start();
}
-bool Indicator::OnReconnectTimer()
+bool IndicatorEcoreWl::OnReconnectTimer()
{
bool retry = false;
return retry;
}
-void Indicator::Disconnect()
+void IndicatorEcoreWl::Disconnect()
{
DALI_LOG_TRACE_METHOD( gIndicatorLogFilter );
ClearSharedFileInfo();
}
-void Indicator::Resize( int width, int height )
+void IndicatorEcoreWl::Resize( int width, int height )
{
if( width < 1 )
{
}
}
-void Indicator::SetLockFileInfo( Ecore_Ipc_Event_Server_Data *epcEvent )
+void IndicatorEcoreWl::SetLockFileInfo( Ecore_Ipc_Event_Server_Data *epcEvent )
{
DALI_LOG_TRACE_METHOD( gIndicatorLogFilter );
}
}
-void Indicator::SetSharedImageInfo( Ecore_Ipc_Event_Server_Data *epcEvent )
+void IndicatorEcoreWl::SetSharedImageInfo( Ecore_Ipc_Event_Server_Data *epcEvent )
{
DALI_LOG_TRACE_METHOD( gIndicatorLogFilter );
}
}
-void Indicator::LoadSharedImage( Ecore_Ipc_Event_Server_Data *epcEvent )
+void IndicatorEcoreWl::LoadSharedImage( Ecore_Ipc_Event_Server_Data *epcEvent )
{
DALI_LOG_TRACE_METHOD( gIndicatorLogFilter );
// 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 )
mSharedFileInfo[n].mSharedFile = SharedFile::New( sharedFilename.c_str(), mSharedFileInfo[n].mImageWidth * mSharedFileInfo[n].mImageWidth * 4, true );
if( mSharedFileInfo[n].mSharedFile != NULL )
{
- mSharedFileInfo[n].mLock = new Indicator::LockFile( mSharedFileInfo[n].mLockFileName );
+ mSharedFileInfo[n].mLock = new IndicatorEcoreWl::LockFile( mSharedFileInfo[n].mLockFileName );
if( mSharedFileInfo[n].mLock->RetrieveAndClearErrorStatus() )
{
DALI_LOG_ERROR( "### Indicator error: Cannot open lock file %s ###\n", mSharedFileInfo[n].mLockFileName.c_str() );
}
}
-void Indicator::LoadPixmapImage( Ecore_Ipc_Event_Server_Data *epcEvent )
-{
- DALI_LOG_TRACE_METHOD( gIndicatorLogFilter );
-
- // epcEvent->ref == pixmap id
- // epcEvent->ref_to == type
- // epcEvent->response == buffer num
-
- if( (epcEvent->ref > 0) && (epcEvent->ref_to > 0) )
- {
- mSharedBufferType = (BufferType)(epcEvent->ref_to);
-
- ClearSharedFileInfo();
-
- mPixmap = static_cast<PixmapId>(epcEvent->ref);
- DALI_LOG_INFO( gIndicatorLogFilter, Debug::General, "mPixmap [%x]", mPixmap);
-
- CreateNewPixmapImage();
- UpdateVisibility();
- }
-}
-
-void Indicator::UpdateTopMargin()
+void IndicatorEcoreWl::UpdateTopMargin()
{
int newMargin = (mVisible == Dali::Window::VISIBLE && mOpacityMode == Dali::Window::OPAQUE) ? mImageHeight : 0;
if (mTopMargin != newMargin)
}
}
-void Indicator::UpdateVisibility()
+void IndicatorEcoreWl::UpdateVisibility()
{
if( CheckVisibleState() )
{
SetVisible(mVisible, true);
}
-void Indicator::UpdateImageData( int bufferNumber )
+void IndicatorEcoreWl::UpdateImageData( int bufferNumber )
{
DALI_LOG_TRACE_METHOD_FMT( gIndicatorLogFilter, "State: %s mVisible: %s", STATE_DEBUG_STRING(mState), mVisible?"T":"F" );
if( mState == CONNECTED && mVisible )
{
- if(mPixmap == 0)
- {
- // in case of shm indicator (not pixmap), not sure we can skip it when mIsShowing is false
- CopyToBuffer( bufferNumber );
- }
- else
- {
- if(mIsShowing)
- {
- mAdaptor->RequestUpdateOnce();
- }
- }
+ // not sure we can skip it when mIsShowing is false
+ CopyToBuffer( bufferNumber );
}
}
-bool Indicator::CopyToBuffer( int bufferNumber )
+bool IndicatorEcoreWl::CopyToBuffer( int bufferNumber )
{
bool success = false;
if( mSharedFileInfo[bufferNumber].mLock )
{
- Indicator::ScopedLock scopedLock(mSharedFileInfo[bufferNumber].mLock);
+ IndicatorEcoreWl::ScopedLock scopedLock(mSharedFileInfo[bufferNumber].mLock);
if( mSharedFileInfo[bufferNumber].mLock->RetrieveAndClearErrorStatus() )
{
// Do nothing here.
return success;
}
-void Indicator::CreateNewPixmapImage()
-{
- DALI_LOG_TRACE_METHOD_FMT( gIndicatorLogFilter, "W:%d H:%d", mImageWidth, mImageHeight );
- Dali::NativeImageSourcePtr nativeImageSource = Dali::NativeImageSource::New( mPixmap );
-
-#ifdef ENABLE_INDICATOR_IMAGE_SAVING
- SaveIndicatorImage( nativeImageSource );
-#endif
-
- if( nativeImageSource )
- {
- Dali::Texture texture = Dali::Texture::New( *nativeImageSource );
- SetForegroundImage( texture );
- mIndicatorContentActor.SetSize( mImageWidth, mImageHeight );
- mIndicatorActor.SetSize( mImageWidth, mImageHeight );
- mEventActor.SetSize( mImageWidth, mImageHeight );
- UpdateTopMargin();
- }
- else
- {
- DALI_LOG_WARNING("### Cannot create indicator image - disconnecting ###\n");
- Disconnect();
- if( mObserver != NULL )
- {
- mObserver->IndicatorClosed( this );
- }
- // Don't do connection in this callback - strange things happen!
- StartReconnectionTimer();
- }
-}
-
-void Indicator::CreateNewImage( int bufferNumber )
+void IndicatorEcoreWl::CreateNewImage( int bufferNumber )
{
DALI_LOG_TRACE_METHOD_FMT( gIndicatorLogFilter, "W:%d H:%d", mSharedFileInfo[bufferNumber].mImageWidth, mSharedFileInfo[bufferNumber].mImageHeight );
mIndicatorBuffer = new IndicatorBuffer( mAdaptor, mSharedFileInfo[bufferNumber].mImageWidth, mSharedFileInfo[bufferNumber].mImageHeight, Pixel::BGRA8888 );
}
}
-Dali::Geometry Indicator::CreateBackgroundGeometry()
+Dali::Geometry IndicatorEcoreWl::CreateBackgroundGeometry()
{
switch( mOpacityMode )
{
return Dali::Geometry();
}
-void Indicator::SetForegroundImage( Dali::Texture texture )
+void IndicatorEcoreWl::SetForegroundImage( Dali::Texture texture )
{
if( !mForegroundRenderer && texture )
{
}
}
-void Indicator::OnIndicatorTypeChanged( Type indicatorType )
+void IndicatorEcoreWl::OnIndicatorTypeChanged( Type indicatorType )
{
if( mObserver != NULL )
{
}
}
-void Indicator::DataReceived( void* event )
+void IndicatorEcoreWl::DataReceived( void* event )
{
DALI_LOG_TRACE_METHOD( gIndicatorLogFilter );
Ecore_Ipc_Event_Server_Data *epcEvent = static_cast<Ecore_Ipc_Event_Server_Data *>( 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" );
}
}
-void Indicator::ConnectionClosed()
+void IndicatorEcoreWl::ConnectionClosed()
{
DALI_LOG_TRACE_METHOD( gIndicatorLogFilter );
Connect();
}
-bool Indicator::CheckVisibleState()
+bool IndicatorEcoreWl::CheckVisibleState()
{
if( mOrientation == Dali::Window::LANDSCAPE
|| mOrientation == Dali::Window::LANDSCAPE_INVERSE
return true;
}
-void Indicator::ClearSharedFileInfo()
+void IndicatorEcoreWl::ClearSharedFileInfo()
{
for( int i = 0; i < SHARED_FILE_NUMBER; i++ )
{
* HIDE_NOW = 0
* };
*/
-void Indicator::ShowIndicator(float duration)
+void IndicatorEcoreWl::ShowIndicator(float duration)
{
if( !mIndicatorAnimation )
{
mIndicatorAnimation = Dali::Animation::New(SLIDING_ANIMATION_DURATION);
- mIndicatorAnimation.FinishedSignal().Connect(this, &Indicator::OnAnimationFinished);
+ mIndicatorAnimation.FinishedSignal().Connect(this, &IndicatorEcoreWl::OnAnimationFinished);
}
if(mIsShowing && !EqualsZero(duration))
if(!mShowTimer)
{
mShowTimer = Dali::Timer::New(1000 * duration);
- mShowTimer.TickSignal().Connect(this, &Indicator::OnShowTimer);
+ mShowTimer.TickSignal().Connect(this, &IndicatorEcoreWl::OnShowTimer);
}
mShowTimer.SetInterval(1000* duration);
mShowTimer.Start();
if( mVisible == Dali::Window::AUTO )
{
// check the stage touch
- Dali::Stage::GetCurrent().TouchSignal().Connect( this, &Indicator::OnStageTouch );
+ Dali::Stage::GetCurrent().TouchSignal().Connect( this, &IndicatorEcoreWl::OnStageTouch );
}
}
else
if( mVisible == Dali::Window::AUTO )
{
// check the stage touch
- Dali::Stage::GetCurrent().TouchSignal().Disconnect( this, &Indicator::OnStageTouch );
+ Dali::Stage::GetCurrent().TouchSignal().Disconnect( this, &IndicatorEcoreWl::OnStageTouch );
}
}
}
-bool Indicator::OnShowTimer()
+bool IndicatorEcoreWl::OnShowTimer()
{
// after time up, hide indicator
ShowIndicator( HIDE_NOW );
return false;
}
-void Indicator::OnAnimationFinished(Dali::Animation& animation)
+void IndicatorEcoreWl::OnAnimationFinished(Dali::Animation& animation)
{
mIsAnimationPlaying = false;
// once animation is finished and indicator is hidden, take it off stage
}
}
-void Indicator::OnPan( Dali::Actor actor, const Dali::PanGesture& gesture )
+void IndicatorEcoreWl::OnPan( Dali::Actor actor, const Dali::PanGesture& gesture )
{
// Nothing to do, but we still want to consume pan
}
-void Indicator::OnStageTouch(const Dali::TouchData& touchData)
+void IndicatorEcoreWl::OnStageTouch(const Dali::TouchData& touchData)
{
// when stage is touched while indicator is showing temporary, hide it
if( mIsShowing && ( CheckVisibleState() == false || mVisible == Dali::Window::AUTO ) )