os/graphics/windowing/windowserver/nga/SERVER/openwfc/WINDOW.CPP
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/graphics/windowing/windowserver/nga/SERVER/openwfc/WINDOW.CPP	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,1093 @@
     1.4 +// Copyright (c) 1994-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.5 +// All rights reserved.
     1.6 +// This component and the accompanying materials are made available
     1.7 +// under the terms of "Eclipse Public License v1.0"
     1.8 +// which accompanies this distribution, and is available
     1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.10 +//
    1.11 +// Initial Contributors:
    1.12 +// Nokia Corporation - initial contribution.
    1.13 +//
    1.14 +// Contributors:
    1.15 +//
    1.16 +// Description:
    1.17 +// Window functions
    1.18 +// 
    1.19 +//
    1.20 +
    1.21 +#include "server.h"
    1.22 +#include "rootwin.h"
    1.23 +#include "window.h"
    1.24 +#include "walkwindowtree.h"
    1.25 +#include "wstop.h"
    1.26 +#include "ScrDev.H"
    1.27 +#include "EVENT.H"
    1.28 +#include "ANIM.H"
    1.29 +#include "Direct.H"
    1.30 +#include "panics.h"
    1.31 +#include "backedupwindow.h"
    1.32 +#include "wstypes.h"
    1.33 +#include "windowelementset.h"
    1.34 +
    1.35 +CWsWindow* CWsWindow::iAccessListRecentEnd = 0;
    1.36 +CWsWindow* CWsWindow::iAccessListOldestEnd = 0;
    1.37 +
    1.38 +#ifndef _DEBUG
    1.39 +
    1.40 +#define LOG_WINDOW_REDRAW_START(wswin)
    1.41 +#define LOG_WINDOW_REDRAW_END(wswin)
    1.42 +#define LOG_WINDOW_ANIM_REDRAW_START(wswin)
    1.43 +#define LOG_WINDOW_ANIM_REDRAW_END(wswin)
    1.44 +#define LOG_WINDOW_SPRITE_REDRAW_START(aWsWin)
    1.45 +#define LOG_WINDOW_SPRITE_REDRAW_END(aWsWin)
    1.46 +
    1.47 +#else
    1.48 +
    1.49 +#define LOG_WINDOW_REDRAW_START(wswin) LogWindowRedrawStart(wswin)
    1.50 +#define LOG_WINDOW_REDRAW_END(wswin) LogWindowRedrawEnd(wswin)
    1.51 +#define LOG_WINDOW_ANIM_REDRAW_START(wswin) LogWindowAnimRedrawStart(wswin)
    1.52 +#define LOG_WINDOW_ANIM_REDRAW_END(wswin) LogWindowAnimRedrawEnd(wswin)
    1.53 +#define LOG_WINDOW_SPRITE_REDRAW_START(wswin) LogWindowSpriteRedrawStart(wswin)
    1.54 +#define LOG_WINDOW_SPRITE_REDRAW_END(wswin) LogWindowSpriteRedrawEnd(wswin) 
    1.55 +
    1.56 +#include "../debuglog/DEBUGLOG.H"
    1.57 +extern CDebugLogBase *wsDebugLog;
    1.58 +
    1.59 +extern void LogRegion(const TRegion* aRegion)
    1.60 +    {
    1.61 +    TBuf<LogTBufSize> log;
    1.62 +    TTruncateOverflow overflow;
    1.63 +    TInt rectCount = (aRegion == NULL ? 0 : aRegion->Count());
    1.64 +    log.AppendFormat(_L("Fading region: [%d,"), &overflow, rectCount);
    1.65 +    if (rectCount > 0)
    1.66 +        {
    1.67 +        const TRect* rectangles = aRegion->RectangleList();
    1.68 +        TBuf<1> comma;
    1.69 +        for (TInt ii = 0; ii < rectCount; ii++)
    1.70 +            {
    1.71 +            TRect current = rectangles[ii];
    1.72 +            log.AppendFormat(_L("%S{{%d,%d},{%d,%d}}"), &overflow, &comma,
    1.73 +                             current.iTl.iX,current.iTl.iY,current.iBr.iX,current.iBr.iY);
    1.74 +            comma = _L(",");
    1.75 +            }
    1.76 +        }
    1.77 +    else
    1.78 +        {
    1.79 +        log.AppendFormat(_L("NULL"), &overflow);
    1.80 +        }
    1.81 +    log.AppendFormat(_L("]"), &overflow);
    1.82 +    wsDebugLog->MiscMessage(CDebugLogBase::ELogEverything, log);
    1.83 +    }
    1.84 +
    1.85 +extern void LogFadeStart(const CWsWindow* aWsWin)
    1.86 +    {
    1.87 +    if (wsDebugLog && aWsWin->WsOwner())
    1.88 +        {
    1.89 +        _LIT(KLogDrawCommandsStart, ">> CWsRedrawMsgWindow::Fade() [%S][app %d] RWindow[%d]");
    1.90 +        const TDesC& clientName = aWsWin->WsOwner()->Client().FullName();
    1.91 +        TBuf<LogTBufSize> log;
    1.92 +        TTruncateOverflow overflow;
    1.93 +        log.AppendFormat(KLogDrawCommandsStart, &overflow, &clientName, aWsWin->WsOwner()->ConnectionHandle(), aWsWin->LogHandle());
    1.94 +        wsDebugLog->MiscMessage(CDebugLogBase::ELogEverything, log);
    1.95 +        }
    1.96 +    }
    1.97 +
    1.98 +extern void LogFadeRegion(const TRegion* aRegion)
    1.99 +    {
   1.100 +    if (wsDebugLog)
   1.101 +        {
   1.102 +        LogRegion(aRegion);
   1.103 +        }
   1.104 +    }
   1.105 +
   1.106 +extern void LogFadeEnd(const CWsWindow* aWsWin)
   1.107 +    {
   1.108 +    if (wsDebugLog && aWsWin->WsOwner())
   1.109 +        {
   1.110 +        _LIT(KLogDrawCommandsEnd, "<< CWsRedrawMsgWindow::Fade() [%S][app %d] RWindow[%d]");
   1.111 +        const TDesC& clientName = aWsWin->WsOwner()->Client().FullName();
   1.112 +        TBuf<LogTBufSize> log;
   1.113 +        TTruncateOverflow overflow;
   1.114 +        log.AppendFormat(KLogDrawCommandsEnd, &overflow, &clientName, aWsWin->WsOwner()->ConnectionHandle(), aWsWin->LogHandle());      
   1.115 +        wsDebugLog->MiscMessage(CDebugLogBase::ELogEverything, log);
   1.116 +        }
   1.117 +    }
   1.118 +
   1.119 +static void LogWindowRedrawStart(const CWsWindow& aWsWin)
   1.120 +    {
   1.121 +    if (wsDebugLog)
   1.122 +         {
   1.123 +         TBuf<LogTBufSize> log;
   1.124 +         TTruncateOverflow overflow;
   1.125 +         if(aWsWin.Type() == WS_HANDLE_ROOT_WINDOW)
   1.126 +             {
   1.127 +             _LIT(KAnnotateWindowRedrawStart, ">> MWsDrawAnnotationObserver::WindowRedrawStart RootWindow for screen:%d");
   1.128 +             log.AppendFormat(KAnnotateWindowRedrawStart, &overflow, aWsWin.Screen()->ScreenNumber());
   1.129 +             }
   1.130 +         else
   1.131 +             {
   1.132 +             _LIT(KAnnotateWindowRedrawStart, ">> MWsDrawAnnotationObserver::WindowRedrawStart [%S][app %d] RWindow[%d]");
   1.133 +             const TDesC& clientName = aWsWin.WsOwner()->Client().FullName();
   1.134 +             log.AppendFormat(KAnnotateWindowRedrawStart, &overflow, &clientName, aWsWin.WsOwner()->ConnectionHandle(), aWsWin.LogHandle());
   1.135 +             }
   1.136 +         wsDebugLog->MiscMessage(CDebugLogBase::ELogEverything, log);
   1.137 +         }    
   1.138 +    }
   1.139 +
   1.140 +static void LogWindowRedrawEnd(const CWsWindow& aWsWin)
   1.141 +    {
   1.142 +    if (wsDebugLog)
   1.143 +        {
   1.144 +        TBuf<LogTBufSize> log;
   1.145 +        TTruncateOverflow overflow;
   1.146 +        if(aWsWin.Type() == WS_HANDLE_ROOT_WINDOW)
   1.147 +            {
   1.148 +            _LIT(KAnnotateWindowRedrawEnd, "<< MWsDrawAnnotationObserver::WindowRedrawEnd RootWindow for screen:%d");
   1.149 +            log.AppendFormat(KAnnotateWindowRedrawEnd, &overflow, aWsWin.Screen()->ScreenNumber());
   1.150 +            }
   1.151 +        else
   1.152 +            {
   1.153 +            _LIT(KAnnotateWindowRedrawEnd, "<< MWsDrawAnnotationObserver::WindowRedrawEnd [%S][app %d] RWindow[%d]");
   1.154 +            const TDesC& clientName = aWsWin.WsOwner()->Client().FullName();
   1.155 +            log.AppendFormat(KAnnotateWindowRedrawEnd, &overflow, &clientName, aWsWin.WsOwner()->ConnectionHandle(), aWsWin.LogHandle());
   1.156 +            }
   1.157 +        wsDebugLog->MiscMessage(CDebugLogBase::ELogEverything, log);
   1.158 +        }
   1.159 +    }
   1.160 +
   1.161 +static void LogWindowAnimRedrawStart(const CWsWindow& aWsWin)
   1.162 +    {
   1.163 +    if (wsDebugLog)
   1.164 +        {
   1.165 +        _LIT(KAnnotateWindowAnimRedrawStart, " >> MWsDrawAnnotationObserver::WindowAnimRedrawStart [%S][app %d] RWindow[%d]");
   1.166 +        const TDesC& clientName = aWsWin.WsOwner()->Client().FullName();
   1.167 +        TBuf<LogTBufSize> log;
   1.168 +        TTruncateOverflow overflow;
   1.169 +        log.AppendFormat(KAnnotateWindowAnimRedrawStart, &overflow, &clientName, aWsWin.WsOwner()->ConnectionHandle(), aWsWin.LogHandle());
   1.170 +        wsDebugLog->MiscMessage(CDebugLogBase::ELogEverything, log);
   1.171 +        }
   1.172 +    }
   1.173 +
   1.174 +static void LogWindowAnimRedrawEnd(const CWsWindow& aWsWin)
   1.175 +    {
   1.176 +    if (wsDebugLog)
   1.177 +        {
   1.178 +        _LIT(KAnnotateWindowAnimRedrawEnd, " << MWsDrawAnnotationObserver::WindowAnimRedrawEnd [%S][app %d] RWindow[%d]");
   1.179 +        const TDesC& clientName = aWsWin.WsOwner()->Client().FullName();
   1.180 +        TBuf<LogTBufSize> log;
   1.181 +        TTruncateOverflow overflow;
   1.182 +        log.AppendFormat(KAnnotateWindowAnimRedrawEnd, &overflow, &clientName, aWsWin.WsOwner()->ConnectionHandle(), aWsWin.LogHandle());
   1.183 +        wsDebugLog->MiscMessage(CDebugLogBase::ELogEverything, log);
   1.184 +        }
   1.185 +    }
   1.186 +
   1.187 +static void LogWindowSpriteRedrawStart(const CWsWindow& aWsWin)
   1.188 +    {
   1.189 +    if (wsDebugLog)
   1.190 +        {
   1.191 +        TBuf<LogTBufSize> log;
   1.192 +        TTruncateOverflow overflow;
   1.193 +        if(aWsWin.Type() == WS_HANDLE_ROOT_WINDOW)
   1.194 +            {
   1.195 +            _LIT(KAnnotateSpriteRedrawStart, "<< MWsDrawAnnotationObserver::WindowSpriteRedrawStart RootWindow for screen:%d");
   1.196 +            log.AppendFormat(KAnnotateSpriteRedrawStart, &overflow, aWsWin.Screen()->ScreenNumber());
   1.197 +            }
   1.198 +        else
   1.199 +            {
   1.200 +            _LIT(KAnnotateSpriteRedrawStart, " >> MWsDrawAnnotationObserver::WindowSpriteRedrawStart [%S][app %d] RWindow[%d]");
   1.201 +            const TDesC& clientName = aWsWin.WsOwner()->Client().FullName();
   1.202 +            log.AppendFormat(KAnnotateSpriteRedrawStart, &overflow, &clientName, aWsWin.WsOwner()->ConnectionHandle(), aWsWin.LogHandle());
   1.203 +            }
   1.204 +        wsDebugLog->MiscMessage(CDebugLogBase::ELogEverything, log);
   1.205 +        }
   1.206 +    }
   1.207 +
   1.208 +static void LogWindowSpriteRedrawEnd(const CWsWindow& aWsWin)
   1.209 +    {
   1.210 +    if (wsDebugLog)
   1.211 +        {
   1.212 +        TBuf<LogTBufSize> log;
   1.213 +        TTruncateOverflow overflow;
   1.214 +        if(aWsWin.Type() == WS_HANDLE_ROOT_WINDOW)
   1.215 +            {
   1.216 +            _LIT(KAnnotateSpriteRedrawEnd, " << MWsDrawAnnotationObserver::WindowSpriteRedrawEnd RootWindow for screen:%d");
   1.217 +            log.AppendFormat(KAnnotateSpriteRedrawEnd, &overflow, aWsWin.Screen()->ScreenNumber());
   1.218 +            }
   1.219 +        else
   1.220 +            {
   1.221 +            _LIT(KAnnotateSpriteRedrawEnd, " << MWsDrawAnnotationObserver::WindowSpriteRedrawEnd [%S][app %d] RWindow[%d]");
   1.222 +            const TDesC& clientName = aWsWin.WsOwner()->Client().FullName();
   1.223 +            log.AppendFormat(KAnnotateSpriteRedrawEnd, &overflow, &clientName, aWsWin.WsOwner()->ConnectionHandle(), aWsWin.LogHandle());
   1.224 +            }
   1.225 +        wsDebugLog->MiscMessage(CDebugLogBase::ELogEverything, log);
   1.226 +        }
   1.227 +    }
   1.228 +
   1.229 +#endif
   1.230 +
   1.231 +extern void AnnotateWindowRedrawStart(const CWsWindow& aWsWin, const TRegion& aRegion)
   1.232 +    {
   1.233 +    LOG_WINDOW_REDRAW_START(aWsWin);
   1.234 +    MWsDrawAnnotationObserver* annoObs = aWsWin.Screen()->DrawAnnotationObserver();
   1.235 +    if(annoObs)
   1.236 +        {
   1.237 +        annoObs->WindowRedrawStart(aWsWin, aRegion);
   1.238 +        }
   1.239 +    }
   1.240 +
   1.241 +extern void AnnotateWindowRedrawEnd(const CWsWindow& aWsWin)
   1.242 +    {
   1.243 +    LOG_WINDOW_REDRAW_END(aWsWin);
   1.244 +    MWsDrawAnnotationObserver* annoObs = aWsWin.Screen()->DrawAnnotationObserver();
   1.245 +    if(annoObs)
   1.246 +        {
   1.247 +        annoObs->WindowRedrawEnd(aWsWin);
   1.248 +        }
   1.249 +    }
   1.250 +
   1.251 +extern void AnnotateWindowAnimRedrawStart(const CWsWindow& aWsWin, const CWsAnim& aAnim, const TRegion& aRegion)
   1.252 +    {
   1.253 +    LOG_WINDOW_ANIM_REDRAW_START(aWsWin);
   1.254 +    MWsDrawAnnotationObserver* annoObs = aWsWin.Screen()->DrawAnnotationObserver();
   1.255 +    if(annoObs)
   1.256 +        {
   1.257 +        annoObs->WindowAnimRedrawStart(aAnim, aRegion);
   1.258 +        }
   1.259 +    }
   1.260 +
   1.261 +extern void AnnotateWindowAnimRedrawEnd(const CWsWindow& aWsWin, const CWsAnim& aAnim)
   1.262 +    {
   1.263 +    LOG_WINDOW_ANIM_REDRAW_END(aWsWin);
   1.264 +    MWsDrawAnnotationObserver* annoObs = aWsWin.Screen()->DrawAnnotationObserver();
   1.265 +    if(annoObs)
   1.266 +        {
   1.267 +        annoObs->WindowAnimRedrawEnd(aAnim);
   1.268 +        }
   1.269 +    }
   1.270 +
   1.271 +extern void AnnotateSpriteRedrawStart(const CWsWindow& aWsWin, const CWsSpriteBase& aSprite, const TRegion& aRegion)
   1.272 +    {
   1.273 +    LOG_WINDOW_SPRITE_REDRAW_START(aWsWin);
   1.274 +    MWsDrawAnnotationObserver* annoObs = aWsWin.Screen()->DrawAnnotationObserver();
   1.275 +    if(annoObs)
   1.276 +        {
   1.277 +        annoObs->SpriteRedrawStart(aSprite, aRegion);
   1.278 +        }   
   1.279 +    }
   1.280 +
   1.281 +extern void AnnotateSpriteRedrawEnd(const CWsWindow& aWsWin, const CWsSpriteBase& aSprite)
   1.282 +    {
   1.283 +    LOG_WINDOW_SPRITE_REDRAW_END(aWsWin);
   1.284 +    MWsDrawAnnotationObserver* annoObs = aWsWin.Screen()->DrawAnnotationObserver();
   1.285 +    if(annoObs)
   1.286 +        {
   1.287 +        annoObs->SpriteRedrawEnd(aSprite);
   1.288 +        }
   1.289 +    }
   1.290 +
   1.291 +CWsWindow::CWsWindow(CWsClient* aOwner,WH_HANDLES aType, CScreen* aScreen) : CWsWindowBase(aOwner,aType,aScreen),
   1.292 +	iFlags(EFlagHidden),
   1.293 +	iDSAs(_FOFF(CWsDirectScreenAccess,iMultipleDSALink))
   1.294 +	{
   1.295 +	}
   1.296 +
   1.297 +CWsWindow::~CWsWindow()
   1.298 +	{
   1.299 +	//2-phase destruction, Shutdown() is called before destructor
   1.300 +	iFadableRegion.Reset();
   1.301 +	iQuickFadeRegion.Reset();
   1.302 +	}
   1.303 +
   1.304 +void CWsWindow::Fade(MWsGraphicsContext * aGc, const TRegion& aRegion)
   1.305 +	{
   1.306 +	if ( NULL != iRedraw )
   1.307 +		{
   1.308 +		iRedraw->Fade( aGc, aRegion );
   1.309 +		}
   1.310 +	}
   1.311 +
   1.312 +void CWsWindow::Construct()
   1.313 +	{	
   1.314 +	InsertIntoAccessListOldestEnd();
   1.315 +	}
   1.316 +
   1.317 +void CWsWindow::Shutdown()
   1.318 +	{
   1.319 +	TWindowServerEvent::NotifyDrawer(TWservCrEvent(TWservCrEvent::EWindowClosing, 0, 0, this));
   1.320 +	RemoveFromAccessList();
   1.321 +	CWsAnim::WindowClosing(iAnimList);	// Destroy any animated objects attached to this window
   1.322 +	iVisibleRegion.Reset();
   1.323 +	iScheduledRegion.Reset();
   1.324 +	iScheduledSpriteRegion.Reset();
   1.325 +	iDirtyWindowRegion.Reset();
   1.326 +	iDirtySpriteRegion.Reset();
   1.327 +	AbortAllDSAs();
   1.328 +	CWsWindowBase::Shutdown();
   1.329 +	SetPointerCursor(NULL);
   1.330 +	delete iRedraw;
   1.331 +	iRedraw=NULL;
   1.332 +	Screen()->RemoveFromScheduledList(this);
   1.333 +	Screen()->RemoveFromTimedDrawList(this);
   1.334 +	Screen()->RemoveFromQuickFadeList(this);
   1.335 +	}
   1.336 +
   1.337 +//
   1.338 +// Region and invalid area functions //
   1.339 +//
   1.340 +
   1.341 +TRect CWsWindow::FullRect() const
   1.342 +	{
   1.343 +	return(TRect(iOrigin,iRel.Size()));
   1.344 +	}
   1.345 +
   1.346 +//
   1.347 +// Normal regions //
   1.348 +//
   1.349 +
   1.350 +void CWsWindow::AreaCovered(TRegion &aRegion)
   1.351 +	{
   1.352 +	aRegion.Copy(WindowArea());
   1.353 +	}
   1.354 +
   1.355 +void CWsWindow::SetNonFading(TBool aNonFade)
   1.356 +	{
   1.357 +	const TUint oldFlags = iFlags;
   1.358 +
   1.359 +	if (aNonFade)
   1.360 +		iFlags|=EFlagNonFadingWindow;
   1.361 +	else
   1.362 +		iFlags&=(~EFlagNonFadingWindow);
   1.363 +	
   1.364 + 	//Schedule window for quickfade if non-fading flag is changed	
   1.365 +	if (!Screen()->ChangeTracking() &&  CWsTop::IsFadeEnabled() && (oldFlags != iFlags) ) 
   1.366 +		{
   1.367 +		Screen()->AcceptFadeRequest(this, !aNonFade);
   1.368 +		}
   1.369 +	
   1.370 +	MWsWindowTreeObserver* const windowTreeObserver = Screen()->WindowTreeObserver();
   1.371 +	if (windowTreeObserver && oldFlags!=iFlags)
   1.372 +		windowTreeObserver->FlagChanged(*this, MWsWindowTreeObserver::ENonFading, aNonFade); 
   1.373 +	}
   1.374 +
   1.375 +TPoint CWsWindow::InquireOffset(TUint32 aHandle) const
   1.376 +	{
   1.377 +	CWsWindowBase *win2;
   1.378 +	iWsOwner->HandleToWindow(aHandle,&win2);
   1.379 +	return(iOrigin-win2->Origin());
   1.380 +	}
   1.381 +
   1.382 +TDisplayMode CWsWindow::SetRequiredDisplayModeL(TDisplayMode)
   1.383 +	{
   1.384 +	return DisplayMode();
   1.385 +	}
   1.386 +
   1.387 +TDisplayMode CWsWindow::DisplayMode() const
   1.388 +	{
   1.389 +	return iScreen->DisplayMode();
   1.390 +	}
   1.391 +
   1.392 +void CWsWindow::StatusDump(TDes &aBuf)
   1.393 +	{
   1.394 +	_LIT(KStatusString1,"CWsWindow[0x%x]RWindow[0x%x,%d],Pos(%d,%d),Size(%d,%d)");
   1.395 +	_LIT(KStatusString3,",Mode=%d");
   1.396 +	_LIT(KStatusInvisible,",Inv");
   1.397 +	aBuf.AppendFormat(KStatusString1,this,iClientHandle,LogHandle(),iRel.iTl.iX,iRel.iTl.iY,Size().iWidth,Size().iHeight);
   1.398 +	TDisplayMode displayMode = DisplayMode();
   1.399 +	aBuf.AppendFormat(KStatusString3,(TInt&)displayMode);
   1.400 +	if (!IsVisible())
   1.401 +		aBuf.Append(KStatusInvisible);
   1.402 +	}
   1.403 +
   1.404 +TDblQue<TPointerKeyList> *CWsWindow::PointerKeyList() const
   1.405 +	{
   1.406 +	return(NULL);
   1.407 +	}
   1.408 +
   1.409 +TInt CWsWindow::AddDSA(CWsDirectScreenAccess& aDirect)
   1.410 +	{
   1.411 +	TInt error = KErrNone;
   1.412 +
   1.413 +	if (iDSAs.IsEmpty() && !aDirect.IsRegionTrackingOnly())
   1.414 +		{
   1.415 +		TRAP(error,iRedraw->SetDsaElementL());
   1.416 +		}
   1.417 +
   1.418 +	if (!error)
   1.419 +		{
   1.420 +		iDSAs.AddLast(aDirect);
   1.421 +		}
   1.422 +
   1.423 +	return error;
   1.424 +	}
   1.425 +
   1.426 +void CWsWindow::RemoveDSA(CWsDirectScreenAccess& aDirect)
   1.427 +	{
   1.428 +	iDSAs.Remove(aDirect);
   1.429 +	}
   1.430 +
   1.431 +void CWsWindow::AbortAllDSAs()
   1.432 +	{
   1.433 +	iScreen->AbortDSAs(RDirectScreenAccess::ETerminateRegion,iDSAs);
   1.434 +	}
   1.435 +
   1.436 +void CWsWindow::PossibleVisibilityChangedEvent(TBool aForceSend)
   1.437 +	{
   1.438 +	// notify plugin
   1.439 +	//
   1.440 +	// coverity[unchecked_value]
   1.441 +	TWservCrEvent crEvent(TWservCrEvent::EWindowVisibilityChanged, HasBeenDrawnToScreen(), IsVisible()? &iVisibleRegion : NULL, this);
   1.442 +	TWindowServerEvent::NotifyDrawer(crEvent);
   1.443 +	
   1.444 +	if (!(iFlags & EFlagGeneratesVisibilityEvents))
   1.445 +		return;
   1.446 +
   1.447 +	if (!IsVisible())
   1.448 +		{
   1.449 +		goto notvisible;
   1.450 +		}
   1.451 +
   1.452 +	if (iVisibleRegion.Count() == 0)
   1.453 +		{
   1.454 +		goto notvisible;
   1.455 +		}
   1.456 +
   1.457 +		{// braces here to avoid gccxml error
   1.458 +		TInt visibleArea = 0;
   1.459 +		TInt count = iVisibleRegion.Count();
   1.460 +		TInt ii;
   1.461 +		for (ii = 0; ii < count; ii++)
   1.462 +			{
   1.463 +			visibleArea+= iVisibleRegion[ii].Width() * iVisibleRegion[ii].Height();
   1.464 +			}
   1.465 +
   1.466 +		const TRegion* baseRegion = (static_cast<CWsClientWindow*>(this))->BaseArea();
   1.467 +		TInt baseArea = 0;
   1.468 +		count = baseRegion->Count();
   1.469 +		for (ii = 0; ii < count; ii++)
   1.470 +			{
   1.471 +			const TRect& rect = (*baseRegion)[ii];
   1.472 +			baseArea+= rect.Width() * rect.Height();
   1.473 +			}
   1.474 +
   1.475 +		if (visibleArea == baseArea)
   1.476 +			{
   1.477 +			goto fullyvisible;
   1.478 +			}
   1.479 +		else
   1.480 +			{
   1.481 +			goto partiallyvisible;
   1.482 +			}
   1.483 +		}
   1.484 +
   1.485 +fullyvisible:
   1.486 +	if (aForceSend || !(iFlags & EFlagNotCantBeSeen) || !(iFlags & EFlagCanBeSeen))
   1.487 +		{
   1.488 +		iFlags |= (EFlagCanBeSeen | EFlagNotCantBeSeen);
   1.489 +		TWindowServerEvent::SendVisibilityChangedEvents(this, TWsVisibilityChangedEvent::EPartiallyVisible | TWsVisibilityChangedEvent::EFullyVisible);
   1.490 +		// we have to set EPartiallyVisible too for compatibility reasons
   1.491 +		}
   1.492 +	return;
   1.493 +
   1.494 +partiallyvisible:
   1.495 +	if (aForceSend || !(iFlags & EFlagCanBeSeen) || (iFlags & EFlagNotCantBeSeen))
   1.496 +		{
   1.497 +		iFlags |= EFlagCanBeSeen;
   1.498 +		iFlags &= ~EFlagNotCantBeSeen;
   1.499 +		TWindowServerEvent::SendVisibilityChangedEvents(this, TWsVisibilityChangedEvent::EPartiallyVisible);
   1.500 +		}
   1.501 +	return;
   1.502 +
   1.503 +notvisible:
   1.504 +	if (aForceSend || (iFlags & EFlagCanBeSeen) || (iFlags & EFlagNotCantBeSeen))
   1.505 +		{
   1.506 +		iFlags &= ~(EFlagCanBeSeen | EFlagNotCantBeSeen);
   1.507 +		TWindowServerEvent::SendVisibilityChangedEvents(this, TWsVisibilityChangedEvent::ENotVisible);
   1.508 +		}
   1.509 +	return;
   1.510 +	}
   1.511 +
   1.512 +TPoint CWsWindow::Origin() const
   1.513 +	{
   1.514 +	return iOrigin;
   1.515 +	}
   1.516 +
   1.517 +TRect CWsWindow::AbsRect() const
   1.518 +	{
   1.519 +	return iAbs;
   1.520 +	}
   1.521 +	
   1.522 +TSize CWsWindow::Size() const
   1.523 +	{
   1.524 +	return iRel.Size();
   1.525 +	}
   1.526 +
   1.527 +TBool CWsWindow::SetScheduledRegion(const TRegion& aRegion)
   1.528 +	{
   1.529 +	iScheduledRegion.Copy(aRegion);
   1.530 +	return !iScheduledRegion.CheckError();
   1.531 +	}
   1.532 +
   1.533 +void CWsWindow::ClearScheduledRegion()
   1.534 +	{
   1.535 +	iScheduledRegion.Reset();
   1.536 +	}
   1.537 +
   1.538 +void CWsWindow::SetFadeBehind(TBool aFade)
   1.539 +	{
   1.540 +	if (aFade != ((iFlags & EFlagFadeBehind) != 0))
   1.541 +		{
   1.542 +		iFlags ^= EFlagFadeBehind;
   1.543 +		}
   1.544 +	}
   1.545 +
   1.546 +void CWsWindow::FocusChanged(TBool aNewFocusState)
   1.547 +	{
   1.548 +	TRAPD(err,FocusChangedL(aNewFocusState));
   1.549 +	if (err!=KErrNone)
   1.550 +		OwnerPanic(EWservPanicAnimLeave);
   1.551 +	}
   1.552 +
   1.553 +void CWsWindow::FocusChangedL(TBool aNewFocusState)
   1.554 +	{
   1.555 +	for (CWsAnim * anim = iAnimList; anim; anim = anim->Next())
   1.556 +		{
   1.557 +		anim->FocusChanged(aNewFocusState);
   1.558 +		}
   1.559 +	}
   1.560 +
   1.561 +// Moves a window to the recent end of the accessed list
   1.562 +void CWsWindow::Accessed()
   1.563 +	{
   1.564 +	WS_ASSERT_DEBUG(iAccessListRecentEnd && iAccessListOldestEnd, EWsPanicAccessList);
   1.565 +
   1.566 +	RemoveFromAccessList();	
   1.567 +	InsertIntoAccessListRecentEnd();
   1.568 +	}
   1.569 +
   1.570 +void CWsWindow::InsertIntoAccessListOldestEnd()
   1.571 +	{
   1.572 +	iAccessListPrev = 0;
   1.573 +	iAccessListNext = iAccessListOldestEnd;
   1.574 +	if (iAccessListNext)
   1.575 +		iAccessListNext->iAccessListPrev = this;
   1.576 +	iAccessListOldestEnd = this;
   1.577 +	if (!iAccessListRecentEnd)
   1.578 +		iAccessListRecentEnd = this;
   1.579 +	}
   1.580 +
   1.581 +void CWsWindow::InsertIntoAccessListRecentEnd()
   1.582 +	{
   1.583 +	iAccessListNext = 0;
   1.584 +	iAccessListPrev = iAccessListRecentEnd;
   1.585 +	if (iAccessListPrev)
   1.586 +		iAccessListPrev->iAccessListNext = this;
   1.587 +	iAccessListRecentEnd = this;
   1.588 +	if (!iAccessListOldestEnd)
   1.589 +		iAccessListOldestEnd = this;
   1.590 +	}
   1.591 +
   1.592 +void CWsWindow::RemoveFromAccessList()
   1.593 +	{
   1.594 +	if (iAccessListOldestEnd == this)
   1.595 +		iAccessListOldestEnd = iAccessListNext;
   1.596 +	if (iAccessListRecentEnd == this)
   1.597 +		iAccessListRecentEnd = iAccessListPrev;
   1.598 +	if (iAccessListPrev)
   1.599 +		iAccessListPrev->iAccessListNext = iAccessListNext;
   1.600 +	if (iAccessListNext)
   1.601 +		iAccessListNext->iAccessListPrev = iAccessListPrev;
   1.602 +	}
   1.603 +	
   1.604 +TBool CWsWindow::ReleaseMemory(MWsMemoryRelease::TMemoryReleaseLevel aLevel)
   1.605 +	{
   1.606 +	for (CWsWindow * access = iAccessListOldestEnd; access; access = access->iAccessListNext)
   1.607 +		{
   1.608 +		if(access->Redraw())
   1.609 +			{
   1.610 +			if (access->Redraw()->ReleaseMemory(aLevel))
   1.611 +				return ETrue;
   1.612 +			}
   1.613 +		}
   1.614 +	return EFalse;
   1.615 +	}
   1.616 +
   1.617 +const TRegion& CWsWindow::VisibleRegion() const
   1.618 +	{
   1.619 +	return(iVisibleRegion);
   1.620 +	}
   1.621 +
   1.622 +const TRegion& CWsWindow::QuickFadeRegion() const
   1.623 +   	{
   1.624 +   	return iQuickFadeRegion;
   1.625 +   	}
   1.626 +
   1.627 +const TRegion& CWsWindow::FadableRegion() const
   1.628 +	{
   1.629 +	return iFadableRegion;
   1.630 +	}
   1.631 +
   1.632 +TBool CWsWindow::IsDSAHost() const
   1.633 +	{
   1.634 +	TBool res = EFalse; 
   1.635 +	if ( !iDSAs.IsEmpty() )
   1.636 +		{
   1.637 +		TSglQueIter<CWsDirectScreenAccess> iter( (TSglQueBase&)iDSAs );
   1.638 +		iter.SetToFirst();
   1.639 +		CWsDirectScreenAccess* dsa;
   1.640 +		while ( (dsa = iter++) != NULL && !res )
   1.641 +			{
   1.642 +			res = dsa->IsVisible();
   1.643 +			}
   1.644 +		}
   1.645 +	return res;
   1.646 +	}
   1.647 +
   1.648 +void CWsWindow::SendState(MWsWindowTreeObserver& aWindowTreeObserver) const
   1.649 +	{
   1.650 +	aWindowTreeObserver.NodeCreated(*this, ParentNode());
   1.651 +	
   1.652 +	if(iFlags & EFlagActive)
   1.653 +		{
   1.654 +		aWindowTreeObserver.NodeExtentChanged(*this, FullRect());
   1.655 +		aWindowTreeObserver.NodeActivated(*this);
   1.656 +		}
   1.657 +	
   1.658 +	if(!IsVisible())
   1.659 +		{
   1.660 +		aWindowTreeObserver.FlagChanged(*this, MWsWindowTreeObserver::EVisible, EFalse);
   1.661 +		}
   1.662 +	
   1.663 +	if(IsTrackingVisibleRegion())
   1.664 +		{
   1.665 +		MWsWindowVisibilityNotifier* windowVisibilityNotifier = Screen()->WindowVisibilityNotifier();
   1.666 +		if(windowVisibilityNotifier)
   1.667 +			windowVisibilityNotifier->RegisterWindow(*this);
   1.668 +		}
   1.669 +
   1.670 +	if(HasAlpha())
   1.671 +		{
   1.672 +		aWindowTreeObserver.FlagChanged(*this, MWsWindowTreeObserver::EAlphaChannelTransparencyEnabled, ETrue);
   1.673 +		}
   1.674 +	
   1.675 +	if(IsNonFading())
   1.676 +		{
   1.677 +		aWindowTreeObserver.FlagChanged(*this, MWsWindowTreeObserver::ENonFading, ETrue); 
   1.678 +		}
   1.679 +	
   1.680 +	if(IsTopClientWindow() && (iFlags&EFlagScreenDeviceInvalid) )
   1.681 +		{
   1.682 +		aWindowTreeObserver.FlagChanged(*this, MWsWindowTreeObserver::EScreenDeviceValid, EFalse);
   1.683 +		}
   1.684 +	
   1.685 +	if(iAnimList)
   1.686 +		iAnimList->SendState(aWindowTreeObserver);
   1.687 +	
   1.688 +	CWsWindowBase::SendState(aWindowTreeObserver);
   1.689 +	}
   1.690 +
   1.691 +void CWsWindow::ResetVisibleRegion()
   1.692 +	{
   1.693 +	if (!iVisibleRegion.IsEmpty())
   1.694 +		{
   1.695 +		iVisibleRegion.Reset();
   1.696 +		}
   1.697 +	iFadableRegion.Reset();
   1.698 +	iQuickFadeRegion.Reset();
   1.699 +	}
   1.700 +
   1.701 +void CWsWindow::SetVisibleRegion(const TRegion& aNewRegion, const TRegion* aTop)
   1.702 +	{
   1.703 +	WS_ASSERT_DEBUG(iScreen, EWsPanicNoScreen);
   1.704 +	STACK_REGION difference;
   1.705 +	TBool diffs = EFalse;
   1.706 +
   1.707 +	difference.Copy(iVisibleRegion);	
   1.708 +	difference.SubRegion(aNewRegion);
   1.709 +	if (!difference.IsEmpty())
   1.710 +		{
   1.711 +		diffs = ETrue;
   1.712 +		if (IsTranslucent())
   1.713 +			{
   1.714 +			iScreen->AddRedrawRegion(difference, EFalse);	
   1.715 +			}
   1.716 +		}
   1.717 +
   1.718 +	difference.Copy(aNewRegion);
   1.719 +	if (HasBeenDrawnToScreen())
   1.720 +		{
   1.721 +		difference.SubRegion(iVisibleRegion);
   1.722 +		}
   1.723 +	if (!difference.IsEmpty())
   1.724 +		{
   1.725 +		diffs = ETrue;
   1.726 +		if(!iScreen->ChangeTracking())
   1.727 +			{
   1.728 +			//the following code will restart animations
   1.729 +			STACK_REGION topDiff;
   1.730 +			topDiff.Copy(difference);
   1.731 +			WS_ASSERT_DEBUG(aTop,EWsPanicRegion);
   1.732 +			topDiff.Intersect(*aTop);
   1.733 +			difference.SubRegion(topDiff);
   1.734 +			iScreen->AddRedrawRegion(topDiff, EFalse, ERedrawTopOnly);
   1.735 +			iScreen->AddRedrawRegion(difference, EFalse, ERedrawAll);
   1.736 +			topDiff.Close();
   1.737 +			}
   1.738 +		else if(IsVisible())
   1.739 +			{
   1.740 +			RestartAnimations(aNewRegion);
   1.741 +			}
   1.742 +		}
   1.743 +
   1.744 +	difference.Close();
   1.745 +
   1.746 +	AbortDsaIfRequired(aNewRegion, aTop);
   1.747 +
   1.748 +	if (diffs)
   1.749 +		{
   1.750 +		ResetVisibleRegion();
   1.751 +		iVisibleRegion.Copy(aNewRegion);
   1.752 +		PossibleVisibilityChangedEvent(EFalse);
   1.753 +		
   1.754 +		if (Redraw()->HasElement())
   1.755 +			{
   1.756 +			WS_ASSERT_DEBUG(WinType()==EWinTypeClient,EWsPanicWindowType);
   1.757 +			
   1.758 +			if (WinType()==EWinTypeClient)
   1.759 +				{
   1.760 +				iScreen->WindowElements().SetVisibleRegion(*static_cast<CWsClientWindow*>(this));
   1.761 +				}
   1.762 +			}
   1.763 +		}
   1.764 +
   1.765 +	// Just because the visible region (screen coordinates) didn't change doesn't
   1.766 +	// mean the invalid region (window coordinates) didn't change, so we always call this.
   1.767 +	iRedraw->VisibleRegionChange();
   1.768 +	}
   1.769 +
   1.770 +//This function sets up the quick fadable region.
   1.771 +//It removes anything that cannot be quick faded, and schedules it to be drawn in the normal fashion.
   1.772 +void CWsWindow::SetFadeableRegion(const TRegion& aNewFadableRegion, const TRegion& aTop)
   1.773 +	{
   1.774 +	WS_ASSERT_DEBUG(iScreen, EWsPanicNoScreen);
   1.775 +	iFadableRegion.Copy(aNewFadableRegion);
   1.776 +
   1.777 +	//Try to figure out if any part of iFadableRegion can be quick faded (i.e. fading applied to 
   1.778 +	//the screen without first having to redraw all visible windows intersecting the region).
   1.779 +	if ( !iFadableRegion.IsEmpty() && iScreen->IsQuickFadeScheduled(this) )
   1.780 +		{
   1.781 +		if (IsTranslucent())
   1.782 +			{
   1.783 +			//If a window is semitransparent, then we cannot apply a quickfade to it if
   1.784 +			//the window below is faded too.
   1.785 +			iScreen->AddRedrawRegion(iVisibleRegion, EFalse, ERedrawAll);
   1.786 +			iScreen->RemoveFromQuickFadeList(this);
   1.787 +			}
   1.788 +		else
   1.789 +			{
   1.790 +			iQuickFadeRegion.Intersection(iFadableRegion, aTop);
   1.791 +			
   1.792 +			//Remove any regions not possible to quick fade from iQuickFadeRegion and
   1.793 +			//schedule these regions for full back-front rendering instead.
   1.794 +			STACK_REGION nonQuickFadableRegion;
   1.795 +
   1.796 +			for(CWsSpriteBase * sprite = iSpriteList; sprite; sprite = sprite->Next())
   1.797 +				{
   1.798 +				nonQuickFadableRegion.AddRect(sprite->Rect());
   1.799 +				}
   1.800 +
   1.801 +			for(CWsAnim * anim = iAnimList; anim; anim = anim->Next())
   1.802 +				{
   1.803 +				nonQuickFadableRegion.AddRect(anim->BestRect());
   1.804 +				}
   1.805 +
   1.806 +			RWsTextCursor* const cursor = CWsTop::CurrentTextCursor();
   1.807 +			if( cursor && (cursor->Window()==this) && cursor->IsStandardCursorActive() )
   1.808 +				{
   1.809 +				nonQuickFadableRegion.AddRect(cursor->Rect());
   1.810 +				}
   1.811 +
   1.812 +			//Any regions scheduled for fading but partly or fully covered by transparent windows above them
   1.813 +			STACK_REGION coveredFadableRegion;
   1.814 +			coveredFadableRegion.Copy(iFadableRegion);
   1.815 +			coveredFadableRegion.SubRegion(iQuickFadeRegion);
   1.816 +			nonQuickFadableRegion.Union(coveredFadableRegion);
   1.817 +			coveredFadableRegion.Close();
   1.818 +
   1.819 +			nonQuickFadableRegion.Tidy();
   1.820 +
   1.821 +			//Remove any regions not possible to quick fade from iQuickFadeRegion
   1.822 +			iQuickFadeRegion.SubRegion(nonQuickFadableRegion);
   1.823 +
   1.824 +			if (!nonQuickFadableRegion.CheckError())
   1.825 +				{
   1.826 +				//Schedule normal drawing (full back to front rendering) for the region not possible to quick fade
   1.827 +				if (!nonQuickFadableRegion.IsEmpty())
   1.828 +					{ 
   1.829 +					iScreen->AddRedrawRegion(nonQuickFadableRegion, EFalse, ERedrawAll);
   1.830 +					}
   1.831 +				}
   1.832 +			else
   1.833 +				{
   1.834 +				//Schedule normal drawing for the whole iVisibleRegion if the calculations are broken
   1.835 +				iScreen->AddRedrawRegion(iVisibleRegion, EFalse, ERedrawAll);
   1.836 +				}
   1.837 +			nonQuickFadableRegion.Close();
   1.838 +			}
   1.839 +		}
   1.840 +	else
   1.841 +		{
   1.842 +		iQuickFadeRegion.Reset();
   1.843 +		}
   1.844 +	}
   1.845 +
   1.846 +void CWsWindow::RestartAnimations(const TRegion& aNewRegion)
   1.847 +	{
   1.848 +	 //When not ChangeTracking, restarting is handled by AddRedrawRegion (called from CWsWindow::SetVisibleRegion) and TWalkWindowTreeScheduleRegions
   1.849 +	WS_ASSERT_DEBUG(iScreen->ChangeTracking(),EWsPanicNoChangetracking);
   1.850 +	
   1.851 +	//Restart uncovered window animations 
   1.852 +	for (CWsAnim* anim = iAnimList; anim; anim = anim->Next())
   1.853 +		{
   1.854 +		if(!iScreen->IsScheduled(EWindowAnim, anim->BestRect(), this) && aNewRegion.Intersects(anim->BestRect()))
   1.855 +			{
   1.856 +			iScreen->ScheduleAnimation(EWindowAnim, anim->BestRect(), 0, 0, 0, this);
   1.857 +			}
   1.858 +		}
   1.859 +	//Restart uncovered sprite animations 
   1.860 +	for (CWsSpriteBase* sprite = iSpriteList; sprite; sprite = sprite->Next())
   1.861 +		{
   1.862 +		if(!iScreen->IsScheduled(ESpriteAnim, sprite->Rect(), sprite->Win()) && aNewRegion.Intersects(sprite->Rect()))
   1.863 +			{
   1.864 +			iScreen->ScheduleAnimation(ESpriteAnim, sprite->Rect(), 0, 0, 0, sprite->Win());
   1.865 +			}
   1.866 +		}
   1.867 +	}
   1.868 +
   1.869 +void CWsWindow::ClearVisibleRegion()
   1.870 +	{
   1.871 +	AbortAllDSAs();         
   1.872 +	iScreen->AddRedrawRegion(VisibleRegion(), EFalse);
   1.873 +	ResetVisibleRegion();
   1.874 +	PossibleVisibilityChangedEvent(EFalse);
   1.875 +	if (Redraw()->HasElement())
   1.876 +		{
   1.877 +		WS_ASSERT_DEBUG(WinType()==EWinTypeClient,EWsPanicWindowType);
   1.878 +		
   1.879 +		if (WinType()==EWinTypeClient)
   1.880 +			{
   1.881 +			iScreen->WindowElements().SetVisibleRegion(*static_cast<CWsClientWindow*>(this));
   1.882 +			}
   1.883 +		}
   1.884 +	iFlags &= ~EFlagDrawnToScreen;
   1.885 +	}
   1.886 +
   1.887 +void CWsWindow::AbortDsaIfRequired(const TRegion& aNewRegion, const TRegion* aTop)
   1.888 +	{
   1.889 +	if (!iDSAs.IsEmpty())
   1.890 +		{
   1.891 +		// If the top visible region of this window has changed, DSA clients may need
   1.892 +		// to be sent a DSA abort, as they may be drawing to a different region
   1.893 +		STACK_REGION newTopVisible;
   1.894 +		newTopVisible.Copy(aNewRegion); // new visible region
   1.895 +		if (aTop!=NULL)
   1.896 +			{
   1.897 +			newTopVisible.Intersect(*aTop); // area of new visible region not obscured by any other opaque or translucent windows
   1.898 +			}
   1.899 +		// Build a list of DSA clients that need to be sent a DSA abort
   1.900 +		TSglQue<CWsDirectScreenAccess> dsaList(_FOFF(CWsDirectScreenAccess,iAbortLink));
   1.901 +		TSglQueIter<CWsDirectScreenAccess> iter(iDSAs);
   1.902 +		CWsDirectScreenAccess* dsa;
   1.903 +		while ((dsa=iter++)!=NULL)
   1.904 +			{
   1.905 +			if (dsa->IsAbortRequired(newTopVisible))
   1.906 +				{
   1.907 +				dsaList.AddLast(*dsa);
   1.908 +				}
   1.909 +			}
   1.910 +		if (!dsaList.IsEmpty())
   1.911 +			{
   1.912 +			iScreen->AbortDSAs(RDirectScreenAccess::ETerminateRegion, dsaList);
   1.913 +			}
   1.914 +		newTopVisible.Close();
   1.915 +		}
   1.916 +	}
   1.917 +
   1.918 +const TRegion* CWsWindow::VisibleRegionIfValid() const
   1.919 +	{
   1.920 +	return iVisibleRegion.CheckError() ? NULL : &iVisibleRegion;
   1.921 +	}
   1.922 +	
   1.923 +TBool CWsWindow::ReadyToDraw() const
   1.924 +	{
   1.925 +	return iRedraw->ReadyToDraw();
   1.926 +	}
   1.927 +
   1.928 +/**
   1.929 +This function draws the region specified
   1.930 +*/
   1.931 +void CWsWindow::Render(MWsGraphicsContext& aGc, const TRegion& aWindowRegion, const TRegion& aWindowChildNodeRegion)
   1.932 +	{
   1.933 +	WS_ASSERT_DEBUG(IsVisible() || (WinType() == EWinTypeRoot), EWsPanicScheduledRedraw);
   1.934 +
   1.935 +	AnnotateWindowRedrawStart(*this, aWindowRegion);
   1.936 +	
   1.937 +	Accessed();
   1.938 +	iFlags |= EFlagDrawnToScreen;
   1.939 +	
   1.940 +	aGc.Reset();
   1.941 +	iRedraw->PreDrawWindow(&aGc, aWindowRegion);
   1.942 +	iRedraw->DrawWindow();
   1.943 +	iRedraw->PostDrawWindow(&aGc, aWindowChildNodeRegion);
   1.944 +	}
   1.945 +
   1.946 +void CWsWindow::SetNextScheduled(CWsWindow * aWin)
   1.947 +	{
   1.948 +	iNextScheduled = aWin;
   1.949 +	}
   1.950 +	
   1.951 +CWsWindow * CWsWindow::NextScheduled()  const
   1.952 +	{
   1.953 +	return iNextScheduled;
   1.954 +	}
   1.955 +
   1.956 +void CWsWindow::DeactivateAllSprites()
   1.957 +	{
   1.958 +	CWsSpriteBase * current = iSpriteList;
   1.959 +	while (current)
   1.960 +		{
   1.961 +		CWsSpriteBase * next = current->Next();
   1.962 +		current->Deactivate();
   1.963 +		current = next;
   1.964 +		}
   1.965 +	}
   1.966 +
   1.967 +void CWsWindow::ClipRectToViewport(TRect& aRect) const
   1.968 +	{
   1.969 +	const CWsWindowBase * win = this;
   1.970 +	while (win)
   1.971 +		{
   1.972 +		if (win->WinType() != EWinTypeGroup)
   1.973 +			{
   1.974 +			aRect.Intersection(win->AbsRect());
   1.975 +			}
   1.976 +		win = win->BaseParent();
   1.977 +		}
   1.978 +	}
   1.979 +
   1.980 +void CWsWindow::AddDirtyWindowRegion(const TRegion& aRegion)
   1.981 +	{
   1.982 +	iDirtyWindowRegion.Union(aRegion);
   1.983 +	if (iDirtyWindowRegion.CheckError())
   1.984 +		{
   1.985 +		iDirtyWindowRegion.Reset();
   1.986 +		iDirtyWindowRegion.AddRect(AbsRect()); // fallback to potentially visible part of window
   1.987 +		}
   1.988 +	}
   1.989 +
   1.990 +const TRegion& CWsWindow::DirtyWindowRegion() const
   1.991 +	{
   1.992 +	return iDirtyWindowRegion;
   1.993 +	}
   1.994 +
   1.995 +void CWsWindow::ScheduleDirtyWindowRegion()
   1.996 +	{
   1.997 +	iDirtyWindowRegion.Tidy();
   1.998 +	iDirtyWindowRegion.Offset(iOrigin); //convert to screen coords 
   1.999 +	iScheduledRegion.Copy(iDirtyWindowRegion);
  1.1000 +	iDirtyWindowRegion.Reset();
  1.1001 +	if (iScheduledRegion.CheckError())
  1.1002 +		{
  1.1003 +		iScheduledRegion.Reset();
  1.1004 +		iScheduledRegion.AddRect(AbsRect()); // fallback to potentially visible part of window
  1.1005 +		}
  1.1006 +	}
  1.1007 +
  1.1008 +void CWsWindow::AddDirtySpriteRegion(const TRegion& aRegion)
  1.1009 +	{
  1.1010 +	iDirtySpriteRegion.Union(aRegion);
  1.1011 +	if (iDirtySpriteRegion.CheckError())
  1.1012 +		{
  1.1013 +		iDirtySpriteRegion.Reset();
  1.1014 +		iDirtySpriteRegion.AddRect(AbsRect()); // fallback to potentially visible part of window
  1.1015 +		}
  1.1016 +	}
  1.1017 +
  1.1018 +const TRegion& CWsWindow::DirtySpriteRegion() const
  1.1019 +	{
  1.1020 +	return iDirtySpriteRegion;
  1.1021 +	}
  1.1022 +
  1.1023 +void CWsWindow::ScheduleDirtySpriteRegion()
  1.1024 +	{
  1.1025 +	iDirtySpriteRegion.Tidy();
  1.1026 +	iDirtySpriteRegion.Offset(iOrigin); //convert to screen coords 
  1.1027 +	iScheduledSpriteRegion.Copy(iDirtySpriteRegion);
  1.1028 +	iDirtySpriteRegion.Reset();
  1.1029 +	if (iScheduledSpriteRegion.CheckError())
  1.1030 +		{
  1.1031 +		iScheduledSpriteRegion.Reset();
  1.1032 +		iScheduledSpriteRegion.AddRect(AbsRect()); // fallback to potentially visible part of window
  1.1033 +		}
  1.1034 +	}
  1.1035 +
  1.1036 +void CWsWindow::ClearScheduledSpriteRegion()
  1.1037 +	{
  1.1038 +	iScheduledSpriteRegion.Reset();
  1.1039 +	}
  1.1040 +
  1.1041 +/**
  1.1042 +In ChangeTracking mode, wserv is not maintaining the visible region of windows.
  1.1043 +Windows that need to keep track of their visible region in ChangeTracking mode 
  1.1044 +should call this function.
  1.1045 +
  1.1046 +@param aRegister 	ETrue if iVisibleRegion should be maintained with accurate information, 
  1.1047 +					EFalse if not.
  1.1048 +					
  1.1049 +@internalComponent
  1.1050 +*/
  1.1051 +void CWsWindow::SetupVisibleRegionTracking(TBool aRegister)
  1.1052 +	{
  1.1053 +	if (aRegister)
  1.1054 +		{
  1.1055 +		++iVisibleRegionTrackingCounter;
  1.1056 +		if (iVisibleRegionTrackingCounter==1)
  1.1057 +			{
  1.1058 +			//If visible region tracking has not been setup, let's do it now.
  1.1059 +			iScreen->SetupVisibleRegionTracking(*this, ETrue);
  1.1060 +			}
  1.1061 +		}
  1.1062 +	else if (iVisibleRegionTrackingCounter>0)
  1.1063 +		{
  1.1064 +		--iVisibleRegionTrackingCounter;
  1.1065 +		if (iVisibleRegionTrackingCounter==0)
  1.1066 +			{
  1.1067 +			//If aReason was the last reason to track visibility, disable further notifications.
  1.1068 +			iScreen->SetupVisibleRegionTracking(*this, EFalse);
  1.1069 +			}
  1.1070 +		}
  1.1071 +	}
  1.1072 +
  1.1073 +/**
  1.1074 +MWsWindow
  1.1075 +*/
  1.1076 +MWsWindow * CWsWindow::FindChildByHandle(TUint32 aHandle)
  1.1077 +	{
  1.1078 +	TWalkWindowTreeFindByHandle wwt(aHandle);
  1.1079 +	WalkWindowTree(wwt, EWalkChildren);
  1.1080 +	return wwt.Found();
  1.1081 +	}
  1.1082 +
  1.1083 +TUint32 CWsWindow::Handle() const
  1.1084 +	{
  1.1085 +	return ClientHandle();
  1.1086 +	}
  1.1087 +
  1.1088 +MWsScreen * CWsWindow::WsScreen() const
  1.1089 +	{
  1.1090 +	return iScreen;
  1.1091 +	}
  1.1092 +
  1.1093 +TInt CWsWindow::OrdinalPriority() const
  1.1094 +	{
  1.1095 +	return iOrdinalPriority;
  1.1096 +	}