|
1 /* |
|
2 * Copyright (c) 2005-2007 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: Implementation for peninput server |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include <e32svr.h> |
|
21 #include <w32std.h> |
|
22 #include <coedef.h> |
|
23 #include <apgwgnam.h> |
|
24 #include <coemain.h> |
|
25 #include <AknFepInternalCRKeys.h> |
|
26 #include <akniconconfig.h> |
|
27 #include <AknSgcc.h> |
|
28 #include <sensorplugindomaincrkeys.h> // KCRUidSensorSettings |
|
29 |
|
30 #ifdef RD_TACTILE_FEEDBACK |
|
31 #include <featmgr.h> |
|
32 #endif //RD_TACTILE_FEEDBACK |
|
33 #include "peninputclientserver.h" |
|
34 #include "peninputserver.h" |
|
35 #include "peninputserversession.h" |
|
36 #include <PtiEngine.h> |
|
37 #include <s32mem.h> |
|
38 #include <gulgcmap.h> |
|
39 #include "peninputanimclientobj.h" |
|
40 #include "peninputuilayoutowner.h" |
|
41 //#include "aknfeppeninputenums.h" |
|
42 #include <UikonInternalPSKeys.h> |
|
43 #include "penuiwndctrl.h" |
|
44 #include "keyrotator.h" |
|
45 #include <AknDef.h> |
|
46 #include <aknfeppeninputenums.h> |
|
47 #include <aknappui.h> |
|
48 |
|
49 #include "peninputcrpclient.h" |
|
50 //#define __WND_TEST_ |
|
51 |
|
52 // CONSTANTS |
|
53 const TSize KInitialPeninputSize= TSize( 10, 10 ); |
|
54 const TInt KMsgQueueLen = 1000; |
|
55 const TInt KMsgResponseQueueLen = 10; |
|
56 |
|
57 const TInt KWsSessionFlushPerioid = 50000;//50ms |
|
58 const TInt KInvalidValue = -1; |
|
59 |
|
60 enum TActivationFlag |
|
61 { |
|
62 ECmdDeactivate = EFalse, |
|
63 ECmdActivate = ETrue, |
|
64 }; |
|
65 |
|
66 enum TUpdateFlag |
|
67 { |
|
68 EPartialUpdate = EFalse, |
|
69 EFullUpdate = ETrue |
|
70 }; |
|
71 |
|
72 #ifdef __LOG_WNDGROU__ |
|
73 |
|
74 #ifdef __WINS__ |
|
75 _LIT(KLogFile,"c:\\penwndgroup.txt"); |
|
76 #else |
|
77 _LIT(KLogFile,"\\penwndgroup.txt"); |
|
78 #endif |
|
79 |
|
80 #endif //__LOG_WNDGROU__ |
|
81 |
|
82 TUid GetAppUidByWndGroupIdL( RWsSession &aWs, TInt aWndGroupId ) |
|
83 { |
|
84 CApaWindowGroupName* wg = CApaWindowGroupName::NewLC(aWs,aWndGroupId); |
|
85 TUid id = wg->AppUid(); |
|
86 CleanupStack::PopAndDestroy(wg); |
|
87 return id; |
|
88 } |
|
89 |
|
90 TUid GetFocusAppUid() |
|
91 { |
|
92 RWsSession &ws = CCoeEnv::Static()->WsSession(); |
|
93 TInt wgId =ws.GetFocusWindowGroup(); |
|
94 TUid id = TUid::Null(); |
|
95 TRAP_IGNORE( id = GetAppUidByWndGroupIdL( ws, wgId ) ); |
|
96 return id; |
|
97 } |
|
98 |
|
99 #ifdef __LOG_WNDGROU__ |
|
100 void Des2Des8(const TDesC& aSrc, TDes8& aDest) |
|
101 { |
|
102 aDest.Zero(); |
|
103 const TUint16* ptr = aSrc.Ptr(); |
|
104 for(TInt i = 0; i < aSrc.Length(); ++i) |
|
105 { |
|
106 aDest.Append(*((TUint8*)ptr)); |
|
107 ptr++; |
|
108 } |
|
109 } |
|
110 |
|
111 #endif |
|
112 |
|
113 |
|
114 #ifdef __LOG_WNDGROU__ |
|
115 void WriteDeactivateLogL( RFile& aFile ) |
|
116 { |
|
117 TInt ret = aFile.Open(CCoeEnv::Static()->FsSession(),KLogFile,EFileShareAny|EFileWrite); |
|
118 if(ret == KErrNone) |
|
119 { |
|
120 _LIT8 (KNotesID, "Notes id: %d \r\n"); |
|
121 TBuf8<30> buf; |
|
122 buf.Zero(); |
|
123 |
|
124 TInt off = 0; |
|
125 aFile.Seek(ESeekEnd,off); |
|
126 |
|
127 RWsSession &ws = CCoeEnv::Static()->WsSession(); |
|
128 TInt wgId =ws.GetFocusWindowGroup(); |
|
129 CApaWindowGroupName* wgname = CApaWindowGroupName::NewLC(ws,wgId); |
|
130 |
|
131 TInt focusuid = GetFocusAppUid().iUid; |
|
132 buf.Format(KNotesID, focusuid); |
|
133 |
|
134 |
|
135 HBufC8* name = HBufC8::NewLC(wgname->Caption().Length()); |
|
136 TPtr8 nameStr = name->Des(); |
|
137 Des2Des8(wgname->Caption(),nameStr); |
|
138 aFile.Write(_L8(" ...")); |
|
139 aFile.Write(nameStr); |
|
140 aFile.Write(buf); |
|
141 aFile.Write(_L8(" Close UI. \r\n")); |
|
142 aFile.Close(); |
|
143 CleanupStack::PopAndDestroy(name); |
|
144 CleanupStack::PopAndDestroy(wgname); |
|
145 } |
|
146 } |
|
147 #endif |
|
148 |
|
149 TBool IsGlobalNotesApp(TUid& aUid) |
|
150 { |
|
151 const TInt KAknCapServerUid = 0x10207218; |
|
152 const TInt KAknNotifySrvUid = 0x10281EF2; |
|
153 if(aUid.iUid == KAknCapServerUid || aUid.iUid == KAknNotifySrvUid) |
|
154 return ETrue; |
|
155 return EFalse; |
|
156 } |
|
157 |
|
158 |
|
159 // ======== MEMBER FUNCTIONS ======== |
|
160 |
|
161 // --------------------------------------------------------------------------- |
|
162 // CPeninputServer::CPeninputServer |
|
163 // --------------------------------------------------------------------------- |
|
164 // |
|
165 CPeninputServer::CPeninputServer ( TInt aPriority) : CServer2 ( aPriority,ESharableSessions ), |
|
166 iActive(EFalse),iDispMode(ENone), |
|
167 iDispModeForMask(ENone), |
|
168 iFullUpdate(EFalse), |
|
169 iPrevActive(EFalse),iUILayoutReady(EFalse), |
|
170 iSupportFeedback(EFalse) |
|
171 { |
|
172 AknIconConfig::TPreferredDisplayMode displayMode; |
|
173 |
|
174 AknIconConfig::PreferredDisplayMode(displayMode, AknIconConfig::EImageTypeIcon); |
|
175 |
|
176 iDispMode = displayMode.iBitmapMode; |
|
177 iDispModeForMask = displayMode.iMaskMode; |
|
178 |
|
179 iSpriteMember.iBitmap = NULL; |
|
180 iSpriteMember.iMaskBitmap = NULL; |
|
181 iLayoutId.iUid = 0; |
|
182 iPrevLayoutId = iLayoutId; |
|
183 |
|
184 iSpriteSize = KInitialPeninputSize; |
|
185 iSpritePosition = TPoint(0,0); |
|
186 //iDispMode = iDispModeForMask= CCoeEnv::Static()->WsSession().GetDefModeMaxNumColors(col,grey); |
|
187 iPreNonGloebalNotesWndGrpId = -1; |
|
188 iNoNeedClean = EFalse; |
|
189 } |
|
190 |
|
191 |
|
192 // --------------------------------------------------------------------------- |
|
193 // CPeninputServer::NewL |
|
194 // --------------------------------------------------------------------------- |
|
195 // |
|
196 CPeninputServer* CPeninputServer::NewL() |
|
197 { |
|
198 CPeninputServer* pS = new (ELeave) CPeninputServer( |
|
199 CActive::EPriorityStandard); |
|
200 CleanupStack::PushL( pS ); |
|
201 pS->ConstructL( ); |
|
202 CleanupStack::Pop(pS); |
|
203 return pS; |
|
204 } |
|
205 |
|
206 |
|
207 // --------------------------------------------------------------------------- |
|
208 // CPeninputServer::ConstructL |
|
209 // --------------------------------------------------------------------------- |
|
210 // |
|
211 void CPeninputServer::ConstructL( ) |
|
212 { |
|
213 #ifdef RD_TACTILE_FEEDBACK |
|
214 //KS: QUICK FIX FOR EGSN-7BCBWS |
|
215 FeatureManager::InitializeLibL(); |
|
216 //KS: QUICK FIX FOR EGSN-7BCBWS |
|
217 iSupportFeedback = FeatureManager::FeatureSupported( KFeatureIdTactileFeedback ); |
|
218 |
|
219 #endif //RD_TACTILE_FEEDBACK |
|
220 |
|
221 // start server, leaves if server already running |
|
222 StartL( KPeninputServerName ); |
|
223 |
|
224 User::LeaveIfError( iKeyEventSemaphore.CreateGlobal( |
|
225 KAnimKeyEventSemaphore,0) ); |
|
226 |
|
227 iEventBufferQueue = CEventQueue::NewL(this,KMsgEventBufferQueue); |
|
228 |
|
229 iKeyMsgResponseQueue.CreateGlobal(KMsgEventResponseQueue,KMsgResponseQueueLen); |
|
230 |
|
231 iFlushTimer = CPeriodic::NewL(CActive::EPriorityHigh); |
|
232 |
|
233 iHardwareLayoutChangeWatcher = CAknLayoutChangeWatcher::NewL(this, |
|
234 KUikLayoutState); |
|
235 iSoftwareLayoutChangeWatcher = CAknLayoutChangeWatcher::NewL(this, |
|
236 KUikPreferredOrientation); |
|
237 iHardwareLayoutChangeWatcher->StartWatching(); |
|
238 iSoftwareLayoutChangeWatcher->StartWatching(); |
|
239 |
|
240 RWindowGroup& rootWin = CCoeEnv::Static()->RootWin(); |
|
241 rootWin.EnableFocusChangeEvents (); // For cover UI/status pane refresh problems |
|
242 rootWin.EnableGroupListChangeEvents(); |
|
243 rootWin.EnableReceiptOfFocus(EFalse); |
|
244 rootWin.AutoForeground(EFalse); |
|
245 |
|
246 ConstructSpriteL(); |
|
247 |
|
248 //create animation object |
|
249 iAnimObj = CPeninputAnimObj::NewL(iSpriteMember); |
|
250 |
|
251 iLayoutOwner = CPeninputUiLayoutOwner::NewL( *this ); |
|
252 iPenUiCtrl = new(ELeave) CPenUiWndCtrl(CCoeEnv::Static()->RootWin(),iSpriteMember.iBitmap); |
|
253 iInternalBackgroundCtrl = new(ELeave) CInternalBkCtrl(CCoeEnv::Static()->RootWin()); |
|
254 iInternalBackgroundCtrl->ConstructL(); |
|
255 iPenUiCtrl->ConstructL(); |
|
256 |
|
257 iCurScreenFocusedWndGrpId = GetFocusAppUid().iUid; |
|
258 #ifdef __LOG_WNDGROU__ |
|
259 iLogFile.Replace(CCoeEnv::Static()->FsSession(),KLogFile,EFileShareAny|EFileWrite); |
|
260 iLogFile.Close(); |
|
261 |
|
262 #endif |
|
263 |
|
264 iCurScrMode = CCoeEnv::Static()->ScreenDevice()->CurrentScreenMode(); |
|
265 iCrpService = CPenInputCrpServiceClient::NewL(); |
|
266 iSensorRepository = CRepository::NewL(KCRUidSensorSettings); |
|
267 } |
|
268 |
|
269 void CPeninputServer::CleanAll() |
|
270 { |
|
271 if(iNoNeedClean) |
|
272 return; |
|
273 |
|
274 delete iHardwareLayoutChangeWatcher; |
|
275 delete iSoftwareLayoutChangeWatcher; |
|
276 if(iAppGc) |
|
277 CCoeEnv::Static()->SwapSystemGc(iAppGc); |
|
278 |
|
279 delete iPtiEngine; |
|
280 |
|
281 iKeyEventSemaphore.Close(); |
|
282 iUiHandlerArray.Close(); |
|
283 // iSprite will be closed by iWsSession.Close() |
|
284 // but the sprite member bitmaps must be deleted |
|
285 // explicitly |
|
286 /* |
|
287 // iPrevUiLayout is not used any more |
|
288 if(iPrevUiLayout && iPrevUiLayout!=iUiLayout) |
|
289 { |
|
290 iPrevUiLayout->Destroy(); |
|
291 iPrevUiLayout = iUiLayout; |
|
292 } |
|
293 */ |
|
294 if(iUiLayout) |
|
295 { |
|
296 iUILayoutReady = EFalse; |
|
297 iDestroyingLayout = ETrue; |
|
298 iUiLayout->Destroy(); |
|
299 iUiLayout = NULL; |
|
300 } |
|
301 delete iBitmapDevice; |
|
302 delete iMaskBitmapDevice; |
|
303 delete iSpriteGc; |
|
304 delete iSpriteMember.iBitmap; |
|
305 delete iSpriteMember.iMaskBitmap; |
|
306 |
|
307 delete iWindowGc; |
|
308 delete iLayoutEng; |
|
309 |
|
310 delete iLayoutOwner; |
|
311 |
|
312 delete iEventBufferQueue; |
|
313 iKeyMsgResponseQueue.Close(); |
|
314 if(iFlushTimer) |
|
315 { |
|
316 iFlushTimer->Cancel(); |
|
317 delete iFlushTimer; |
|
318 } |
|
319 |
|
320 |
|
321 #ifdef RD_TACTILE_FEEDBACK |
|
322 //KS: QUICK FIX FOR EGSN-7BCBWS |
|
323 FeatureManager::UnInitializeLib(); |
|
324 //KS: QUICK FIX FOR EGSN-7BCBWS |
|
325 iFeedbackAreaArray.Close(); |
|
326 #endif // RD_TACTILE_FEEDBACK |
|
327 delete iPenUiCtrl; |
|
328 delete iInternalBackgroundCtrl; |
|
329 |
|
330 iClientProcess.Close(); |
|
331 iClientLayouts.Close(); |
|
332 #ifdef __LOG_WNDGROU__ |
|
333 iLogFile.Close(); |
|
334 #endif |
|
335 delete iAnimObj; |
|
336 iAnimObj = NULL; |
|
337 |
|
338 iNoNeedClean = ETrue; |
|
339 |
|
340 delete iCrpService; |
|
341 iCrpService = NULL; |
|
342 } |
|
343 // --------------------------------------------------------------------------- |
|
344 // CPeninputServer::~CPeninputServer |
|
345 // Destructor |
|
346 // --------------------------------------------------------------------------- |
|
347 // |
|
348 CPeninputServer::~CPeninputServer() |
|
349 { |
|
350 CleanAll(); |
|
351 #ifdef __WINS__ |
|
352 iCloseServer = ETrue; |
|
353 #endif |
|
354 delete iSensorRepository; |
|
355 } |
|
356 |
|
357 |
|
358 // --------------------------------------------------------------------------- |
|
359 // CPeninputServer::IncreaseSessionCount |
|
360 // --------------------------------------------------------------------------- |
|
361 // |
|
362 void CPeninputServer::IncreaseSessionCount() |
|
363 { |
|
364 ++iSessionCount; |
|
365 } |
|
366 |
|
367 // --------------------------------------------------------------------------- |
|
368 // CPeninputServer::DecreaseSessionCount |
|
369 // --------------------------------------------------------------------------- |
|
370 // |
|
371 void CPeninputServer::DecreaseSessionCount(CPeninputServerSession* aSession) |
|
372 { |
|
373 if( aSession == iForegroundSession) |
|
374 { |
|
375 iForegroundSession = NULL; |
|
376 Hide(); |
|
377 } |
|
378 else |
|
379 { |
|
380 if( aSession == iForegroundUiHandler ) |
|
381 { |
|
382 iForegroundUiHandler = NULL; |
|
383 } |
|
384 } |
|
385 |
|
386 //remove the session from list |
|
387 for(TInt i = 0; i < iUiHandlerArray.Count(); i++) |
|
388 { |
|
389 if( aSession == iUiHandlerArray[i] ) |
|
390 iUiHandlerArray.Remove(i); |
|
391 } |
|
392 |
|
393 --iSessionCount; |
|
394 |
|
395 #ifdef __WINS__ |
|
396 if ( iSessionCount == 0 && !iCloseServer) |
|
397 { |
|
398 DeactivateSprite(); |
|
399 PrepareExit(); |
|
400 CActiveScheduler::Stop(); |
|
401 } |
|
402 #endif |
|
403 } |
|
404 |
|
405 |
|
406 // --------------------------------------------------------------------------- |
|
407 // CPeninputServer::ActivateSpriteInGlobalNotesL() |
|
408 // Activate sprite |
|
409 // --------------------------------------------------------------------------- |
|
410 // |
|
411 void CPeninputServer::ActivateSpriteInGlobalNotesL() |
|
412 { |
|
413 if(iActive) |
|
414 { |
|
415 if(iUseWindowCtrl) |
|
416 { |
|
417 /* RWsSession &ws = CCoeEnv::Static()->WsSession(); |
|
418 TInt wgId =ws.GetFocusWindowGroup(); |
|
419 //TInt wgHandle = ws.GetWindowGroupHandle(wgId); |
|
420 |
|
421 |
|
422 TInt priority; |
|
423 //TInt pos; |
|
424 //wg.Construct(wgHandle); |
|
425 //pos = wg.FullOrdinalPosition(); |
|
426 priority = ws.GetWindowGroupOrdinalPriority(wgId);*/ |
|
427 //wg.Close(); |
|
428 //iPenUiCtrl->ShowPenUi(); |
|
429 ActivatePenUiLayout(EFalse); |
|
430 iDimmed = EFalse; |
|
431 iPenUiCtrl->ShowPenUiL(iDimmed); |
|
432 } |
|
433 return; |
|
434 } |
|
435 |
|
436 TBool bNeedWait = AnimOpNeedWaiting(ESignalPenUiActivated); |
|
437 //add animation command |
|
438 |
|
439 /* |
|
440 if(iAnimObj->AddActivationCmd(ECmdActivate,bNeedWait)) |
|
441 { |
|
442 if(bNeedWait) |
|
443 iForegroundUiHandler->AddDelayedCmd(); |
|
444 //iUiLayout->OnActivate(); |
|
445 ActivatePenUiLayout(); |
|
446 |
|
447 DrawSprite(); |
|
448 |
|
449 iEventBufferQueue->GetEvent(); |
|
450 |
|
451 iActive = ETrue; |
|
452 |
|
453 if(iUseWindowCtrl) |
|
454 iPenUiCtrl->ShowPenUi(); |
|
455 } |
|
456 */ |
|
457 if(ActivatePenUiLayout(bNeedWait)) |
|
458 { |
|
459 if(bNeedWait) |
|
460 iForegroundUiHandler->AddDelayedCmd(); |
|
461 |
|
462 DrawSprite(); |
|
463 |
|
464 iActive = ETrue; |
|
465 |
|
466 if(iUseWindowCtrl) |
|
467 { |
|
468 /*RWsSession &ws = CCoeEnv::Static()->WsSession(); |
|
469 TInt wgId =ws.GetFocusWindowGroup(); |
|
470 //TInt wgHandle = ws.GetWindowGroupHandle(wgId); |
|
471 |
|
472 |
|
473 TInt priority; |
|
474 //TInt pos; |
|
475 //wg.Construct(wgHandle); |
|
476 //pos = wg.FullOrdinalPosition(); |
|
477 priority = ws.GetWindowGroupOrdinalPriority(wgId);*/ |
|
478 //wg.Close(); |
|
479 iPenUiCtrl->ShowPenUiL(iDimmed); |
|
480 } |
|
481 } |
|
482 } |
|
483 // --------------------------------------------------------------------------- |
|
484 // CPeninputServer::ActivateSprite |
|
485 // Activate sprite |
|
486 // --------------------------------------------------------------------------- |
|
487 // |
|
488 void CPeninputServer::ActivateSprite(TInt aRequiredScrMode) |
|
489 { |
|
490 if(!iUiLayout) |
|
491 return; |
|
492 |
|
493 if(iCurScrMode != aRequiredScrMode) |
|
494 { |
|
495 iUiLayout->OnResourceChange(KEikDynamicLayoutVariantSwitch); |
|
496 iCurScrMode = aRequiredScrMode; |
|
497 } |
|
498 ActivateSprite(); |
|
499 } |
|
500 // --------------------------------------------------------------------------- |
|
501 // CPeninputServer::ActivateSprite |
|
502 // Activate sprite |
|
503 // --------------------------------------------------------------------------- |
|
504 // |
|
505 void CPeninputServer::ActivateSprite() |
|
506 { |
|
507 //do nothing if we don't have ui layout or already activated. |
|
508 TUid focusApp = GetFocusAppUid(); |
|
509 if(!IsGlobalNotesApp(focusApp)) |
|
510 iPreNonGloebalNotesWndGrpId = focusApp.iUid; |
|
511 |
|
512 if(!iUiLayout) |
|
513 return; |
|
514 |
|
515 // move it out from if(!iActive) to make sure that msg bubble can be |
|
516 // shown if fast swap from other application to msg application. |
|
517 TBool bNeedWait = AnimOpNeedWaiting(ESignalPenUiActivated); |
|
518 |
|
519 if(!iActive) |
|
520 { |
|
521 /* |
|
522 TInt scrMode = CCoeEnv::Static()->ScreenDevice()->CurrentScreenMode(); |
|
523 TBool bScrRotated = scrMode != iCurScrMode; |
|
524 |
|
525 if(bScrRotated) |
|
526 { |
|
527 iCurScrMode = scrMode; |
|
528 iUiLayout->OnResourceChange(KEikDynamicLayoutVariantSwitch); |
|
529 } |
|
530 */ |
|
531 //TBool bNeedWait = AnimOpNeedWaiting(ESignalPenUiActivated); |
|
532 //add animation command |
|
533 |
|
534 /* |
|
535 if(iAnimObj->AddActivationCmd(ECmdActivate,bNeedWait)) |
|
536 { |
|
537 if(bNeedWait) |
|
538 iForegroundUiHandler->AddDelayedCmd(); |
|
539 //iUiLayout->OnActivate(); |
|
540 ActivatePenUiLayout(); |
|
541 |
|
542 DrawSprite(); |
|
543 |
|
544 iEventBufferQueue->GetEvent(); |
|
545 |
|
546 iActive = ETrue; |
|
547 |
|
548 if(iUseWindowCtrl) |
|
549 iPenUiCtrl->ShowPenUi(); |
|
550 } |
|
551 */ |
|
552 |
|
553 if(ActivatePenUiLayout(bNeedWait, ETrue)) |
|
554 { |
|
555 if(bNeedWait) |
|
556 iForegroundUiHandler->AddDelayedCmd(); |
|
557 |
|
558 DrawSprite(); |
|
559 |
|
560 iActive = ETrue; |
|
561 |
|
562 if(iUseWindowCtrl) |
|
563 { |
|
564 TRAP_IGNORE( iPenUiCtrl->ShowPenUiL(iDimmed) ); |
|
565 |
|
566 if (iPreNonGloebalNotesWndGrpId != focusApp.iUid && |
|
567 IsGlobalNotesApp(focusApp) && !iInGlobalEditorState ) |
|
568 { |
|
569 iDimmed = ETrue; |
|
570 DimPenUi(); |
|
571 } |
|
572 } |
|
573 } |
|
574 } |
|
575 else |
|
576 { |
|
577 //actived but dimmed by global notes |
|
578 if(iUseWindowCtrl) |
|
579 { |
|
580 ActivatePenUiLayout(EFalse); |
|
581 |
|
582 if (iDimmed && (iInGlobalNotesApp || iInGlobalEditorState)) |
|
583 { |
|
584 DeactivatePenUiLayout(EFalse); |
|
585 return; |
|
586 } |
|
587 |
|
588 TRAP_IGNORE( iPenUiCtrl->ShowPenUiL(iDimmed) ); |
|
589 iDimmed = EFalse; |
|
590 } |
|
591 } |
|
592 } |
|
593 |
|
594 // --------------------------------------------------------------------------- |
|
595 // CPeninputServer::ActivatePenUiLayout |
|
596 // --------------------------------------------------------------------------- |
|
597 // |
|
598 TBool CPeninputServer::ActivatePenUiLayout(TBool aWaitFlag, TBool aSkipDraw) |
|
599 { |
|
600 RecoverSimulatedKeyEventState(); |
|
601 RecoverButtonEventState(); |
|
602 |
|
603 if (iAnimObj && iAnimObj->AddActivationCmd(ECmdActivate,aWaitFlag)) |
|
604 { |
|
605 if (iUiLayout) |
|
606 { |
|
607 iUiLayout->OnActivate(); |
|
608 if( !aSkipDraw ) |
|
609 iUiLayout->Draw(); |
|
610 } |
|
611 |
|
612 iEventBufferQueue->GetEvent(); |
|
613 |
|
614 if (iUseWindowCtrl) |
|
615 { |
|
616 CPenUiWndCtrl::EditorType type; |
|
617 |
|
618 if (iInGlobalEditorState) |
|
619 { |
|
620 type = CPenUiWndCtrl::EGlobleNotesWithEditor; |
|
621 } |
|
622 else |
|
623 { |
|
624 TUid focusApp = GetFocusAppUid(); |
|
625 if(IsGlobalNotesApp(focusApp)) |
|
626 { |
|
627 type = CPenUiWndCtrl::EGlobleNotes; |
|
628 } |
|
629 else |
|
630 { |
|
631 type = CPenUiWndCtrl::ENoremalEditor; |
|
632 } |
|
633 } |
|
634 |
|
635 iPenUiCtrl->OnActivate(type); |
|
636 //iPenUiCtrl->ShowPenUi(); |
|
637 } |
|
638 return ETrue; |
|
639 } |
|
640 return EFalse; |
|
641 } |
|
642 |
|
643 |
|
644 void CPeninputServer::DimPenUiWnd(TBool aFlag) |
|
645 { |
|
646 RecoverSimulatedKeyEventState(); |
|
647 if(aFlag) |
|
648 { |
|
649 iEventBufferQueue->Cancel(); |
|
650 iUiLayout->OnDeActivate(); |
|
651 if(iUseWindowCtrl) |
|
652 iPenUiCtrl->OnDeactivate(); //disable non fading |
|
653 } |
|
654 else |
|
655 { |
|
656 iEventBufferQueue->GetEvent(); |
|
657 iUiLayout->OnActivate(); |
|
658 if(iUseWindowCtrl) |
|
659 iPenUiCtrl->OnActivate(CPenUiWndCtrl::ENoremalEditor); //disable non fading |
|
660 } |
|
661 |
|
662 } |
|
663 // --------------------------------------------------------------------------- |
|
664 // CPeninputServer::DeactivatePenUiLayout |
|
665 // --------------------------------------------------------------------------- |
|
666 // |
|
667 TBool CPeninputServer::DeactivatePenUiLayout(TBool aWaitFlag) |
|
668 { |
|
669 //iEventBufferQueue->Cancel(); |
|
670 |
|
671 if (iAnimObj && iAnimObj->AddActivationCmd(ECmdDeactivate,aWaitFlag)) |
|
672 { |
|
673 if (iUiLayout) |
|
674 { |
|
675 RecoverSimulatedKeyEventState(); |
|
676 RecoverButtonEventState(); |
|
677 iUiLayout->OnDeActivate(); |
|
678 if(iUseWindowCtrl) |
|
679 iPenUiCtrl->OnDeactivate(); //disable non fading |
|
680 } |
|
681 |
|
682 return ETrue; |
|
683 } |
|
684 return EFalse; |
|
685 } |
|
686 |
|
687 // --------------------------------------------------------------------------- |
|
688 // CPeninputServer::DeactivatePenUiLayout |
|
689 // --------------------------------------------------------------------------- |
|
690 // |
|
691 TBool CPeninputServer::DeactivateDimPenUiLayout(TBool aWaitFlag) |
|
692 { |
|
693 //iEventBufferQueue->Cancel(); |
|
694 |
|
695 if (iAnimObj && iAnimObj->AddActivationCmd(ECmdDeactivate,aWaitFlag)) |
|
696 { |
|
697 if (iUiLayout) |
|
698 { |
|
699 RecoverSimulatedKeyEventState(); |
|
700 iUiLayout->OnDeActivate(); |
|
701 } |
|
702 |
|
703 return ETrue; |
|
704 } |
|
705 return EFalse; |
|
706 } |
|
707 |
|
708 // CPeninputServer::DeactivateSprite |
|
709 // --------------------------------------------------------------------------- |
|
710 // |
|
711 void CPeninputServer::DeactivateSprite(TBool aImmediateHideFlag, TBool aRotation) |
|
712 { |
|
713 if (!iActive || !iUiLayout) |
|
714 return; |
|
715 #ifdef __LOG_WNDGROU__ |
|
716 // TRAP_IGNORE( WriteDeactivateLogL(iLogFile) ) ; |
|
717 #endif |
|
718 |
|
719 aRotation = aRotation || iResourceChange; |
|
720 |
|
721 iActive = EFalse; |
|
722 if (!aRotation) |
|
723 { |
|
724 iDimmed = EFalse; |
|
725 iInGlobalNotesState = EFalse; |
|
726 } |
|
727 iFlushTimer->Cancel(); |
|
728 TBool bNeedWait = !aImmediateHideFlag && |
|
729 AnimOpNeedWaiting(ESignalPenUiDeActivated); |
|
730 |
|
731 |
|
732 if (DeactivatePenUiLayout(bNeedWait) && bNeedWait) |
|
733 iForegroundUiHandler->AddDelayedCmd(); |
|
734 |
|
735 if (iUseWindowCtrl) |
|
736 iPenUiCtrl->ClosePenUi(aRotation); |
|
737 |
|
738 //save current screen mode |
|
739 iCurScrMode = CCoeEnv::Static()->ScreenDevice()->CurrentScreenMode(); |
|
740 } |
|
741 |
|
742 // --------------------------------------------------------------------------- |
|
743 // CPeninputServer::HandleMessageL |
|
744 // Handle client message |
|
745 // --------------------------------------------------------------------------- |
|
746 // |
|
747 TInt CPeninputServer::HandleMessageL(const RMessage2& aMessage) |
|
748 { |
|
749 //It's traped in server session |
|
750 TInt err = KErrNone; |
|
751 if(!iPtiEngine || !iLayoutEng) |
|
752 DoIdleConstructL(); |
|
753 |
|
754 TBool isForeground = IsForegroundSession( |
|
755 static_cast<CPeninputServerSession*>(aMessage.Session())); |
|
756 //message requests UI attribute is always handled. |
|
757 switch(aMessage.Function()) |
|
758 { |
|
759 |
|
760 case EPeninputRequestUiIsVisible: |
|
761 { |
|
762 TPckg<TBool> msg(iActive); |
|
763 |
|
764 aMessage.WriteL(0,msg); |
|
765 } |
|
766 |
|
767 break; |
|
768 case EPeninputRequestUiGetUiPos: |
|
769 { |
|
770 TPckgC<TPoint> msg(iSpritePosition); |
|
771 TPckgC<TSize> msgSize(iSpriteSize); |
|
772 |
|
773 aMessage.WriteL(0,msg); |
|
774 aMessage.WriteL(1,msgSize); |
|
775 } |
|
776 break; |
|
777 |
|
778 case EPenInputRequestGetPenSupportLanguages: |
|
779 GetPenSupportLanguagesL(aMessage); |
|
780 break; |
|
781 case EPenInputRequestGetImePluginIdList: |
|
782 GetImePluginIdListL(aMessage); |
|
783 break; |
|
784 case EPeninputRequestRelinquishForeground: |
|
785 { |
|
786 if(isForeground) |
|
787 iForegroundSession = NULL; |
|
788 } |
|
789 break; |
|
790 case EPeninputRequestSetForeground: |
|
791 { |
|
792 TInt msgGroupId; |
|
793 TPckg<TInt> msgIdData(msgGroupId); |
|
794 aMessage.ReadL(KMsgSlot0,msgIdData); |
|
795 |
|
796 //TInt curFocusId = GetFocusAppUid().iUid; |
|
797 TBool mustOpenFlag; |
|
798 TPckg<TBool> msgFlagData(mustOpenFlag); |
|
799 aMessage.ReadL(KMsgSlot1,msgFlagData); |
|
800 |
|
801 //ignore the command if it's from another focused group. |
|
802 /*******************************************************************/ |
|
803 //This is a fix to web browse case. When swithing to web, device changeded |
|
804 // to landscape mode automatically, but previous app with pen UI, e.g. |
|
805 // Notepad, will gain the foregound, thus open the UI. |
|
806 /*******************************************************************/ |
|
807 if(!mustOpenFlag && msgGroupId != iCurScreenFocusedWndGrpId) //screen has changed, but foreground is wrong. |
|
808 { |
|
809 //only check this if it's not openned by pen click |
|
810 err = KErrNotWrongFocusedWindowGroup; |
|
811 //iForegroundSession = NULL; |
|
812 } |
|
813 else |
|
814 { |
|
815 CPeninputServerSession* session = |
|
816 static_cast<CPeninputServerSession*>(aMessage.Session()); |
|
817 /*if(!IsSameProcess(iForegroundSession, session)) |
|
818 { |
|
819 // |
|
820 }*/ |
|
821 iForegroundSession = session; |
|
822 |
|
823 //check whether there is ui notification handler from the same process |
|
824 if(iUiHandlerArray.Count()) |
|
825 SetForeGroundUiHandlerL(); |
|
826 } |
|
827 |
|
828 TPckgC<TBool> msg(iForegroundSession != NULL); |
|
829 aMessage.WriteL(KMsgSlot2,msg); |
|
830 } |
|
831 break; |
|
832 |
|
833 case EPeninputRequestIsForeground: |
|
834 { |
|
835 TPckgC<TBool> msg(isForeground); |
|
836 aMessage.WriteL(0,msg); |
|
837 } |
|
838 break; |
|
839 |
|
840 case EPeninputRequestIsLayoutDimmed: |
|
841 { |
|
842 TPckgC<TBool> msg(iDimmed); |
|
843 aMessage.WriteL(0,msg); |
|
844 } |
|
845 break; |
|
846 |
|
847 //other message is only handled when the request session is foreground session. |
|
848 |
|
849 case EPeninputRequestUiSetUiPos: |
|
850 if(isForeground) |
|
851 { |
|
852 TPoint pt; |
|
853 TPckg<TPoint> msg(pt); |
|
854 aMessage.ReadL(KMsgSlot0,msg); |
|
855 |
|
856 SetPosition(pt); |
|
857 } |
|
858 else |
|
859 { |
|
860 err = KErrNotForegroundSession; |
|
861 } |
|
862 break; |
|
863 case EPeninputServerRequestSetDisplayMode: |
|
864 if(isForeground) |
|
865 { |
|
866 TDisplayMode mode; |
|
867 TDisplayMode maskMode; |
|
868 TPckg<TDisplayMode> data1(mode); |
|
869 TPckg<TDisplayMode> data2(maskMode); |
|
870 |
|
871 aMessage.ReadL(KMsgSlot0,data1); |
|
872 aMessage.ReadL(KMsgSlot1,data2); |
|
873 |
|
874 ChangeDisplayModeL(mode,maskMode); |
|
875 } |
|
876 else |
|
877 { |
|
878 err = KErrNotForegroundSession; |
|
879 } |
|
880 |
|
881 break; |
|
882 case EPeninputRequestActivateLayout: |
|
883 if(isForeground) |
|
884 { |
|
885 iInGlobalEditorState = EFalse; |
|
886 TBool bFlag ; |
|
887 |
|
888 TPckg<TBool> msg(bFlag ); |
|
889 aMessage.ReadL(KMsgSlot0,msg); |
|
890 if(bFlag) |
|
891 { |
|
892 TInt requiredMode; |
|
893 TPckg<TInt> scrMsg(requiredMode); |
|
894 aMessage.ReadL(KMsgSlot1,scrMsg); |
|
895 |
|
896 ActivateSprite(requiredMode); |
|
897 static_cast<CPeninputServerSession*>( |
|
898 aMessage.Session())->DoUpdateAppInfo(); |
|
899 } |
|
900 else |
|
901 { |
|
902 DeactivateSprite(); |
|
903 } |
|
904 } |
|
905 else |
|
906 { |
|
907 err = KErrNotForegroundSession; |
|
908 } |
|
909 break; |
|
910 case EPeninputRequestActivateLayoutInGlobalNotes: |
|
911 //if(isForeground) |
|
912 { |
|
913 iCurGlobalNotesId = GetFocusAppUid().iUid; |
|
914 iInGlobalEditorState = ETrue; |
|
915 ActivateSpriteInGlobalNotesL(); |
|
916 } |
|
917 /*else |
|
918 { |
|
919 err = KErrNotForegroundSession; |
|
920 }*/ |
|
921 break; |
|
922 |
|
923 case EPeninputRequestInternalDimLayout: |
|
924 { |
|
925 if(iUseWindowCtrl && iActive) |
|
926 { |
|
927 TBool dim; |
|
928 TPckg<TBool> msg(dim); |
|
929 aMessage.ReadL(KMsgSlot0,msg); |
|
930 TInt priority; |
|
931 TPckg<TInt> priorityMsg(priority); |
|
932 aMessage.ReadL(KMsgSlot1,priorityMsg); |
|
933 |
|
934 TInt bmpHandle = iSpriteMember.iBitmap->Handle(); |
|
935 TPckg<TInt> handleMsg(bmpHandle); |
|
936 aMessage.WriteL(KMsgSlot2,handleMsg); |
|
937 |
|
938 TRect pos = iPenUiCtrl->Rect(); |
|
939 pos.Move(iPenUiCtrl->Position()); |
|
940 TPckg<TRect> extMsg(pos); |
|
941 aMessage.WriteL(KMsgSlot3,extMsg); |
|
942 iDimmed = dim; |
|
943 DimPenInternalUi(iDimmed,priority); |
|
944 } |
|
945 } |
|
946 break; |
|
947 case EPeninputRequestDimLayout: |
|
948 if(iUseWindowCtrl && iActive) |
|
949 { |
|
950 TBool dim; |
|
951 TPckg<TBool> msg(dim); |
|
952 aMessage.ReadL(KMsgSlot0,msg); |
|
953 TInt priority; |
|
954 TPckg<TInt> priorityMsg(priority); |
|
955 aMessage.ReadL(KMsgSlot1,priorityMsg); |
|
956 |
|
957 |
|
958 TInt bmpHandle = iSpriteMember.iBitmap->Handle(); |
|
959 TPckg<TInt> handleMsg(bmpHandle); |
|
960 aMessage.WriteL(KMsgSlot2,handleMsg); |
|
961 |
|
962 TRect pos = iPenUiCtrl->Rect(); |
|
963 pos.Move(iPenUiCtrl->Position()); |
|
964 TPckg<TRect> extMsg(pos); |
|
965 aMessage.WriteL(KMsgSlot3,extMsg); |
|
966 if(dim != iDimmed) |
|
967 { |
|
968 iDimmed = dim; |
|
969 DimPenUi(); |
|
970 /*if(iDimmed) |
|
971 //DeactivatePenUiLayout(EFalse); |
|
972 DeactivateSprite(); |
|
973 else |
|
974 ActivatePenUiLayout(EFalse); |
|
975 */ |
|
976 } |
|
977 } |
|
978 break; |
|
979 case EPeninputRequestSetUiLayoutId: |
|
980 case EPeninputRequestSetUiLayoutIdWithData: |
|
981 if(isForeground || iDimmed) |
|
982 { |
|
983 err = CreateLayoutL(aMessage); |
|
984 } |
|
985 else |
|
986 { |
|
987 err = KErrNotForegroundSession; |
|
988 } |
|
989 |
|
990 break; |
|
991 case EPeninputRequestResourceChanged: |
|
992 if(isForeground) |
|
993 { |
|
994 if(!iUiLayout) |
|
995 return KErrNoLayout; |
|
996 |
|
997 if(iPrevActive) |
|
998 { |
|
999 ActivateSprite(); |
|
1000 iPrevActive = EFalse; |
|
1001 } |
|
1002 } |
|
1003 else |
|
1004 { |
|
1005 err = KErrNotForegroundSession; |
|
1006 } |
|
1007 |
|
1008 break; |
|
1009 case EPeninputRequestAddUiObserver: |
|
1010 { |
|
1011 TInt type ; |
|
1012 |
|
1013 TPckg<TInt> msg(type); |
|
1014 aMessage.ReadL(KMsgSlot0,msg); |
|
1015 static_cast<CPeninputServerSession*>(aMessage.Session())-> |
|
1016 RegisterPenUiType(type); |
|
1017 |
|
1018 iUiHandlerArray.Append(static_cast<CPeninputServerSession*>(aMessage.Session())); |
|
1019 if(iForegroundSession) |
|
1020 SetForeGroundUiHandlerL(); |
|
1021 } |
|
1022 break; |
|
1023 |
|
1024 case EPeninputRequestRemoveUiObserver: |
|
1025 { |
|
1026 CPeninputServerSession* s =static_cast<CPeninputServerSession*> |
|
1027 (aMessage.Session()); |
|
1028 if( s == iForegroundUiHandler) |
|
1029 { |
|
1030 s->ProcessPendingEventBeforeExit(); |
|
1031 iForegroundUiHandler = NULL; |
|
1032 } |
|
1033 |
|
1034 for(TInt i = 0; i < iUiHandlerArray.Count();i++) |
|
1035 { |
|
1036 if(s == iUiHandlerArray[i]) |
|
1037 { |
|
1038 iUiHandlerArray.Remove(i); |
|
1039 break; |
|
1040 } |
|
1041 } |
|
1042 } |
|
1043 break; |
|
1044 /*case EPeninputRequestGetDisableLayout: |
|
1045 { |
|
1046 TInt layoyts = 0; |
|
1047 CPeninputServerSession* pSession = static_cast<CPeninputServerSession*>(aMessage.Session()); |
|
1048 GetProcessLayouts( pSession->ClientProcessId(), layoyts ); |
|
1049 |
|
1050 TPckg<TInt> msg(layoyts); |
|
1051 |
|
1052 aMessage.WriteL(0,msg); |
|
1053 } |
|
1054 break; |
|
1055 case EPeninputRequestDisableLayout: |
|
1056 { |
|
1057 TInt layouts = aMessage.Int0(); |
|
1058 CPeninputServerSession* pSession = static_cast<CPeninputServerSession*>(aMessage.Session()); |
|
1059 SetProcessLayouts( pSession->ClientProcessId(), layouts ); |
|
1060 } |
|
1061 break;*/ |
|
1062 case EPeninputRequestServerThreadId: |
|
1063 { |
|
1064 RThread thread; |
|
1065 TThreadId id = thread.Id(); |
|
1066 TPckg<TThreadId> msg(id); |
|
1067 |
|
1068 aMessage.WriteL(0,msg); |
|
1069 thread.Close(); |
|
1070 } |
|
1071 break; |
|
1072 case EPeninputBackgroudDefaultOri: |
|
1073 { |
|
1074 TInt flag = 0; |
|
1075 TPckg<TInt> msg(flag); |
|
1076 |
|
1077 aMessage.ReadL(0,msg); |
|
1078 BackgroudDefaultOri( flag ); |
|
1079 } |
|
1080 break; |
|
1081 case EPeninputRequestDimResChangeLayout: |
|
1082 { |
|
1083 TInt flag = 0; |
|
1084 TPckg<TInt> msg(flag); |
|
1085 |
|
1086 aMessage.ReadL(0,msg); |
|
1087 |
|
1088 iResourceChange = flag; |
|
1089 |
|
1090 if(iUseWindowCtrl) |
|
1091 iPenUiCtrl->SetResourceChange(iResourceChange); |
|
1092 } |
|
1093 break; |
|
1094 case EPeninputRequestSupportInputMode: |
|
1095 { |
|
1096 TInt supportMode = GetSupportModeL(); |
|
1097 |
|
1098 TPckg<TInt> msg(supportMode); |
|
1099 |
|
1100 aMessage.WriteL(0,msg); |
|
1101 } |
|
1102 break; |
|
1103 |
|
1104 case EPeninputRequestSetInputLanguage: |
|
1105 { |
|
1106 TPckg<TInt> msg(iInputLanguage); |
|
1107 aMessage.ReadL(0,msg); |
|
1108 if(iUiLayout) |
|
1109 { |
|
1110 iUiLayout->HandleCommand(ECmdPenInputLanguage, |
|
1111 (unsigned char*)&iInputLanguage); |
|
1112 } |
|
1113 } |
|
1114 break; |
|
1115 default: //Let user pluging handling the user command |
|
1116 break; |
|
1117 } |
|
1118 return err; |
|
1119 } |
|
1120 // --------------------------------------------------------------------------- |
|
1121 // CPeninputServer::HandleCommandL |
|
1122 // Handle client command |
|
1123 // --------------------------------------------------------------------------- |
|
1124 // |
|
1125 TInt CPeninputServer::HandleCommandL(const RMessage2& aMessage) |
|
1126 { |
|
1127 //let UI layout handles the command |
|
1128 TInt err = KErrNone; |
|
1129 |
|
1130 //command is only handled when the request session is foreground session. |
|
1131 /*CPeninputServerSession* s = |
|
1132 static_cast<CPeninputServerSession*>(aMessage.Session()); |
|
1133 if( iForegroundSession == static_cast<CPeninputServerSession*>( |
|
1134 aMessage.Session()) )*/ |
|
1135 if(IsForegroundSession(static_cast<CPeninputServerSession*>(aMessage.Session()))) |
|
1136 { |
|
1137 //get cmd id |
|
1138 TInt cmdId; |
|
1139 TPckg<TInt> cmdMsg(cmdId); |
|
1140 aMessage.ReadL(KMsgSlot0,cmdMsg); |
|
1141 |
|
1142 TInt len = aMessage.GetDesLength(KMsgSlot1); |
|
1143 HBufC8* dataBuf = HBufC8::NewLC(len); |
|
1144 TPtr8 msgData = dataBuf->Des(); |
|
1145 aMessage.ReadL(KMsgSlot1,msgData); |
|
1146 |
|
1147 if(iUiLayout) |
|
1148 { |
|
1149 err = iUiLayout->HandleCommand(cmdId,(unsigned char*)msgData.Ptr()); |
|
1150 TPckg<TInt> msg(err); |
|
1151 aMessage.WriteL(KMsgSlot2,msg); |
|
1152 } |
|
1153 |
|
1154 CleanupStack::PopAndDestroy(dataBuf); |
|
1155 } |
|
1156 else |
|
1157 { |
|
1158 err = KErrNotForegroundSession; |
|
1159 } |
|
1160 return err; |
|
1161 |
|
1162 } |
|
1163 |
|
1164 TInt CPeninputServer::CreateLayoutL(const RMessage2& aMessage ) |
|
1165 { |
|
1166 //check initialization status |
|
1167 //if(!iAppGc) |
|
1168 // iAppGc = CCoeEnv::Static()->SwapSystemGc(iWindowGc); |
|
1169 |
|
1170 TInt id; |
|
1171 TPckg<TInt> msg(id); |
|
1172 aMessage.Read(KMsgSlot0,msg); |
|
1173 TUid uid; |
|
1174 uid.iUid = id; |
|
1175 |
|
1176 |
|
1177 if(iLayoutId == uid && iUiLayout) |
|
1178 return KErrNone; |
|
1179 |
|
1180 iLayoutId = uid; |
|
1181 |
|
1182 //clear sprite before delete ui layout |
|
1183 iUILayoutReady = EFalse; |
|
1184 if(iUiLayout) |
|
1185 { |
|
1186 ClearSpriteGc(); |
|
1187 DeactivateSprite(); |
|
1188 iDestroyingLayout = ETrue; |
|
1189 iUiLayout->Destroy(); |
|
1190 iUiLayout = NULL; |
|
1191 iDestroyingLayout = EFalse; |
|
1192 if(iAnimObj) |
|
1193 { |
|
1194 iAnimObj->AddFlushSessionCmd(); |
|
1195 } |
|
1196 #ifdef RD_TACTILE_FEEDBACK |
|
1197 //remove all registered feedback area |
|
1198 const TInt KRemoveAllId = -1; |
|
1199 TTactileFeedbackArea area = {KRemoveAllId,TRect(0,0,0,0)}; |
|
1200 RemoveFeedbackArea(area); |
|
1201 #endif |
|
1202 } |
|
1203 if(aMessage.Function() == EPeninputRequestSetUiLayoutId) |
|
1204 { |
|
1205 TPeninputLayoutData layoutData = |
|
1206 { |
|
1207 iPtiEngine, |
|
1208 //iPenUiCtrl |
|
1209 iInternalBackgroundCtrl, |
|
1210 }; |
|
1211 //iUiLayout = iLayoutEng->GetUiLayout(iLayoutId,iLayoutOwner,iPtiEngine); |
|
1212 iUiLayout = iLayoutEng->GetUiLayout(iLayoutId,iLayoutOwner,&layoutData); |
|
1213 } |
|
1214 else |
|
1215 { |
|
1216 TInt len = aMessage.GetDesLength(KMsgSlot1); |
|
1217 HBufC8* dataBuf = HBufC8::NewLC(len); |
|
1218 TPtr8 msgData = dataBuf->Des(); |
|
1219 aMessage.ReadL(KMsgSlot1,msgData); |
|
1220 |
|
1221 iUiLayout=iLayoutEng->GetUiLayout(iLayoutId,iLayoutOwner,msgData.Ptr()); |
|
1222 CleanupStack::PopAndDestroy(dataBuf); |
|
1223 } |
|
1224 |
|
1225 if(!iUiLayout) |
|
1226 return KErrNoLayout; |
|
1227 |
|
1228 iSpriteMember.iInvertMask = EFalse; |
|
1229 TRect layoutRect; |
|
1230 //do we need transparency? |
|
1231 TBool bTransparency = iUiLayout->SemiTransparencyRequired(); |
|
1232 if(bTransparency) |
|
1233 { |
|
1234 #ifdef __ALPHA_TRANCEPARENCY__ |
|
1235 ChangeDisplayModeL(iDispMode,EGray256); |
|
1236 #else |
|
1237 ChangeDisplayModeL(iDispMode,EColor16MU); |
|
1238 #endif |
|
1239 } |
|
1240 else |
|
1241 { |
|
1242 ChangeDisplayModeL(iDispMode,EGray2); //use black-white mask |
|
1243 } |
|
1244 |
|
1245 layoutRect = iUiLayout->Init(); |
|
1246 |
|
1247 if( layoutRect.IsEmpty() ) |
|
1248 {//this is a temp solution for VKB, the layout size can not |
|
1249 //be determined at construct time |
|
1250 TPixelsTwipsAndRotation ptSize; |
|
1251 CCoeEnv::Static()->ScreenDevice()->GetDefaultScreenSizeAndRotation( ptSize ); |
|
1252 layoutRect = TRect( TPoint(), ptSize.iPixelSize ); |
|
1253 } |
|
1254 iUILayoutReady = ETrue; |
|
1255 // register feedback area |
|
1256 /*if(iSupportFeedback && iFeedbackAreaArray.Count()) |
|
1257 { |
|
1258 iAnimObj->AddRegisterFeedbackAreaCmd(iFeedbackAreaArray); |
|
1259 iFeedbackAreaArray.Reset(); }*/ |
|
1260 |
|
1261 //flush the command |
|
1262 if(iAnimObj) |
|
1263 { |
|
1264 iAnimObj->AddFlushSessionCmd(); |
|
1265 } |
|
1266 |
|
1267 TSize layoutSize = layoutRect.Size(); |
|
1268 |
|
1269 iSpriteSize = layoutSize; |
|
1270 /* iBitmapDevice->Resize( layoutSize); |
|
1271 iMaskBitmapDevice->Resize( layoutSize); |
|
1272 |
|
1273 //gc must be adjusted |
|
1274 iSpriteGc->Activate(iBitmapDevice); |
|
1275 iSpriteGc->Resized(); |
|
1276 */ |
|
1277 ResizeDrawingDevice(layoutSize); |
|
1278 if(iAnimObj) |
|
1279 { |
|
1280 iAnimObj->AddChangeSizeCmd(layoutSize); |
|
1281 } |
|
1282 |
|
1283 SetPosition(layoutRect.iTl); |
|
1284 if(iUiLayout->PenInputType() == EPluginInputModeItut || |
|
1285 iUiLayout->PenInputType() == EPluginInputModeFSQ || |
|
1286 iUiLayout->PenInputType() == EPluginInputModeFingerHwr ) |
|
1287 { |
|
1288 iOpaqueUi = ETrue; |
|
1289 iUseWindowCtrl = ETrue; |
|
1290 |
|
1291 if(iUseWindowCtrl) |
|
1292 { |
|
1293 iPenUiCtrl->SetExtent(layoutRect.iTl,layoutSize); |
|
1294 if(iAnimObj) |
|
1295 { |
|
1296 iAnimObj->AddEnalbeSpriteCmd(EFalse); |
|
1297 } |
|
1298 //must swap back when using window background |
|
1299 if(iAppGc) |
|
1300 { |
|
1301 CCoeEnv::Static()->SwapSystemGc(iAppGc); |
|
1302 } |
|
1303 } |
|
1304 else |
|
1305 { |
|
1306 if(iAnimObj) |
|
1307 { |
|
1308 iAnimObj->AddEnalbeSpriteCmd(ETrue); |
|
1309 } |
|
1310 |
|
1311 iAppGc = CCoeEnv::Static()->SwapSystemGc(iWindowGc); |
|
1312 |
|
1313 } |
|
1314 } |
|
1315 else |
|
1316 { |
|
1317 iOpaqueUi = EFalse; |
|
1318 if(iUseWindowCtrl && iAnimObj) //previous window control used |
|
1319 { |
|
1320 iUseWindowCtrl = EFalse; |
|
1321 iAnimObj->AddEnalbeSpriteCmd(ETrue); |
|
1322 } |
|
1323 } |
|
1324 |
|
1325 TInt type = iUiLayout->PenInputType(); |
|
1326 TPckg<TBool> typeMsg(type); |
|
1327 |
|
1328 aMessage.WriteL(KMsgSlot2,typeMsg); |
|
1329 |
|
1330 return KErrNone; |
|
1331 } |
|
1332 |
|
1333 // --------------------------------------------------------------------------- |
|
1334 // CPeninputServer::SignalObserverL |
|
1335 // Signal oberver |
|
1336 // --------------------------------------------------------------------------- |
|
1337 // |
|
1338 void CPeninputServer::SignalObserverL(TInt aEventId,const TDesC& aEventData) |
|
1339 { |
|
1340 if(iForegroundSession) |
|
1341 iForegroundSession->SignalClientL(aEventId,aEventData); |
|
1342 } |
|
1343 |
|
1344 // --------------------------------------------------------------------------- |
|
1345 // CPeninputServer::NewSessionL |
|
1346 // --------------------------------------------------------------------------- |
|
1347 // |
|
1348 CSession2* CPeninputServer::NewSessionL(const TVersion& aVersion, |
|
1349 const RMessage2& aMessage) const |
|
1350 { |
|
1351 // check we're the right version |
|
1352 TVersion v( KPeninputServerMajorVersionNumber, |
|
1353 KPeninputServerMinorVersionNumber, |
|
1354 KPeninputServerBuildVersionNumber ); |
|
1355 |
|
1356 if ( !User::QueryVersionSupported(v,aVersion) ) |
|
1357 { |
|
1358 User::Leave( KErrNotSupported ); |
|
1359 } |
|
1360 |
|
1361 // create new session |
|
1362 RThread client; |
|
1363 CleanupClosePushL(client); |
|
1364 CSession2* ret = 0; |
|
1365 |
|
1366 if(KErrNone == aMessage.Client(client)) |
|
1367 { |
|
1368 //create new one |
|
1369 ret = CPeninputServerSession::NewL(client, |
|
1370 const_cast<CPeninputServer&>(*this));\ |
|
1371 } |
|
1372 CleanupStack::PopAndDestroy(&client); |
|
1373 return ret; |
|
1374 } |
|
1375 |
|
1376 |
|
1377 // --------------------------------------------------------------------------- |
|
1378 // CPeninputServer::RunError |
|
1379 // Handle an error from CPeninputServerSession::ServiceL() |
|
1380 // Reports the error to the client and completes the message |
|
1381 // --------------------------------------------------------------------------- |
|
1382 // |
|
1383 TInt CPeninputServer::RunError( TInt aError ) |
|
1384 { |
|
1385 Message().Complete( aError ); |
|
1386 |
|
1387 // The leave will result in an early return from CServer::RunL(), skipping |
|
1388 // the call to request another message. So do that now in order to keep the |
|
1389 // server running. |
|
1390 ReStart(); |
|
1391 return KErrNone;// handled the error fully |
|
1392 } |
|
1393 |
|
1394 |
|
1395 // --------------------------------------------------------------------------- |
|
1396 // CPeninputServer::ConstructSpriteAnimL |
|
1397 // --------------------------------------------------------------------------- |
|
1398 // |
|
1399 void CPeninputServer::ConstructSpriteL() |
|
1400 { |
|
1401 // create bitmaps for sprite |
|
1402 iSpriteMember.iBitmap = CreateBitmapL( iSpriteSize, iDispMode ); |
|
1403 #ifdef __ALPHA_TRANCEPARENCY__ |
|
1404 iSpriteMember.iMaskBitmap = CreateBitmapL( iSpriteSize, EGray256); |
|
1405 iDispModeForMask = EGray256; |
|
1406 |
|
1407 #else |
|
1408 iSpriteMember.iMaskBitmap = CreateBitmapL( iSpriteSize, iDispModeForMask); |
|
1409 iSpriteMember.iInvertMask = EFalse; |
|
1410 #endif |
|
1411 |
|
1412 // set spritemember attributes |
|
1413 iSpriteMember.iOffset.iX = 0; |
|
1414 iSpriteMember.iOffset.iY = 0; |
|
1415 iSpriteMember.iInterval = 0; |
|
1416 |
|
1417 iBitmapDevice = CFbsBitmapDevice::NewL(iSpriteMember.iBitmap); |
|
1418 iMaskBitmapDevice = CFbsBitmapDevice::NewL( |
|
1419 iSpriteMember.iMaskBitmap ); |
|
1420 iSpriteGc = CFbsBitGc::NewL(); |
|
1421 iSpriteGc->Reset(); |
|
1422 |
|
1423 CWsScreenDevice *screenDevice = CCoeEnv::Static()->ScreenDevice(); |
|
1424 iWindowGc = CWindowToBitmapMappingGc::NewL(*screenDevice,*iSpriteGc); |
|
1425 |
|
1426 /*iBitmapDevice->Resize( iSpriteSize); |
|
1427 iMaskBitmapDevice->Resize( iSpriteSize); */ |
|
1428 ResizeDrawingDevice(iSpriteSize); |
|
1429 } |
|
1430 |
|
1431 |
|
1432 // --------------------------------------------------------------------------- |
|
1433 // CPeninputServer::CreateBitmapL |
|
1434 // --------------------------------------------------------------------------- |
|
1435 // |
|
1436 CFbsBitmap* CPeninputServer::CreateBitmapL( const TSize& aBitmapSize, |
|
1437 TDisplayMode aDisplayMode ) const |
|
1438 { |
|
1439 CFbsBitmap* const bitmap = new ( ELeave ) CFbsBitmap; |
|
1440 CleanupStack::PushL( bitmap ); |
|
1441 // bitmaps are automatically cleared to white when first created |
|
1442 User::LeaveIfError( bitmap->Create( aBitmapSize, aDisplayMode ) ); |
|
1443 CleanupStack::Pop(bitmap); |
|
1444 return bitmap; |
|
1445 } |
|
1446 |
|
1447 // --------------------------------------------------------------------------- |
|
1448 // CPeninputServer::ChangeDisplayMode |
|
1449 // --------------------------------------------------------------------------- |
|
1450 // |
|
1451 void CPeninputServer::ChangeDisplayModeL(TDisplayMode aMode, |
|
1452 TDisplayMode aMaskMode) |
|
1453 { |
|
1454 if(aMode == iDispMode && aMaskMode == iDispModeForMask) |
|
1455 return; |
|
1456 |
|
1457 if(iDispMode != aMode) |
|
1458 { |
|
1459 //use initial size to create small one in the first |
|
1460 CFbsBitmap* bmp = CreateBitmapL( iSpriteSize, aMode ); |
|
1461 delete iSpriteMember.iBitmap; |
|
1462 iSpriteMember.iBitmap = bmp; |
|
1463 iDispMode = aMode; |
|
1464 delete iBitmapDevice; |
|
1465 iBitmapDevice = NULL; |
|
1466 iBitmapDevice = CFbsBitmapDevice::NewL(iSpriteMember.iBitmap); |
|
1467 } |
|
1468 |
|
1469 if(iDispModeForMask != aMaskMode) |
|
1470 { |
|
1471 CFbsBitmap* maskbmp = CreateBitmapL( iSpriteSize, aMaskMode); |
|
1472 delete iSpriteMember.iMaskBitmap; |
|
1473 iSpriteMember.iMaskBitmap = maskbmp; |
|
1474 delete iMaskBitmapDevice; |
|
1475 iMaskBitmapDevice = NULL; |
|
1476 iMaskBitmapDevice = CFbsBitmapDevice::NewL( |
|
1477 iSpriteMember.iMaskBitmap ); |
|
1478 iDispModeForMask = aMaskMode; |
|
1479 } |
|
1480 if(iAnimObj) |
|
1481 { |
|
1482 iAnimObj->AddChangeDispModeCmd(iSpriteMember); |
|
1483 } |
|
1484 } |
|
1485 // --------------------------------------------------------------------------- |
|
1486 // CPeninputServer::ClearSpriteGc |
|
1487 // Clears the bitmap - and mask bitmap devices. |
|
1488 // --------------------------------------------------------------------------- |
|
1489 // |
|
1490 void CPeninputServer::ClearSpriteGc() |
|
1491 { |
|
1492 //bitmap device |
|
1493 TPoint pt(0,0); |
|
1494 TRect rect(pt,iSpriteSize); |
|
1495 iSpriteGc->Activate( iBitmapDevice ); |
|
1496 iSpriteGc->SetBrushStyle( CGraphicsContext::ESolidBrush ); |
|
1497 iSpriteGc->SetBrushColor( KRgbWhite ); |
|
1498 iSpriteGc->Clear(rect); |
|
1499 |
|
1500 //mask bitmap device |
|
1501 iSpriteGc->Activate( iMaskBitmapDevice ); |
|
1502 iSpriteGc->SetBrushColor( KRgbBlack ); //transparent |
|
1503 iSpriteGc->SetBrushStyle( CGraphicsContext::ESolidBrush ); |
|
1504 iSpriteGc->Clear(rect); |
|
1505 } |
|
1506 |
|
1507 |
|
1508 // --------------------------------------------------------------------------- |
|
1509 // CPeninputServer::DrawSprite |
|
1510 // Draw the sprite |
|
1511 // --------------------------------------------------------------------------- |
|
1512 // |
|
1513 void CPeninputServer::DrawSprite() |
|
1514 { |
|
1515 |
|
1516 if(!iUiLayout) |
|
1517 return; |
|
1518 ClearSpriteGc(); |
|
1519 |
|
1520 iUiLayout->Draw(); |
|
1521 |
|
1522 TRect r(TPoint(0,0),iSpriteSize); |
|
1523 |
|
1524 if(iUseWindowCtrl) |
|
1525 { |
|
1526 iPenUiCtrl->Invalidate(r,EFullUpdate); |
|
1527 return; |
|
1528 } |
|
1529 else |
|
1530 { |
|
1531 if(iAnimObj) |
|
1532 { |
|
1533 iAnimObj->AddUpdateUiCmd(r,EFullUpdate); |
|
1534 } |
|
1535 |
|
1536 //The best place for the timer should also in animation object. Can be refactored |
|
1537 //later |
|
1538 if(!iFlushTimer->IsActive()) |
|
1539 { |
|
1540 iFlushTimer->Start(KWsSessionFlushPerioid, KWsSessionFlushPerioid, |
|
1541 TCallBack(FlushTimerCallBack,this)); |
|
1542 } |
|
1543 iCurRectNumInBuf = 0; |
|
1544 } |
|
1545 return; |
|
1546 } |
|
1547 |
|
1548 //MLayoutOwner |
|
1549 // --------------------------------------------------------------------------- |
|
1550 // CPeninputServer::UpdateArea |
|
1551 // Update sprite rect |
|
1552 // --------------------------------------------------------------------------- |
|
1553 // |
|
1554 void CPeninputServer::UpdateArea(const TRect& aRect,TBool /*aFullUpdate*/, |
|
1555 TBool aImmedFlag) |
|
1556 { |
|
1557 if (!iActive) //only update when sprite is active |
|
1558 return; |
|
1559 |
|
1560 if(iUseWindowCtrl) |
|
1561 { |
|
1562 iPenUiCtrl->Invalidate(aRect,EFalse); |
|
1563 return; |
|
1564 } |
|
1565 |
|
1566 TRect rect; |
|
1567 if(aRect.IsEmpty()) |
|
1568 { |
|
1569 iSpriteGc->RectDrawnTo(rect); |
|
1570 } |
|
1571 else |
|
1572 rect = aRect; |
|
1573 |
|
1574 // if (iOpaqueUi) |
|
1575 // aFullUpdate = EFalse; //never does full update to screen. |
|
1576 |
|
1577 TUpdateArea area = |
|
1578 { |
|
1579 aRect,EFalse |
|
1580 }; |
|
1581 AddFlushArea(area); |
|
1582 if(aImmedFlag) |
|
1583 { |
|
1584 FlushTimerCallBack(this); |
|
1585 } |
|
1586 else |
|
1587 { |
|
1588 if(!iFlushTimer->IsActive()) |
|
1589 { |
|
1590 iFlushTimer->Start(KWsSessionFlushPerioid, KWsSessionFlushPerioid, |
|
1591 TCallBack(FlushTimerCallBack,this)); |
|
1592 } |
|
1593 } |
|
1594 } |
|
1595 |
|
1596 //from MLayuoutOwner |
|
1597 |
|
1598 // --------------------------------------------------------------------------- |
|
1599 // CPeninputServer::BitmapContext |
|
1600 // Get bitmap context |
|
1601 // --------------------------------------------------------------------------- |
|
1602 // |
|
1603 CBitmapContext* CPeninputServer::BitmapContext() |
|
1604 { |
|
1605 return iSpriteGc; |
|
1606 } |
|
1607 |
|
1608 // --------------------------------------------------------------------------- |
|
1609 // CPeninputServer::BitmapDevice |
|
1610 // Get bitmap device |
|
1611 // --------------------------------------------------------------------------- |
|
1612 // |
|
1613 CFbsBitmapDevice* CPeninputServer::BitmapDevice() |
|
1614 { |
|
1615 return iBitmapDevice; |
|
1616 } |
|
1617 |
|
1618 // --------------------------------------------------------------------------- |
|
1619 // CPeninputServer::MaskBmpDevice |
|
1620 // Get mask bitmap device |
|
1621 // --------------------------------------------------------------------------- |
|
1622 // |
|
1623 CFbsBitmapDevice* CPeninputServer::MaskBmpDevice() |
|
1624 { |
|
1625 return iMaskBitmapDevice; |
|
1626 } |
|
1627 |
|
1628 // --------------------------------------------------------------------------- |
|
1629 // CPeninputServer::Hide |
|
1630 // Hide/show sprite |
|
1631 // --------------------------------------------------------------------------- |
|
1632 // |
|
1633 void CPeninputServer::Hide(TBool aHideFlag) |
|
1634 { |
|
1635 if(aHideFlag) |
|
1636 { |
|
1637 DeactivateSprite(); |
|
1638 } |
|
1639 else |
|
1640 { |
|
1641 ActivateSprite(); |
|
1642 } |
|
1643 } |
|
1644 |
|
1645 // --------------------------------------------------------------------------- |
|
1646 // CPeninputServer::LayoutSizeChanged |
|
1647 // Handle layout size change |
|
1648 // --------------------------------------------------------------------------- |
|
1649 // |
|
1650 TInt CPeninputServer::LayoutSizeChanged(const TSize& aSize, TBool aNeedUpdate) |
|
1651 { |
|
1652 TInt ret = KErrNone; |
|
1653 if(iUiLayout) |
|
1654 { |
|
1655 //This is the tricky place. We need to deactivate and activate the sprite, |
|
1656 //otherwise blank area appears. |
|
1657 |
|
1658 TSize layoutSize = aSize; |
|
1659 TRect layoutRect = iUiLayout->Init(); |
|
1660 layoutSize = layoutRect.Size(); |
|
1661 |
|
1662 layoutSize.iWidth = layoutSize.iWidth > aSize.iWidth ? |
|
1663 layoutSize.iWidth : aSize.iWidth; |
|
1664 |
|
1665 layoutSize.iHeight = layoutSize.iHeight > aSize.iHeight ? |
|
1666 layoutSize.iHeight : aSize.iHeight; |
|
1667 |
|
1668 if(iSpriteSize != layoutSize) |
|
1669 { |
|
1670 //deactive sprite first |
|
1671 TBool bRestoreActive = iActive; |
|
1672 //DeactivateSprite(); |
|
1673 iSpriteSize = layoutSize; |
|
1674 //iBitmapDevice->Resize( layoutSize); |
|
1675 //iMaskBitmapDevice->Resize( layoutSize); |
|
1676 ResizeDrawingDevice(layoutSize); |
|
1677 if (aNeedUpdate) |
|
1678 { |
|
1679 FlushWsSession(); |
|
1680 } |
|
1681 if(iAnimObj) |
|
1682 { |
|
1683 iAnimObj->AddChangeSizeCmd(layoutSize); |
|
1684 } |
|
1685 |
|
1686 if(bRestoreActive ) |
|
1687 { |
|
1688 //ActivateSprite(); |
|
1689 } |
|
1690 } |
|
1691 |
|
1692 if (iUseWindowCtrl) |
|
1693 { |
|
1694 iPenUiCtrl->SetExtent(LayoutRect().iTl,layoutSize); |
|
1695 //DrawSprite(); |
|
1696 } |
|
1697 } |
|
1698 return ret; |
|
1699 } |
|
1700 |
|
1701 void CPeninputServer::DimPenUi() |
|
1702 { |
|
1703 if(iDimmed) |
|
1704 { |
|
1705 RecoverButtonEventState(); |
|
1706 DeactivateDimPenUiLayout(EFalse); |
|
1707 if(iUseWindowCtrl) |
|
1708 { |
|
1709 iPenUiCtrl->DimPenUiForMenu(); |
|
1710 } |
|
1711 } |
|
1712 else |
|
1713 { |
|
1714 ActivatePenUiLayout(EFalse); |
|
1715 } |
|
1716 } |
|
1717 |
|
1718 void CPeninputServer::DimPenInternalUi(TBool /*aFlag*/,TInt aPriority) |
|
1719 { |
|
1720 if(iDimmed) |
|
1721 { |
|
1722 RecoverButtonEventState(); |
|
1723 DeactivateDimPenUiLayout(EFalse); |
|
1724 |
|
1725 if(iUseWindowCtrl) |
|
1726 { |
|
1727 iPenUiCtrl->DimInternalPenUiForMenu(aPriority); |
|
1728 |
|
1729 } |
|
1730 } |
|
1731 else |
|
1732 { |
|
1733 ActivatePenUiLayout(EFalse); |
|
1734 } |
|
1735 } |
|
1736 |
|
1737 void CPeninputServer::DimPenUiForMenu(TInt aPriority) |
|
1738 { |
|
1739 if(iUseWindowCtrl) |
|
1740 { |
|
1741 iPenUiCtrl->DimPenUiForMenu(aPriority); |
|
1742 } |
|
1743 } |
|
1744 // --------------------------------------------------------------------------- |
|
1745 // CPeninputServer::SignalOwner |
|
1746 // Signal owner |
|
1747 // --------------------------------------------------------------------------- |
|
1748 // |
|
1749 void CPeninputServer::SignalOwner(TInt aEventType, const TDesC& aEventData) |
|
1750 { |
|
1751 //send fep related event to observer ( application) |
|
1752 if(ESignalFepEventBase <= aEventType) |
|
1753 { |
|
1754 TRAP_IGNORE(SignalObserverL(aEventType,aEventData)); |
|
1755 } |
|
1756 else |
|
1757 { |
|
1758 switch(aEventType) |
|
1759 { |
|
1760 case ESignalCapturePointer: //request capture pointer |
|
1761 { |
|
1762 TUint16* buf = const_cast<TUint16* >( aEventData.Ptr() ); |
|
1763 TBool flag = *(TBool*)aEventData.Ptr(); |
|
1764 TInt captureID = *(TInt* )( buf + sizeof(TUint16)); |
|
1765 if(iAnimObj) |
|
1766 { |
|
1767 iAnimObj->AddCapturePointerCmd(flag, captureID); |
|
1768 } |
|
1769 } |
|
1770 break; |
|
1771 |
|
1772 case ESignalSimulateEvent: //request simulate event |
|
1773 { |
|
1774 //TBool* flag = (TBool*)aEventData.Ptr(); |
|
1775 const TRawEvent* event = reinterpret_cast<const TRawEvent*>(aEventData.Ptr()); |
|
1776 TRawEvent* modifyEvent = const_cast<TRawEvent*>( event ); |
|
1777 modifyEvent->SetTip( ETrue ); |
|
1778 if(iAnimObj) |
|
1779 { |
|
1780 iAnimObj->AddSimulateEventCmd(*event); |
|
1781 } |
|
1782 if( event->Type() == TRawEvent::EKeyDown ) |
|
1783 { |
|
1784 static_cast<CAknAppUi*>(CEikonEnv::Static()->EikAppUi())-> |
|
1785 DisableNextKeySound( event->ScanCode() ); |
|
1786 } |
|
1787 iLastSimulatedKeyEvent = *event; |
|
1788 } |
|
1789 break; |
|
1790 case ESignalImmeSimulateEvent: |
|
1791 { |
|
1792 const TRawEvent* event = reinterpret_cast<const TRawEvent*>( aEventData.Ptr() ); |
|
1793 TRawEvent* modifyEvent = const_cast<TRawEvent*>( event ); |
|
1794 modifyEvent->SetTip( ETrue ); |
|
1795 if(iAnimObj) |
|
1796 { |
|
1797 iAnimObj->ExecuteSimulateEventCmd(*event); |
|
1798 } |
|
1799 |
|
1800 if( event->Type() == TRawEvent::EKeyDown ) |
|
1801 { |
|
1802 static_cast<CAknAppUi*>(CEikonEnv::Static()->EikAppUi())-> |
|
1803 DisableNextKeySound( event->ScanCode() ); |
|
1804 } |
|
1805 iLastSimulatedKeyEvent = *event; |
|
1806 } |
|
1807 break; |
|
1808 #ifdef RD_TACTILE_FEEDBACK |
|
1809 case ESignalRegisterFeedbackArea: |
|
1810 { |
|
1811 if(!iSupportFeedback) |
|
1812 return; |
|
1813 AddFeedbackArea(FeedbackData(aEventData)); |
|
1814 } |
|
1815 break; |
|
1816 case ESignalDeRegisterFeedbackArea: |
|
1817 { |
|
1818 if(!iSupportFeedback) |
|
1819 return; |
|
1820 |
|
1821 RemoveFeedbackArea(FeedbackData(aEventData)); |
|
1822 } |
|
1823 break; |
|
1824 case ESignalChangeFeedbackArea: |
|
1825 { |
|
1826 if(!iSupportFeedback) |
|
1827 return; |
|
1828 |
|
1829 ChangeFeedbackArea(FeedbackData(aEventData)); |
|
1830 } |
|
1831 break; |
|
1832 case ESignalChangeFeedbackType: |
|
1833 { |
|
1834 if(!iSupportFeedback) |
|
1835 return; |
|
1836 |
|
1837 ChangeFeedbackType(FeedbackData(aEventData)); |
|
1838 } |
|
1839 break; |
|
1840 |
|
1841 #endif // RD_TACTILE_FEEDBACK |
|
1842 case ESignalGetAllowedInputMode: |
|
1843 { |
|
1844 TInt disabled = 0; |
|
1845 if ( iForegroundSession ) |
|
1846 { |
|
1847 //GetProcessLayouts( iForegroundSession->ClientProcessId(),disabled ); |
|
1848 disabled = iForegroundSession->DisabledUiType() | DisabledByOrientation(); |
|
1849 |
|
1850 if( iForegroundSession->DsaEverHappened() ) |
|
1851 { |
|
1852 disabled |= DisabledByDSAFromAnim(); |
|
1853 } |
|
1854 } |
|
1855 TInt allowed = SetDisabledLayouts( disabled ); |
|
1856 TUint16* buf = const_cast<TUint16* >( aEventData.Ptr() ); |
|
1857 TInt* retVal = reinterpret_cast< TInt* > ( buf ); |
|
1858 *retVal = allowed; |
|
1859 } |
|
1860 break; |
|
1861 |
|
1862 case ESignalPopupWnd: |
|
1863 { |
|
1864 if(iUseWindowCtrl) |
|
1865 { |
|
1866 TUint16* buf = const_cast<TUint16*>( aEventData.Ptr() ); |
|
1867 TRect* rects = reinterpret_cast<TRect*>( buf ); |
|
1868 TRect rectInLayout = *rects; |
|
1869 TRect rectTrimLayout = *(rects+1); |
|
1870 TRect rectInScreen = rectInLayout; |
|
1871 rectInScreen.Move( iSpritePosition ); |
|
1872 |
|
1873 iPenUiCtrl->ShowPopup( rectInScreen, rectInLayout, rectTrimLayout ); |
|
1874 } |
|
1875 } |
|
1876 break; |
|
1877 |
|
1878 case ESignalPopupWndClosed: |
|
1879 { |
|
1880 if(iUseWindowCtrl) |
|
1881 { |
|
1882 iPenUiCtrl->ClosePopup(); |
|
1883 } |
|
1884 } |
|
1885 break; |
|
1886 default: |
|
1887 break; |
|
1888 } |
|
1889 } |
|
1890 |
|
1891 } |
|
1892 |
|
1893 // --------------------------------------------------------------------------- |
|
1894 // CPeninputServer::LayoutRect |
|
1895 // Get sprite size and position |
|
1896 // --------------------------------------------------------------------------- |
|
1897 // |
|
1898 TRect CPeninputServer::LayoutRect() |
|
1899 { |
|
1900 return TRect(iSpritePosition,iSpriteSize); |
|
1901 } |
|
1902 |
|
1903 // --------------------------------------------------------------------------- |
|
1904 // CPeninputServer::SetPosition |
|
1905 // called when sprite has been moved |
|
1906 // --------------------------------------------------------------------------- |
|
1907 // |
|
1908 |
|
1909 TPoint CPeninputServer::SetPosition(const TPoint& aNewPos) |
|
1910 { |
|
1911 if(iSpritePosition != aNewPos) |
|
1912 { |
|
1913 iSpritePosition = aNewPos; |
|
1914 |
|
1915 if(iUseWindowCtrl) |
|
1916 iPenUiCtrl->SetPosition(aNewPos); |
|
1917 |
|
1918 if(iAnimObj) |
|
1919 { |
|
1920 iAnimObj->AddSetPosCmd(iSpritePosition); |
|
1921 } |
|
1922 } |
|
1923 return iSpritePosition; |
|
1924 } |
|
1925 |
|
1926 // --------------------------------------------------------------------------- |
|
1927 // CPeninputServer::FlushTimerCallBack |
|
1928 // CPeriodic callback function: Flush window session |
|
1929 // --------------------------------------------------------------------------- |
|
1930 // |
|
1931 TInt CPeninputServer::FlushTimerCallBack(TAny *aPtr) |
|
1932 { |
|
1933 CPeninputServer* self = static_cast<CPeninputServer*>(aPtr); |
|
1934 |
|
1935 self->FlushWsSession(); |
|
1936 |
|
1937 return EFalse; |
|
1938 } |
|
1939 |
|
1940 // --------------------------------------------------------------------------- |
|
1941 // CPeninputServer::FlushWsSession |
|
1942 // Flush window session |
|
1943 // --------------------------------------------------------------------------- |
|
1944 // |
|
1945 void CPeninputServer::FlushWsSession() |
|
1946 { |
|
1947 if (iCurRectNumInBuf) |
|
1948 { |
|
1949 if(iAnimObj) |
|
1950 { |
|
1951 iAnimObj->AddUpdateUiCmd(iFlushArea,iCurRectNumInBuf); |
|
1952 } |
|
1953 |
|
1954 iCurRectNumInBuf = 0; |
|
1955 { |
|
1956 iFullUpdate = EFalse; |
|
1957 //cancel the timer |
|
1958 iFlushTimer->Cancel(); |
|
1959 } |
|
1960 } |
|
1961 } |
|
1962 |
|
1963 // --------------------------------------------------------------------------- |
|
1964 // CPeninputServer::DoIdleConstructL |
|
1965 // Do idle construction. |
|
1966 // --------------------------------------------------------------------------- |
|
1967 // |
|
1968 void CPeninputServer::DoIdleConstructL() |
|
1969 { |
|
1970 if(!iPtiEngine) |
|
1971 { |
|
1972 iPtiEngine = CPtiEngine::NewL(ETrue); |
|
1973 } |
|
1974 |
|
1975 if(!iLayoutEng) |
|
1976 { |
|
1977 iLayoutEng = CFepLayoutEngine::NewL(iPtiEngine); |
|
1978 } |
|
1979 |
|
1980 //this will only do once |
|
1981 } |
|
1982 |
|
1983 // --------------------------------------------------------------------------- |
|
1984 // CPeninputServer::HandleResourceChange |
|
1985 // Handle application resource change |
|
1986 // --------------------------------------------------------------------------- |
|
1987 // |
|
1988 void CPeninputServer::HandleResourceChange(TInt aType) |
|
1989 { |
|
1990 if(iUiLayout && !(iUiLayout->PenInputType() & DisabledByOrientation()) ) |
|
1991 { |
|
1992 //hide the layout if it's already shown |
|
1993 |
|
1994 iUiLayout->OnResourceChange(aType); |
|
1995 //show the layout if it's active |
|
1996 } |
|
1997 } |
|
1998 |
|
1999 // --------------------------------------------------------------------------- |
|
2000 // CPeninputServer::GetImePluginIdListL |
|
2001 // Get IME plugin implementation id list |
|
2002 // --------------------------------------------------------------------------- |
|
2003 // |
|
2004 void CPeninputServer::GetImePluginIdListL(const RMessage2& aMessage) |
|
2005 { |
|
2006 TInt language = aMessage.Int0(); |
|
2007 TInt mode = aMessage.Int1(); |
|
2008 TInt maxlen = aMessage.Int2(); |
|
2009 |
|
2010 const RArray<TInt>& implList = iLayoutEng->ImePluginListL(language, mode); |
|
2011 // +1 means there is extra position for count |
|
2012 TInt count = implList.Count() > (maxlen/sizeof(TInt) - 1)? |
|
2013 (maxlen/sizeof(TInt) - 1): implList.Count(); |
|
2014 |
|
2015 HBufC8* buf = HBufC8::NewLC((count + 1)*sizeof(TInt)); |
|
2016 TPtr8 bufPtr = buf->Des(); |
|
2017 RDesWriteStream writeStream; |
|
2018 writeStream.Open(bufPtr); |
|
2019 CleanupClosePushL(writeStream); |
|
2020 writeStream.WriteInt32L(count); |
|
2021 for(TInt ii = 0; ii < count; ++ii) |
|
2022 { |
|
2023 writeStream.WriteInt32L(implList[ii]); |
|
2024 } |
|
2025 writeStream.CommitL(); |
|
2026 |
|
2027 aMessage.WriteL(KMsgSlot3, *buf); |
|
2028 |
|
2029 CleanupStack::PopAndDestroy(&writeStream); |
|
2030 CleanupStack::PopAndDestroy(buf); |
|
2031 } |
|
2032 |
|
2033 // --------------------------------------------------------------------------- |
|
2034 // CPeninputServer::GetPenSupportLanguagesL |
|
2035 // Get touch input support language lists |
|
2036 // --------------------------------------------------------------------------- |
|
2037 // |
|
2038 void CPeninputServer::GetPenSupportLanguagesL(const RMessage2& aMessage) |
|
2039 { |
|
2040 TInt maxlen = aMessage.Int0(); |
|
2041 |
|
2042 const RArray<TInt>& implList = iLayoutEng->TouchSupportLanguagesL(); |
|
2043 // +1 means there is extra position for count |
|
2044 TInt count = implList.Count() > (maxlen/sizeof(TInt) - 1)? |
|
2045 (maxlen/sizeof(TInt) - 1): implList.Count(); |
|
2046 |
|
2047 HBufC8* buf = HBufC8::NewLC((count + 1)*sizeof(TInt)); |
|
2048 TPtr8 bufPtr = buf->Des(); |
|
2049 RDesWriteStream writeStream; |
|
2050 writeStream.Open(bufPtr); |
|
2051 CleanupClosePushL(writeStream); |
|
2052 writeStream.WriteInt32L(count); |
|
2053 for(TInt ii = 0; ii < count; ++ii) |
|
2054 { |
|
2055 writeStream.WriteInt32L(implList[ii]); |
|
2056 } |
|
2057 |
|
2058 writeStream.CommitL(); |
|
2059 aMessage.WriteL(KMsgSlot1, *buf); |
|
2060 CleanupStack::PopAndDestroy(&writeStream); |
|
2061 CleanupStack::PopAndDestroy(buf); |
|
2062 } |
|
2063 |
|
2064 // --------------------------------------------------------------------------- |
|
2065 // CPeninputServer::PropertyChangeCallBack |
|
2066 // Handle proproty change |
|
2067 // --------------------------------------------------------------------------- |
|
2068 // |
|
2069 TInt CPeninputServer::PropertyChangeCallBack(TAny* aData) |
|
2070 { |
|
2071 TRAP_IGNORE(static_cast<CPeninputServer*>(aData)->HideLayoutTemporaryL()); |
|
2072 return 0; |
|
2073 } |
|
2074 |
|
2075 // --------------------------------------------------------------------------- |
|
2076 // CPeninputServer::HideLayoutTemporary |
|
2077 // Temporarily hide the layout |
|
2078 // --------------------------------------------------------------------------- |
|
2079 // |
|
2080 void CPeninputServer::HideLayoutTemporaryL() |
|
2081 { |
|
2082 /* if (iUseWindowCtrl) |
|
2083 { |
|
2084 if (iActive && iUiLayout && |
|
2085 iUiLayout->PenInputType() == EPluginInputModeItut) |
|
2086 { |
|
2087 iUiLayout->HandleCommand(ECmdPenInputRotation, NULL); |
|
2088 ClearSpriteGc(); |
|
2089 iPenUiCtrl->ClosePenUi(ETrue); |
|
2090 iActive = EFalse; |
|
2091 } |
|
2092 return; |
|
2093 } |
|
2094 */ if(iActive && !iPrevActive && |
|
2095 iUiLayout->PenInputType() != EPluginInputModeFSQ && |
|
2096 iBackgroudDefaultOri == CAknAppUiBase::EAppUiOrientationUnspecified ) |
|
2097 { |
|
2098 |
|
2099 iPrevActive = ETrue; |
|
2100 ClearSpriteGc(); |
|
2101 //Close the UI immediately, without notify UI handler |
|
2102 DeactivateSprite(ETrue, ETrue); |
|
2103 } |
|
2104 } |
|
2105 |
|
2106 // --------------------------------------------------------------------------- |
|
2107 // CPeninputServer::SetDisabledLayouts |
|
2108 // Temporarily hide the layout |
|
2109 // --------------------------------------------------------------------------- |
|
2110 // |
|
2111 TInt CPeninputServer::SetDisabledLayouts( TInt aDisabledLayouts ) |
|
2112 { |
|
2113 // No spcified logic now, so just store the disabled layout in the CFepUiLayoutBase class. |
|
2114 TInt allowedPlugin = EPluginInputModeNone;// EPluginInputModeHwr | EPluginInputModeVkb | EPluginInputModeItut | EPluginInputModeFSc; |
|
2115 TInt curLanguage = iInputLanguage; |
|
2116 |
|
2117 if (curLanguage == 401) curLanguage = 102; |
|
2118 if (curLanguage == 402) curLanguage = 103; |
|
2119 |
|
2120 |
|
2121 TInt testMode = EPluginInputModeHwr; |
|
2122 while ( testMode < EPluginInputModeAll ) |
|
2123 { |
|
2124 if ( iLayoutEng->IsSupportPluginMode( ( TLanguage )curLanguage, |
|
2125 ( TPluginInputMode )testMode ) |
|
2126 && !( aDisabledLayouts & testMode ) ) |
|
2127 { |
|
2128 allowedPlugin |= testMode; |
|
2129 } |
|
2130 testMode<<=1; |
|
2131 } |
|
2132 return allowedPlugin; |
|
2133 } |
|
2134 |
|
2135 // --------------------------------------------------------------------------- |
|
2136 // CPeninputServer::GetProcessLayouts |
|
2137 // --------------------------------------------------------------------------- |
|
2138 // |
|
2139 TInt CPeninputServer::GetProcessLayouts( const TProcessId& aProcessId, TInt& aLayouts ) |
|
2140 { |
|
2141 for ( int i = 0 ; i < iClientProcess.Count() ; i ++ ) |
|
2142 { |
|
2143 if ( aProcessId == iClientProcess[i] ) |
|
2144 { |
|
2145 aLayouts = iClientLayouts[i]; |
|
2146 return KErrNone; |
|
2147 } |
|
2148 } |
|
2149 return KErrNotFound; |
|
2150 } |
|
2151 |
|
2152 |
|
2153 // --------------------------------------------------------------------------- |
|
2154 // CPeninputServer::SetProcessLayouts |
|
2155 // --------------------------------------------------------------------------- |
|
2156 // |
|
2157 TInt CPeninputServer::SetProcessLayouts( const TProcessId& aProcessId, TInt aLayouts) |
|
2158 { |
|
2159 |
|
2160 for ( int i = 0 ; i < iClientProcess.Count() ; i ++ ) |
|
2161 { |
|
2162 if ( aProcessId == iClientProcess[i] ) |
|
2163 { |
|
2164 iClientLayouts[i] = aLayouts; |
|
2165 return KErrNone; |
|
2166 } |
|
2167 } |
|
2168 // not found, Insert |
|
2169 iClientProcess.Append( aProcessId ); |
|
2170 iClientLayouts.Append( aLayouts ); |
|
2171 return KErrNone; |
|
2172 } |
|
2173 |
|
2174 // --------------------------------------------------------------------------- |
|
2175 // CPeninputServer::DelProcessLayouts |
|
2176 // --------------------------------------------------------------------------- |
|
2177 // |
|
2178 void CPeninputServer::DelProcessLayouts( const TProcessId& /*aProcessId*/ ) |
|
2179 { |
|
2180 } |
|
2181 |
|
2182 void CPeninputServer::ExecutePendingAnimCmd() |
|
2183 { |
|
2184 if( iAnimObj ) |
|
2185 { |
|
2186 iAnimObj->ExeOnePendingAnimCmd(); |
|
2187 } |
|
2188 } |
|
2189 |
|
2190 void CPeninputServer::SetForeGroundUiHandlerL() |
|
2191 { |
|
2192 if(iForegroundUiHandler) |
|
2193 { |
|
2194 iForegroundUiHandler->ProcessPendingEventBeforeExit(); |
|
2195 iForegroundUiHandler = NULL; |
|
2196 } |
|
2197 |
|
2198 TBool bContinue = ETrue; |
|
2199 for(TInt i = iUiHandlerArray.Count()-1 ; i >= 0 && bContinue; i--) |
|
2200 { |
|
2201 if( (iForegroundSession == iUiHandlerArray[i]) // same session |
|
2202 || (iForegroundSession->ClientId() == iUiHandlerArray[i]->ClientId())) //same thread |
|
2203 { |
|
2204 iForegroundUiHandler = iUiHandlerArray[i]; |
|
2205 bContinue = EFalse; //found, break the loop |
|
2206 } |
|
2207 else |
|
2208 { |
|
2209 //check whether it's from same process |
|
2210 bContinue = !IsSameProcess(iForegroundSession,iUiHandlerArray[i]); |
|
2211 } |
|
2212 } |
|
2213 } |
|
2214 |
|
2215 |
|
2216 // --------------------------------------------------------------------------- |
|
2217 // CPeninputServer::HandleRawEventL |
|
2218 // Handle event from event queue, i.e, from animation dll |
|
2219 // --------------------------------------------------------------------------- |
|
2220 // |
|
2221 void CPeninputServer::HandleRawEventL(const TRawEvent& aEvent) |
|
2222 { |
|
2223 if(iActive) |
|
2224 { |
|
2225 if( aEvent.Type() == TRawEvent::ENone && |
|
2226 aEvent.IsTip() && |
|
2227 iCrpService->IsDsaActive() ) |
|
2228 { |
|
2229 SignalOwner( ESignalLayoutClosed, KNullDesC ); |
|
2230 } |
|
2231 |
|
2232 TBool handled = iUiLayout->HandleEventL(ERawEvent,&aEvent); |
|
2233 |
|
2234 if (TRawEvent::EButton1Down == aEvent.Type()) |
|
2235 { |
|
2236 iLastRawEvent = aEvent; |
|
2237 } |
|
2238 else if (TRawEvent::EPointerMove != aEvent.Type()) |
|
2239 { |
|
2240 iLastRawEvent.Set(TRawEvent::EButton1Up); |
|
2241 } |
|
2242 |
|
2243 if(aEvent.Type() == TRawEvent::EKeyDown || |
|
2244 aEvent.Type() == TRawEvent::EKeyUp) |
|
2245 { |
|
2246 //write response to response queue |
|
2247 iKeyMsgResponseQueue.Send(handled); |
|
2248 //signal the semaphore |
|
2249 iKeyEventSemaphore.Signal(); |
|
2250 |
|
2251 } |
|
2252 } |
|
2253 } |
|
2254 |
|
2255 |
|
2256 // --------------------------------------------------------------------------- |
|
2257 // CPeninputServer::HandleRawEventL |
|
2258 // Handle event from window server |
|
2259 // --------------------------------------------------------------------------- |
|
2260 // |
|
2261 void CPeninputServer::HandleWsEventL(const TWsEvent &aEvent, |
|
2262 CCoeControl* /*aDestination*/) |
|
2263 { |
|
2264 switch(aEvent.Type()) |
|
2265 { |
|
2266 case EEventWindowGroupListChanged: |
|
2267 { |
|
2268 iCurScreenFocusedWndGrpId = GetFocusAppUid().iUid; |
|
2269 } |
|
2270 break; |
|
2271 case EEventFocusGroupChanged: |
|
2272 { |
|
2273 TUid focusApp = GetFocusAppUid(); |
|
2274 if(IsGlobalNotesApp(focusApp)) |
|
2275 { |
|
2276 iInGlobalNotesApp = ETrue; |
|
2277 } |
|
2278 else |
|
2279 { |
|
2280 iInGlobalNotesApp = EFalse; |
|
2281 } |
|
2282 if(!(iUiLayout && iActive )) |
|
2283 return; |
|
2284 |
|
2285 if(iUseWindowCtrl) |
|
2286 { |
|
2287 /* //Switch to akncapserver or leave |
|
2288 if(iUiLayout->PenInputType() == EPluginInputModeItut || |
|
2289 iUiLayout->PenInputType() == EPluginInputModeFSQ ) |
|
2290 { |
|
2291 DeactivatePenUiLayout(EFalse); |
|
2292 iPenUiCtrl->DimPenUiForMenu(); |
|
2293 break; |
|
2294 } |
|
2295 */ |
|
2296 if(IsGlobalNotesApp(focusApp)) |
|
2297 { |
|
2298 iInGlobalNotesState = ETrue; |
|
2299 break; |
|
2300 } |
|
2301 |
|
2302 /* else if (focusApp.iUid == 0x102750f0) |
|
2303 { |
|
2304 DeactivateSprite(); |
|
2305 } |
|
2306 */ else |
|
2307 { |
|
2308 if(iInGlobalNotesState) |
|
2309 { |
|
2310 //fix for fast swap case |
|
2311 iInGlobalNotesState = EFalse; |
|
2312 if(iPreNonGloebalNotesWndGrpId != focusApp.iUid) |
|
2313 { |
|
2314 iPreNonGloebalNotesWndGrpId = focusApp.iUid; |
|
2315 |
|
2316 DeactivateSprite(ETrue);//hide pen ui immediately if switched to another application |
|
2317 iForegroundSession = NULL; |
|
2318 } |
|
2319 } |
|
2320 else |
|
2321 { |
|
2322 DeactivateSprite(ETrue); |
|
2323 } |
|
2324 } |
|
2325 break; |
|
2326 } |
|
2327 DeactivateSprite(ETrue);//hide pen ui immediately |
|
2328 } |
|
2329 break; |
|
2330 default: |
|
2331 break; |
|
2332 } |
|
2333 |
|
2334 } |
|
2335 |
|
2336 #ifdef RD_TACTILE_FEEDBACK |
|
2337 // --------------------------------------------------------------------------- |
|
2338 // CPeninputServer::AddFeedbackArea |
|
2339 // add the feedback area |
|
2340 // --------------------------------------------------------------------------- |
|
2341 // |
|
2342 void CPeninputServer::AddFeedbackArea(const TTactileFeedbackArea& aAreaData) |
|
2343 { |
|
2344 if( iDestroyingLayout || !iAnimObj ) |
|
2345 { |
|
2346 return; |
|
2347 } |
|
2348 iAnimObj->AddRegisterFeedbackAreaCmd(aAreaData,iUILayoutReady); |
|
2349 } |
|
2350 |
|
2351 // --------------------------------------------------------------------------- |
|
2352 // CPeninputServer::RemoveFeedbackArea |
|
2353 // remove the feedback area |
|
2354 // --------------------------------------------------------------------------- |
|
2355 // |
|
2356 void CPeninputServer::RemoveFeedbackArea(const TTactileFeedbackArea& aAreaData) |
|
2357 { |
|
2358 if( iDestroyingLayout || !iAnimObj ) |
|
2359 { |
|
2360 return; |
|
2361 } |
|
2362 iAnimObj->AddDeRegisterFeedbackAreaCmd(aAreaData,iUILayoutReady); |
|
2363 } |
|
2364 |
|
2365 // --------------------------------------------------------------------------- |
|
2366 // CPeninputServer::ChangeFeedbackArea |
|
2367 // change the feedback area |
|
2368 // --------------------------------------------------------------------------- |
|
2369 // |
|
2370 void CPeninputServer::ChangeFeedbackArea(const TTactileFeedbackArea& aAreaData) |
|
2371 { |
|
2372 if( iDestroyingLayout || !iAnimObj ) |
|
2373 { |
|
2374 return; |
|
2375 } |
|
2376 iAnimObj->AddChangeFeedbackAreaCmd(aAreaData,iUILayoutReady); |
|
2377 } |
|
2378 |
|
2379 // --------------------------------------------------------------------------- |
|
2380 // CPeninputServer::ChangeFeedbackType |
|
2381 // change the feedback type |
|
2382 // --------------------------------------------------------------------------- |
|
2383 // |
|
2384 void CPeninputServer::ChangeFeedbackType(const TTactileFeedbackArea& aAreaData) |
|
2385 { |
|
2386 if( iDestroyingLayout || !iAnimObj) |
|
2387 { |
|
2388 return; |
|
2389 } |
|
2390 iAnimObj->AddChangeFeedbackTypeCmd(aAreaData,iUILayoutReady); |
|
2391 } |
|
2392 |
|
2393 // --------------------------------------------------------------------------- |
|
2394 // CPeninputServer::FindFeedbackArea |
|
2395 // Find the feedback area |
|
2396 // --------------------------------------------------------------------------- |
|
2397 // |
|
2398 TInt CPeninputServer::FindFeedbackArea(const TTactileFeedbackArea& aArea) |
|
2399 { |
|
2400 for(TInt i = 0; i < iFeedbackAreaArray.Count(); ++i) |
|
2401 { |
|
2402 TTactileFeedbackArea temp = iFeedbackAreaArray[i]; |
|
2403 if(iFeedbackAreaArray[i].iId == aArea.iId) |
|
2404 return i; |
|
2405 } |
|
2406 return KErrNotFound; |
|
2407 } |
|
2408 |
|
2409 #endif // RD_TACTILE_FEEDBACK |
|
2410 |
|
2411 // --------------------------------------------------------------------------- |
|
2412 // CPeninputServer::AnimOpNeedWaiting |
|
2413 // Check command for this type of event whether needs waiting. |
|
2414 // --------------------------------------------------------------------------- |
|
2415 // |
|
2416 TBool CPeninputServer::AnimOpNeedWaiting(TInt aSignalCode) |
|
2417 { |
|
2418 TBool bNeedWait = EFalse; |
|
2419 if(ESignalPenUiDeActivated == aSignalCode) |
|
2420 { |
|
2421 return EFalse; |
|
2422 } |
|
2423 if(iForegroundUiHandler) |
|
2424 { |
|
2425 TInt uiType = iUiLayout->PenInputType(); |
|
2426 bNeedWait = iForegroundUiHandler->SignalUiActivationObserver( |
|
2427 aSignalCode,uiType); |
|
2428 } |
|
2429 return bNeedWait; |
|
2430 } |
|
2431 |
|
2432 // --------------------------------------------------------------------------- |
|
2433 // CPeninputServer::RecoverSimulatedKeyEventState |
|
2434 // --------------------------------------------------------------------------- |
|
2435 // |
|
2436 void CPeninputServer::RecoverSimulatedKeyEventState() |
|
2437 { |
|
2438 if(!iAnimObj) |
|
2439 { |
|
2440 return; |
|
2441 } |
|
2442 |
|
2443 if(iLastSimulatedKeyEvent.Type() == TRawEvent::EKeyDown) |
|
2444 { |
|
2445 //key up event is missing, we must manually simulate the up event. |
|
2446 iLastSimulatedKeyEvent.Set(TRawEvent::EKeyUp,iLastSimulatedKeyEvent.ScanCode()); |
|
2447 iAnimObj->AddSimulateEventCmd(iLastSimulatedKeyEvent); |
|
2448 } |
|
2449 } |
|
2450 |
|
2451 void CPeninputServer::RecoverButtonEventState() |
|
2452 { |
|
2453 if (TRawEvent::EButton1Down == iLastRawEvent.Type()) |
|
2454 { |
|
2455 iLastRawEvent.Set(TRawEvent::EButton1Up);//,iLastSimulatedKeyEvent.ScanCode() |
|
2456 TRAP_IGNORE( iUiLayout->HandleEventL(ERawEvent,&iLastRawEvent) ); |
|
2457 } |
|
2458 } |
|
2459 |
|
2460 void CPeninputServer::EnsureUpdateBuffer() |
|
2461 { |
|
2462 if(!iAnimObj) |
|
2463 { |
|
2464 return; |
|
2465 } |
|
2466 |
|
2467 if(iCurRectNumInBuf >= KMaxRectNumInBuf-1) |
|
2468 { |
|
2469 //flush previous buffer |
|
2470 iAnimObj->AddUpdateUiCmd(iFlushArea,iCurRectNumInBuf); |
|
2471 iCurRectNumInBuf = 0; |
|
2472 } |
|
2473 } |
|
2474 |
|
2475 inline TBool ContainsEachOther(const TRect aRt1, const TRect aRt2 ) |
|
2476 { |
|
2477 TRect rt(aRt1); |
|
2478 rt.BoundingRect( aRt2 ); |
|
2479 return rt == aRt1 || rt == aRt2; |
|
2480 } |
|
2481 |
|
2482 void CPeninputServer::PackFlushArea() |
|
2483 { |
|
2484 for( TInt i = iCurRectNumInBuf - 1; i > 0; i-- ) |
|
2485 { |
|
2486 for( TInt j = i -1; j >=0; j-- ) |
|
2487 { |
|
2488 if( ContainsEachOther(iFlushArea[i].iRect, iFlushArea[j].iRect) ) |
|
2489 { |
|
2490 iFlushArea[j].iRect.BoundingRect(iFlushArea[i].iRect); |
|
2491 iCurRectNumInBuf--; |
|
2492 } |
|
2493 } |
|
2494 } |
|
2495 } |
|
2496 |
|
2497 void CPeninputServer::AddFlushArea(const TUpdateArea& aArea) |
|
2498 { |
|
2499 for(TInt i = 0 ; i < iCurRectNumInBuf; ++i) |
|
2500 { |
|
2501 if(iFlushArea[i].iRect == aArea.iRect) |
|
2502 { |
|
2503 iFlushArea[i].iFullUpdateFlag |= aArea.iFullUpdateFlag; |
|
2504 return; |
|
2505 } |
|
2506 else if( iFlushArea[i].iFullUpdateFlag == aArea.iFullUpdateFlag ) |
|
2507 { |
|
2508 TRect rt(aArea.iRect); |
|
2509 rt.BoundingRect(iFlushArea[i].iRect); |
|
2510 if( rt == iFlushArea[i].iRect || rt == aArea.iRect ) |
|
2511 { |
|
2512 iFlushArea[i].iRect = rt; |
|
2513 //PackFlushArea(); |
|
2514 return; |
|
2515 } |
|
2516 } |
|
2517 } |
|
2518 //Ensure buffer can hold new data |
|
2519 EnsureUpdateBuffer(); |
|
2520 iFlushArea[iCurRectNumInBuf++] = aArea; |
|
2521 } |
|
2522 void CPeninputServer::PrepareExit() |
|
2523 { |
|
2524 CleanAll(); |
|
2525 } |
|
2526 |
|
2527 // --------------------------------------------------------------------------- |
|
2528 // CPeninputServer::MonitorWsGroupEvent |
|
2529 // Request to enable or disable window group change event |
|
2530 // --------------------------------------------------------------------------- |
|
2531 // |
|
2532 void CPeninputServer::MonitorWsGroupEvent(TBool aMonitorFlag) |
|
2533 { |
|
2534 RWindowGroup& rootWin = CCoeEnv::Static()->RootWin(); |
|
2535 if(aMonitorFlag) |
|
2536 { |
|
2537 rootWin.EnableFocusChangeEvents (); // For cover UI/status pane refresh problems |
|
2538 //rootWin.EnableGroupListChangeEvents(); |
|
2539 } |
|
2540 else |
|
2541 { |
|
2542 rootWin.DisableFocusChangeEvents (); // For cover UI/status pane refresh problems |
|
2543 //rootWin.DisableGroupListChangeEvents(); |
|
2544 } |
|
2545 } |
|
2546 |
|
2547 void CPeninputServer::CheckSessionValidL(CPeninputServerSession* aSession1, |
|
2548 CPeninputServerSession* aSession2) const |
|
2549 { |
|
2550 __ASSERT_DEBUG(aSession1 && aSession2, User::Leave(ENullSession)); |
|
2551 } |
|
2552 |
|
2553 // --------------------------------------------------------------------------- |
|
2554 // CPeninputServer::IsSameProcess |
|
2555 // Tests whether two sessions from same process |
|
2556 // --------------------------------------------------------------------------- |
|
2557 // |
|
2558 inline TBool CPeninputServer::IsSameProcess(CPeninputServerSession* aSession1, |
|
2559 CPeninputServerSession* aSession2) const |
|
2560 { |
|
2561 TRAP_IGNORE(CheckSessionValidL(aSession1, aSession2)); |
|
2562 return aSession1->ClientProcessId().Id() == aSession2->ClientProcessId().Id(); |
|
2563 } |
|
2564 // --------------------------------------------------------------------------- |
|
2565 // CPeninputServer::IsForegroundSession |
|
2566 // Tests whether current session is the foreground session. |
|
2567 // --------------------------------------------------------------------------- |
|
2568 // |
|
2569 inline TBool CPeninputServer::IsForegroundSession(CPeninputServerSession* aSession) const |
|
2570 { |
|
2571 if(!iForegroundSession) |
|
2572 return EFalse; |
|
2573 |
|
2574 if(iForegroundSession == aSession) |
|
2575 return ETrue; |
|
2576 |
|
2577 //same thread? |
|
2578 if(iForegroundSession->ClientId() == aSession->ClientId()) |
|
2579 return ETrue; |
|
2580 |
|
2581 //check whether the session is from the same process of foreground session |
|
2582 return IsSameProcess(iForegroundSession,aSession); |
|
2583 } |
|
2584 |
|
2585 // --------------------------------------------------------------------------- |
|
2586 // CPeninputServer::ResizeDrawingDevice |
|
2587 // Resize the drawing device |
|
2588 // --------------------------------------------------------------------------- |
|
2589 // |
|
2590 void CPeninputServer::ResizeDrawingDevice(const TSize& aSize) |
|
2591 { |
|
2592 iSpriteMember.iBitmap->Resize(aSize); |
|
2593 iSpriteMember.iMaskBitmap->Resize(aSize); |
|
2594 |
|
2595 iBitmapDevice->Resize( aSize); |
|
2596 iMaskBitmapDevice->Resize( aSize); |
|
2597 |
|
2598 //gc must be adjusted |
|
2599 iSpriteGc->Activate(iBitmapDevice); |
|
2600 iSpriteGc->Resized(); |
|
2601 } |
|
2602 |
|
2603 TInt CPeninputServer::HandleAppInfoChange(CPeninputServerSession* aSession, |
|
2604 const TDesC& aAppInfo, TPeninputAppInfo aType) const |
|
2605 { |
|
2606 if(!iUiLayout) |
|
2607 return KErrNoLayout; |
|
2608 |
|
2609 TInt err = KErrNone; |
|
2610 if(IsForegroundSession(aSession)) |
|
2611 { |
|
2612 iUiLayout->HandleAppInfoChange(aAppInfo,aType); |
|
2613 } |
|
2614 else |
|
2615 { |
|
2616 err = KErrNotForegroundSession; |
|
2617 } |
|
2618 return err; |
|
2619 } |
|
2620 |
|
2621 void CPeninputServer::BackgroudDefaultOri( TInt aOri) |
|
2622 { |
|
2623 iBackgroudDefaultOri = aOri; |
|
2624 } |
|
2625 |
|
2626 |
|
2627 TInt CPeninputServer::DisabledByDSA() |
|
2628 { |
|
2629 TInt disabled = 0; |
|
2630 TBool dsaOn = iCrpService->IsDsaActive(); |
|
2631 //iAnimObj->GetDSAState(dsaOn); |
|
2632 if(dsaOn) |
|
2633 { |
|
2634 disabled = EPluginInputModeVkb | EPluginInputModeHwr | EPluginInputModeFSc; |
|
2635 } |
|
2636 return disabled; |
|
2637 } |
|
2638 |
|
2639 TInt CPeninputServer::DisabledByDSAFromAnim() |
|
2640 { |
|
2641 TInt disabled = 0; |
|
2642 TBool dsaOn = EFalse; |
|
2643 if(!iAnimObj) |
|
2644 { |
|
2645 return disabled; |
|
2646 } |
|
2647 |
|
2648 iAnimObj->GetDSAState(dsaOn); |
|
2649 if(dsaOn) |
|
2650 { |
|
2651 disabled = EPluginInputModeVkb | EPluginInputModeHwr | EPluginInputModeFSc; |
|
2652 } |
|
2653 return disabled; |
|
2654 } |
|
2655 TInt CPeninputServer::DisabledByOrientation() |
|
2656 { |
|
2657 TInt disabled = 0; |
|
2658 TBool sensorOn = EFalse; |
|
2659 if ( iSensorRepository ) |
|
2660 { |
|
2661 iSensorRepository->Get( KSenSettingsSensorsOn, sensorOn ); |
|
2662 if ( sensorOn ) |
|
2663 { |
|
2664 TInt turnCtrl = 0; |
|
2665 iSensorRepository->Get( KSenSettingsTurnCtrl, turnCtrl ); |
|
2666 turnCtrl = turnCtrl >> 2; |
|
2667 |
|
2668 if ( turnCtrl ) |
|
2669 { |
|
2670 TPixelsTwipsAndRotation size; |
|
2671 CCoeEnv::Static()->ScreenDevice()->GetDefaultScreenSizeAndRotation(size); |
|
2672 |
|
2673 if( size.iPixelSize.iWidth < size.iPixelSize.iHeight ) |
|
2674 { |
|
2675 return disabled |= EPluginInputModeFSQ; |
|
2676 } |
|
2677 if( size.iPixelSize.iWidth > size.iPixelSize.iHeight ) |
|
2678 { |
|
2679 return disabled |= EPluginInputModeItut; |
|
2680 } |
|
2681 } |
|
2682 } |
|
2683 } |
|
2684 return disabled; |
|
2685 } |
|
2686 |
|
2687 TInt CPeninputServer::GetSupportModeL() |
|
2688 { |
|
2689 TInt curLanguage = iInputLanguage; |
|
2690 |
|
2691 if (curLanguage == 401) curLanguage = 102; |
|
2692 if (curLanguage == 402) curLanguage = 103; |
|
2693 |
|
2694 |
|
2695 TInt supportMode = EPluginInputModeNone; |
|
2696 TInt tempMode = EPluginInputModeHwr; |
|
2697 |
|
2698 iLayoutEng->InitializeL(); |
|
2699 |
|
2700 while ( tempMode < EPluginInputModeAll ) |
|
2701 { |
|
2702 if ( iLayoutEng->IsSupportPluginMode( ( TLanguage )curLanguage, |
|
2703 ( TPluginInputMode )tempMode ) ) |
|
2704 { |
|
2705 supportMode |= tempMode; |
|
2706 } |
|
2707 tempMode<<=1; |
|
2708 } |
|
2709 return supportMode; |
|
2710 } |
|
2711 |
|
2712 // ======== class CEventQueue======== |
|
2713 // |
|
2714 // --------------------------------------------------------------------------- |
|
2715 // CEventQueue::CEventQueue |
|
2716 // Constructor. Adds the active object to the active scheduler |
|
2717 // and issues a request for server notification. |
|
2718 // --------------------------------------------------------------------------- |
|
2719 // |
|
2720 |
|
2721 CEventQueue::CEventQueue(MRawEventHandler* aHandler):CActive( EPriorityHigh ), |
|
2722 iHandler(aHandler) |
|
2723 { |
|
2724 // issue asynchronous request and set this object active |
|
2725 CActiveScheduler::Add( this ); |
|
2726 } |
|
2727 |
|
2728 // --------------------------------------------------------------------------- |
|
2729 // CEventQueue::NewL |
|
2730 // factory constructor. |
|
2731 // --------------------------------------------------------------------------- |
|
2732 // |
|
2733 CEventQueue* CEventQueue::NewL(MRawEventHandler* aHandler,const TDesC& aName) |
|
2734 { |
|
2735 CEventQueue* queue = new(ELeave)CEventQueue(aHandler); |
|
2736 CleanupStack::PushL(queue); |
|
2737 queue->ConstructL(aName); |
|
2738 CleanupStack::Pop(queue); |
|
2739 return queue; |
|
2740 } |
|
2741 |
|
2742 // --------------------------------------------------------------------------- |
|
2743 // CEventQueue::ConstructL |
|
2744 // 2nd phase constructor |
|
2745 // --------------------------------------------------------------------------- |
|
2746 // |
|
2747 void CEventQueue::ConstructL(const TDesC& aName) |
|
2748 { |
|
2749 //create message queue |
|
2750 User::LeaveIfError(iMsgBufQueue.CreateGlobal(aName,KMsgQueueLen)); |
|
2751 } |
|
2752 // --------------------------------------------------------------------------- |
|
2753 // CEventQueue::CEventQueue |
|
2754 // Destructor. Cancels any outstanding requests |
|
2755 // --------------------------------------------------------------------------- |
|
2756 // |
|
2757 CEventQueue::~CEventQueue() |
|
2758 { |
|
2759 Cancel(); |
|
2760 iMsgBufQueue.Close(); |
|
2761 } |
|
2762 |
|
2763 // --------------------------------------------------------------------------- |
|
2764 // CEventQueue::DoCancel |
|
2765 // Cancels the notification requests |
|
2766 // --------------------------------------------------------------------------- |
|
2767 // |
|
2768 void CEventQueue::DoCancel() |
|
2769 { |
|
2770 iMsgBufQueue.CancelDataAvailable(); |
|
2771 } |
|
2772 |
|
2773 |
|
2774 // --------------------------------------------------------------------------- |
|
2775 // CEventQueue::RunL |
|
2776 // --------------------------------------------------------------------------- |
|
2777 // |
|
2778 void CEventQueue::RunL() |
|
2779 { |
|
2780 //iHandler is always there. No need to check it |
|
2781 TRawEventBuffer events; |
|
2782 iMsgBufQueue.Receive(events); |
|
2783 for(TInt i = 0; i < events.iNum; i++) |
|
2784 { |
|
2785 iHandler->HandleRawEventL(events.iEvent[i]); |
|
2786 } |
|
2787 // re-issue request |
|
2788 GetEvent(); |
|
2789 } |
|
2790 |
|
2791 // --------------------------------------------------------------------------- |
|
2792 // CEventQueue::RunError |
|
2793 // --------------------------------------------------------------------------- |
|
2794 // |
|
2795 TInt CEventQueue::RunError(TInt /*aError*/) |
|
2796 { |
|
2797 // re-issue request |
|
2798 GetEvent(); |
|
2799 return KErrNone; |
|
2800 } |
|
2801 |
|
2802 // --------------------------------------------------------------------------- |
|
2803 // CEventQueue::GetEvent |
|
2804 // Reissue request for event |
|
2805 // --------------------------------------------------------------------------- |
|
2806 // |
|
2807 void CEventQueue::GetEvent() |
|
2808 { |
|
2809 if(IsActive()) |
|
2810 return; |
|
2811 iMsgBufQueue.NotifyDataAvailable(iStatus); |
|
2812 SetActive(); |
|
2813 } |
|
2814 |
|
2815 |
|
2816 // ======== class CAknLayoutChangeWatcher======== |
|
2817 // |
|
2818 |
|
2819 // --------------------------------------------------------------------------- |
|
2820 // CAknLayoutChangeWatcher::NewL |
|
2821 // Factory constructor. |
|
2822 // --------------------------------------------------------------------------- |
|
2823 // |
|
2824 CAknLayoutChangeWatcher* CAknLayoutChangeWatcher::NewL( |
|
2825 CPeninputServer* aHandler,TUint aKey) |
|
2826 { |
|
2827 CAknLayoutChangeWatcher* self = new(ELeave)CAknLayoutChangeWatcher( |
|
2828 aHandler,aKey); |
|
2829 CActiveScheduler::Add(self); |
|
2830 return self; |
|
2831 } |
|
2832 |
|
2833 // --------------------------------------------------------------------------- |
|
2834 // CAknLayoutChangeWatcher::~CAknLayoutChangeWatcher |
|
2835 // Destructor |
|
2836 // --------------------------------------------------------------------------- |
|
2837 // |
|
2838 CAknLayoutChangeWatcher::~CAknLayoutChangeWatcher() |
|
2839 { |
|
2840 Cancel(); |
|
2841 } |
|
2842 |
|
2843 // --------------------------------------------------------------------------- |
|
2844 // CAknLayoutChangeWatcher::CAknLayoutChangeWatcher |
|
2845 // Default constructor |
|
2846 // --------------------------------------------------------------------------- |
|
2847 // |
|
2848 CAknLayoutChangeWatcher::CAknLayoutChangeWatcher(CPeninputServer* aHandler, |
|
2849 TUint aKey) |
|
2850 : CActive( EPriorityHigh ),iHandler(aHandler) |
|
2851 { |
|
2852 iProperty.Attach(KPSUidUikon,aKey); |
|
2853 iLayoutState = KInvalidValue; |
|
2854 iOrientationState = KInvalidValue; |
|
2855 } |
|
2856 |
|
2857 // --------------------------------------------------------------------------- |
|
2858 // CAknLayoutChangeWatcher::StartWatching |
|
2859 // Start to monitor |
|
2860 // --------------------------------------------------------------------------- |
|
2861 // |
|
2862 void CAknLayoutChangeWatcher::StartWatching() |
|
2863 { |
|
2864 iProperty.Subscribe(iStatus); |
|
2865 SetActive(); |
|
2866 } |
|
2867 |
|
2868 // --------------------------------------------------------------------------- |
|
2869 // CAknLayoutChangeWatcher::DoCancel |
|
2870 // Cancels the notification requests |
|
2871 // --------------------------------------------------------------------------- |
|
2872 // |
|
2873 void CAknLayoutChangeWatcher::DoCancel() |
|
2874 { |
|
2875 iProperty.Cancel(); |
|
2876 } |
|
2877 |
|
2878 |
|
2879 // --------------------------------------------------------------------------- |
|
2880 // CAknLayoutChangeWatcher::RunL |
|
2881 // --------------------------------------------------------------------------- |
|
2882 // |
|
2883 void CAknLayoutChangeWatcher::RunL() |
|
2884 { |
|
2885 TInt layoutstate = KInvalidValue; |
|
2886 TInt orientstate = KInvalidValue; |
|
2887 iProperty.Get(KPSUidUikon, KUikLayoutState, layoutstate); |
|
2888 iProperty.Get(KPSUidUikon, KUikPreferredOrientation, orientstate); |
|
2889 if(layoutstate != iLayoutState || orientstate != iOrientationState) |
|
2890 { |
|
2891 // save the previous state |
|
2892 iLayoutState = layoutstate; |
|
2893 iOrientationState = orientstate; |
|
2894 |
|
2895 // hide layout when monitered object change state |
|
2896 iHandler->HideLayoutTemporaryL(); |
|
2897 } |
|
2898 StartWatching(); |
|
2899 } |
|
2900 |
|
2901 // --------------------------------------------------------------------------- |
|
2902 // CEventQueue::RunError |
|
2903 // --------------------------------------------------------------------------- |
|
2904 // |
|
2905 TInt CAknLayoutChangeWatcher::RunError(TInt /*aError*/) |
|
2906 { |
|
2907 // re-issue request |
|
2908 StartWatching(); |
|
2909 return KErrNone; |
|
2910 } |
|
2911 |
|
2912 // ======== GLOBAL FUNCTIONS ======== |
|
2913 // --------------------------------------------------------- |
|
2914 // PanicServer |
|
2915 // --------------------------------------------------------- |
|
2916 // |
|
2917 GLDEF_C void PanicServer(TPeninputServerPanic aPanic) |
|
2918 { |
|
2919 User::Panic( KPeninputServerName, aPanic ); |
|
2920 } |
|
2921 // End of File |
|
2922 |