|
1 /* |
|
2 * Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: AppUi class |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include <apgtask.h> |
|
20 #include <AknDoc.h> |
|
21 #include "alf/alfappui.h" |
|
22 #include "alf/alfappserver.h" |
|
23 #include <uiacceltk/HuiEnv.h> |
|
24 #include <aknenv.h> |
|
25 #include <AknsConstants.h> |
|
26 #include <uiacceltk/HuiSkin.h> |
|
27 #include <uiacceltk/HuiDisplay.h> |
|
28 #include <uiacceltk/HuiControl.h> |
|
29 #include <uiacceltk/HuiControlGroup.h> |
|
30 #include <uiacceltk/HuiEvent.h> |
|
31 #include <uiacceltk/HuiDeckLayout.h> |
|
32 #include <uiacceltk/HuiImageVisual.h> |
|
33 #include <uiacceltk/HuiTransformation.h> |
|
34 #include <uiacceltk/HuiBorderBrush.h> |
|
35 #include <uiacceltk/HuiUtil.h> |
|
36 #include <uiacceltk/HuiTextVisual.h> |
|
37 #include <uiacceltk/HuiGradientBrush.h> |
|
38 #include <apgwgnam.h> |
|
39 |
|
40 #ifdef ALF_USE_CANVAS |
|
41 #include <uiacceltk/HuiCanvasVisual.h> |
|
42 #endif |
|
43 |
|
44 #include "alflogger.h" |
|
45 #include "alf/alfappsrvsessionbase.h" |
|
46 #include "alf/alfappserver.h" |
|
47 #include "alfsrvresourcemanager.h" |
|
48 #include "alfsrvsettingshandler.h" |
|
49 #include <uiacceltk/HuiTextureManager.h> |
|
50 #include "alfsrvtexturemanager.h" |
|
51 #include "alfshareddisplaycoecontrol.h" |
|
52 #include "alfuids.h" |
|
53 |
|
54 #ifdef SYMBIAN_BUILD_GCE |
|
55 #include "alfbridge.h" |
|
56 #include "alfstreamerserver.h" |
|
57 #include "alfdecoderserverclient.h" |
|
58 #include "alfstreamerconsts.h" |
|
59 #endif // #ifdef SYMBIAN_BUILD_GCE |
|
60 |
|
61 // DISABLE this if you want to use the AHDemoApp layout switch. If this is enabled |
|
62 // and switch is done through AHDemoApp, the layout will be rotated too much. |
|
63 #ifdef __WINSCW__ |
|
64 // Use this, if you want the VGA layout to show correctly |
|
65 #define ALF_USE_EMULATOR_LAYOUT_SWITCH_BUTTON |
|
66 #endif |
|
67 |
|
68 |
|
69 _LIT(KAlfEventThreadName,"alfevents"); |
|
70 NONSHARABLE_CLASS(CAlfEventCatcher): public CActive |
|
71 { // this class does not actually catch the events but moves the wg so that alf can get pointer events |
|
72 public: |
|
73 CAlfEventCatcher(RWsSession& aWsSession, |
|
74 RWindowGroup& aWindowGroup, RWindow* aWindow, CWsScreenDevice* aScreenDevice) |
|
75 :CActive(CActive::EPriorityStandard), |
|
76 iWsSession(aWsSession), |
|
77 iWindowGroup(aWindowGroup), |
|
78 iWindow(aWindow), |
|
79 iScreenDevice(aScreenDevice), |
|
80 iThread(RThread().Id()) |
|
81 { |
|
82 CActiveScheduler::Add(this); |
|
83 iSema.CreateLocal(); |
|
84 DoActivate(); |
|
85 } |
|
86 |
|
87 ~CAlfEventCatcher() |
|
88 { |
|
89 Cancel(); |
|
90 iSema.Close(); |
|
91 } |
|
92 |
|
93 void DoActivate() |
|
94 { |
|
95 SetActive(); |
|
96 iStatus = KRequestPending; |
|
97 } |
|
98 |
|
99 void AdjustWindowGroupPositionL(TInt aParentIdentifier, TInt aPosition) |
|
100 { |
|
101 iSema.Wait(); |
|
102 // ok to update previous values even they were not applied by ao |
|
103 iParentIdentifier = aParentIdentifier; |
|
104 iPosition = aPosition; |
|
105 if (IsActive() && iStatus == KRequestPending) |
|
106 { |
|
107 RThread t; |
|
108 TInt err = t.Open(iThread); |
|
109 if (err) |
|
110 { |
|
111 __ALFLOGSTRING1( "CAlfEventCatcher::Trigger() ignore RThread::Open() error: %d", err ); |
|
112 } |
|
113 TRequestStatus* status = &iStatus; |
|
114 __ALFLOGSTRING("CAlfEventCatcher::Trigger - completing CAlfEventCatcher"); |
|
115 t.RequestComplete(status, err); |
|
116 t.Close(); |
|
117 } |
|
118 iSema.Signal(); |
|
119 } |
|
120 |
|
121 void RunL() |
|
122 { |
|
123 iSema.Wait(); |
|
124 if (iStatus.Int() == KErrNone) |
|
125 { |
|
126 TRAPD(err, DoAdjustPositionL()); |
|
127 if (err) |
|
128 { |
|
129 __ALFLOGSTRING1("ALF: WG Parent not found, err %d", err); |
|
130 } |
|
131 } |
|
132 DoActivate(); |
|
133 iSema.Signal(); |
|
134 } |
|
135 |
|
136 void DoAdjustPositionL() |
|
137 { |
|
138 __ALFLOGSTRING1("ALF: DoAdjustPositionL() %d", iPosition); |
|
139 |
|
140 if (iPosition == CAlfAppServer::EAbsoluteBackground) // just for convenience |
|
141 { |
|
142 __ALFLOGSTRING("CAlfEventCatcher::DoAdjustPositionL - CAlfAppServer::EAbsoluteBackground"); |
|
143 iWindowGroup.SetOrdinalPosition(-1,ECoeWinPriorityNeverAtFront); |
|
144 iWsSession.Flush(); |
|
145 return; |
|
146 } |
|
147 else if (iPosition == CAlfAppServer::EAlfWindowSize ) // just for developer convenience |
|
148 { |
|
149 __ALFLOGSTRING("CAlfEventCatcher::DoAdjustPositionL - CAlfAppServer::EAlfWindowSize"); |
|
150 // update window size when layout changes |
|
151 iScreenDevice->SetAppScreenMode(iScreenDevice->CurrentScreenMode()); |
|
152 iWindow->SetSize(iScreenDevice->SizeInPixels()); |
|
153 __ALFLOGSTRING2("ALF EventWin: Size(%d,%d)", iWindow->Size().iWidth, iWindow->Size().iHeight ); |
|
154 return; |
|
155 } |
|
156 |
|
157 |
|
158 TInt parentPriority = |
|
159 iWsSession.GetWindowGroupOrdinalPriority(iParentIdentifier); |
|
160 |
|
161 // perhaps we should maintain wg-list elsewhere |
|
162 CArrayFixFlat<TInt>* wgs = new (ELeave) CArrayFixFlat<TInt>(1); |
|
163 CleanupStack::PushL(wgs); |
|
164 iWsSession.WindowGroupList(parentPriority,wgs); |
|
165 |
|
166 TInt pos = KErrNotFound; |
|
167 TInt movingWgOldPos = KErrNotFound; |
|
168 TInt wgCount = wgs->Count(); |
|
169 for (TInt i = 0; i < wgCount; i++) |
|
170 { |
|
171 if (iParentIdentifier == wgs->At(i)) |
|
172 { |
|
173 if ( iPosition == CAlfAppServer::EOnTopOfParent ) |
|
174 { |
|
175 pos = i; |
|
176 } |
|
177 else |
|
178 { |
|
179 pos = i+1; |
|
180 } |
|
181 } |
|
182 if ( iWindowGroup.WindowGroupId() == wgs->At(i)) |
|
183 { |
|
184 movingWgOldPos = i; |
|
185 } |
|
186 |
|
187 if ( pos != KErrNotFound && movingWgOldPos != KErrNotFound ) |
|
188 { |
|
189 // Both found already. |
|
190 break; |
|
191 } |
|
192 } |
|
193 |
|
194 // If the moving window group has already been before the parent |
|
195 // we need to adjust the new position |
|
196 if ( movingWgOldPos < pos && movingWgOldPos != KErrNotFound ) |
|
197 { |
|
198 pos--; |
|
199 } |
|
200 |
|
201 User::LeaveIfError(pos); // parent not found, leave |
|
202 CleanupStack::PopAndDestroy(wgs); |
|
203 iWindowGroup.SetOrdinalPosition(pos, parentPriority); |
|
204 iWsSession.Flush(); |
|
205 } |
|
206 |
|
207 void DoCancel() |
|
208 { |
|
209 // do not.. |
|
210 } |
|
211 |
|
212 RWsSession& iWsSession; |
|
213 RWindowGroup& iWindowGroup; |
|
214 RWindow* iWindow; |
|
215 CWsScreenDevice* iScreenDevice; |
|
216 TThreadId iThread; |
|
217 RCriticalSection iSema; |
|
218 TInt iPosition; |
|
219 TInt iParentIdentifier; |
|
220 }; |
|
221 |
|
222 NONSHARABLE_CLASS(CAlfEventBridge): public CActive |
|
223 { |
|
224 public: |
|
225 CAlfEventBridge(CAlfAppUi& aAppUi, CHuiDisplay& aDisplay) |
|
226 :CActive(CActive::EPriorityUserInput), |
|
227 iAppUi(aAppUi), |
|
228 iDisplay(aDisplay), |
|
229 iThread(RThread().Id()) |
|
230 { |
|
231 CActiveScheduler::Add(this); |
|
232 iSema.CreateLocal(); |
|
233 TPixelsAndRotation rot; |
|
234 CWsScreenDevice* sd = CHuiStatic::ScreenDevice(); |
|
235 sd->GetScreenModeSizeAndRotation(sd->CurrentScreenMode(),rot); |
|
236 iVirtualSize = rot.iPixelSize; // for pointer event re-mapping |
|
237 RequestEventNotification(); |
|
238 } |
|
239 |
|
240 ~CAlfEventBridge() |
|
241 { |
|
242 Cancel(); |
|
243 iSema.Close(); |
|
244 iQueue1.Close(); |
|
245 iQueue2.Close(); |
|
246 } |
|
247 |
|
248 void RequestEventNotification() |
|
249 /** Asks WSERV proxy to give notification when an event is waiting */ |
|
250 { |
|
251 iSema.Wait(); |
|
252 iQueueSelection++; |
|
253 iQueueSelection%=2; |
|
254 iStatus = KRequestPending; |
|
255 SetActive(); |
|
256 iSema.Signal(); |
|
257 } |
|
258 |
|
259 void AdjustWindowGroupPositionL(TInt aParentIdentifier, TInt aPosition) |
|
260 { |
|
261 if (iEventCatcher) |
|
262 { |
|
263 iEventCatcher->AdjustWindowGroupPositionL(aParentIdentifier, aPosition); |
|
264 } |
|
265 } |
|
266 |
|
267 void Trigger(TInt aReason) |
|
268 { |
|
269 if (IsActive() && iStatus == KRequestPending) |
|
270 { |
|
271 RThread t; |
|
272 TInt err = t.Open(iThread); |
|
273 if (err) |
|
274 { |
|
275 __ALFLOGSTRING1( "CAlfEventBridge::Trigger() ignore RThread::Open() error: %d", err ); |
|
276 } |
|
277 TRequestStatus* status = &iStatus; |
|
278 __ALFLOGSTRING("CAlfEventBridge::Trigger - completing CAlfEventBridge") |
|
279 t.RequestComplete(status, err?err:aReason); |
|
280 t.Close(); |
|
281 } |
|
282 |
|
283 } |
|
284 |
|
285 void AddEventL(TWsEvent& aEvent) |
|
286 { |
|
287 iSema.Wait(); |
|
288 User::LeaveIfError((!iQueueSelection?iQueue1:iQueue2).Append(aEvent)); |
|
289 Trigger(KErrNone); |
|
290 iSema.Signal(); |
|
291 } |
|
292 |
|
293 // Todo: Should cache entries |
|
294 TBool GetEvent(TWsEvent& aEvent) |
|
295 { |
|
296 if ((iQueueSelection?iQueue1:iQueue2).Count()) |
|
297 { |
|
298 aEvent = (iQueueSelection?iQueue1:iQueue2)[0]; |
|
299 (iQueueSelection?iQueue1:iQueue2).Remove(0); |
|
300 return ETrue; |
|
301 } |
|
302 return EFalse; |
|
303 } |
|
304 |
|
305 void RunL() |
|
306 { |
|
307 switch (iStatus.Int()) |
|
308 { |
|
309 case KErrNone: |
|
310 break; |
|
311 case KErrCancel: |
|
312 case KErrServerTerminated: |
|
313 return; |
|
314 default: |
|
315 // Let bridge object know the event window group so that it is able reorder window groups correctly |
|
316 if (iStatus.Int() > KErrNone) |
|
317 { |
|
318 iAppUi.SetAlfWindowGroupId(iStatus.Int()); |
|
319 } |
|
320 break; |
|
321 } |
|
322 |
|
323 RequestEventNotification(); |
|
324 |
|
325 TWsEvent event; |
|
326 while (GetEvent(event)) |
|
327 { |
|
328 TRAPD(err,DoHandleEventL(event)) |
|
329 if (err) |
|
330 { |
|
331 __ALFLOGSTRING2("ALF: Error in handling WSEvent: event: %d err: %d", err, event.Type()); |
|
332 } |
|
333 } |
|
334 } |
|
335 |
|
336 void DoHandleEventL(TWsEvent& aEvent) |
|
337 { |
|
338 iAppUi.HandleWsEventL(aEvent, 0); |
|
339 |
|
340 if (aEvent.Type() >= EEventPointer && aEvent.Type() <= EEventDragDrop ) |
|
341 { |
|
342 // twiddle pointer coordinates |
|
343 THuiEvent huiEvent(&iDisplay, *aEvent.Pointer()); |
|
344 // Send events received here only to the associated display |
|
345 iDisplay.Roster().HandleEventL(huiEvent); |
|
346 iAppUi.EndPointerEventHandling(); // flush here |
|
347 } |
|
348 } |
|
349 |
|
350 void DoCancel() |
|
351 { |
|
352 } |
|
353 |
|
354 CAlfAppUi& iAppUi; |
|
355 CHuiDisplay& iDisplay; // if we ever need to support touch events from multiple displays, this needs to change |
|
356 // of course we could have several event fetchers on that scnario.. |
|
357 RArray<TWsEvent> iQueue1; |
|
358 RArray<TWsEvent> iQueue2; |
|
359 TInt iQueueSelection; |
|
360 RCriticalSection iSema; |
|
361 TThreadId iThread; |
|
362 CAlfEventCatcher* iEventCatcher; |
|
363 TSize iVirtualSize; |
|
364 }; |
|
365 |
|
366 // ===========ALF WINDOW THREAD================ |
|
367 |
|
368 |
|
369 NONSHARABLE_CLASS(CAlfEventFetcher): public CActive |
|
370 { |
|
371 public: |
|
372 CAlfEventFetcher(RWsSession& aWsSession, |
|
373 CAlfEventBridge* aBridge ) |
|
374 :CActive(CActive::EPriorityUserInput), |
|
375 iWsSession(aWsSession), |
|
376 iWindowGroup(aWsSession), |
|
377 iBridge(aBridge) |
|
378 { |
|
379 CActiveScheduler::Add(this); |
|
380 } |
|
381 |
|
382 ~CAlfEventFetcher() |
|
383 { |
|
384 Cancel(); |
|
385 delete iWindowGc; |
|
386 if (iWindow) |
|
387 { |
|
388 iWindow->Close(); |
|
389 delete iWindow; |
|
390 } |
|
391 iWindowGroup.Close(); |
|
392 delete iScreenDevice; |
|
393 } |
|
394 |
|
395 static CAlfEventFetcher* NewLC(RWsSession& aWsSession, |
|
396 CAlfEventBridge* aBridge ) |
|
397 { |
|
398 CAlfEventFetcher* ret = new (ELeave)CAlfEventFetcher(aWsSession,aBridge); |
|
399 CleanupStack::PushL(ret); |
|
400 ret->CreateWindowAndStartL(); |
|
401 return ret; |
|
402 } |
|
403 |
|
404 void CreateWindowAndStartL() |
|
405 { |
|
406 iWsSession.ComputeMode(RWsSession::EPriorityControlDisabled); |
|
407 RThread thread; |
|
408 #if defined(__EPOC32__) |
|
409 thread.SetProcessPriority(EPriorityForeground); |
|
410 #else |
|
411 thread.SetPriority(EPriorityAbsoluteForegroundNormal); |
|
412 #endif |
|
413 iScreenDevice =new(ELeave) CWsScreenDevice(iWsSession); |
|
414 iScreenDevice->Construct(0); // For main display only |
|
415 |
|
416 User::LeaveIfError(iWindowGroup.Construct((TUint32)iScreenDevice, EFalse,iScreenDevice)); |
|
417 iWindowGroup.EnableReceiptOfFocus(EFalse); |
|
418 // disable pointer events based autoforwarding |
|
419 iWindowGroup.AutoForeground(EFalse); |
|
420 iWindowGroup.EnableScreenChangeEvents(); |
|
421 |
|
422 CApaWindowGroupName* wgName = CApaWindowGroupName::NewLC(iWsSession); |
|
423 wgName->SetHidden(ETrue); // hides us from FSW and protects us from OOM FW etc. |
|
424 wgName->SetSystem(ETrue); // Allow only application with PowerManagement cap to shut us down |
|
425 wgName->SetCaptionL(_L("ALF Event")); |
|
426 wgName->SetAppUid(KNullUid); |
|
427 wgName->SetWindowGroupName(iWindowGroup); |
|
428 CleanupStack::PopAndDestroy(); |
|
429 |
|
430 iWindow = new (ELeave) RWindow(iWsSession); |
|
431 iWindow->Construct(iWindowGroup,0x000FAB11); // FYI: multiple display support neglegted atm |
|
432 iWindow->SetExtent(TPoint(0,0),iScreenDevice->SizeInPixels()); // FYI: multiple display support neglegted atm |
|
433 iWindow->EnableAdvancedPointers(); |
|
434 iWindow->PointerFilter(EPointerFilterDrag,0); |
|
435 iWindow->SetPointerGrab(ETrue); |
|
436 iWindow->Activate(); |
|
437 iWindow->SetVisible(ETrue); |
|
438 iWindow->SetTransparencyAlphaChannel(); |
|
439 iWindow->SetBackgroundColor(~0); |
|
440 |
|
441 iBridge->iEventCatcher = new (ELeave) CAlfEventCatcher(iWsSession, iWindowGroup, iWindow, iScreenDevice); |
|
442 iBridge->Trigger(iWindowGroup.Identifier()); // let appui know our wgid |
|
443 |
|
444 //RequestEventNotification(); |
|
445 SetActive(); |
|
446 TRequestStatus* sptr = &iStatus; |
|
447 User::RequestComplete(sptr, KErrNone); |
|
448 } |
|
449 |
|
450 |
|
451 void RequestEventNotification() |
|
452 /** Asks WSERV to give notification when an event is waiting */ |
|
453 { |
|
454 SetActive(); |
|
455 iWsSession.EventReady(&iStatus); |
|
456 } |
|
457 |
|
458 void RunL() |
|
459 { |
|
460 if (!iInitializationComplete) |
|
461 { // invalidate window server scene to get the latest drawing commands |
|
462 // now that alf is there |
|
463 iWindowGc = new CWindowGc(iScreenDevice); |
|
464 if (iWindowGc) |
|
465 { |
|
466 if(iWindowGc->Construct() == KErrNone) |
|
467 { |
|
468 iWindowGc->Activate(*iWindow); |
|
469 iWindowGc->SetBrushColor(0xffffffff); |
|
470 iWindowGc->Clear(); |
|
471 iWindowGc->Deactivate(); |
|
472 } |
|
473 } |
|
474 |
|
475 iWindowGroup.SetOrdinalPosition(-1,ECoeWinPriorityNeverAtFront); |
|
476 iWsSession.Flush(); |
|
477 iInitializationComplete = ETrue; |
|
478 RequestEventNotification(); |
|
479 return; |
|
480 } |
|
481 |
|
482 switch (iStatus.Int()) |
|
483 { |
|
484 case KErrNone: |
|
485 break; |
|
486 case KErrCancel: |
|
487 case KErrServerTerminated: |
|
488 default: |
|
489 return; |
|
490 } |
|
491 |
|
492 TWsEvent event; |
|
493 iWsSession.GetEvent(event); |
|
494 |
|
495 if( event.Type() == EEventScreenDeviceChanged ) |
|
496 { |
|
497 #ifdef ALF_USE_EMULATOR_LAYOUT_SWITCH_BUTTON |
|
498 // Update window size when layout changes. The ScreenDevice |
|
499 // has to be updated separately, otherwise it will always return the orig resolution. |
|
500 iScreenDevice->SetAppScreenMode(iScreenDevice->CurrentScreenMode()); |
|
501 |
|
502 TSize size = iScreenDevice->SizeInPixels(); |
|
503 TSize origSize = iWindow->Size(); |
|
504 |
|
505 TPixelsAndRotation rotation; |
|
506 iScreenDevice->GetDefaultScreenSizeAndRotation(rotation); |
|
507 |
|
508 // Set the new size to the window, if it wasn't orientation change within same resolution. |
|
509 if (origSize != size && rotation.iRotation == CFbsBitGc::EGraphicsOrientationNormal) |
|
510 { |
|
511 iWindow->SetSize(size); |
|
512 iWindow->Size(); // To populate size cache |
|
513 } |
|
514 #else |
|
515 // update window size when layout changes |
|
516 iScreenDevice->SetAppScreenMode(iScreenDevice->CurrentScreenMode()); |
|
517 iWindow->SetSize(iScreenDevice->SizeInPixels()); |
|
518 #endif |
|
519 |
|
520 // This is a workaround for possibly missing command buffers at layout switch |
|
521 iWsSession.ClearAllRedrawStores(); |
|
522 |
|
523 __ALFLOGSTRING2("ALF EventWin: Size(%d,%d)", iWindow->Size().iWidth, iWindow->Size().iHeight ); |
|
524 //and fall through |
|
525 } |
|
526 |
|
527 RequestEventNotification(); //Request now so that WSERV has time to respond (on SMP systems) before the return to the Active Scheduler |
|
528 iBridge->AddEventL(event); |
|
529 } |
|
530 |
|
531 void DoCancel() |
|
532 { |
|
533 iWsSession.EventReadyCancel(); |
|
534 } |
|
535 |
|
536 RWsSession& iWsSession; |
|
537 RWindowGroup iWindowGroup; |
|
538 CWsScreenDevice* iScreenDevice; |
|
539 RWindow* iWindow; |
|
540 CAlfEventBridge* iBridge; |
|
541 TBool iInitializationComplete; |
|
542 CWindowGc* iWindowGc; |
|
543 }; |
|
544 |
|
545 LOCAL_C void DoAlfEventThreadStartFunctionL(CAlfEventBridge* aBridge) |
|
546 { |
|
547 RWsSession wsSession; |
|
548 wsSession.Connect(); |
|
549 CleanupClosePushL(wsSession); |
|
550 |
|
551 CAlfEventFetcher* fetch = CAlfEventFetcher::NewLC(wsSession, aBridge); |
|
552 |
|
553 CActiveScheduler::Start(); |
|
554 CleanupStack::PopAndDestroy(2); // ws, fetcher |
|
555 } |
|
556 |
|
557 // --------------------------------------------------------------------------- |
|
558 // Entry point into the new thread |
|
559 // --------------------------------------------------------------------------- |
|
560 // |
|
561 GLDEF_C TInt AlfEventThreadStartFunction(TAny* aBridge) |
|
562 { |
|
563 __UHEAP_MARK; |
|
564 |
|
565 TInt err = User::RenameThread(KAlfEventThreadName); |
|
566 if (err == KErrNone) |
|
567 { |
|
568 // Set up scheduler and cleanup stack for this thread |
|
569 CActiveScheduler* scheduler = new CActiveScheduler; |
|
570 if (!scheduler) |
|
571 { |
|
572 return KErrNoMemory; |
|
573 } |
|
574 CActiveScheduler::Install(scheduler); |
|
575 CTrapCleanup* trapCleanup = CTrapCleanup::New(); |
|
576 if (!trapCleanup) |
|
577 { |
|
578 return KErrNoMemory; |
|
579 } |
|
580 |
|
581 TRAP(err,DoAlfEventThreadStartFunctionL((CAlfEventBridge*)aBridge)); |
|
582 |
|
583 delete CActiveScheduler::Current(); |
|
584 delete trapCleanup; |
|
585 } |
|
586 __UHEAP_MARKEND; |
|
587 return err; |
|
588 } |
|
589 |
|
590 // ==============END EVENT THREAD===================== |
|
591 |
|
592 |
|
593 |
|
594 NONSHARABLE_CLASS(CAlfAppUi::CAlfAppUiData) |
|
595 : public CBase |
|
596 { |
|
597 public: |
|
598 // Environment. Owned. |
|
599 CHuiEnv* iHuiEnv; |
|
600 |
|
601 // Pointer to server. Not owned. |
|
602 CAlfAppServer* iServer; |
|
603 |
|
604 // Shared window-owning control. Owned. |
|
605 CAlfSharedDisplayCoeControl* iSharedWindow; |
|
606 CAlfAppSrvSessionBase* iActiveSession; |
|
607 |
|
608 CAlfSrvResourceManager* iResourceManager; |
|
609 CAlfSrvSettingsHandler* iSettingsHandler; |
|
610 |
|
611 ~CAlfAppUiData() // for convenience |
|
612 { |
|
613 if ( iServer ) |
|
614 { |
|
615 // Infom texture manager that env is deleted. |
|
616 iServer->TextureManager().HandleEnvToBeDeleted(); |
|
617 } |
|
618 |
|
619 delete iSettingsHandler; |
|
620 delete iResourceManager; |
|
621 if (iEventAo) |
|
622 { |
|
623 iEventAo->Cancel(); |
|
624 } |
|
625 delete iEventAo; // before session is being terminated |
|
626 delete iHuiEnv; |
|
627 delete iSharedWindow; |
|
628 #ifdef SYMBIAN_BUILD_GCE |
|
629 delete iBridgeObj; |
|
630 #endif // #ifdef SYMBIAN_BUILD_GCE |
|
631 } |
|
632 TBool iAllClientsClosed; |
|
633 |
|
634 // Boolean flag indicating if non-fading of shared window is enabled or disabled. |
|
635 TBool iSharedWindowNonFading; |
|
636 #ifdef SYMBIAN_BUILD_GCE |
|
637 CAlfBridge* iBridgeObj; |
|
638 CAlfStreamerBridge* iBridge; |
|
639 #endif // #ifdef SYMBIAN_BUILD_GCE |
|
640 RWindow* iPlainWindow; |
|
641 CHuiDisplay* iMainDisplay; |
|
642 CHuiDisplay* iTVDisplay; |
|
643 CAlfEventBridge* iEventAo; |
|
644 RAlfTfxClient iDsServer; |
|
645 TBool iDsActivated; |
|
646 }; |
|
647 |
|
648 // ======== MEMBER FUNCTIONS ======== |
|
649 |
|
650 // --------------------------------------------------------------------------- |
|
651 // Constructor |
|
652 // --------------------------------------------------------------------------- |
|
653 // |
|
654 EXPORT_C CAlfAppUi::CAlfAppUi() |
|
655 { |
|
656 if (CCoeEnv::Static()) |
|
657 { |
|
658 SetFullScreenApp(EFalse); // to avoid getting queued/suspended in case of S60 system events |
|
659 } |
|
660 } |
|
661 |
|
662 // --------------------------------------------------------------------------- |
|
663 // Destructor |
|
664 // --------------------------------------------------------------------------- |
|
665 // |
|
666 EXPORT_C CAlfAppUi::~CAlfAppUi() |
|
667 { |
|
668 delete iData; |
|
669 } |
|
670 |
|
671 |
|
672 // --------------------------------------------------------------------------- |
|
673 // Returns HuiEnv. |
|
674 // --------------------------------------------------------------------------- |
|
675 // |
|
676 CHuiEnv& CAlfAppUi::HuiEnv() |
|
677 { |
|
678 return *iData->iHuiEnv; |
|
679 } |
|
680 |
|
681 |
|
682 void AllocTestCreateHuiEnvL(CHuiEnv** aEnv, TInt aRenderer) |
|
683 { |
|
684 // Create as big bitmap as CHuiTextureManager. This will create |
|
685 // a scanline buffer in the "static" RFbsSession. |
|
686 CFbsBitmap* bitmap = new (ELeave) CFbsBitmap(); |
|
687 CleanupStack::PushL( bitmap ); |
|
688 User::LeaveIfError( bitmap->Create(TSize(4, 4), EColor64K) ); |
|
689 |
|
690 TUint allocFail(0); |
|
691 for (TInt err = KErrNoMemory; err != KErrNone; allocFail++) |
|
692 { |
|
693 __UHEAP_SETFAIL(RHeap::EDeterministic, allocFail); |
|
694 __UHEAP_MARK; |
|
695 TRAP(err, *aEnv = CHuiEnv::NewL((THuiRenderer)aRenderer)); |
|
696 if ( (err != KErrNoMemory) && (err != KErrNone) ) |
|
697 { |
|
698 //User::Panic(_L("HUIEnv Alloc Test"), err); |
|
699 } |
|
700 if (err == KErrNone) |
|
701 { |
|
702 __UHEAP_RESET; |
|
703 } |
|
704 else |
|
705 { |
|
706 __UHEAP_MARKEND; |
|
707 } |
|
708 } |
|
709 __UHEAP_SETFAIL(RHeap::ENone, 0); |
|
710 |
|
711 // delete the bitmap |
|
712 CleanupStack::PopAndDestroy( bitmap ); |
|
713 } |
|
714 |
|
715 // --------------------------------------------------------------------------- |
|
716 // Allocates HuiEnv. |
|
717 // --------------------------------------------------------------------------- |
|
718 // |
|
719 void CAlfAppUi::CreateHuiEnvL() |
|
720 { |
|
721 ASSERT(!iData->iHuiEnv); // Cannot create the environment twice. |
|
722 |
|
723 THuiRenderer renderer = iData->iSettingsHandler->Renderer(); |
|
724 |
|
725 // Note: CHuiEnv::NewL might change renderer internally |
|
726 |
|
727 #ifdef _DEBUG |
|
728 if ( renderer == EHuiRendererBitgdi ) // OPEN GL Would fail because of driver probs |
|
729 { |
|
730 // Remove memory failure test because it causes problems with ECOM plugins |
|
731 // AllocTestCreateHuiEnvL(&iData->iHuiEnv, renderer); |
|
732 iData->iHuiEnv = CHuiEnv::NewL( renderer ); |
|
733 } |
|
734 else |
|
735 { |
|
736 iData->iHuiEnv = CHuiEnv::NewL( renderer ); |
|
737 } |
|
738 #else |
|
739 iData->iHuiEnv = CHuiEnv::NewL( renderer ); |
|
740 #endif |
|
741 iData->iHuiEnv->SetMaxCpuTime( iData->iSettingsHandler->MaxCpuUsage() ); |
|
742 } |
|
743 |
|
744 // --------------------------------------------------------------------------- |
|
745 // Called when all the clients have exited. |
|
746 // --------------------------------------------------------------------------- |
|
747 // |
|
748 void CAlfAppUi::AllClientsClosed() |
|
749 { |
|
750 // In NGA master scene graph role, |
|
751 // we must not close the server even there were no hitchcock app clients present |
|
752 #ifndef SYMBIAN_BUILD_GCE |
|
753 iData->iAllClientsClosed = ETrue; |
|
754 CAknEnv::Static()->RunAppShutter(); |
|
755 #endif // #ifdef SYMBIAN_BUILD_GCE |
|
756 } |
|
757 |
|
758 // --------------------------------------------------------------------------- |
|
759 // From class CAknAppUi. |
|
760 // 2nd phase constructor |
|
761 // --------------------------------------------------------------------------- |
|
762 // |
|
763 EXPORT_C void CAlfAppUi::ConstructL() |
|
764 { |
|
765 __ALFLOGSTRING( "CAlfAppUi::ConstructL start" ) |
|
766 TInt flags = EStandardApp|ENoScreenFurniture|ENonStandardResourceFile|EAknEnableSkin; |
|
767 CCoeEnv* coe = CCoeEnv::Static(); |
|
768 iData = new (ELeave) CAlfAppUiData(); |
|
769 |
|
770 iData->iSettingsHandler = CAlfSrvSettingsHandler::NewL( *this ); |
|
771 CreateHuiEnvL(); |
|
772 |
|
773 if (coe) |
|
774 { |
|
775 // initialize app basic services |
|
776 CAknAppUi::BaseConstructL(flags); |
|
777 |
|
778 // create direct pointer to server so no need to access coestatics whenever server needed |
|
779 iData->iServer = static_cast<CAlfAppServer*>(static_cast<CEikonEnv*>(coe)->AppServer()); |
|
780 } |
|
781 else |
|
782 { |
|
783 iData->iServer = CAlfAppServer::NewAppServerL(); |
|
784 } |
|
785 |
|
786 iData->iServer->SetAppUi(this); |
|
787 |
|
788 RWindowGroup& mainWg = *CHuiStatic::RootWin(); |
|
789 // to non-focusing |
|
790 mainWg.EnableReceiptOfFocus(EFalse); |
|
791 // disable pointer events based autoforwarding |
|
792 mainWg.AutoForeground(EFalse); |
|
793 mainWg.SetOrdinalPosition(-1,ECoeWinPriorityNeverAtFront); |
|
794 |
|
795 |
|
796 if (!coe) // multiple screen support missing, for main display only atm |
|
797 { |
|
798 TUid appUid = TUid::Uid(KAlfAppServerInterfaceUid3); |
|
799 // complete server construction |
|
800 TName serverName; |
|
801 _LIT(KServerNameFormat, "%08x_%08x_AppServer"); |
|
802 serverName.Format( |
|
803 KServerNameFormat, |
|
804 appUid, |
|
805 appUid.iUid ); |
|
806 |
|
807 iData->iServer->ConstructL(serverName); |
|
808 |
|
809 // parametrize our window group |
|
810 CApaWindowGroupName* wgName = CApaWindowGroupName::NewLC(CHuiStatic::WsSession()); |
|
811 wgName->SetHidden(ETrue); // hides us from FSW and protects us from OOM FW etc. |
|
812 wgName->SetSystem(ETrue); // Allow only application with PowerManagement cap to shut us down |
|
813 wgName->SetCaptionL(_L("ALF")); |
|
814 wgName->SetAppUid(appUid); |
|
815 wgName->SetWindowGroupName(mainWg); |
|
816 CleanupStack::PopAndDestroy(); |
|
817 } |
|
818 // misc settings for surroundings |
|
819 if (coe) |
|
820 { // we ndon't need these in NGA |
|
821 mainWg.EnableFocusChangeEvents(); |
|
822 } |
|
823 |
|
824 CHuiStatic::WsSession().ComputeMode(RWsSession::EPriorityControlDisabled); |
|
825 |
|
826 RThread thread; |
|
827 #if defined(__EPOC32__) |
|
828 thread.SetProcessPriority(EPriorityForeground); |
|
829 #else |
|
830 thread.SetPriority(EPriorityAbsoluteForegroundNormal); |
|
831 #endif |
|
832 |
|
833 // delegates.. |
|
834 iData->iResourceManager = CAlfSrvResourceManager::NewL( *iData->iHuiEnv ); |
|
835 |
|
836 if (coe) |
|
837 { |
|
838 iData->iSharedWindow = new (ELeave) CAlfSharedDisplayCoeControl(); |
|
839 iData->iSharedWindow->ConstructL(); |
|
840 iData->iSharedWindow->DrawableWindow()->EnableVisibilityChangeEvents(); |
|
841 } |
|
842 else |
|
843 { |
|
844 //mainWg.EnableScreenChangeEvents(); |
|
845 |
|
846 CHuiStatic::WsSession().EnableWindowSizeCacheL(); |
|
847 iData->iPlainWindow = new (ELeave) RWindow(CHuiStatic::WsSession()); |
|
848 iData->iPlainWindow->Construct(*CHuiStatic::RootWin(),0x000FAB10); // FYI: multiple display support neglegted atm |
|
849 iData->iPlainWindow->SetExtentErr(TPoint(0,0),CHuiStatic::ScreenDevice()->SizeInPixels()); // FYI: multiple display support neglegted atm |
|
850 iData->iPlainWindow->Size(); // to populate size cache |
|
851 iData->iPlainWindow->Activate(); |
|
852 iData->iPlainWindow->SetVisible(ETrue); |
|
853 iData->iPlainWindow->SetTransparencyAlphaChannel(); |
|
854 iData->iPlainWindow->SetBackgroundColor(~0); |
|
855 } |
|
856 |
|
857 #ifdef SYMBIAN_BUILD_GCE |
|
858 |
|
859 iData->iBridgeObj = CAlfBridge::NewL( &iData->iBridge, iData->iHuiEnv ); |
|
860 iData->iBridgeObj->iAppUi = this; |
|
861 |
|
862 if( !iData->iPlainWindow) |
|
863 { |
|
864 // Create default CAlfScreen already now to be able to show controlgroups early enough... |
|
865 iData->iBridgeObj->AddNewScreenL(iData->iSharedWindow); |
|
866 } |
|
867 else |
|
868 { |
|
869 iData->iBridgeObj->AddNewScreenFromWindowL(iData->iPlainWindow); |
|
870 iData->iEventAo = new (ELeave) CAlfEventBridge(*this, *iData->iBridgeObj->Display(0)); |
|
871 |
|
872 RThread eventThread; |
|
873 |
|
874 User::LeaveIfError(eventThread.Create( |
|
875 KAlfEventThreadName, |
|
876 AlfEventThreadStartFunction, |
|
877 16384, // magic |
|
878 0, // uses same heap |
|
879 (TAny*)iData->iEventAo, |
|
880 EOwnerThread)); |
|
881 |
|
882 eventThread.Resume(); |
|
883 eventThread.Close(); |
|
884 } |
|
885 |
|
886 AppendDisplayOnSharedWindowL(*(iData->iBridgeObj->Display(0))); |
|
887 |
|
888 iData->iBridge = CAlfStreamerBridge::NewL(iData->iBridgeObj); |
|
889 iData->iBridge->iAlfWindowData.iAlfWindowGrpId = mainWg.Identifier(); |
|
890 iData->iBridge->iAlfWindowData.iAlfWindowHandle = iData->iPlainWindow->ClientHandle(); |
|
891 iData->iBridge->iAlfWindowData.iScreenNumber = 0; // TBD multiple screen support |
|
892 |
|
893 TThreadId threadId; |
|
894 CAlfStreamerServer::LaunchServer(threadId, iData->iBridge); |
|
895 |
|
896 #endif // #ifdef SYMBIAN_BUILD_GCE |
|
897 // Inform texture manager that env has been created. |
|
898 iData->iServer->TextureManager().HandleEnvCreateL( *iData->iHuiEnv ); |
|
899 |
|
900 // Construct transition effect instance if it does not yet exist |
|
901 iData->iServer->CreateTransitionEffectsL(); |
|
902 |
|
903 // Load Tfx server client API plugin, if exists |
|
904 iData->iServer->CreateTfxServerPlugin(); |
|
905 |
|
906 __ALFLOGSTRING( "CAlfAppUi::ConstructL end" ) |
|
907 } |
|
908 |
|
909 // --------------------------------------------------------------------------- |
|
910 // From class CAknAppUi. |
|
911 // Handles system event. |
|
912 // --------------------------------------------------------------------------- |
|
913 // |
|
914 EXPORT_C void CAlfAppUi::HandleSystemEventL(const TWsEvent& aEvent) |
|
915 { |
|
916 switch (*(TApaSystemEvent*)(aEvent.EventData())) |
|
917 { |
|
918 case EApaSystemEventBroughtToForeground: |
|
919 { // we need to suppress this event as it causes undesired effects on applications underneath |
|
920 break; |
|
921 } |
|
922 default: |
|
923 CAknAppUi::HandleSystemEventL(aEvent); |
|
924 } |
|
925 |
|
926 return; |
|
927 } |
|
928 |
|
929 void CAlfAppUi::StartPointerEventHandling() |
|
930 { |
|
931 if (iData->iActiveSession) |
|
932 { |
|
933 iData->iActiveSession->StartPointerHandling(); |
|
934 } |
|
935 } |
|
936 |
|
937 void CAlfAppUi::EndPointerEventHandling() |
|
938 { |
|
939 if (iData->iActiveSession) |
|
940 { |
|
941 iData->iActiveSession->FlushPointerHandling(); |
|
942 } |
|
943 } |
|
944 |
|
945 void CAlfAppUi::UpdateActiveSession(CAlfAppSrvSessionBase* aSession) |
|
946 { |
|
947 EndPointerEventHandling(); |
|
948 iData->iActiveSession = aSession; |
|
949 |
|
950 iData->iResourceManager->SetActiveSession( iData->iActiveSession ); |
|
951 |
|
952 if (CCoeEnv::Static()) |
|
953 { |
|
954 if( aSession ) |
|
955 { |
|
956 CHuiStatic::RootWin()->EnableGroupListChangeEvents(); |
|
957 } |
|
958 else |
|
959 { |
|
960 CHuiStatic::RootWin()->DisableGroupListChangeEvents(); |
|
961 } |
|
962 } |
|
963 if(!aSession) |
|
964 { |
|
965 if (iData->iMainDisplay) // TBD: multiple display support once again... |
|
966 { |
|
967 iData->iMainDisplay->SetClearBackgroundL(CHuiDisplay::EClearNone); |
|
968 } |
|
969 } |
|
970 } |
|
971 |
|
972 // --------------------------------------------------------------------------- |
|
973 // From class CAknAppUi. |
|
974 // Handles window server event. |
|
975 // --------------------------------------------------------------------------- |
|
976 // |
|
977 EXPORT_C void CAlfAppUi::HandleWsEventL(const TWsEvent& aEvent, CCoeControl* aDestination) |
|
978 { |
|
979 TBool handlingPtrEvent(EFalse); |
|
980 |
|
981 if (aEvent.Type() >= EEventPointer && aEvent.Type() <= EEventDragDrop ) |
|
982 { |
|
983 StartPointerEventHandling(); |
|
984 handlingPtrEvent = ETrue; // just to play it safe |
|
985 } |
|
986 |
|
987 // A Fix for AlfServer not shutting down on power off (ANIA-7EWFV6) |
|
988 if ( aEvent.Type() == EEventPowerMgmt ) |
|
989 { |
|
990 TApaSystemEvent systemEvent( *(TApaSystemEvent*)(aEvent.EventData()) ); |
|
991 if ( systemEvent == EApaSystemEventShutdown || systemEvent == EApaSystemEventSecureShutdown ) |
|
992 { |
|
993 // Don't let this event go further to base class' HandleWsEventL, |
|
994 // since it'll start the appShutter, which will be ignored first, |
|
995 // and when it would be really needed (after AllClientsClosed), it's already destroyed. |
|
996 return; |
|
997 } |
|
998 } |
|
999 |
|
1000 if (!iData->iEventAo) // CCoeEnv exists |
|
1001 { |
|
1002 CAknAppUi::HandleWsEventL(aEvent, aDestination); |
|
1003 if (handlingPtrEvent) |
|
1004 { |
|
1005 EndPointerEventHandling(); |
|
1006 } |
|
1007 } |
|
1008 else |
|
1009 { |
|
1010 if( aEvent.Type() == EEventScreenDeviceChanged ) |
|
1011 { |
|
1012 HandleResourceChangeL( KEikDynamicLayoutVariantSwitch ); |
|
1013 } |
|
1014 } |
|
1015 |
|
1016 switch ( aEvent.Type() ) |
|
1017 { |
|
1018 case EEventFocusGroupChanged: |
|
1019 case EEventWindowGroupListChanged: |
|
1020 { |
|
1021 if( iData->iActiveSession ) |
|
1022 { |
|
1023 if( iData->iServer->AlfClientHasFocus() ) |
|
1024 { |
|
1025 iData->iActiveSession->SetBackgroundMaxFps( EFalse ); |
|
1026 } |
|
1027 else |
|
1028 { |
|
1029 iData->iActiveSession->SetBackgroundMaxFps( ETrue ); |
|
1030 } |
|
1031 } |
|
1032 break; |
|
1033 } |
|
1034 case EEventWindowVisibilityChanged: |
|
1035 { |
|
1036 iData->iResourceManager->SetServerWindowPartiallyVisible( |
|
1037 !(aEvent.VisibilityChanged()->iFlags&TWsVisibilityChangedEvent::ENotVisible) ); |
|
1038 break; |
|
1039 } |
|
1040 default: |
|
1041 break; |
|
1042 } |
|
1043 } |
|
1044 |
|
1045 // --------------------------------------------------------------------------- |
|
1046 // Called when client is about to exit. |
|
1047 // --------------------------------------------------------------------------- |
|
1048 // |
|
1049 void CAlfAppUi::FreeResourcesForClient( TInt aClientId ) |
|
1050 { |
|
1051 if (aClientId == TInt(iData->iActiveSession)) |
|
1052 { |
|
1053 iData->iActiveSession = 0; |
|
1054 iData->iResourceManager->SetActiveSession( NULL ); |
|
1055 } |
|
1056 } |
|
1057 |
|
1058 // --------------------------------------------------------------------------- |
|
1059 // Returns the shared window-owning control. |
|
1060 // --------------------------------------------------------------------------- |
|
1061 // |
|
1062 EXPORT_C CCoeControl* CAlfAppUi::Container() |
|
1063 { |
|
1064 return iData->iSharedWindow; |
|
1065 } |
|
1066 |
|
1067 // --------------------------------------------------------------------------- |
|
1068 // Adds display into the redraw stack. |
|
1069 // --------------------------------------------------------------------------- |
|
1070 // |
|
1071 EXPORT_C void CAlfAppUi::AppendDisplayOnSharedWindowL( CHuiDisplay& aDisplay ) |
|
1072 { |
|
1073 if (!iData->iMainDisplay) // TBD: multiple display support once again... |
|
1074 { |
|
1075 iData->iMainDisplay = &aDisplay; |
|
1076 } |
|
1077 // with one display, one session (then one who creates the display) |
|
1078 // needs to add the display onto the shared window list. |
|
1079 if ( !iData->iSharedWindow || iData->iSharedWindow->iDisplays.Count() > 0 ) |
|
1080 { |
|
1081 return; |
|
1082 } |
|
1083 User::LeaveIfError( iData->iSharedWindow->iDisplays.Append( &aDisplay ) ); |
|
1084 } |
|
1085 |
|
1086 // --------------------------------------------------------------------------- |
|
1087 // Adds TV display into the redraw stack. |
|
1088 // --------------------------------------------------------------------------- |
|
1089 // |
|
1090 void CAlfAppUi::AppendTvDisplayOnSharedWindowL( CHuiDisplay& aDisplay ) |
|
1091 { |
|
1092 if (!iData->iTVDisplay) // TBD: true multiple display support once again... |
|
1093 { |
|
1094 iData->iTVDisplay = &aDisplay; |
|
1095 } |
|
1096 |
|
1097 if ( !iData->iSharedWindow || iData->iSharedWindow->iDisplays.Count() > 1 ) |
|
1098 { |
|
1099 return; |
|
1100 } |
|
1101 |
|
1102 User::LeaveIfError( iData->iSharedWindow->iDisplays.Append( &aDisplay ) ); |
|
1103 } |
|
1104 |
|
1105 // --------------------------------------------------------------------------- |
|
1106 // Removes TV display from the redraw stack. |
|
1107 // --------------------------------------------------------------------------- |
|
1108 // |
|
1109 void CAlfAppUi::RemoveTvDisplayOnSharedWindow( CHuiDisplay& /*aDisplay*/ ) |
|
1110 { |
|
1111 iData->iTVDisplay = 0; |
|
1112 |
|
1113 if ( !iData->iSharedWindow || iData->iSharedWindow->iDisplays.Count() > 1 ) |
|
1114 { |
|
1115 iData->iSharedWindow->iDisplays.Remove(1); |
|
1116 } |
|
1117 } |
|
1118 |
|
1119 |
|
1120 // --------------------------------------------------------------------------- |
|
1121 // Finds TV display from the redraw stack. |
|
1122 // --------------------------------------------------------------------------- |
|
1123 // |
|
1124 CHuiDisplay* CAlfAppUi::FindTvDisplayOnSharedWindow() |
|
1125 { |
|
1126 return iData->iTVDisplay; |
|
1127 } |
|
1128 |
|
1129 // --------------------------------------------------------------------------- |
|
1130 // From class CAknAppUi. |
|
1131 // This is last entry where we can execute code before coe scheduler started |
|
1132 // --------------------------------------------------------------------------- |
|
1133 // |
|
1134 EXPORT_C TBool CAlfAppUi::FrameworkCallsRendezvous() const |
|
1135 { |
|
1136 // just basecall for now |
|
1137 return CAknAppUi::FrameworkCallsRendezvous(); |
|
1138 } |
|
1139 |
|
1140 // --------------------------------------------------------------------------- |
|
1141 // From class CAknAppUi. |
|
1142 // Called when system resources have changed. |
|
1143 // --------------------------------------------------------------------------- |
|
1144 // |
|
1145 EXPORT_C void CAlfAppUi::HandleResourceChangeL( TInt aType ) |
|
1146 { |
|
1147 // A piece of code to resizing the surface on emulator. |
|
1148 #ifdef ALF_USE_EMULATOR_LAYOUT_SWITCH_BUTTON |
|
1149 // Re-create the CWsScreenDevice, as the one cached in the HuiStatic doesn't |
|
1150 // seem to notice the layout & orientation changes.. |
|
1151 |
|
1152 CWsScreenDevice* screenDevice = CHuiStatic::ScreenDevice(0); |
|
1153 screenDevice->SetAppScreenMode(screenDevice->CurrentScreenMode()); |
|
1154 |
|
1155 TPixelsAndRotation rotation; |
|
1156 screenDevice->GetDefaultScreenSizeAndRotation(rotation); |
|
1157 |
|
1158 // Get the sizes and set the new size for the main window |
|
1159 TSize size = screenDevice->SizeInPixels(); |
|
1160 TSize origSize = iData->iHuiEnv->Display(0).Size(); |
|
1161 |
|
1162 // No need to touch if just rotating, so skip the plain orientation change |
|
1163 if (origSize != size && rotation.iRotation == CFbsBitGc::EGraphicsOrientationNormal) |
|
1164 { |
|
1165 TInt err = iData->iPlainWindow->SetSizeErr(size); |
|
1166 iData->iPlainWindow->Size(); // To populate size cache. |
|
1167 |
|
1168 iData->iHuiEnv->Display(0).SetSizeL(size); |
|
1169 iData->iHuiEnv->Display(0).SetVisibleArea(TRect(size)); |
|
1170 } |
|
1171 #endif |
|
1172 |
|
1173 if ( aType == KEikDynamicLayoutVariantSwitch || aType == KAknsMessageSkinChange && iData->iHuiEnv) |
|
1174 { |
|
1175 iData->iHuiEnv->Skin().NotifyDisplaySizeChangedL(); |
|
1176 } |
|
1177 |
|
1178 // Send notification events to clients here if needed |
|
1179 if (iData->iServer) |
|
1180 { |
|
1181 // Only KAknsMessageSkinChange is delivered to clients for now |
|
1182 if (aType == KAknsMessageSkinChange) |
|
1183 { |
|
1184 // We don't deliver wallpapaper change or morphing change |
|
1185 // because textures should not depend on those -> no texture reuploads needed. |
|
1186 if (CHuiStatic::SkinInstance()) |
|
1187 { |
|
1188 if (AknsUtils::SkinInstance()->SkinChangeReason() == ENormalSkinChange) |
|
1189 { |
|
1190 iData->iServer->TriggerSystemEvent(KAknsMessageSkinChange); |
|
1191 } |
|
1192 } |
|
1193 } |
|
1194 } |
|
1195 |
|
1196 // don't base call |
|
1197 } |
|
1198 |
|
1199 // --------------------------------------------------------------------------- |
|
1200 // From class CAknAppUi. |
|
1201 // Called when a command is received. |
|
1202 // --------------------------------------------------------------------------- |
|
1203 // |
|
1204 EXPORT_C void CAlfAppUi::HandleCommandL(TInt aCommand) |
|
1205 { |
|
1206 if (aCommand == EEikCmdExit && iData->iAllClientsClosed) |
|
1207 { |
|
1208 Exit(); |
|
1209 } |
|
1210 } |
|
1211 |
|
1212 // --------------------------------------------------------------------------- |
|
1213 // Return settings handler |
|
1214 // --------------------------------------------------------------------------- |
|
1215 // |
|
1216 CAlfSrvSettingsHandler& CAlfAppUi::SettingsHandler() |
|
1217 { |
|
1218 return *iData->iSettingsHandler; |
|
1219 } |
|
1220 |
|
1221 // --------------------------------------------------------------------------- |
|
1222 // Updates non-fading setting to window. |
|
1223 // --------------------------------------------------------------------------- |
|
1224 // |
|
1225 void CAlfAppUi::SetContainerNonFading( TBool aNonFading ) |
|
1226 { |
|
1227 const TBool nonFading = iData->iSharedWindowNonFading; |
|
1228 if ( ( nonFading && !aNonFading ) || |
|
1229 ( !nonFading && aNonFading ) ) |
|
1230 { |
|
1231 // Update window server setting. |
|
1232 iData->iSharedWindowNonFading = aNonFading; |
|
1233 iData->iSharedWindow->DrawableWindow()->SetNonFading( aNonFading ); |
|
1234 |
|
1235 // If non-fading is turned off, update fading to correct value. |
|
1236 // It's assumed that alfred applications are not shown in a pop up. |
|
1237 // If it were possible, we would need to know if alfred pop up is |
|
1238 // topmost. |
|
1239 if ( !aNonFading ) |
|
1240 { |
|
1241 iData->iSharedWindow->DrawableWindow()->SetFaded( |
|
1242 IsFaded(), |
|
1243 RWindowTreeNode::EFadeIncludeChildren ); |
|
1244 } |
|
1245 } |
|
1246 } |
|
1247 |
|
1248 // --------------------------------------------------------------------------- |
|
1249 // Called when setting changes. |
|
1250 // --------------------------------------------------------------------------- |
|
1251 // |
|
1252 void CAlfAppUi::MAlfSrvUintSettingChangedL( TAlfSrvSetting aSetting, TUint aNewValue ) |
|
1253 { |
|
1254 switch( aSetting ) |
|
1255 { |
|
1256 case EAlfSrvSettingDefaultFramerate: |
|
1257 // No need to update. Session will fetch the |
|
1258 // updated default frame rate when it receives |
|
1259 // focus for the next time. |
|
1260 break; |
|
1261 case EAlfSrvSettingMaxCpuUsage: |
|
1262 iData->iHuiEnv->SetMaxCpuTime( aNewValue ); |
|
1263 break; |
|
1264 case EAlfSrvSettingMaxResourceCacheSize: |
|
1265 // RnD feature. Cache side will not change in the |
|
1266 // final release. |
|
1267 break; |
|
1268 case EAlfSrvSettingEffectsComplexityFactor: |
|
1269 { |
|
1270 // Currently this key has no effect, for future expansion. |
|
1271 |
|
1272 // check RnD flags update |
|
1273 const TUint rndFlags = iData->iSettingsHandler->RndFlags(); |
|
1274 // check dirty region redrawing |
|
1275 for ( TInt d = 0; d < iData->iHuiEnv->DisplayCount() ; d++ ) |
|
1276 { |
|
1277 // check dirty region redrawing |
|
1278 iData->iHuiEnv->Display( d ).ShowDirtyRegions( |
|
1279 rndFlags&EAlfSrvRndFlagDrawDirtyRegions ); |
|
1280 |
|
1281 //check visual outline drawing |
|
1282 if ( rndFlags&EAlfSrvRndFlagDrawAllVisualOutline ) |
|
1283 { |
|
1284 iData->iHuiEnv->Display( d ).SetDrawVisualOutline( CHuiDisplay::EDrawVisualOutlineAllVisuals ); |
|
1285 } |
|
1286 else if ( rndFlags&EAlfSrvRndFlagDrawSelectedVisualOutline ) |
|
1287 { |
|
1288 iData->iHuiEnv->Display( d ).SetDrawVisualOutline( CHuiDisplay::EDrawVisualOutlineSelectedVisuals ); |
|
1289 } |
|
1290 else |
|
1291 { |
|
1292 iData->iHuiEnv->Display( d ).SetDrawVisualOutline( CHuiDisplay::EDrawVisualOutlineNone ); |
|
1293 } |
|
1294 } |
|
1295 |
|
1296 // Check for Rnd flags |
|
1297 // Currently used to enable/disable texture memory calculation but can be used for any Rnd flag in future |
|
1298 iData->iHuiEnv->EnableDebugFlag( rndFlags ); |
|
1299 |
|
1300 } |
|
1301 break; |
|
1302 default: |
|
1303 User::Leave( KErrNotSupported ); |
|
1304 break; |
|
1305 } |
|
1306 } |
|
1307 |
|
1308 |
|
1309 TTypeUid::Ptr CAlfAppUi::MopSupplyObject(TTypeUid aId) |
|
1310 { |
|
1311 return CAknAppUi::MopSupplyObject(aId); |
|
1312 } |
|
1313 |
|
1314 // --------------------------------------------------------------------------- |
|
1315 // |
|
1316 // --------------------------------------------------------------------------- |
|
1317 // |
|
1318 TInt CAlfAppUi::FirstAlfControlGroupIndex( TInt aScreenNumber ) |
|
1319 { |
|
1320 #ifdef SYMBIAN_BUILD_GCE |
|
1321 return iData->iBridgeObj->FirstAlfControlGroupIndex( aScreenNumber ); |
|
1322 #endif // #ifdef SYMBIAN_BUILD_GCE |
|
1323 } |
|
1324 |
|
1325 // --------------------------------------------------------------------------- |
|
1326 // |
|
1327 // --------------------------------------------------------------------------- |
|
1328 // |
|
1329 TInt CAlfAppUi::LastAlfControlGroupIndex( TInt aScreenNumber ) |
|
1330 { |
|
1331 #ifdef SYMBIAN_BUILD_GCE |
|
1332 return iData->iBridgeObj->LastAlfControlGroupIndex( aScreenNumber ); |
|
1333 #endif // #ifdef SYMBIAN_BUILD_GCE |
|
1334 } |
|
1335 |
|
1336 |
|
1337 // --------------------------------------------------------------------------- |
|
1338 // |
|
1339 // --------------------------------------------------------------------------- |
|
1340 // |
|
1341 void CAlfAppUi::ShowControlGroupL(CHuiRoster& aRoster, CHuiControlGroup& aGroup, TInt aWhere, TInt aScreenNumber ) |
|
1342 { |
|
1343 #ifdef SYMBIAN_BUILD_GCE |
|
1344 iData->iBridgeObj->ShowControlGroupL(aRoster, aGroup, aWhere, aScreenNumber); |
|
1345 iData->iBridgeObj->HandleVisualVisibility( aScreenNumber ); |
|
1346 #endif // #ifdef SYMBIAN_BUILD_GCE |
|
1347 |
|
1348 } |
|
1349 |
|
1350 // --------------------------------------------------------------------------- |
|
1351 // PostQTCommandBufferL |
|
1352 // --------------------------------------------------------------------------- |
|
1353 // |
|
1354 void CAlfAppUi::PostQTCommandBufferL( TAlfQtCommandBufferParams aParams ) |
|
1355 { |
|
1356 if ( iData ) |
|
1357 { |
|
1358 if( iData->iBridgeObj ) |
|
1359 { |
|
1360 iData->iBridgeObj->PostQTCommandBufferL( aParams ); |
|
1361 } |
|
1362 } |
|
1363 } |
|
1364 |
|
1365 |
|
1366 // --------------------------------------------------------------------------- |
|
1367 // |
|
1368 // --------------------------------------------------------------------------- |
|
1369 // |
|
1370 void CAlfAppUi::SetClientWindowForDrawingL(TInt aWindowGroupId, TInt aClientWindowHandle, CHuiVisual* aVisual) |
|
1371 { |
|
1372 iData->iBridgeObj->SetClientWindowForDrawingL(aWindowGroupId, aClientWindowHandle, aVisual); |
|
1373 } |
|
1374 |
|
1375 |
|
1376 void CAlfAppUi::AdjustWindowGroupPositionL(TInt aParentIdentifier, TInt aPosition) |
|
1377 { |
|
1378 iData->iEventAo->AdjustWindowGroupPositionL(aParentIdentifier, aPosition); |
|
1379 } |
|
1380 |
|
1381 void CAlfAppUi::SetAlfWindowGroupId(TInt aWgId) |
|
1382 { |
|
1383 iData->iBridgeObj->SetAlfWindowGroupId(aWgId); |
|
1384 } |
|
1385 |
|
1386 |
|
1387 // --------------------------------------------------------------------------- |
|
1388 // NotifyLowMemory |
|
1389 // --------------------------------------------------------------------------- |
|
1390 // |
|
1391 void CAlfAppUi::NotifyLowMemory(TInt aAmountOfFreeMemRequested) |
|
1392 { |
|
1393 if (!iData->iDsActivated) |
|
1394 { |
|
1395 if (iData->iDsServer.Open() == KErrNone) |
|
1396 { |
|
1397 iData->iDsActivated = ETrue; |
|
1398 } |
|
1399 } |
|
1400 |
|
1401 if (iData->iDsActivated ) |
|
1402 { |
|
1403 if (!aAmountOfFreeMemRequested) |
|
1404 { |
|
1405 iData->iDsServer.SendSynch(KAlfCompositionGoodOnGraphicsMemory, TIpcArgs()); |
|
1406 } |
|
1407 else |
|
1408 { |
|
1409 iData->iDsServer.SendSynch(KAlfCompositionLowOnGraphicsMemory, TIpcArgs()); |
|
1410 } |
|
1411 } |
|
1412 |
|
1413 /* |
|
1414 // Toggle between normal & low memory levels |
|
1415 if (!aAmountOfFreeMemRequested) |
|
1416 { |
|
1417 iData->iBridgeObj->SetMemoryLevel(EHuiMemoryLevelNormal); |
|
1418 } |
|
1419 else |
|
1420 { |
|
1421 iData->iBridgeObj->SetMemoryLevel(EHuiMemoryLevelLow); |
|
1422 } |
|
1423 */ |
|
1424 |
|
1425 // Enable "ultra-low" memory mode |
|
1426 if (!aAmountOfFreeMemRequested) |
|
1427 { |
|
1428 iData->iBridgeObj->SetMemoryLevel(EHuiMemoryLevelNormal); |
|
1429 } |
|
1430 else |
|
1431 { |
|
1432 iData->iBridgeObj->SetMemoryLevel(EHuiMemoryLevelLowest); |
|
1433 } |
|
1434 } |
|
1435 |
|
1436 // --------------------------------------------------------------------------- |
|
1437 // ForceSwRendering |
|
1438 // --------------------------------------------------------------------------- |
|
1439 // |
|
1440 TInt CAlfAppUi::ForceSwRendering( TBool aEnabled ) |
|
1441 { |
|
1442 return iData->iBridgeObj->ForceSwRendering( aEnabled ); |
|
1443 } |
|
1444 |
|
1445 // end of file |