×

Discussion Board

Results 1 to 3 of 3
  1. #1
    Regular Contributor
    Join Date
    Apr 2008
    Posts
    55

    RWindowGroup mystery

    The question is - why the code below doesn't display window immediately if I change EnableReceiptOfFocus(EFalse) to EnableReceiptOfFocus(ETrue). I get 3-4s of delay when starting or switching to such application. Yes, that's the code from Forum Nokia Wiki!

    Code:
    #include <e32base.h>
    #include <w32std.h>     // ws32.lib
    #include <coedef.h>
    class CCustomGraphics : public CActive
        {
    public:
        static CCustomGraphics* NewL();
        void CustomDraw( TRect& aRect );
        virtual ~CCustomGraphics();
    protected:
        CCustomGraphics();
        void    ConstructL();
        // from CActive
        void    DoCancel();
        void    RunL();
    protected:
        RWsSession       iWsSession;
        CWsScreenDevice* iScreenDevice;
        RWindowGroup     iWindowGroup;
        RWindow*         iWindow;
        CWindowGc*       iWindowGc;
        };
    CCustomGraphics::CCustomGraphics()
    : CActive( CActive::EPriorityLow )
        {
        CActiveScheduler::Add( this );
        }
    CCustomGraphics* CCustomGraphics::NewL()
        {
        CCustomGraphics* self = new (ELeave) CCustomGraphics;
        CleanupStack::PushL( self );
        self->ConstructL();
        CleanupStack::Pop(); // self;
        return self;
        }   
    void CCustomGraphics::ConstructL()
        {
        // Connect to window server session
        User::LeaveIfError( iWsSession.Connect() );  
        // Set client priority permanently to current level. See documentation on
        // RWsSession for more information
        iWsSession.ComputeMode( RWsSession::EPriorityControlDisabled );
        iScreenDevice = new (ELeave) CWsScreenDevice( iWsSession );
        User::LeaveIfError( iScreenDevice->Construct() );
        iScreenDevice->SetScreenModeEnforcement( ESizeEnforcementNone );
    iWindowGroup = RWindowGroup( iWsSession );
        User::LeaveIfError( iWindowGroup.Construct( (TUint32)this, ETrue ) );
        // This window group cannot receive keyboard focus
        iWindowGroup.EnableReceiptOfFocus( EFalse );
        // Window group will always be on top
        iWindowGroup.SetOrdinalPosition( 0, ECoeWinPriorityAlwaysAtFront+1 );
        // Create graphics context for the screen device
        User::LeaveIfError(iScreenDevice->CreateContext( iWindowGc ) );
    
        // Finally, create a window, set its properties, and display it
        iWindow = new (ELeave) RWindow( iWsSession );
        User::LeaveIfError(iWindow->Construct( iWindowGroup, (TUint32)iWindow ) );
        iWindow->SetExtent( TPoint( 10, 10 ), TSize( 100, 100 ) );
        iWindow->SetOrdinalPosition(0, ECoeWinPriorityAlwaysAtFront+1 );
        iWindow->SetCornerType( EWindowCorner5 );
        iWindow->SetNonFading( ETrue );
        iWindow->SetVisible( ETrue );
        iWindow->Activate();
        // Start waiting for redraw events
        iWsSession.RedrawReady( &iStatus );
        SetActive();
        }
    CCustomGraphics::~CCustomGraphics()
        {
        Cancel();
        iWindow->Close();
        delete iWindow;
        iWindowGroup.Close();
        delete iWindowGc;
        delete iScreenDevice;
        iWsSession.Close();
        }
    void CCustomGraphics::RunL()
        {
        if( iStatus == KErrNone )
            {
            TWsRedrawEvent event;
            iWsSession.GetRedraw( event );   
            // Handle of the window which is the target of redraw event
            // Can be used for ID purposes if multiple windows are used
            RWindow* window = ( RWindow* )( event.Handle() );   
            // Rectangle that needs to be redrawn
            TRect eventRect = event.Rect();
            CustomDraw( eventRect );                 
            iWsSession.RedrawReady( &iStatus );
            SetActive();
            }
        }
    void CCustomGraphics::DoCancel()
        {
        iWsSession.RedrawReadyCancel();
        }
    void CCustomGraphics::CustomDraw( TRect& /*aRect*/ )
        {
        iWindowGc->Activate( *iWindow );
        iWindow->BeginRedraw();
        iWindowGc->SetBrushStyle( CGraphicsContext::ESolidBrush );
        iWindowGc->SetBrushColor( TRgb( 255, 0, 0 ) );
        iWindowGc->Clear();
        iWindow->EndRedraw();
        iWindowGc->Deactivate();
        iWsSession.Flush();
        }
    Everything works just the way it should except there is this super strange delay. Any clue?

  2. #2
    Regular Contributor
    Join Date
    Apr 2008
    Posts
    55

    Re: RWindowGroup mystery

    *Bump* *bump*

  3. #3
    Nokia Developer Moderator
    Join Date
    Mar 2003
    Location
    Lempäälä/Finland
    Posts
    29,165

    Re: RWindowGroup mystery

    Never had a such problem, so I would think maybe others have not gotten it either, though I usually use non-focusing windows, if I do it that way. Anyway, can you add some time measurements, and see where the time is spend.

Similar Threads

  1. A Mystery – PYS60 3rd FP1 for N95 8G Phones
    By RickTheGreat in forum Symbian
    Replies: 4
    Last Post: 2009-01-09, 19:21
  2. related to RWindowGroup
    By jayshahce in forum Symbian User Interface
    Replies: 8
    Last Post: 2008-05-13, 13:33
  3. Replies: 2
    Last Post: 2007-09-13, 08:44
  4. Retrieving a RWindowGroup through ID
    By gdesantos in forum Symbian
    Replies: 0
    Last Post: 2006-09-08, 12:03
  5. closing window created through RWindowGroup
    By nitrajpal in forum Symbian
    Replies: 1
    Last Post: 2005-08-10, 12:11

Posting Permissions

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