#include <errno.h>
#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/events/touch-data.h>
#include <dali/public-api/common/stage.h>
#include <dali/public-api/images/buffer-image.h>
unsigned int timestamp;
Evas_Event_Flags event_flags;
- IpcDataEvMouseMove(const Dali::TouchPoint& touchPoint, unsigned long timestamp)
- : x(static_cast<Evas_Coord>(touchPoint.local.x)),
- y(static_cast<Evas_Coord>(touchPoint.local.y)),
+ IpcDataEvMouseMove(const Dali::TouchData& touchData, unsigned long timestamp)
+ : x(static_cast<Evas_Coord>(touchData.GetLocalPosition( 0 ).x)),
+ y(static_cast<Evas_Coord>(touchData.GetLocalPosition( 0 ).y)),
flags(EVAS_BUTTON_NONE),
mask(0),
timestamp(static_cast<unsigned int>(timestamp)),
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;
}
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() );
}
}
mCurrentSharedFile( 0 ),
mSharedBufferType( BUFFER_TYPE_SHM ),
mImpl( NULL ),
- mBackgroundVisible( false )
+ mBackgroundVisible( false ),
+ mTopMargin( 0 )
{
mIndicatorContentActor = Dali::Actor::New();
mIndicatorContentActor.SetParentOrigin( ParentOrigin::TOP_CENTER );
// 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();
if(mEventActor)
{
- mEventActor.TouchedSignal().Disconnect( this, &Indicator::OnTouched );
+ mEventActor.TouchSignal().Disconnect( this, &Indicator::OnTouched );
}
Disconnect();
}
mIndicatorContentActor.RemoveRenderer( mBackgroundRenderer );
mBackgroundVisible = false;
}
+ UpdateTopMargin();
}
void Indicator::SetVisible( Dali::Window::IndicatorVisibleMode visibleMode, bool forceUpdate )
}
mVisible = visibleMode;
+ UpdateTopMargin();
if( mForegroundRenderer && mForegroundRenderer.GetTextures().GetTexture( 0u ) )
{
}
}
-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) );
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 )
}
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;
mIndicatorContentActor.SetSize( mImageWidth, mImageHeight );
mIndicatorActor.SetSize( mImageWidth, mImageHeight );
mEventActor.SetSize(mImageWidth, mImageHeight);
+ UpdateTopMargin();
}
}
if( mSharedFileInfo[n].mLock->RetrieveAndClearErrorStatus() )
{
DALI_LOG_ERROR( "### Indicator error: Cannot open lock file %s ###\n", mSharedFileInfo[n].mLockFileName.c_str() );
+
+ return;
}
CreateNewImage( n );
}
}
+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() )
mIndicatorContentActor.SetSize( mImageWidth, mImageHeight );
mIndicatorActor.SetSize( mImageWidth, mImageHeight );
mEventActor.SetSize( mImageWidth, mImageHeight );
+ UpdateTopMargin();
}
else
{
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
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 );
}
}
}
}
}
-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 );
}