|
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 <e32std.h> |
|
19 #include "server.h" |
|
20 #include "rootwin.h" |
|
21 #include "windowgroup.h" |
|
22 #include "walkwindowtree.h" |
|
23 #include "wstop.h" |
|
24 #include "ScrDev.H" |
|
25 #include "panics.h" |
|
26 #include "inifile.h" |
|
27 #include "EVENT.H" |
|
28 |
|
29 _LIT(KNoBlank,"NOBLANKSCREEN"); |
|
30 _LIT(KDefaultBackgroundColor,"BACKGROUNDCOLOR"); |
|
31 _LIT(KDefaultBackgroundAlpha,"BACKGROUNDALPHA"); |
|
32 _LIT(KRootWinDefaultBackgroundColor,"ROOTBACKGROUNDCOLOR"); |
|
33 _LIT(KRootWinDefaultBackgroundAlpha,"ROOTBACKGROUNDALPHA"); |
|
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 Shutdown(); |
|
43 } |
|
44 |
|
45 void CWsRootWindow::ConstructL() |
|
46 { |
|
47 CWsWindow::Construct(); |
|
48 iParent=NULL; |
|
49 iSibling=NULL; |
|
50 iChild=NULL; |
|
51 iClientHandle=NULL; |
|
52 iAbs.Resize(iScreen->ScreenDevice()->SizeInPixels()); |
|
53 iRel=iAbs; |
|
54 iFlags=EFlagPointerCaptured; |
|
55 iPointerFilter=EPointerFilterEnterExit|EPointerFilterMove|EPointerFilterDrag; |
|
56 iArea.AddRect(iAbs); |
|
57 iRedraw=new(ELeave) CWsBlankWindow(this); |
|
58 iRedraw->ConstructL(); |
|
59 TInt backgroundcolor; |
|
60 if(!WsIniFile->FindVar(KDefaultBackgroundColor,backgroundcolor)) |
|
61 backgroundcolor = KRgbWhite.Value(); |
|
62 TInt backgroundalpha; |
|
63 if(!WsIniFile->FindVar(KDefaultBackgroundAlpha,backgroundalpha)) |
|
64 backgroundalpha = 0xFF; |
|
65 iDefaultBackgroundColor = TRgb(backgroundcolor,backgroundalpha); |
|
66 |
|
67 if (WsIniFile->FindVar(KNoBlank)) |
|
68 { |
|
69 BlankRedraw()->SetBackgroundClear(); |
|
70 } |
|
71 else |
|
72 { |
|
73 TInt rootAlpha; |
|
74 TInt rootColor; |
|
75 if (!WsIniFile->FindVar(KRootWinDefaultBackgroundColor,rootColor)) |
|
76 rootColor = backgroundcolor; |
|
77 if (!WsIniFile->FindVar(KRootWinDefaultBackgroundAlpha,rootAlpha)) |
|
78 rootAlpha = backgroundalpha; |
|
79 SetColor(TRgb(rootColor,rootAlpha)); |
|
80 } |
|
81 } |
|
82 |
|
83 void CWsRootWindow::SetColor(TRgb aColor) |
|
84 { |
|
85 BlankRedraw()->SetColor(aColor); |
|
86 } |
|
87 |
|
88 void CWsRootWindow::SetColorIfClear() |
|
89 { |
|
90 if (!BlankRedraw()->IsBackgroundColor()) |
|
91 SetColor(iDefaultBackgroundColor); |
|
92 } |
|
93 |
|
94 const CWsWindow *CWsRootWindow::PointerWindow(const TPoint &aInPos,TPoint *aOutPos, TPoint *aParentPos, |
|
95 const CWsWindow *aGrabWin, const CWsWindow *&aOriginalWinItIsIn, const CWsWindowGroup *aForceInGroup) |
|
96 // |
|
97 // For aInPos (a global point on screen) find which window it is in, starting the search from 'this'. |
|
98 // aOutPos is set to be aInPos adjusted relative to the top left of the result window. |
|
99 // If the pointer is not in any of the searched windows the result is returned as though it was in 'this' |
|
100 // even though it may actually be oustside the bounds of this. |
|
101 // |
|
102 // If aForceInGroup==NULL search all groups otherwise only search it only |
|
103 // |
|
104 { |
|
105 aOriginalWinItIsIn=this; |
|
106 const CWsWindowGroup *group; |
|
107 const CWsWindowGroup *winItIsInGroup=aForceInGroup; |
|
108 // |
|
109 // First determine owner of the window the event is in regardless of any capture |
|
110 // This is so we can decide whether the capture affects this case or not |
|
111 // |
|
112 for(group=(aForceInGroup ? aForceInGroup:Child());group!=NULL;group=group->NextSibling()) |
|
113 { |
|
114 CWsClientWindow *win=group->Child(); |
|
115 while(win!=NULL) |
|
116 { |
|
117 const TRegion *baseArea=win->BaseArea(); |
|
118 if (win->IsVisible() && baseArea->Contains(aInPos)) |
|
119 { |
|
120 aOriginalWinItIsIn=win; |
|
121 winItIsInGroup=group; |
|
122 win=win->Child(); |
|
123 } |
|
124 else |
|
125 win=win->NextSibling(); |
|
126 } |
|
127 if (aOriginalWinItIsIn!=this || aForceInGroup!=NULL) |
|
128 break; |
|
129 } |
|
130 // |
|
131 // Then try again taking note of any pointer capture or grab |
|
132 // |
|
133 const CWsWindow *winItIsIn; |
|
134 if (aGrabWin!=NULL) |
|
135 winItIsIn=aGrabWin; |
|
136 else |
|
137 { |
|
138 winItIsIn=this; |
|
139 for(group=(aForceInGroup ? aForceInGroup:Child());group!=NULL;group=group->NextSibling()) |
|
140 { |
|
141 CWsClientWindow *win=group->Child(); |
|
142 while(win!=NULL) |
|
143 { |
|
144 const TRegion *baseArea=win->BaseArea(); |
|
145 const TBool underTheSameGroup=winItIsInGroup==group; |
|
146 if (win->IsVisible() && |
|
147 ((win->iFlags&EFlagPointerCaptured && |
|
148 ((!underTheSameGroup && win->iFlags&EFlagPointerCaptureAllGroups) || |
|
149 (winItIsInGroup==NULL && group==CWsTop::FocusWindowGroup()) || |
|
150 (underTheSameGroup && win->iPointerCapturePriority>=aOriginalWinItIsIn->iPointerCapturePriority))) |
|
151 || baseArea->Contains(aInPos))) |
|
152 { |
|
153 winItIsIn=win; |
|
154 win=win->Child(); |
|
155 } |
|
156 else |
|
157 win=win->NextSibling(); |
|
158 } |
|
159 if (winItIsIn!=this || aForceInGroup!=NULL) |
|
160 break; |
|
161 } |
|
162 } |
|
163 if (aOutPos!=NULL) |
|
164 { |
|
165 *aOutPos=aInPos-winItIsIn->iOrigin; |
|
166 } |
|
167 if (aParentPos!=NULL) |
|
168 { |
|
169 const CWsWindowBase *win=winItIsIn->BaseParent(); |
|
170 if (win==NULL) |
|
171 win=winItIsIn; |
|
172 *aParentPos=aInPos-win->Origin(); |
|
173 } |
|
174 return(winItIsIn); |
|
175 } |
|
176 |
|
177 void CWsRootWindow::GenerateWindowRegion(RWsRegion &aRegion) const |
|
178 { |
|
179 aRegion.Clear(); |
|
180 aRegion.AddRect(iAbs); |
|
181 if (iChild) |
|
182 { |
|
183 for(CWsClientWindow *win=FirstTopClientWindow();aRegion.Count()>0 && win!=NULL;win=win->NextSiblingMultiParent()) |
|
184 { |
|
185 if (win->IsVisible()) |
|
186 aRegion.SubRegion(*win->BaseArea()); |
|
187 } |
|
188 } |
|
189 } |
|
190 |
|
191 void CWsRootWindow::CommandL(TInt , const TAny *) |
|
192 { |
|
193 WS_PANIC_ALWAYS(EWsPanicRootCommand); |
|
194 } |
|
195 |
|
196 void CWsRootWindow::InvalidateWholeScreen() |
|
197 { |
|
198 RWsRegion screen(iAbs); |
|
199 Invalidate(&screen); |
|
200 screen.Close(); |
|
201 } |
|
202 |
|
203 void CWsRootWindow::Invalidate(RWsRegion* aRegion) |
|
204 { |
|
205 iScreen->AddRedrawRegion(*aRegion); |
|
206 } |
|
207 |
|
208 void CWsRootWindow::ScreenSizeChanged(const TBool aSwapWidthAndHeight) |
|
209 { |
|
210 // We have to disable the text cursor here while we are still in the |
|
211 // same orientation as we drew it. |
|
212 RWsTextCursor* cursor=CWsTop::CurrentTextCursor(); |
|
213 if (cursor) |
|
214 { |
|
215 cursor->Disable(); |
|
216 } |
|
217 iScreen->SetScalingFactor(); |
|
218 iScreen->UpdateOrientation(); |
|
219 iScreen->UpdateGcs(); |
|
220 iScreen->UpdateOffScreenBitmapGc(aSwapWidthAndHeight); |
|
221 iArea.Clear(); |
|
222 iAbs=iScreen->DrawableArea(); |
|
223 iRel=iAbs; |
|
224 iArea.AddRect(iAbs); |
|
225 iOrigin=iAbs.iTl; |
|
226 for(CWsClientWindow *win=FirstTopClientWindow();win!=NULL;win=win->NextSiblingMultiParent()) |
|
227 { |
|
228 win->RecalcChildAbs(NULL); |
|
229 } |
|
230 if (iScreen->BlankScreenOnRotation()) |
|
231 { |
|
232 ClearDisplay(); |
|
233 } |
|
234 iScreen->DiscardAllSchedules(); |
|
235 CWsTop::ClearAllRedrawStores(); |
|
236 OrientationChanged(); |
|
237 iScreen->AbortAllDirectDrawing(RDirectScreenAccess::ETerminateRotation); |
|
238 iScreen->ScheduleRegionUpdate(&iArea); |
|
239 } |
|
240 |
|
241 void CWsRootWindow::OrientationChanged() |
|
242 { |
|
243 InvalidateWholeScreen(); |
|
244 } |
|
245 |
|
246 void CWsRootWindow::ClearDisplay() |
|
247 { |
|
248 CFbsBitGc *gdi=iScreen->ScreenGdi(); |
|
249 gdi->SetBrushStyle(CGraphicsContext::ESolidBrush); |
|
250 gdi->SetPenStyle(CGraphicsContext::ENullPen); |
|
251 gdi->SetOrientation(iScreen->Orientation()); |
|
252 gdi->SetBrushColor(BackColor()); |
|
253 gdi->SetDrawMode(CGraphicsContext::EDrawModeWriteAlpha); |
|
254 TRect absRect(AbsRect()); |
|
255 gdi->DrawRect(absRect); |
|
256 gdi->SetDrawMode(CGraphicsContext::EDrawModePEN); |
|
257 |
|
258 TWindowServerEvent::NotifyScreenDrawingEvent(absRect); |
|
259 } |
|
260 |
|
261 void CWsRootWindow::SetSystemFaded(TBool aFaded, TUint8 aBlackMap, TUint8 aWhiteMap) |
|
262 { |
|
263 for(CWsWindowGroup* win=Child();win!=NULL;win=win->NextSibling()) |
|
264 { |
|
265 TWalkWindowTreeSetFaded wwt(aFaded,win,aBlackMap,aWhiteMap); |
|
266 win->WalkWindowTree(wwt,EWalkChildren); |
|
267 } |
|
268 WS_ASSERT_DEBUG(Screen(),EWsPanicNoScreen); |
|
269 } |
|
270 |
|
271 CWsWindowGroup* CWsRootWindow::WindowGroup(TInt aWindowGroup) |
|
272 { |
|
273 CWsWindowBase* group=iChild; |
|
274 while (aWindowGroup-->0 && group) |
|
275 group=group->NextSibling(); |
|
276 return static_cast<CWsWindowGroup*>(group); |
|
277 } |
|
278 |
|
279 CWsClientWindow *CWsRootWindow::FirstTopClientWindow() const |
|
280 { |
|
281 CWsWindowGroup* group; |
|
282 for(group=Child();group && group->Child()==NULL;group=group->NextSibling()) |
|
283 {} |
|
284 return(group?group->Child():NULL); |
|
285 } |
|
286 |
|
287 const TRegion& CWsRootWindow::WindowArea() const |
|
288 { |
|
289 return iArea; |
|
290 } |