×

Discussion Board

Results 1 to 1 of 1
  1. #1
    Regular Contributor
    Join Date
    Mar 2007
    Posts
    235

    Arrow Need help on window server session

    I am trying to create an application that goes foreground->background->foreground. My application should go foreground to background with selection of a menu item in application window and would again come to foreground with selection of open menu item in the root screen , if the current list item selected is the application icon. Meanwhile while in background it must show two lines running text in two always on top windows .I am using structure less application for background and structured one for foreground .
    Here are my attempts :
    I have tried to use only one window session and tried to create an always on window on it

    Result : the emulator exits .
    I have tried to use two window sessions
    The default for appui and the drawing the text and the other for keypress handling ,
    Result : the emulator exits .
    one for all foreground activities and the other for background activities (like drawing the text and keypress handling).
    Code:
    void CAknExGridAppUi::ForeGround()
    	{
    	iDrawer0->DoCancel();
    	delete iDrawer0 ;
    	iDrawer0=NULL;
    	iDrawer1->DoCancel();
    	delete iDrawer1 ;
    	iDrawer1=NULL;
    	iCapture->DoCancel();
    	iCapture->Cancel();
    	delete iCapture ;
    	iCapture=NULL;
    	   iBackground=EFalse;
    	iWsBackSession.Close();
    	}
    
    
    	//------------------------------------------------//
    	// loosing focus/being sent to background. //
    	//------------------------------------------------//
    	void CAknExGridAppUi::BackGround()
    	{
    	iBackground=ETrue;
    	if(!iShowingTicker)
            FetchTicker();
           iShowingTicker=ETrue;
           iShowingList=EFalse;
    	User::LeaveIfError(iWsBackSession.Connect());
    	iWindowsGroupID = CEikonEnv::Static()->RootWin().Identifier();
    	
    	CEikonEnv::Static()->WsSession().SetWindowGroupOrdinalPosition(iWindowsGroupID,0);
    	iDrawer0 =new (ELeave) CDrawer();
       	iDrawer0->SetMopParent( this );
       	iDrawer0->ConstructL( TRect(TPoint(0,0), TSize(ClientRect().Width(),16))	,0 ,KRgbDarkBlue,KRgbWhite,15);
       	iDrawer1 =new (ELeave) CDrawer();
       	iDrawer1->SetMopParent( this );
       	iDrawer1->ConstructL(  TRect(TPoint(0,0), TSize(ClientRect().Width(),16))
       			,1,KRgbYellow, KRgbDarkBlue,25);
       	iCapture= CKeyCapture::NewL(*this);
       	iCapture->ConstructL();
       	iCapture->Listen();
       		}
    Result : Drawing fine but when I am trying to capture keypress and send it to the root window three things are happening on thee combinations .

    Combination 1: On first keypress an empty root opens with no running texts or application window . This window gives us the root menu too . I can now reopen the program through fire key or selecting it from open in popup menu .

    Code:
       void CKeyCapture::RunL()
    {
    
    	if (iStatus == KErrNone) 
    	{
    		TWsEvent e;
    		iWsSession.GetEvent(e);
    		TInt type = e.Type();
     
    		switch (type)
    		{
    		case EEventKey:	
    			if(iObserver.KeyCapturedL(e))
    			{
    			if(e.Key()->iScanCode==167)// fire key
    			{ 
    /***************here I am forcefully passing the keypress to the handler****/
    					
    (CAknExGridAppUi*)CEikonEnv::Static()->AppUi())->HandleCommandL(EEikBidCancel);
    
    /*************************************************************************/
    
    				}
    			   }
    			break;
    		case EEventKeyUp:
    		case EEventKeyDown:
    			break;
    		};
    	}
    	
    	if (iStatus != KErrCancel&&((CAknExGridAppUi*)CEikonEnv::Static()->AppUi())->iBackground) 
    	{
    		Listen();
    	}
    Combination 2:

    Code:
       void CKeyCapture::RunL()
    {
    
    	if (iStatus == KErrNone) 
    	{
    		TWsEvent e;
    		iWsSession.GetEvent(e);
    		TInt type = e.Type();
     
    		switch (type)
    		{
    		case EEventKey:	
    			if(iObserver.KeyCapturedL(e))
    			{
    			if(e.Key()->iScanCode==167)// fire key
    			{ 
    
                    TInt wgId =iWsSession.GetFocusWindowGroup(); 
    /* here the focus window id of the foreground session is returned and 
    sendeventtowindowgroup do not end up in offerkeyeventl or handlekeyeventL */ 
    iWsSession.SendEventToWindowGroup(wgId, e);
    				}
    			   }
    			break;
    		case EEventKeyUp:
    		case EEventKeyDown:
    			break;
    		};
    	}
    	
    	if (iStatus != KErrCancel&&((CAknExGridAppUi*)CEikonEnv::Static()->AppUi())->iBackground) 
    	{
    		Listen();
    	}
    
    	
    }
    Combination 3:
    Code:
       void CKeyCapture::RunL()
    {
    
    	if (iStatus == KErrNone) 
    	{
    		TWsEvent e;
    		iWsSession.GetEvent(e);
    		TInt type = e.Type();
     
    		switch (type)
    		{
    		case EEventKey:	
    			if(iObserver.KeyCapturedL(e))
    			{
    			if(e.Key()->iScanCode==167)// fire key
    			{ 
    
                    TInt wgId =iWsSession.GetFocusWindowGroup(); 
    /* here the focus window id of the foreground session is returned  */ 
    		iWsSession.SendEventToAllWindowGroups(e);
    /* only the running text part is not getting refreshed for rest of the 
    area the application window shows , and is flickering very much*/
    				}
    			   }
    			break;
    		case EEventKeyUp:
    		case EEventKeyDown:
    			break;
    		};
    	}
    	
    	if (iStatus != KErrCancel&&((CAknExGridAppUi*)CEikonEnv::Static()->AppUi())->iBackground) 
    	{
    		Listen();
    	}
    
    	
    }
    Last edited by gigglie; 2008-05-03 at 11:48.

Similar Threads

  1. TCP server packet receiving problem
    By raj_rr7 in forum Symbian Networking & Messaging (Closed)
    Replies: 9
    Last Post: 2007-07-12, 12:24
  2. http and session management in j2me.
    By qasitouch in forum Mobile Java Networking & Messaging & Security
    Replies: 4
    Last Post: 2007-05-22, 14:31
  3. Window server events
    By rrrs in forum Symbian
    Replies: 3
    Last Post: 2006-11-30, 14:47
  4. How to enable Window Server AutoFlush?
    By Hendrik Bock in forum Symbian User Interface
    Replies: 0
    Last Post: 2004-04-04, 18:59
  5. http session
    By ysdl in forum Mobile Java Networking & Messaging & Security
    Replies: 0
    Last Post: 2003-09-29, 11:27

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×