taskswitcher/taskswitcherui/taskswitcherapp/src/tsfastswaparea.cpp
branchRCL_3
changeset 23 7be2816dbabd
parent 19 79311d856354
child 25 137ebc85284b
equal deleted inserted replaced
19:79311d856354 23:7be2816dbabd
    29 #include <layoutmetadata.cdl.h>
    29 #include <layoutmetadata.cdl.h>
    30 #include <aknlists.h>
    30 #include <aknlists.h>
    31 #include <touchfeedback.h>
    31 #include <touchfeedback.h>
    32 #include <akntransitionutils.h>
    32 #include <akntransitionutils.h>
    33 #include <akntranseffect.h>
    33 #include <akntranseffect.h>
       
    34 #include <aknlongtapanimation.h>
    34 
    35 
    35 #include "tsfastswaparea.h"
    36 #include "tsfastswaparea.h"
    36 #include "tsapplogging.h"
    37 #include "tsapplogging.h"
    37 #include "tsfswclient.h"
    38 #include "tsfswclient.h"
    38 #include "tsappui.h"
    39 #include "tsappui.h"
    61 const TInt KRedrawTime = 250000; // 0.25 sec
    62 const TInt KRedrawTime = 250000; // 0.25 sec
    62 const TInt KRedrawTimeForLayoutSwitch = 700000; // 0.7 sec
    63 const TInt KRedrawTimeForLayoutSwitch = 700000; // 0.7 sec
    63 const TInt KHighlighActivationTime = 100000; // 100 ms
    64 const TInt KHighlighActivationTime = 100000; // 100 ms
    64 const TInt KUpdateGridTime = 0; // imediately
    65 const TInt KUpdateGridTime = 0; // imediately
    65 const TInt KOrientationSwitchTime = 1000000; // 1 sec
    66 const TInt KOrientationSwitchTime = 1000000; // 1 sec
       
    67 const TInt KLongTapAnimationInitTime = 150000; // 0.15 sec
       
    68 const TInt KLongTapAnimationTimeout = 1000000; // 1 sec
    66 
    69 
    67 const TInt KMaxGranularity = 4;
    70 const TInt KMaxGranularity = 4;
       
    71 
       
    72 const TUid KTsMenuUid = { 0x101f4cd2 };
       
    73 const TUid KTsHomescreenUid = { 0x102750f0 };
    68 
    74 
    69 // -----------------------------------------------------------------------------
    75 // -----------------------------------------------------------------------------
    70 // CTsFastSwapArea::NewL
    76 // CTsFastSwapArea::NewL
    71 // -----------------------------------------------------------------------------
    77 // -----------------------------------------------------------------------------
    72 //
    78 //
   101 //
   107 //
   102 CTsFastSwapArea::CTsFastSwapArea(CCoeControl& aParent,
   108 CTsFastSwapArea::CTsFastSwapArea(CCoeControl& aParent,
   103     CTsDeviceState& aDeviceState,
   109     CTsDeviceState& aDeviceState,
   104     CTsEventControler& aEventHandler) :
   110     CTsEventControler& aEventHandler) :
   105     iParent(aParent), iDeviceState(aDeviceState), iEvtHandler(aEventHandler),
   111     iParent(aParent), iDeviceState(aDeviceState), iEvtHandler(aEventHandler),
   106     iIgnoreLayoutSwitch(EFalse), iWidgetClosingCount(0)
   112     iIgnoreLayoutSwitch(EFalse), iWidgetClosingCount(0), iLongTapAnimationRunning(EFalse)
   107     {
   113     {
   108     // no implementation required
   114     // no implementation required
   109     }
   115     }
   110 
   116 
   111 // -----------------------------------------------------------------------------
   117 // -----------------------------------------------------------------------------
   121     delete iPopup;
   127     delete iPopup;
   122     delete iHighlightTimer;
   128     delete iHighlightTimer;
   123     delete iRedrawTimer;
   129     delete iRedrawTimer;
   124     delete iUpdateGridTimer;
   130     delete iUpdateGridTimer;
   125     delete iOrientationSignalTimer;
   131     delete iOrientationSignalTimer;
       
   132     delete iLongTapAnimation;
       
   133     delete iLongTapAnimationTimer;
   126     }
   134     }
   127 
   135 
   128 // -----------------------------------------------------------------------------
   136 // -----------------------------------------------------------------------------
   129 // CTsFastSwapArea::ConstructL
   137 // CTsFastSwapArea::ConstructL
   130 // -----------------------------------------------------------------------------
   138 // -----------------------------------------------------------------------------
   158     iUpdateGridTimer = new (ELeave) CTsFastSwapTimer( *this );
   166     iUpdateGridTimer = new (ELeave) CTsFastSwapTimer( *this );
   159     iUpdateGridTimer->ConstructL();
   167     iUpdateGridTimer->ConstructL();
   160     
   168     
   161     iOrientationSignalTimer = new (ELeave) CTsFastSwapTimer( *this ); 
   169     iOrientationSignalTimer = new (ELeave) CTsFastSwapTimer( *this ); 
   162     iOrientationSignalTimer->ConstructL();
   170     iOrientationSignalTimer->ConstructL();
       
   171     
       
   172     iLongTapAnimationTimer = new (ELeave) CTsFastSwapTimer( *this ); 
       
   173     iLongTapAnimationTimer->ConstructL();
       
   174     
       
   175     iActivateOnPointerRelease = TPoint();
       
   176     iHandlePointerCandidate = EFalse;
   163     
   177     
   164     ActivateL();
   178     ActivateL();
   165     }
   179     }
   166 
   180 
   167 // -----------------------------------------------------------------------------
   181 // -----------------------------------------------------------------------------
   417     {
   431     {
   418     if ( aIndex >= 0 && aIndex < iArray.Count() )
   432     if ( aIndex >= 0 && aIndex < iArray.Count() )
   419         {
   433         {
   420         TInt wgId = iArray[aIndex]->WgId();
   434         TInt wgId = iArray[aIndex]->WgId();
   421         TUid appUid = iArray[aIndex]->AppUid();
   435         TUid appUid = iArray[aIndex]->AppUid();
   422         // Move other app to foreground and then move ourselves to background.
   436         SwitchToApp( wgId, appUid );
   423         // Order is important and cannot be reversed.
   437         }
   424         iFSClient->SwitchToApp( wgId );
   438     }
   425         // We do not want to come back to ts if the activated app is closed.
   439 
   426         // Therefore ts must be moved to background. Ignore orientation updates, it
   440 // --------------------------------------------------------------------------
   427         // will be done after task switcher is sent to background
   441 // CTsFastSwapArea::SwitchToApp
   428         iIgnoreLayoutSwitch = ETrue;
   442 // --------------------------------------------------------------------------
   429         CTsAppUi* appui =
   443 //
   430             static_cast<CTsAppUi*>( iEikonEnv->AppUi() );
   444 void CTsFastSwapArea::SwitchToApp( const TUid& aUid )
   431         appui->MoveAppToBackground( CTsAppUi::EActivationTransition, appUid, wgId );
   445     {
   432         iIgnoreLayoutSwitch = EFalse;
   446     TApaTaskList taskList( iEikonEnv->WsSession() );
   433         
   447     TApaTask task = taskList.FindApp( aUid );
   434         // Orientation update
   448     TInt wgId = task.WgId();
   435         iPrevScreenOrientation = -1; // force orientation reinit
   449     SwitchToApp( wgId, aUid );
   436         iOrientationSignalTimer->Cancel();
   450     }
   437         iOrientationSignalTimer->After(KOrientationSwitchTime);
   451 
   438         }
   452 
       
   453 // --------------------------------------------------------------------------
       
   454 // CTsFastSwapArea::SwitchToApp
       
   455 // --------------------------------------------------------------------------
       
   456 //
       
   457 void CTsFastSwapArea::SwitchToApp( TInt aWgId, const TUid& aUid )
       
   458     {
       
   459     CTsAppUi* appui =
       
   460         static_cast<CTsAppUi*>( iEikonEnv->AppUi() );
       
   461     TBool effectsEnabled = appui->EffectsEnabled();
       
   462 
       
   463     // Move other app to foreground
       
   464     if ( !effectsEnabled )
       
   465         {
       
   466         iFSClient->SwitchToApp( aWgId );
       
   467         }
       
   468     
       
   469     // We do not want to come back to ts if the activated app is closed.
       
   470     // Therefore ts must be moved to background. Ignore orientation updates, it
       
   471     // will be done after task switcher is sent to background
       
   472     iIgnoreLayoutSwitch = ETrue;
       
   473     appui->MoveAppToBackground( CTsAppUi::EActivationTransition, aUid, aWgId );
       
   474     iIgnoreLayoutSwitch = EFalse;
       
   475     
       
   476     // Move other app to foreground
       
   477     if ( effectsEnabled )
       
   478         {
       
   479         iFSClient->SwitchToApp( aWgId );
       
   480         }
       
   481     
       
   482     // Orientation update
       
   483     iPrevScreenOrientation = -1; // force orientation reinit
       
   484     iOrientationSignalTimer->Cancel();
       
   485     iOrientationSignalTimer->After(KOrientationSwitchTime);
   439     }
   486     }
   440 
   487 
   441 // --------------------------------------------------------------------------
   488 // --------------------------------------------------------------------------
   442 // CTsFastSwapArea::TryCloseAppL
   489 // CTsFastSwapArea::TryCloseAppL
   443 // --------------------------------------------------------------------------
   490 // --------------------------------------------------------------------------
   497         
   544         
   498         // Orientation update
   545         // Orientation update
   499         iPrevScreenOrientation = GetCurrentScreenOrientation();
   546         iPrevScreenOrientation = GetCurrentScreenOrientation();
   500         iOrientationSignalTimer->Cancel();
   547         iOrientationSignalTimer->Cancel();
   501         iOrientationSignalTimer->After(KOrientationSwitchTime);
   548         iOrientationSignalTimer->After(KOrientationSwitchTime);
       
   549         
       
   550         iPrevAppCount = iArray.Count();
   502         }
   551         }
   503 
   552 
   504     TSLOG_OUT();
   553     TSLOG_OUT();
   505     }
   554     }
   506 
   555 
   534 // --------------------------------------------------------------------------
   583 // --------------------------------------------------------------------------
   535 //
   584 //
   536 TBool CTsFastSwapArea::CanClose( TInt aIndex ) const
   585 TBool CTsFastSwapArea::CanClose( TInt aIndex ) const
   537     {
   586     {
   538     CTsFswEntry* e = iArray[aIndex];
   587     CTsFswEntry* e = iArray[aIndex];
   539     return !e->AlwaysShown() && !e->SystemApp();
   588     TBool canClose = !e->AlwaysShown() && !e->SystemApp();
       
   589     // Special cases: Menu
       
   590     canClose |= e->AppUid() == KTsMenuUid;
       
   591     return canClose;
   540     }
   592     }
   541 
   593 
   542 // --------------------------------------------------------------------------
   594 // --------------------------------------------------------------------------
   543 // CTsFastSwapArea::CanCloseOthers
   595 // CTsFastSwapArea::CanCloseOthers
   544 // --------------------------------------------------------------------------
   596 // --------------------------------------------------------------------------
   813     // Hide highlight
   865     // Hide highlight
   814     if ( iGrid->GridBehaviour() == CTsFastSwapGrid::ETouchOnly )
   866     if ( iGrid->GridBehaviour() == CTsFastSwapGrid::ETouchOnly )
   815         {
   867         {
   816         iGrid->HideHighlight();
   868         iGrid->HideHighlight();
   817         }
   869         }
       
   870     CancelLongTapAnimation();
   818     }
   871     }
   819 
   872 
   820 // -----------------------------------------------------------------------------
   873 // -----------------------------------------------------------------------------
   821 // CTsFastSwapArea::HandleSwitchToForegroundEvent
   874 // CTsFastSwapArea::HandleSwitchToForegroundEvent
   822 // -----------------------------------------------------------------------------
   875 // -----------------------------------------------------------------------------
   826     TSLOG_CONTEXT( CTsFastSwapArea::HandleSwitchToForegroundEvent, TSLOG_LOCAL );
   879     TSLOG_CONTEXT( CTsFastSwapArea::HandleSwitchToForegroundEvent, TSLOG_LOCAL );
   827     TSLOG_IN();
   880     TSLOG_IN();
   828     
   881     
   829     iIsClosing.Reset();
   882     iIsClosing.Reset();
   830     iWidgetClosingCount = 0;
   883     iWidgetClosingCount = 0;
       
   884     iHandlePointerCandidate = EFalse;
   831     
   885     
   832     CTsGridItemDrawer* itemDrawer =
   886     CTsGridItemDrawer* itemDrawer =
   833         static_cast<CTsGridItemDrawer*>( iGrid->ItemDrawer() );
   887         static_cast<CTsGridItemDrawer*>( iGrid->ItemDrawer() );
   834     itemDrawer->SetRedrawBackground(ETrue);
   888     itemDrawer->SetRedrawBackground(ETrue);
   835     
   889     
   863     
   917     
   864     itemDrawer->SetRedrawBackground(EFalse);
   918     itemDrawer->SetRedrawBackground(EFalse);
   865     
   919     
   866     // give feedback
   920     // give feedback
   867     LaunchPopupFeedback();
   921     LaunchPopupFeedback();
       
   922     
       
   923     iPrevAppCount = iArray.Count();
   868 
   924 
   869     TSLOG_OUT();
   925     TSLOG_OUT();
   870     }
   926     }
   871 
   927 
   872 // -----------------------------------------------------------------------------
   928 // -----------------------------------------------------------------------------
   898 //
   954 //
   899 TKeyResponse CTsFastSwapArea::OfferKeyEventL(
   955 TKeyResponse CTsFastSwapArea::OfferKeyEventL(
   900         const TKeyEvent& aKeyEvent,
   956         const TKeyEvent& aKeyEvent,
   901         TEventCode aType )
   957         TEventCode aType )
   902     {
   958     {
       
   959     CancelLongTapAnimation();
       
   960     
   903     iKeyEvent = ETrue;
   961     iKeyEvent = ETrue;
   904     // handle the 'clear' key
   962     // handle the 'clear' key
   905     if ( aType == EEventKey && aKeyEvent.iCode == EKeyBackspace )
   963     if ( aType == EEventKey && aKeyEvent.iCode == EKeyBackspace )
   906         {
   964         {
   907         TInt idx = SelectedIndex();
   965         TInt idx = SelectedIndex();
   920     	}
   978     	}
   921     
   979     
   922     // pass the event to grid
   980     // pass the event to grid
   923     // do not pass down and up arrow key events
   981     // do not pass down and up arrow key events
   924     if ( aKeyEvent.iScanCode != EStdKeyUpArrow &&
   982     if ( aKeyEvent.iScanCode != EStdKeyUpArrow &&
   925          aKeyEvent.iScanCode != EStdKeyDownArrow )
   983          aKeyEvent.iScanCode != EStdKeyDownArrow &&
       
   984          aKeyEvent.iScanCode != EStdKeyApplication0 )
   926         {
   985         {
   927         TBool animate(ETrue);
   986         TBool animate(ETrue);
   928         TBool redraw(EFalse);
   987         TBool redraw(EFalse);
   929         TInt prevItem = SelectedIndex();
   988         TInt prevItem = SelectedIndex();
   930         TKeyResponse response = iGrid->OfferKeyEventL( aKeyEvent, aType );
   989         TKeyResponse response = iGrid->OfferKeyEventL( aKeyEvent, aType );
   997 void CTsFastSwapArea::HandlePointerEventL( const TPointerEvent& aPointerEvent )
  1056 void CTsFastSwapArea::HandlePointerEventL( const TPointerEvent& aPointerEvent )
   998     {
  1057     {
   999     iKeyEvent = EFalse;
  1058     iKeyEvent = EFalse;
  1000     if(aPointerEvent.iType == TPointerEvent::EButton1Down)
  1059     if(aPointerEvent.iType == TPointerEvent::EButton1Down)
  1001         {
  1060         {
       
  1061         iHandlePointerCandidate = ETrue;
  1002         iTapEvent = aPointerEvent;
  1062         iTapEvent = aPointerEvent;
  1003         iGrid->EnableAknEventHandling(EFalse);
  1063         iGrid->EnableAknEventHandling(EFalse);
  1004         iGrid->HandlePointerEventL(aPointerEvent);
  1064         iGrid->HandlePointerEventL(aPointerEvent);
  1005         iGrid->EnableAknEventHandling(ETrue);
  1065         iGrid->EnableAknEventHandling(ETrue);
       
  1066         // Check if long tap animation should be launched
       
  1067         if ( LongTapAnimForPos(aPointerEvent.iParentPosition) )
       
  1068             {
       
  1069             iLongTapAnimationTimer->Cancel();
       
  1070             iLongTapAnimationTimer->After(KLongTapAnimationInitTime);
       
  1071             }
       
  1072         }
       
  1073     else if ( aPointerEvent.iType == TPointerEvent::EButton1Up )
       
  1074         {
       
  1075         CancelLongTapAnimation( EFalse );
       
  1076         if( iActivateOnPointerRelease != TPoint() )
       
  1077             {
       
  1078             TapL(iActivateOnPointerRelease);
       
  1079             iActivateOnPointerRelease = TPoint();
       
  1080             }
  1006         }
  1081         }
  1007     }
  1082     }
  1008 
  1083 
  1009 // -----------------------------------------------------------------------------
  1084 // -----------------------------------------------------------------------------
  1010 // CTsFastSwapArea::SelectedIndex
  1085 // CTsFastSwapArea::SelectedIndex
  1135             {
  1210             {
  1136             // Order layout change
  1211             // Order layout change
  1137             static_cast<CAknAppUi*>(iCoeEnv->AppUi())->HandleResourceChangeL(KEikDynamicLayoutVariantSwitch);
  1212             static_cast<CAknAppUi*>(iCoeEnv->AppUi())->HandleResourceChangeL(KEikDynamicLayoutVariantSwitch);
  1138             iRedrawTimer->Cancel();
  1213             iRedrawTimer->Cancel();
  1139             iRedrawTimer->After(KRedrawTime);
  1214             iRedrawTimer->After(KRedrawTime);
       
  1215             }
       
  1216         }
       
  1217     else if ( aSource == iLongTapAnimationTimer )
       
  1218         {
       
  1219         if ( iLongTapAnimationRunning )
       
  1220             {
       
  1221             CancelLongTapAnimation();
       
  1222             }
       
  1223         else
       
  1224             {
       
  1225             static_cast<CTsAppUi*>(iEikonEnv->AppUi())->RequestPopUpL();
       
  1226             if ( iLongTapAnimation )
       
  1227                 {
       
  1228                 delete iLongTapAnimation;
       
  1229                 iLongTapAnimation = NULL;
       
  1230                 }
       
  1231             iLongTapAnimation = CAknLongTapAnimation::NewL(EFalse);
       
  1232             iLongTapAnimation->SetParent( this );
       
  1233             iLongTapAnimation->ShowAnimationL( iTapEvent.iParentPosition.iX,
       
  1234                                                iTapEvent.iParentPosition.iY );
       
  1235             iLongTapAnimationRunning = ETrue;
       
  1236             iLongTapAnimationTimer->Cancel();
       
  1237             iLongTapAnimationTimer->After(KLongTapAnimationTimeout);
  1140             }
  1238             }
  1141         }
  1239         }
  1142     }
  1240     }
  1143 
  1241 
  1144 
  1242 
  1395     {
  1493     {
  1396     if ( iArray.Count() )
  1494     if ( iArray.Count() )
  1397         {
  1495         {
  1398         if( aType == KAppKeyTypeShort )
  1496         if( aType == KAppKeyTypeShort )
  1399             {
  1497             {
  1400             if(iGrid->IsHighlightVisible())
  1498             // Switch to homescreen
  1401                 {
  1499             SwitchToApp( KTsHomescreenUid );
  1402                 SelectNextItem();
       
  1403                 }
       
  1404             else
       
  1405                 {
       
  1406                 iGrid->ShowHighlight();
       
  1407                 }
       
  1408             }
  1500             }
  1409         else if( aType == KAppKeyTypeLong )
  1501         else if( aType == KAppKeyTypeLong )
  1410             {
  1502             {
  1411             SwitchToApp( SelectedIndex() );
  1503             // Dismiss task switcher
       
  1504             TRAP_IGNORE( iEikonEnv->EikAppUi()->HandleCommandL(EAknSoftkeyExit) );
  1412             }
  1505             }
  1413         }
  1506         }
  1414     else
  1507     else
  1415         {
  1508         {
  1416         TRAP_IGNORE( iEikonEnv->EikAppUi()->HandleCommandL(EAknSoftkeyExit) );
  1509         TRAP_IGNORE( iEikonEnv->EikAppUi()->HandleCommandL(EAknSoftkeyExit) );
  1425     {
  1518     {
  1426     TSLOG_CONTEXT( CTsFastSwapArea::MoveOffset, TSLOG_LOCAL );
  1519     TSLOG_CONTEXT( CTsFastSwapArea::MoveOffset, TSLOG_LOCAL );
  1427     TSLOG2_IN("Old position x: %d, y:%d", ViewPos().iX, ViewPos().iY);
  1520     TSLOG2_IN("Old position x: %d, y:%d", ViewPos().iX, ViewPos().iY);
  1428     TSLOG2_IN("New position x: %d, y:%d", aPoint.iX, aPoint.iY);
  1521     TSLOG2_IN("New position x: %d, y:%d", aPoint.iX, aPoint.iY);
  1429     TSLOG_OUT();
  1522     TSLOG_OUT();
       
  1523     
       
  1524     
       
  1525     if( iHandlePointerCandidate )
       
  1526         {
       
  1527 		//pointer was pressed and it's being waiting for handling
       
  1528         return;
       
  1529         }
  1430 
  1530 
  1431     //postpone center item request in case of being moved
  1531     //postpone center item request in case of being moved
  1432     if(iUpdateGridTimer->IsActive())
  1532     if(iUpdateGridTimer->IsActive())
  1433     	{
  1533     	{
  1434     	iUpdateGridTimer->Cancel();
  1534     	iUpdateGridTimer->Cancel();
  1463 // CTsFastSwapArea::Tap
  1563 // CTsFastSwapArea::Tap
  1464 // --------------------------------------------------------------------------
  1564 // --------------------------------------------------------------------------
  1465 //
  1565 //
  1466 void CTsFastSwapArea::TapL(const TPoint& aPoint)
  1566 void CTsFastSwapArea::TapL(const TPoint& aPoint)
  1467     {
  1567     {
       
  1568     CancelLongTapAnimation();
       
  1569     
       
  1570     if(!iHandlePointerCandidate)
       
  1571         {
       
  1572         return;
       
  1573         }
       
  1574     
  1468     if(Rect().Contains(aPoint) && iArray.Count())
  1575     if(Rect().Contains(aPoint) && iArray.Count())
  1469         {
  1576         {
  1470         //provide tap pointer event to grid
  1577         //provide tap pointer event to grid
  1471         iGrid->HandlePointerEventL(iTapEvent);
  1578         iGrid->HandlePointerEventL(iTapEvent);
  1472         iHighlightTimer->Cancel();
  1579         iHighlightTimer->Cancel();
  1475     else
  1582     else
  1476         {
  1583         {
  1477         //move task switcher to background
  1584         //move task switcher to background
  1478         iEikonEnv->EikAppUi()->HandleCommandL(EAknSoftkeyExit);
  1585         iEikonEnv->EikAppUi()->HandleCommandL(EAknSoftkeyExit);
  1479         }
  1586         }
       
  1587 	iHandlePointerCandidate = EFalse;
  1480     }
  1588     }
  1481 
  1589 
  1482 // --------------------------------------------------------------------------
  1590 // --------------------------------------------------------------------------
  1483 // CTsFastSwapArea::LongTap
  1591 // CTsFastSwapArea::LongTap
  1484 // --------------------------------------------------------------------------
  1592 // --------------------------------------------------------------------------
  1485 //
  1593 //
  1486 void CTsFastSwapArea::LongTapL(const TPoint& aPoint)
  1594 void CTsFastSwapArea::LongTapL(const TPoint& aPoint)
  1487     {
  1595     {
       
  1596     CancelLongTapAnimation();
       
  1597     
       
  1598     if(!iHandlePointerCandidate)
       
  1599         {
       
  1600         return;
       
  1601         }
       
  1602     
  1488     TInt index(KErrNotFound);
  1603     TInt index(KErrNotFound);
  1489     if( iGrid->GridView()->XYPosToItemIndex(aPoint,index) && iArray.Count() )
  1604     if( iGrid->GridView()->XYPosToItemIndex(aPoint,index) && iArray.Count() )
  1490         {
  1605         {
  1491         iGrid->SetCurrentItemIndex(index);
  1606         iGrid->SetCurrentItemIndex(index);
  1492         SaveSelectedIndex();
  1607         SaveSelectedIndex();
  1493         if ( !ShowPopupL(iSavedSelectedIndex, aPoint) )
  1608         if ( !ShowPopupL(iSavedSelectedIndex, aPoint) )
  1494             {
  1609             {
  1495             TapL(aPoint);
  1610             iActivateOnPointerRelease = aPoint;
  1496             }
  1611             }
  1497         else
  1612         iGrid->ShowHighlight();
  1498             {
  1613         DrawNow();
  1499             iGrid->ShowHighlight();
  1614         }
  1500             DrawNow();
  1615 	iHandlePointerCandidate = EFalse;
  1501             }
       
  1502         }
       
  1503     else
       
  1504         {
       
  1505         TapL(aPoint);
       
  1506         }
       
  1507     }
  1616     }
  1508 
  1617 
  1509 // --------------------------------------------------------------------------
  1618 // --------------------------------------------------------------------------
  1510 // CTsFastSwapArea::DragL
  1619 // CTsFastSwapArea::DragL
  1511 // --------------------------------------------------------------------------
  1620 // --------------------------------------------------------------------------
  1512 //
  1621 //
  1513 void CTsFastSwapArea::DragL(
  1622 void CTsFastSwapArea::DragL(
  1514     const MAknTouchGestureFwDragEvent& aEvent)
  1623     const MAknTouchGestureFwDragEvent& aEvent)
  1515     {
  1624     {
       
  1625     CancelLongTapAnimation();
       
  1626     // Reset activation point
       
  1627     iActivateOnPointerRelease = TPoint();
       
  1628 	iHandlePointerCandidate = EFalse;
  1516 	if( aEvent.State() == EAknTouchGestureFwStop)
  1629 	if( aEvent.State() == EAknTouchGestureFwStop)
  1517 		{
  1630 		{
  1518 		CenterItem( KUpdateGridTime );
  1631 		CenterItem( KUpdateGridTime );
  1519 		}
  1632 		}
  1520 
  1633 
  1755 // -----------------------------------------------------------------------------
  1868 // -----------------------------------------------------------------------------
  1756 //
  1869 //
  1757 TBool CTsFastSwapArea::GetVariety( TInt& aVariety )
  1870 TBool CTsFastSwapArea::GetVariety( TInt& aVariety )
  1758     {
  1871     {
  1759     aVariety = Layout_Meta_Data::IsLandscapeOrientation() ? 1 : 0;
  1872     aVariety = Layout_Meta_Data::IsLandscapeOrientation() ? 1 : 0;
  1760     TInt screenOrientation = GetCurrentScreenOrientation();
  1873     TBool foreground = static_cast<CTsAppUi*>(iEikonEnv->AppUi())->IsForeground();
  1761     if ( aVariety != screenOrientation )
  1874     if ( foreground )
  1762         {
  1875         {
  1763         aVariety = screenOrientation;
  1876         TInt screenOrientation = GetCurrentScreenOrientation();
  1764         return ETrue;
  1877         if ( aVariety != screenOrientation )
       
  1878             {
       
  1879             aVariety = screenOrientation;
       
  1880             return ETrue;
       
  1881             }
  1765         }
  1882         }
  1766     return EFalse;
  1883     return EFalse;
  1767     }
  1884     }
  1768 
  1885 
  1769 // -----------------------------------------------------------------------------
  1886 // -----------------------------------------------------------------------------
  1785             {
  1902             {
  1786             retVal = ETrue;
  1903             retVal = ETrue;
  1787             iWidgetClosingCount--;
  1904             iWidgetClosingCount--;
  1788             }
  1905             }
  1789         }
  1906         }
  1790     else
  1907     return retVal;
  1791         {
  1908     }
  1792         // Check current item list
  1909 
       
  1910 
       
  1911 // -----------------------------------------------------------------------------
       
  1912 // CTsFastSwapArea::WgOnTaskList
       
  1913 // -----------------------------------------------------------------------------
       
  1914 //
       
  1915 TBool CTsFastSwapArea::WgOnTaskList( TInt aWgId )
       
  1916     {
       
  1917     TBool retVal(EFalse);
       
  1918     TInt appCount = iArray.Count();
       
  1919     if ( iPrevAppCount != appCount )
       
  1920         {
       
  1921         TApaTaskList taskList( iEikonEnv->WsSession() );
       
  1922         TApaTask task = taskList.FindApp( KTsHomescreenUid );
       
  1923         TInt homescrWgId = task.WgId();
       
  1924         
  1793         for ( TInt i = 0; i < iArray.Count(); i++ )
  1925         for ( TInt i = 0; i < iArray.Count(); i++ )
  1794             {
  1926             {
  1795             TInt wgId = iArray[i]->WgId();
  1927             TInt wgId = iArray[i]->WgId();
  1796             if ( wgId == aWgId )
  1928             if ( wgId == aWgId ||
       
  1929                  homescrWgId == aWgId )
  1797                 {
  1930                 {
  1798                 retVal = ETrue;
  1931                 retVal = ETrue;
  1799                 }
  1932                 }
  1800             }
  1933             }
  1801         }
  1934         }
       
  1935     iPrevAppCount = appCount;
  1802     return retVal;
  1936     return retVal;
  1803     }
  1937     }
  1804 
  1938 
       
  1939 // -----------------------------------------------------------------------------
       
  1940 // CTsFastSwapArea::CancelLongTapAnimation
       
  1941 // -----------------------------------------------------------------------------
       
  1942 //
       
  1943 void CTsFastSwapArea::CancelLongTapAnimation(TBool aDisablePopup)
       
  1944     {
       
  1945     iLongTapAnimationRunning = EFalse;
       
  1946     iLongTapAnimationTimer->Cancel();
       
  1947     if ( iLongTapAnimation )
       
  1948         {
       
  1949         iLongTapAnimation->HideAnimation();
       
  1950         delete iLongTapAnimation;
       
  1951         iLongTapAnimation = NULL;
       
  1952         }
       
  1953     if( aDisablePopup )
       
  1954         {
       
  1955         TRAP_IGNORE( 
       
  1956         static_cast<CTsAppUi*>(iEikonEnv->AppUi())->DisablePopUpL() );
       
  1957         }
       
  1958     }
       
  1959 
       
  1960 
       
  1961 // -----------------------------------------------------------------------------
       
  1962 // CTsFastSwapArea::LongTapAnimForPos
       
  1963 // -----------------------------------------------------------------------------
       
  1964 //
       
  1965 TBool CTsFastSwapArea::LongTapAnimForPos( const TPoint& aHitPoint )
       
  1966     {
       
  1967     if ( Rect().Contains(aHitPoint) )
       
  1968         {
       
  1969         for ( TInt i = 0; i < GridItemCount(); i++ )
       
  1970             {
       
  1971             TBool isItemHit = iGrid->GridView()->XYPosToItemIndex( aHitPoint, i );
       
  1972             if ( isItemHit && ( CanClose( i ) || CanCloseAll( i ) ) )
       
  1973                 {
       
  1974                 return ETrue;
       
  1975                 }
       
  1976             }
       
  1977         }
       
  1978     return EFalse;
       
  1979     }
       
  1980 
  1805 // End of file
  1981 // End of file