os/graphics/windowing/windowserver/nga/SERVER/ROOTWIN.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/ROOTWIN.CPP	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,288 @@
     1.4 +// Copyright (c) 1995-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 +// Root window sub-class of CWsWindow
    1.18 +// 
    1.19 +//
    1.20 +
    1.21 +#include "rootwin.h"
    1.22 +#include <e32std.h>
    1.23 +#include <graphics/wsscreendevice.h>
    1.24 +#include "server.h"
    1.25 +#include "windowgroup.h"
    1.26 +#include "walkwindowtree.h"
    1.27 +#include "wstop.h"
    1.28 +#include "ScrDev.H"
    1.29 +#include "panics.h"
    1.30 +#include "inifile.h"
    1.31 +#include "EVENT.H"
    1.32 +
    1.33 +_LIT(KNoBlank,"NOBLANKSCREEN");
    1.34 +_LIT(KDefaultBackgroundColor,"BACKGROUNDCOLOR");
    1.35 +_LIT(KDefaultBackgroundAlpha,"BACKGROUNDALPHA");
    1.36 +_LIT(KRootWinDefaultBackgroundColor,"ROOTBACKGROUNDCOLOR");
    1.37 +
    1.38 +CWsRootWindow::CWsRootWindow(CWsClient* aOwner, CScreen* aScreen) : CWsWindow(aOwner,WS_HANDLE_ROOT_WINDOW,aScreen)
    1.39 +	{
    1.40 +	iWinType=EWinTypeRoot;
    1.41 +	}
    1.42 +
    1.43 +CWsRootWindow::~CWsRootWindow()
    1.44 +	{
    1.45 +	if (Screen() && (iBaseWinFlags&EBaseWinNodeCreated))
    1.46 +		{
    1.47 +		MWsWindowTreeObserver* const windowTreeObserver = Screen()->WindowTreeObserver();
    1.48 +		if (windowTreeObserver)
    1.49 +			{
    1.50 +			windowTreeObserver->NodeReleased(*this);
    1.51 +			iBaseWinFlags &= ~EBaseWinNodeCreated;
    1.52 +			}
    1.53 +		}
    1.54 +	Shutdown();
    1.55 +	}
    1.56 +
    1.57 +void CWsRootWindow::ConstructL()
    1.58 +	{
    1.59 +	CWsWindow::Construct();
    1.60 +	iParent=NULL;
    1.61 +	iSibling=NULL;
    1.62 +	iChild=NULL;
    1.63 +	iClientHandle=NULL;
    1.64 +	iAbs.Resize(iScreen->SizeInPixels());
    1.65 +	iRel=iAbs;
    1.66 +	iFlags=EFlagPointerCaptured;
    1.67 +	iPointerFilter=EPointerFilterEnterExit|EPointerFilterMove|EPointerFilterDrag;
    1.68 +	iArea.AddRect(iAbs);
    1.69 +	iRedraw=new(ELeave) CWsBlankWindow(this);
    1.70 +	iRedraw->ConstructL();
    1.71 +	TInt backgroundcolor;
    1.72 +	if(!WsIniFile->FindVar(KDefaultBackgroundColor,backgroundcolor))
    1.73 +		backgroundcolor = KRgbWhite.Value();
    1.74 +	TInt backgroundalpha;
    1.75 +	if(!WsIniFile->FindVar(KDefaultBackgroundAlpha,backgroundalpha))
    1.76 +		backgroundalpha = 0xFF;	
    1.77 +	iDefaultBackgroundColor = TRgb(backgroundcolor,backgroundalpha);
    1.78 +	
    1.79 +	if (WsIniFile->FindVar(KNoBlank))
    1.80 +		BlankRedraw()->SetBackgroundClear();
    1.81 +	else
    1.82 +		{
    1.83 +		if (WsIniFile->FindVar(KRootWinDefaultBackgroundColor,backgroundcolor))
    1.84 +			SetColor(TRgb(backgroundcolor,backgroundalpha));
    1.85 +		else
    1.86 +			SetColor(iDefaultBackgroundColor);
    1.87 +		}
    1.88 +
    1.89 +	MWsWindowTreeObserver* const windowTreeObserver = Screen()->WindowTreeObserver();
    1.90 +	if (windowTreeObserver)
    1.91 +		{
    1.92 +		windowTreeObserver->NodeCreated(*this, NULL);
    1.93 +		iBaseWinFlags |= EBaseWinNodeCreated;
    1.94 +		}
    1.95 +	}
    1.96 +
    1.97 +void CWsRootWindow::SetColor(TRgb aColor)
    1.98 +	{
    1.99 +	BlankRedraw()->SetColor(aColor);
   1.100 +	}
   1.101 +
   1.102 +void CWsRootWindow::SetColorIfClear()
   1.103 +	{
   1.104 +	if (!BlankRedraw()->IsBackgroundColor())
   1.105 +		SetColor(iDefaultBackgroundColor);
   1.106 +	}
   1.107 +
   1.108 +const CWsWindow *CWsRootWindow::PointerWindow(const TPoint &aInPos,TPoint *aOutPos, TPoint *aParentPos,
   1.109 +					const CWsWindow *aGrabWin, const CWsWindow *&aOriginalWinItIsIn, const CWsWindowGroup *aForceInGroup)
   1.110 +//
   1.111 +// For aInPos (a global point on screen) find which window it is in, starting the search from 'this'.
   1.112 +// aOutPos is set to be aInPos adjusted relative to the top left of the result window.
   1.113 +// If the pointer is not in any of the searched windows the result is returned as though it was in 'this'
   1.114 +// even though it may actually be oustside the bounds of this.
   1.115 +//
   1.116 +// If aForceInGroup==NULL search all groups otherwise only search it only
   1.117 +//
   1.118 +	{
   1.119 +	aOriginalWinItIsIn=this;
   1.120 +	const CWsWindowGroup *group;
   1.121 +	const CWsWindowGroup *winItIsInGroup=aForceInGroup;
   1.122 +//
   1.123 +// First determine owner of the window the event is in regardless of any capture
   1.124 +// This is so we can decide whether the capture affects this case or not
   1.125 +//
   1.126 +	for(group=(aForceInGroup ? aForceInGroup:Child());group!=NULL;group=group->NextSibling())
   1.127 +		{
   1.128 +		CWsClientWindow *win=group->Child();
   1.129 +		while(win!=NULL)
   1.130 +			{
   1.131 +			const TRegion *baseArea=win->BaseArea();
   1.132 +			if (win->IsVisible() && baseArea->Contains(aInPos))
   1.133 +				{
   1.134 +				aOriginalWinItIsIn=win;
   1.135 +				winItIsInGroup=group;
   1.136 +				win=win->Child();
   1.137 +				}
   1.138 +			else
   1.139 +				win=win->NextSibling();
   1.140 +			}
   1.141 +		if (aOriginalWinItIsIn!=this || aForceInGroup!=NULL)
   1.142 +			break;
   1.143 +		}
   1.144 +//
   1.145 +// Then try again taking note of any pointer capture or grab
   1.146 +//
   1.147 +	const CWsWindow *winItIsIn;
   1.148 +	if (aGrabWin!=NULL)
   1.149 +		winItIsIn=aGrabWin;
   1.150 +	else
   1.151 +		{
   1.152 +		winItIsIn=this;
   1.153 +		for(group=(aForceInGroup ? aForceInGroup:Child());group!=NULL;group=group->NextSibling())
   1.154 +			{
   1.155 +			CWsClientWindow *win=group->Child();
   1.156 +			while(win!=NULL)
   1.157 +				{
   1.158 +				const TRegion *baseArea=win->BaseArea();
   1.159 +				const TBool underTheSameGroup=winItIsInGroup==group;
   1.160 +				if (win->IsVisible() && 
   1.161 +					((win->iFlags&EFlagPointerCaptured && 
   1.162 +					 ((!underTheSameGroup && win->iFlags&EFlagPointerCaptureAllGroups) || 
   1.163 +					  (winItIsInGroup==NULL && group==CWsTop::FocusWindowGroup()) || 
   1.164 +					  (underTheSameGroup && win->iPointerCapturePriority>=aOriginalWinItIsIn->iPointerCapturePriority)))
   1.165 +					   || baseArea->Contains(aInPos)))
   1.166 +					{
   1.167 +				 	winItIsIn=win;
   1.168 +					win=win->Child();
   1.169 +					}
   1.170 +				else
   1.171 +					win=win->NextSibling();
   1.172 +				}
   1.173 +			if (winItIsIn!=this || aForceInGroup!=NULL)
   1.174 +				break;
   1.175 +			}
   1.176 +		}
   1.177 +	if (aOutPos!=NULL)
   1.178 +		{
   1.179 +		*aOutPos=aInPos-winItIsIn->iOrigin;
   1.180 +		}
   1.181 +	if (aParentPos!=NULL)
   1.182 +		{
   1.183 +		const CWsWindowBase *win=winItIsIn->BaseParent();
   1.184 +		if (win==NULL)
   1.185 +			win=winItIsIn;
   1.186 +		*aParentPos=aInPos-win->Origin();
   1.187 +		}
   1.188 +	return(winItIsIn);
   1.189 +	}
   1.190 +
   1.191 +void CWsRootWindow::GenerateWindowRegion(RWsRegion &aRegion) const
   1.192 +	{
   1.193 +	aRegion.Clear();
   1.194 +	aRegion.AddRect(iAbs);
   1.195 +	if (iChild)
   1.196 +		{
   1.197 +		for(CWsTopClientWindow *win=FirstTopClientWindow();aRegion.Count()>0 && win!=NULL;win=win->NextSiblingMultiParent())
   1.198 +			{
   1.199 +			if (win->IsVisible())
   1.200 +				aRegion.SubRegion(*win->BaseArea());
   1.201 +			}
   1.202 +		}
   1.203 +	}
   1.204 +
   1.205 +void CWsRootWindow::CommandL(TInt , const TAny *)
   1.206 +	{
   1.207 +	WS_PANIC_ALWAYS(EWsPanicRootCommand);
   1.208 +	}
   1.209 +
   1.210 +void CWsRootWindow::InvalidateWholeScreen()
   1.211 +	{
   1.212 +	RWsRegion screen(iAbs);
   1.213 +	Invalidate(&screen);
   1.214 +	screen.Close();
   1.215 +	}
   1.216 +
   1.217 +void CWsRootWindow::Invalidate(RWsRegion* aRegion)
   1.218 +	{
   1.219 +	iScreen->AddRedrawRegion(*aRegion);
   1.220 +	}
   1.221 +
   1.222 +void CWsRootWindow::AdjustCoordsDueToRotation()
   1.223 +	{
   1.224 +	iArea.Clear();
   1.225 +	iAbs=iScreen->DrawableArea();
   1.226 +	iRel=iAbs;
   1.227 +	iArea.AddRect(iAbs);
   1.228 +	iOrigin=iAbs.iTl;
   1.229 +	for(CWsTopClientWindow *win=FirstTopClientWindow();win!=NULL;win=win->NextSiblingMultiParent())
   1.230 +		{
   1.231 +		win->RecalcChildAbs(NULL);
   1.232 +		}
   1.233 +	}
   1.234 +
   1.235 +void CWsRootWindow::ClearDisplay()
   1.236 +	{
   1.237 +	MWsScreenDevice *sd=static_cast<MWsScreenDevice*>(iScreen->ResolveObjectInterface(KMWsScreenDevice));
   1.238 +	WS_ASSERT_ALWAYS(sd, EWsPanicScreenDeviceMissing); 
   1.239 +	sd->ClearDisplay(BackColor());	
   1.240 +	}
   1.241 +
   1.242 +void CWsRootWindow::SetSystemFaded(TBool aFaded, TUint8 aBlackMap, TUint8 aWhiteMap)
   1.243 +	{
   1.244 +	WS_ASSERT_DEBUG(Screen(),EWsPanicNoScreen);
   1.245 +	
   1.246 +	TBool stateChanged = EFalse; //will be set to true if one or more windows change fade state.
   1.247 +	for(CWsWindowGroup* win=Child();win!=NULL;win=win->NextSibling())
   1.248 +		{
   1.249 +		TWalkWindowTreeSetSystemFaded wwt(aFaded, win, aBlackMap, aWhiteMap, stateChanged);
   1.250 +		win->WalkWindowTree(wwt,EWalkChildren);
   1.251 +		}
   1.252 +
   1.253 +	MWsWindowTreeObserver* windowTreeObserver = Screen()->WindowTreeObserver();
   1.254 +	if(windowTreeObserver && stateChanged)
   1.255 +		{
   1.256 +		windowTreeObserver->FadeAllChildren(*this, aFaded);
   1.257 +		}
   1.258 +	}
   1.259 +
   1.260 +CWsWindowGroup* CWsRootWindow::WindowGroup(TInt aWindowGroup)
   1.261 +	{
   1.262 +	CWsWindowBase* group=iChild;
   1.263 +	while (aWindowGroup-->0 && group)
   1.264 +		group=group->NextSibling();
   1.265 +	return static_cast<CWsWindowGroup*>(group);
   1.266 +	}
   1.267 +
   1.268 +CWsTopClientWindow *CWsRootWindow::FirstTopClientWindow() const
   1.269 +	{
   1.270 +	CWsWindowGroup* group;
   1.271 +	for(group=Child();group && group->Child()==NULL;group=group->NextSibling())
   1.272 +		{}
   1.273 +	return(group?group->Child():NULL);
   1.274 +	}
   1.275 +
   1.276 +const TRegion& CWsRootWindow::WindowArea() const
   1.277 +	{
   1.278 +	return iArea;
   1.279 +	}
   1.280 +
   1.281 +void CWsRootWindow::SendState(MWsWindowTreeObserver& aWindowTreeObserver) const
   1.282 +	{
   1.283 +	aWindowTreeObserver.NodeCreated(*this, NULL);
   1.284 +	}
   1.285 +
   1.286 +/** @see MWsWindowTreeNode */
   1.287 +const MWsWindow* CWsRootWindow::Window() const
   1.288 +	{
   1.289 +	return NULL;
   1.290 +	}
   1.291 +