backsteppingsrv/src/bsserver.cpp
branchRCL_3
changeset 101 9e077f9a342c
parent 0 79c6a41cd166
equal deleted inserted replaced
82:ace62b58f4b2 101:9e077f9a342c
    25 #include "bsengine.h"
    25 #include "bsengine.h"
    26 #include "bsserversession.h"
    26 #include "bsserversession.h"
    27 #include "bsdebug.h"
    27 #include "bsdebug.h"
    28 #include "bsserver.h"
    28 #include "bsserver.h"
    29 
    29 
    30 const TInt idsArrayGranularity = 30;
       
    31 
       
    32 // ============================ MEMBER FUNCTIONS ===============================
    30 // ============================ MEMBER FUNCTIONS ===============================
    33 
    31 
    34 // -----------------------------------------------------------------------------
    32 // -----------------------------------------------------------------------------
    35 // C++ default constructor can NOT contain any code, that might leave.
    33 // C++ default constructor can NOT contain any code, that might leave.
    36 // -----------------------------------------------------------------------------
    34 // -----------------------------------------------------------------------------
   172     CleanupStack::PopAndDestroy( server );
   170     CleanupStack::PopAndDestroy( server );
   173 
   171 
   174     ui->PrepareToExit( );
   172     ui->PrepareToExit( );
   175 
   173 
   176     }
   174     }
       
   175 
   177 // -----------------------------------------------------------------------------
   176 // -----------------------------------------------------------------------------
   178 // Create and start the server.
   177 // Create and start the server.
   179 // -----------------------------------------------------------------------------
   178 // -----------------------------------------------------------------------------
   180 //
   179 //
   181 TInt CBSServer::ThreadFunction()
   180 TInt CBSServer::ThreadFunction()
   228     {
   227     {
   229     CEikonEnv::ConstructL( EFalse ); 
   228     CEikonEnv::ConstructL( EFalse ); 
   230     SetAutoForwarding(ETrue); 
   229     SetAutoForwarding(ETrue); 
   231     User::SetPriorityControl(EFalse);
   230     User::SetPriorityControl(EFalse);
   232     }
   231     }
       
   232 
   233 // -----------------------------------------------------------------------------
   233 // -----------------------------------------------------------------------------
   234 // 
   234 // 
   235 // -----------------------------------------------------------------------------
   235 // -----------------------------------------------------------------------------
   236 //
   236 //
   237 CBSServer::CBSAppUi::~CBSAppUi()
   237 CBSServer::CBSAppUi::~CBSAppUi()
   241 // -----------------------------------------------------------------------------
   241 // -----------------------------------------------------------------------------
   242 // 
   242 // 
   243 // -----------------------------------------------------------------------------
   243 // -----------------------------------------------------------------------------
   244 //
   244 //
   245 void CBSServer::CBSAppUi::HandleWsEventL( const TWsEvent& aEvent,
   245 void CBSServer::CBSAppUi::HandleWsEventL( const TWsEvent& aEvent,
   246     CCoeControl* /*aDestination*/)
   246     CCoeControl* aDestination)
   247     {
   247     {
   248     if ( aEvent.Type( ) == EEventFocusGroupChanged 
   248     if ( aEvent.Type( ) == EEventFocusGroupChanged 
   249         || aEvent.Type( ) == EEventWindowGroupsChanged )
   249         || aEvent.Type( ) == EEventWindowGroupsChanged )
   250         {
   250         {
   251 
       
   252         TInt windowsGroupID = iCoeEnv->WsSession().GetFocusWindowGroup( );
   251         TInt windowsGroupID = iCoeEnv->WsSession().GetFocusWindowGroup( );
   253         CApaWindowGroupName* apaWGName = CApaWindowGroupName::NewLC(
   252         CApaWindowGroupName* apaWGName = CApaWindowGroupName::NewLC(
   254             iCoeEnv->WsSession( ), windowsGroupID );
   253             iCoeEnv->WsSession( ), windowsGroupID );
   255         TUid uid = apaWGName->AppUid( );
   254         TUid uid = apaWGName->AppUid( );
   256         CleanupStack::PopAndDestroy( apaWGName );
   255         CleanupStack::PopAndDestroy( apaWGName );
   259         if ( uid.iUid )
   258         if ( uid.iUid )
   260             {
   259             {
   261             iEngine->HandleFocusChangeL( uid );
   260             iEngine->HandleFocusChangeL( uid );
   262             }
   261             }
   263         }
   262         }
   264     else if( aEvent.Type( ) == EEventKeyDown ) 
   263     CEikAppUi::HandleWsEventL( aEvent, aDestination );
   265         {
       
   266         iEngine->ApplicationKeyWasPressed( );
       
   267         ForwardEventL( aEvent );     
       
   268         }
       
   269     else if( aEvent.Type( ) == EEventKeyUp )
       
   270         {
       
   271         ForwardEventL( aEvent );     
       
   272         }
       
   273     }
       
   274 
       
   275 // -----------------------------------------------------------------------------
       
   276 // 
       
   277 // -----------------------------------------------------------------------------
       
   278 //
       
   279 void CBSServer::CBSAppUi::ForwardEventL( const TWsEvent& aEvent )
       
   280     {
       
   281     CArrayFixFlat<TInt>* idArray = 
       
   282                     new (ELeave) CArrayFixFlat<TInt>( idsArrayGranularity );
       
   283     iCoeEnv->WsSession().WindowGroupList( idArray );
       
   284     
       
   285     TInt ownId = iCoeEnv->RootWin().Identifier();
       
   286     for( TInt x(0); x < idArray->Count(); x++ )
       
   287         {
       
   288         if( (*idArray)[x] != ownId )
       
   289             {
       
   290             iCoeEnv->WsSession().SendEventToWindowGroup( 
       
   291                                                     (*idArray)[x], aEvent );
       
   292             }
       
   293         }
       
   294     delete idArray;
       
   295     }
   264     }
   296 
   265 
   297 // -----------------------------------------------------------------------------
   266 // -----------------------------------------------------------------------------
   298 // 
   267 // 
   299 // -----------------------------------------------------------------------------
   268 // -----------------------------------------------------------------------------
   305     iCoeEnv->RootWin().EnableFocusChangeEvents( );
   274     iCoeEnv->RootWin().EnableFocusChangeEvents( );
   306     //get notifications about windows group change events    
   275     //get notifications about windows group change events    
   307     iCoeEnv->RootWin().EnableGroupChangeEvents( );
   276     iCoeEnv->RootWin().EnableGroupChangeEvents( );
   308     //disable notifications about layout change
   277     //disable notifications about layout change
   309     iCoeEnv->RootWin().DisableScreenChangeEvents();
   278     iCoeEnv->RootWin().DisableScreenChangeEvents();
   310     //get notifications about application key event
       
   311     iCoeEnv->RootWin().CaptureKeyUpAndDowns( EStdKeyApplication0, 0, 0 );
       
   312     }
   279     }
   313 
   280 
   314 // ============================= LOCAL FUNCTIONS ===============================
   281 // ============================= LOCAL FUNCTIONS ===============================
   315 
   282 
   316 // -----------------------------------------------------------------------------
   283 // -----------------------------------------------------------------------------