idlehomescreen/xmluirendering/uiengine/src/xngesturehelper.cpp
branchRCL_3
changeset 30 b8fae6b8a148
parent 16 9674c1a575e9
equal deleted inserted replaced
16:9674c1a575e9 30:b8fae6b8a148
   249             // down event was received in a different *client* state, and
   249             // down event was received in a different *client* state, and
   250             // client did not forward the down event to here.
   250             // client did not forward the down event to here.
   251             // Also, while stylus down, the same event is received repeatedly
   251             // Also, while stylus down, the same event is received repeatedly
   252             // even if stylus does not move. Filter out by checking if point
   252             // even if stylus does not move. Filter out by checking if point
   253             // is the same as the latest point
   253             // is the same as the latest point
   254             if ( iDirection != EGestureCanceled )
   254             iDirection = iGesture->LastDirection( CXnGesture::EAxisHorizontal );
       
   255             
       
   256             if ( !IsIdle() && !iGesture->IsLatestPoint( Position( aEvent ) ) )
   255                 {
   257                 {
   256                 if ( iDirection == EGestureUnknown )
   258                 AddPointL( aEvent );
       
   259                 if ( !( iGesture->IsHolding() ||
       
   260                         iGesture->IsNearHoldingPoint( Position( aEvent ) ) ) )
   257                     {
   261                     {
   258                     // check current direction
   262                     // restart hold timer, since pointer has moved
   259                     iDirection = iGesture->CodeFromPoints( CXnGesture::EAxisBoth );
   263                     iHoldingTimer->Start();
   260                     }
   264                     // Remember the point in which holding was started
   261                 else
   265                     iGesture->SetHoldingPoint();
   262                     {
       
   263                     // check if direction has changed
       
   264                     if ( iDirection != iGesture->LastDirection( CXnGesture::EAxisBoth ) )
       
   265                         {
       
   266                         // cancel swipe
       
   267                         iDirection = EGestureCanceled;
       
   268                         }
       
   269                     }
       
   270                 
       
   271                 if ( !IsIdle() && !iGesture->IsLatestPoint( Position( aEvent ) ) )
       
   272                     {
       
   273                     AddPointL( aEvent );
       
   274                     if ( !( iGesture->IsHolding() ||
       
   275                             iGesture->IsNearHoldingPoint( Position( aEvent ) ) ) )
       
   276                         {
       
   277                         // restart hold timer, since pointer has moved
       
   278                         iHoldingTimer->Start();
       
   279                         // Remember the point in which holding was started
       
   280                         iGesture->SetHoldingPoint();
       
   281                         }
       
   282                     }
   266                     }
   283                 }
   267                 }
   284             break;
   268             break;
   285 
   269 
   286         case TPointerEvent::EButton1Up:
   270         case TPointerEvent::EButton1Up:
   291                 // in client, and instead drag or up events are received.
   275                 // in client, and instead drag or up events are received.
   292                 // reset via cleanup stack to ensure Reset is run even if
   276                 // reset via cleanup stack to ensure Reset is run even if
   293                 // observer leaves
   277                 // observer leaves
   294                 CleanupStack::PushL( TCleanupItem( &ResetHelper, this ) );
   278                 CleanupStack::PushL( TCleanupItem( &ResetHelper, this ) );
   295                 iGesture->SetComplete();
   279                 iGesture->SetComplete();
   296                 if ( iDirection != EGestureCanceled )
   280                 // if adding of the point fails, notify client with a
       
   281                 // cancelled event. It would be wrong to send another
       
   282                 // gesture code when the up point is not known
       
   283                 if ( AddPoint( aEvent ) != KErrNone )
   297                     {
   284                     {
   298                     // if adding of the point fails, notify client with a
   285                     iGesture->SetCancelled();
   299                     // cancelled event. It would be wrong to send another
   286                     }
   300                     // gesture code when the up point is not known
   287                 else
   301                     if ( AddPoint( aEvent ) != KErrNone )
   288                     {
       
   289                     // send gesture code if holding has not been started
       
   290                     if ( !iGesture->IsHolding() )
   302                         {
   291                         {
   303                         iGesture->SetCancelled();
   292                         // if client leaves, the state is automatically reset.
       
   293                         // In this case the client will not get the released event
       
   294                         ret = iDirection;
   304                         }
   295                         }
   305                     else
   296                     // send an event that stylus was lifted
   306                         {
   297                     iGesture->SetReleased();
   307                         // send gesture code if holding has not been started
       
   308                         if ( !iGesture->IsHolding() )
       
   309                             {
       
   310                             // if client leaves, the state is automatically reset.
       
   311                             // In this case the client will not get the released event
       
   312                             ret = iDirection;
       
   313                             }
       
   314                         // send an event that stylus was lifted
       
   315                         iGesture->SetReleased();
       
   316                         }
       
   317                     }
   298                     }
   318                 // reset state
   299                 // reset state
   319                 CleanupStack::PopAndDestroy( this );
   300                 CleanupStack::PopAndDestroy( this );
   320                 }
   301                 }
   321             break;
   302             break;