|
1 // Copyright (c) 1995-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // Root window sub-class of CWsWindow |
|
15 // |
|
16 // |
|
17 |
|
18 #include "rootwin.h" |
|
19 #include <e32std.h> |
|
20 #include <graphics/wsscreendevice.h> |
|
21 #include "server.h" |
|
22 #include "windowgroup.h" |
|
23 #include "walkwindowtree.h" |
|
24 #include "wstop.h" |
|
25 #include "ScrDev.H" |
|
26 #include "panics.h" |
|
27 #include "inifile.h" |
|
28 #include "EVENT.H" |
|
29 |
|
30 _LIT(KNoBlank,"NOBLANKSCREEN"); |
|
31 _LIT(KDefaultBackgroundColor,"BACKGROUNDCOLOR"); |
|
32 _LIT(KDefaultBackgroundAlpha,"BACKGROUNDALPHA"); |
|
33 _LIT(KRootWinDefaultBackgroundColor,"ROOTBACKGROUNDCOLOR"); |
|
34 |
|
35 CWsRootWindow::CWsRootWindow(CWsClient* aOwner, CScreen* aScreen) : CWsWindow(aOwner,WS_HANDLE_ROOT_WINDOW,aScreen) |
|
36 { |
|
37 iWinType=EWinTypeRoot; |
|
38 } |
|
39 |
|
40 CWsRootWindow::~CWsRootWindow() |
|
41 { |
|
42 if (Screen() && (iBaseWinFlags&EBaseWinNodeCreated)) |
|
43 { |
|
44 MWsWindowTreeObserver* const windowTreeObserver = Screen()->WindowTreeObserver(); |
|
45 if (windowTreeObserver) |
|
46 { |
|
47 windowTreeObserver->NodeReleased(*this); |
|
48 iBaseWinFlags &= ~EBaseWinNodeCreated; |
|
49 } |
|
50 } |
|
51 Shutdown(); |
|
52 } |
|
53 |
|
54 void CWsRootWindow::ConstructL() |
|
55 { |
|
56 CWsWindow::Construct(); |
|
57 iParent=NULL; |
|
58 iSibling=NULL; |
|
59 iChild=NULL; |
|
60 iClientHandle=NULL; |
|
61 iAbs.Resize(iScreen->SizeInPixels()); |
|
62 iRel=iAbs; |
|
63 iFlags=EFlagPointerCaptured; |
|
64 iPointerFilter=EPointerFilterEnterExit|EPointerFilterMove|EPointerFilterDrag; |
|
65 iArea.AddRect(iAbs); |
|
66 iRedraw=new(ELeave) CWsBlankWindow(this); |
|
67 iRedraw->ConstructL(); |
|
68 TInt backgroundcolor; |
|
69 if(!WsIniFile->FindVar(KDefaultBackgroundColor,backgroundcolor)) |
|
70 backgroundcolor = KRgbWhite.Value(); |
|
71 TInt backgroundalpha; |
|
72 if(!WsIniFile->FindVar(KDefaultBackgroundAlpha,backgroundalpha)) |
|
73 backgroundalpha = 0xFF; |
|
74 iDefaultBackgroundColor = TRgb(backgroundcolor,backgroundalpha); |
|
75 |
|
76 if (WsIniFile->FindVar(KNoBlank)) |
|
77 BlankRedraw()->SetBackgroundClear(); |
|
78 else |
|
79 { |
|
80 if (WsIniFile->FindVar(KRootWinDefaultBackgroundColor,backgroundcolor)) |
|
81 SetColor(TRgb(backgroundcolor,backgroundalpha)); |
|
82 else |
|
83 SetColor(iDefaultBackgroundColor); |
|
84 } |
|
85 |
|
86 MWsWindowTreeObserver* const windowTreeObserver = Screen()->WindowTreeObserver(); |
|
87 if (windowTreeObserver) |
|
88 { |
|
89 windowTreeObserver->NodeCreated(*this, NULL); |
|
90 iBaseWinFlags |= EBaseWinNodeCreated; |
|
91 } |
|
92 } |
|
93 |
|
94 void CWsRootWindow::SetColor(TRgb aColor) |
|
95 { |
|
96 BlankRedraw()->SetColor(aColor); |
|
97 } |
|
98 |
|
99 void CWsRootWindow::SetColorIfClear() |
|
100 { |
|
101 if (!BlankRedraw()->IsBackgroundColor()) |
|
102 SetColor(iDefaultBackgroundColor); |
|
103 } |
|
104 |
|
105 const CWsWindow *CWsRootWindow::PointerWindow(const TPoint &aInPos,TPoint *aOutPos, TPoint *aParentPos, |
|
106 const CWsWindow *aGrabWin, const CWsWindow *&aOriginalWinItIsIn, const CWsWindowGroup *aForceInGroup) |
|
107 // |
|
108 // For aInPos (a global point on screen) find which window it is in, starting the search from 'this'. |
|
109 // aOutPos is set to be aInPos adjusted relative to the top left of the result window. |
|
110 // If the pointer is not in any of the searched windows the result is returned as though it was in 'this' |
|
111 // even though it may actually be oustside the bounds of this. |
|
112 // |
|
113 // If aForceInGroup==NULL search all groups otherwise only search it only |
|
114 // |
|
115 { |
|
116 aOriginalWinItIsIn=this; |
|
117 const CWsWindowGroup *group; |
|
118 const CWsWindowGroup *winItIsInGroup=aForceInGroup; |
|
119 // |
|
120 // First determine owner of the window the event is in regardless of any capture |
|
121 // This is so we can decide whether the capture affects this case or not |
|
122 // |
|
123 for(group=(aForceInGroup ? aForceInGroup:Child());group!=NULL;group=group->NextSibling()) |
|
124 { |
|
125 CWsClientWindow *win=group->Child(); |
|
126 while(win!=NULL) |
|
127 { |
|
128 const TRegion *baseArea=win->BaseArea(); |
|
129 if (win->IsVisible() && baseArea->Contains(aInPos)) |
|
130 { |
|
131 aOriginalWinItIsIn=win; |
|
132 winItIsInGroup=group; |
|
133 win=win->Child(); |
|
134 } |
|
135 else |
|
136 win=win->NextSibling(); |
|
137 } |
|
138 if (aOriginalWinItIsIn!=this || aForceInGroup!=NULL) |
|
139 break; |
|
140 } |
|
141 // |
|
142 // Then try again taking note of any pointer capture or grab |
|
143 // |
|
144 const CWsWindow *winItIsIn; |
|
145 if (aGrabWin!=NULL) |
|
146 winItIsIn=aGrabWin; |
|
147 else |
|
148 { |
|
149 winItIsIn=this; |
|
150 for(group=(aForceInGroup ? aForceInGroup:Child());group!=NULL;group=group->NextSibling()) |
|
151 { |
|
152 CWsClientWindow *win=group->Child(); |
|
153 while(win!=NULL) |
|
154 { |
|
155 const TRegion *baseArea=win->BaseArea(); |
|
156 const TBool underTheSameGroup=winItIsInGroup==group; |
|
157 if (win->IsVisible() && |
|
158 ((win->iFlags&EFlagPointerCaptured && |
|
159 ((!underTheSameGroup && win->iFlags&EFlagPointerCaptureAllGroups) || |
|
160 (winItIsInGroup==NULL && group==CWsTop::FocusWindowGroup()) || |
|
161 (underTheSameGroup && win->iPointerCapturePriority>=aOriginalWinItIsIn->iPointerCapturePriority))) |
|
162 || baseArea->Contains(aInPos))) |
|
163 { |
|
164 winItIsIn=win; |
|
165 win=win->Child(); |
|
166 } |
|
167 else |
|
168 win=win->NextSibling(); |
|
169 } |
|
170 if (winItIsIn!=this || aForceInGroup!=NULL) |
|
171 break; |
|
172 } |
|
173 } |
|
174 if (aOutPos!=NULL) |
|
175 { |
|
176 *aOutPos=aInPos-winItIsIn->iOrigin; |
|
177 } |
|
178 if (aParentPos!=NULL) |
|
179 { |
|
180 const CWsWindowBase *win=winItIsIn->BaseParent(); |
|
181 if (win==NULL) |
|
182 win=winItIsIn; |
|
183 *aParentPos=aInPos-win->Origin(); |
|
184 } |
|
185 return(winItIsIn); |
|
186 } |
|
187 |
|
188 void CWsRootWindow::GenerateWindowRegion(RWsRegion &aRegion) const |
|
189 { |
|
190 aRegion.Clear(); |
|
191 aRegion.AddRect(iAbs); |
|
192 if (iChild) |
|
193 { |
|
194 for(CWsTopClientWindow *win=FirstTopClientWindow();aRegion.Count()>0 && win!=NULL;win=win->NextSiblingMultiParent()) |
|
195 { |
|
196 if (win->IsVisible()) |
|
197 aRegion.SubRegion(*win->BaseArea()); |
|
198 } |
|
199 } |
|
200 } |
|
201 |
|
202 void CWsRootWindow::CommandL(TInt , const TAny *) |
|
203 { |
|
204 WS_PANIC_ALWAYS(EWsPanicRootCommand); |
|
205 } |
|
206 |
|
207 void CWsRootWindow::InvalidateWholeScreen() |
|
208 { |
|
209 RWsRegion screen(iAbs); |
|
210 Invalidate(&screen); |
|
211 screen.Close(); |
|
212 } |
|
213 |
|
214 void CWsRootWindow::Invalidate(RWsRegion* aRegion) |
|
215 { |
|
216 iScreen->AddRedrawRegion(*aRegion); |
|
217 } |
|
218 |
|
219 void CWsRootWindow::AdjustCoordsDueToRotation() |
|
220 { |
|
221 iArea.Clear(); |
|
222 iAbs=iScreen->DrawableArea(); |
|
223 iRel=iAbs; |
|
224 iArea.AddRect(iAbs); |
|
225 iOrigin=iAbs.iTl; |
|
226 for(CWsTopClientWindow *win=FirstTopClientWindow();win!=NULL;win=win->NextSiblingMultiParent()) |
|
227 { |
|
228 win->RecalcChildAbs(NULL); |
|
229 } |
|
230 } |
|
231 |
|
232 void CWsRootWindow::ClearDisplay() |
|
233 { |
|
234 MWsScreenDevice *sd=static_cast<MWsScreenDevice*>(iScreen->ResolveObjectInterface(KMWsScreenDevice)); |
|
235 WS_ASSERT_ALWAYS(sd, EWsPanicScreenDeviceMissing); |
|
236 sd->ClearDisplay(BackColor()); |
|
237 } |
|
238 |
|
239 void CWsRootWindow::SetSystemFaded(TBool aFaded, TUint8 aBlackMap, TUint8 aWhiteMap) |
|
240 { |
|
241 WS_ASSERT_DEBUG(Screen(),EWsPanicNoScreen); |
|
242 |
|
243 TBool stateChanged = EFalse; //will be set to true if one or more windows change fade state. |
|
244 for(CWsWindowGroup* win=Child();win!=NULL;win=win->NextSibling()) |
|
245 { |
|
246 TWalkWindowTreeSetSystemFaded wwt(aFaded, win, aBlackMap, aWhiteMap, stateChanged); |
|
247 win->WalkWindowTree(wwt,EWalkChildren); |
|
248 } |
|
249 |
|
250 MWsWindowTreeObserver* windowTreeObserver = Screen()->WindowTreeObserver(); |
|
251 if(windowTreeObserver && stateChanged) |
|
252 { |
|
253 windowTreeObserver->FadeAllChildren(*this, aFaded); |
|
254 } |
|
255 } |
|
256 |
|
257 CWsWindowGroup* CWsRootWindow::WindowGroup(TInt aWindowGroup) |
|
258 { |
|
259 CWsWindowBase* group=iChild; |
|
260 while (aWindowGroup-->0 && group) |
|
261 group=group->NextSibling(); |
|
262 return static_cast<CWsWindowGroup*>(group); |
|
263 } |
|
264 |
|
265 CWsTopClientWindow *CWsRootWindow::FirstTopClientWindow() const |
|
266 { |
|
267 CWsWindowGroup* group; |
|
268 for(group=Child();group && group->Child()==NULL;group=group->NextSibling()) |
|
269 {} |
|
270 return(group?group->Child():NULL); |
|
271 } |
|
272 |
|
273 const TRegion& CWsRootWindow::WindowArea() const |
|
274 { |
|
275 return iArea; |
|
276 } |
|
277 |
|
278 void CWsRootWindow::SendState(MWsWindowTreeObserver& aWindowTreeObserver) const |
|
279 { |
|
280 aWindowTreeObserver.NodeCreated(*this, NULL); |
|
281 } |
|
282 |
|
283 /** @see MWsWindowTreeNode */ |
|
284 const MWsWindow* CWsRootWindow::Window() const |
|
285 { |
|
286 return NULL; |
|
287 } |
|
288 |