windowing/windowserver/test/TClick/CLICK.CPP
branchRCL_3
changeset 163 bbf46f59e123
equal deleted inserted replaced
150:57c618273d5c 163:bbf46f59e123
       
     1 // Copyright (c) 2001-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 // Test Key Click Plug-In DLL
       
    15 // 
       
    16 //
       
    17 
       
    18 #include <e32std.h>
       
    19 #include "W32CLICK.H"
       
    20 #include "CLICK.H"
       
    21 #include <graphics/pointereventdata.h>
       
    22 #if defined(__WINS__)
       
    23 	#include <emulator.h>
       
    24 	#include "LOGWIN.H"
       
    25 #endif
       
    26 
       
    27 #define bufSize 64
       
    28 
       
    29 GLREF_D struct TSharedMemory GSharedMemory;
       
    30 
       
    31 class MClickMaker
       
    32 	{
       
    33 public:
       
    34 	virtual void KeyEvent(TEventCode aType,const TKeyEvent& aEvent)=0;
       
    35 	virtual void PointerEvent(const TPointerEvent& aEvent)=0;
       
    36 	virtual void OtherEvent(TInt aType,TAny* aParam)=0;
       
    37 	};
       
    38 
       
    39 struct TGpWinInfo
       
    40 	{
       
    41 	TBool iInUse;
       
    42 	TInt iServerValue;
       
    43 	TInt iNumGroups;
       
    44 	};
       
    45 
       
    46 struct TGpWinIdData
       
    47 	{
       
    48 	TInt iId;
       
    49 	TInt iClient;
       
    50 	};
       
    51 
       
    52 NONSHARABLE_CLASS(TLogClicks) : public MClickMaker
       
    53 	{
       
    54 public:
       
    55 	void StartLoggingL();
       
    56 	inline TBool IsLogging() {return iLogging;}
       
    57 	//Pure virtual functions from MClickMaker
       
    58 	void KeyEvent(TEventCode aType,const TKeyEvent& aEvent);
       
    59 	void PointerEvent(const TPointerEvent& aEvent);
       
    60     void OtherEvent(TInt aType,TAny* aParam=NULL);
       
    61 private:
       
    62 	TBool iLogging;
       
    63 	};
       
    64 
       
    65 NONSHARABLE_CLASS(CEventClicks) : public CBase, public MClickMaker
       
    66 	{
       
    67 	enum {
       
    68 		EEventBufferSize=32,
       
    69 		EMaxGroupWinClients=6,
       
    70 		EMaxGroupWinIdData=12
       
    71 		};
       
    72 public:
       
    73 	void ConstructL();
       
    74 	TInt Add(TWsEvent* aEvent);
       
    75 	inline TInt Failed() {return iFailed;}
       
    76 	inline TInt Events() {return iEventsTested;}
       
    77 	void Reset();
       
    78 	void ExtendedPointerEvent(const TPointerEventData& aPointerEvent);
       
    79 	void ExpectNewWindowGroup(TInt aClient);
       
    80 	void NewWindowGroup(const TGroupWindowOpenData& aGpWinOpen);
       
    81 	void CheckGpWinId(TInt aId);
       
    82 	void ExpectCloseWindowGroup(TInt aId);
       
    83 	void CloseWindowGroup(TInt aId);
       
    84 	void ExpectCloseWindow(TWindowCloseData& aCloseWin);
       
    85 	void CloseWindow(TWindowCloseData& aCloseWin);
       
    86 	void PointerEventInfo(TPointerEventInfo& aPointerEventInfo);	
       
    87 	//Pure virtual functions from MClickMaker
       
    88 	void KeyEvent(TEventCode aType,const TKeyEvent& aEvent);
       
    89 	void PointerEvent(const TPointerEvent& aEvent);
       
    90 	void OtherEvent(TInt aType,TAny* aParam=NULL);
       
    91 private:
       
    92 	TBool GetEvent(TWsEvent& aEvent);
       
    93 	void Fail();
       
    94 	void AddGroupWindowId(TInt aClient,TInt aGpWinId);
       
    95 	void RemoveGroupWindowId(TInt aGpWinId);
       
    96 private:
       
    97 	CCirBuf<TWsEvent> iEventBuffer;
       
    98 	TInt iFailed;
       
    99 	TInt iEventsTested;
       
   100 	TInt iFailedAt;
       
   101 	TGpWinInfo iGroupWins[EMaxGroupWinClients];
       
   102 	TGpWinIdData iGroupWinIds[EMaxGroupWinIdData];
       
   103 	TInt iExpectedEvent;
       
   104 	TInt iExpectedEventData;
       
   105 	TInt iExpectedHandle;
       
   106 	TPointerEventInfo iExpectedPointerEventInfo;
       
   107 	TInt iLastNewGpWinId;
       
   108 	TAdvancedPointerEvent iLastPointerEvent;
       
   109 	TBool iExpectingExtendedPointer;
       
   110 	};
       
   111 
       
   112 NONSHARABLE_CLASS(CMyClickMaker) : public CClickMaker
       
   113 	{
       
   114 public:
       
   115 	~CMyClickMaker();
       
   116 	void ConstructL();
       
   117 	//Virtual function from CClickMaker
       
   118 	void KeyEvent(TEventCode aType,const TKeyEvent& aEvent);
       
   119 	void PointerEvent(const TPointerEvent& aEvent);
       
   120 	void OtherEvent(TInt aType,TAny* aParam);
       
   121 	TInt CommandReplyL(TInt aOpcode, TAny *aArgs);
       
   122 private:
       
   123 	void LogToWindowL();
       
   124 private:
       
   125 	TClickOutputModes iMode;
       
   126 	MClickMaker* iCurrentClick;
       
   127 	TLogClicks iLogClicks;
       
   128 	CEventClicks* iEventClicks;
       
   129 	};
       
   130 
       
   131 
       
   132 /*TLogClicks*/
       
   133 
       
   134 void TLogClicks::StartLoggingL()
       
   135 	{
       
   136 #if defined(__WINS__)
       
   137 	if (!IsLogging())
       
   138 		{
       
   139 		CreateLogWinThreadL();
       
   140 		iLogging=ETrue;
       
   141 		}
       
   142 #else
       
   143 	User::Leave(KErrNotSupported);
       
   144 #endif
       
   145 	}
       
   146 
       
   147 void TLogClicks::KeyEvent(TEventCode aType,const TKeyEvent& aEvent)
       
   148 	{
       
   149 	_LIT(KKeyDown,		"KEY DOWN   ");
       
   150 	_LIT(KKeyUp,		"KEY UP     ");
       
   151 	_LIT(KKeyEvent,		"KEY EVENT  ");
       
   152 	_LIT(KKeyRepeat,	"KEY REPEAT ");
       
   153 	_LIT(KKeyUnknown,	"KEY Unknown");
       
   154 	_LIT(KKeyDataFormatChar,"'%c',");
       
   155 	_LIT(KKeyDataFormatCode," Code=%u,");
       
   156 	_LIT(KKeyDataFormatScan," Scan=%d,");
       
   157 	_LIT(KKeyDataFormatModRep," Mod=0x%x, Rep=%d");
       
   158 	TBuf<bufSize> bufPlusZero;
       
   159 	switch (aType)
       
   160 		{
       
   161 	case EEventKey:
       
   162 		bufPlusZero.Copy(KKeyEvent);
       
   163 		break;
       
   164 	case EEventKeyUp:
       
   165 		bufPlusZero.Copy(KKeyUp);
       
   166 		break;
       
   167 	case EEventKeyDown:
       
   168 		bufPlusZero.Copy(KKeyDown);
       
   169 		break;
       
   170 	case EEventKeyRepeat:
       
   171 		bufPlusZero.Copy(KKeyRepeat);
       
   172 		break;
       
   173 	default:
       
   174 		bufPlusZero.Copy(KKeyUnknown);
       
   175 		break;
       
   176 		}
       
   177 	bufPlusZero.AppendFormat(KKeyDataFormatCode,aEvent.iCode);
       
   178 	if (aEvent.iCode!=0)
       
   179 		bufPlusZero.AppendFormat(KKeyDataFormatChar,aEvent.iCode);
       
   180 	bufPlusZero.AppendFormat(KKeyDataFormatScan,aEvent.iScanCode);
       
   181 	if (aEvent.iScanCode!=0)
       
   182 		bufPlusZero.AppendFormat(KKeyDataFormatChar,aEvent.iScanCode);
       
   183 	bufPlusZero.AppendFormat(KKeyDataFormatModRep,aEvent.iModifiers,aEvent.iRepeats);
       
   184 	bufPlusZero.ZeroTerminate();
       
   185 #if defined(__WINS__)
       
   186 	Emulator::Escape();
       
   187 	SendMessage(GSharedMemory.iHwnd, WM_USER+EAppendText, (bufPlusZero.Length()+1)*sizeof(TText), (TInt32)(bufPlusZero.Ptr()));
       
   188 	Emulator::Reenter();
       
   189 #endif
       
   190 	}
       
   191 
       
   192 void TLogClicks::PointerEvent(const TPointerEvent& aEvent)
       
   193 	{
       
   194 	_LIT(KButtonDown,	"POINTER DOWN ");
       
   195 	_LIT(KButtonUp,		"POINTER UP   ");
       
   196 	_LIT(KButton2Down,	"BUTTON 2 DOWN");
       
   197 	_LIT(KButton2Up,	"BUTTON 2 UP  ");
       
   198 	_LIT(KButton3Down,	"BUTTON 3 DOWN");
       
   199 	_LIT(KButton3Up,	"BUTTON 3 UP  ");
       
   200 	_LIT(KButtonDrag,	"POINTER DRAG ");
       
   201 	_LIT(KButtonMove,	"POINTER MOVE ");
       
   202 	_LIT(KButtonRepeat,	"BUTTON REPEAT");
       
   203 	_LIT(KSwitchOn,		"POINTER ON   ");
       
   204 	_LIT(KUnknown,		"PTR Unknown  ");
       
   205 	//_LIT(KPtrDataFormat," Pos=(%d,%d), ScrPos=(%d,%d), Modifiers=%x");
       
   206 	_LIT(KPtrDataFormat," Pos=(%d,%d), ScrPos=(%d,%d), Mod=%x");
       
   207 	TBuf<bufSize> bufPlusZero;
       
   208 	switch (aEvent.iType)
       
   209 		{
       
   210 	case TPointerEvent::EButton1Down:
       
   211 		bufPlusZero.Copy(KButtonDown);
       
   212 		break;
       
   213 	case TPointerEvent::EButton1Up:
       
   214 		bufPlusZero.Copy(KButtonUp);
       
   215 		break;
       
   216 	case TPointerEvent::EButton2Down:
       
   217 		bufPlusZero.Copy(KButton2Down);
       
   218 		break;
       
   219 	case TPointerEvent::EButton2Up:
       
   220 		bufPlusZero.Copy(KButton2Up);
       
   221 		break;
       
   222 	case TPointerEvent::EButton3Down:
       
   223 		bufPlusZero.Copy(KButton3Down);
       
   224 		break;
       
   225 	case TPointerEvent::EButton3Up:
       
   226 		bufPlusZero.Copy(KButton3Up);
       
   227 		break;
       
   228 	case TPointerEvent::EDrag:
       
   229 		bufPlusZero.Copy(KButtonDrag);
       
   230 		break;
       
   231 	case TPointerEvent::EMove:
       
   232 		bufPlusZero.Copy(KButtonMove);
       
   233 		break;
       
   234 	case TPointerEvent::EButtonRepeat:
       
   235 		bufPlusZero.Copy(KButtonRepeat);
       
   236 		break;
       
   237 	case TPointerEvent::ESwitchOn:
       
   238 		bufPlusZero.Copy(KSwitchOn);
       
   239 		break;
       
   240 	default:
       
   241 		bufPlusZero.Copy(KUnknown);
       
   242 		break;
       
   243 		}
       
   244 	bufPlusZero.AppendFormat(KPtrDataFormat,aEvent.iPosition.iX,aEvent.iPosition.iY
       
   245 																,aEvent.iParentPosition.iX,aEvent.iParentPosition.iY,aEvent.iModifiers);
       
   246 	bufPlusZero.ZeroTerminate();
       
   247 #if defined(__WINS__)
       
   248 	Emulator::Escape();
       
   249 	SendMessage(GSharedMemory.iHwnd, WM_USER+EAppendText, (bufPlusZero.Length()+1)*sizeof(TText), (TInt32)(bufPlusZero.Ptr()));
       
   250 	Emulator::Reenter();
       
   251 #endif
       
   252 	}
       
   253 
       
   254 void TLogClicks::OtherEvent(TInt aType,TAny* aParam)
       
   255 	{
       
   256 	_LIT(KPointer,"POINTER EVENT Ver=%d, ScrPos=(%d,%d), WinClientHandle=0x%x, WinOrigin=%d, WinGpId=%d");
       
   257 	_LIT(KScreenDeviceChanged,"SCREEN DEVICE CHANGED EVENT, Mode=%d");
       
   258 	_LIT(KGroupWindowOpen,"GROUP WINDOW OPEN EVENT WinGpId=%d, Client=%d, NumWinGps=%d");
       
   259 	_LIT(KGroupWindowClose,"GROUP WINDOW CLOSE EVENT WinGpId=%d");
       
   260 	_LIT(KWindowClose,"WINDOW CLOSE EVENT Client=%d, WinGpId=%d");
       
   261 	_LIT(KEventUnknown,	"EVENT Unknown");
       
   262 	TBuf<bufSize> bufPlusZero;
       
   263 	switch (aType)
       
   264 		{
       
   265 	case EEventPointer:
       
   266 		{
       
   267 		TPointerEventData& data=*static_cast<TPointerEventData*>(aParam);
       
   268 		bufPlusZero.Format(KPointer,data.iVersion,data.iCurrentPos.iX,data.iCurrentPos.iY,data.iClientHandle
       
   269 										,data.iWindowOrigin.iX,data.iWindowOrigin.iY,data.iWindowGroupId);
       
   270 		}
       
   271 		break;
       
   272 	case EEventScreenDeviceChanged:
       
   273 		{
       
   274 		TClickMakerData& data=*static_cast<TClickMakerData*>(aParam);
       
   275 		bufPlusZero.Format(KScreenDeviceChanged,data.screenDeviceMode);
       
   276 		}
       
   277 		break;
       
   278 	case EEventGroupWindowOpen:
       
   279 		{
       
   280 		TGroupWindowOpenData& data=*static_cast<TGroupWindowOpenData*>(aParam);
       
   281 		bufPlusZero.Format(KGroupWindowOpen,data.iIdentifier,data.iClient,data.iNumClientWindowGroups);
       
   282 		}
       
   283 		break;
       
   284 	case EEventGroupWindowClose:
       
   285 		bufPlusZero.Format(KGroupWindowClose,reinterpret_cast<TInt&>(aParam));
       
   286 		break;
       
   287 	case EEventWindowClose:
       
   288 		{
       
   289 		TWindowCloseData& data=*static_cast<TWindowCloseData*>(aParam);
       
   290 		bufPlusZero.Format(KWindowClose,data.iClientHandle,data.iWindowGroupId);
       
   291 		}
       
   292 		break;
       
   293 	default:
       
   294 		bufPlusZero.Copy(KEventUnknown);
       
   295 		break;
       
   296 		}
       
   297 	bufPlusZero.ZeroTerminate();
       
   298 #if defined(__WINS__)
       
   299 	Emulator::Escape();
       
   300 	SendMessage(GSharedMemory.iHwnd, WM_USER+EAppendText, (bufPlusZero.Length()+1)*sizeof(TText), (TInt32)(bufPlusZero.Ptr()));
       
   301 	Emulator::Reenter();
       
   302 #endif
       
   303 	}
       
   304 
       
   305 /*CEventClicks*/
       
   306 
       
   307 void CEventClicks::ConstructL()
       
   308 	{
       
   309 	iEventBuffer.SetLengthL(EEventBufferSize);
       
   310 	}
       
   311 
       
   312 TInt CEventClicks::Add(TWsEvent* aEvent)
       
   313 	{
       
   314 	return (iEventBuffer.Add(aEvent) ? KErrNone:KErrOverflow);
       
   315 	}
       
   316 
       
   317 void CEventClicks::Reset()
       
   318 	{
       
   319 	iFailed=EFalse;
       
   320 	iEventsTested=0;
       
   321 	iExpectedEvent=0;
       
   322 	iLastNewGpWinId=0;
       
   323 	}
       
   324 
       
   325 void CEventClicks::ExtendedPointerEvent(const TPointerEventData& aPointerEvent)
       
   326 	{
       
   327 	if (!iExpectingExtendedPointer)
       
   328 		{
       
   329 		Fail();
       
   330 		return;
       
   331 		}
       
   332 	iExpectingExtendedPointer=EFalse;
       
   333 	TBool match=ETrue;
       
   334 	if (0!=aPointerEvent.iVersion)
       
   335 		match=EFalse;
       
   336 	if (iLastPointerEvent.iType!=aPointerEvent.iPointerEvent.iType)
       
   337 		match=EFalse;
       
   338 	if (iLastPointerEvent.iModifiers!=aPointerEvent.iPointerEvent.iModifiers)
       
   339 		match=EFalse;
       
   340 	if (iLastPointerEvent.iPosition!=aPointerEvent.iPointerEvent.iPosition)
       
   341 		match=EFalse;
       
   342 	if (iLastPointerEvent.iParentPosition!=aPointerEvent.iCurrentPos)
       
   343 		match=EFalse;
       
   344 	if (TPointerEventData::EUnspecified!=aPointerEvent.iSource)
       
   345 		match=EFalse;
       
   346 	if (iExpectedPointerEventInfo.iClientHandle && iExpectedPointerEventInfo.iWinGpId>0)
       
   347 		{
       
   348 		if (iLastPointerEvent.iParentPosition-iExpectedPointerEventInfo.iParentOrigin
       
   349 										!=aPointerEvent.iPointerEvent.iParentPosition)
       
   350 			match=EFalse;
       
   351 		if (iExpectedPointerEventInfo.iParentOrigin+iExpectedPointerEventInfo.iWinOrigin
       
   352 															!=aPointerEvent.iWindowOrigin)
       
   353 			match=EFalse;
       
   354 		if (iExpectedPointerEventInfo.iClientHandle!=aPointerEvent.iClientHandle)
       
   355 			match=EFalse;
       
   356 		if (iExpectedPointerEventInfo.iWinGpId!=aPointerEvent.iWindowGroupId)
       
   357 			match=EFalse;
       
   358 		}
       
   359 	if (!match)
       
   360 		Fail();
       
   361 	}
       
   362 
       
   363 void CEventClicks::ExpectNewWindowGroup(TInt aClient)
       
   364 	{
       
   365 	if (iExpectedEvent>0)
       
   366 		Fail();
       
   367 	iExpectedEvent=EEventGroupWindowOpen;
       
   368 	iExpectedEventData=aClient;
       
   369 	}
       
   370 
       
   371 void CEventClicks::NewWindowGroup(const TGroupWindowOpenData& aGpWinOpen)
       
   372 	{
       
   373 	iLastNewGpWinId=aGpWinOpen.iIdentifier;
       
   374 	if (iExpectedEvent!=EEventGroupWindowOpen)
       
   375 		{
       
   376 		Fail();
       
   377 		return;
       
   378 		}
       
   379 	iExpectedEvent=0;
       
   380 	if (iExpectedEventData>=EMaxGroupWinClients)
       
   381 		return;
       
   382 	AddGroupWindowId(iExpectedEventData,iLastNewGpWinId);
       
   383 	TGpWinInfo& gpWinInfo=iGroupWins[iExpectedEventData];
       
   384 	if (gpWinInfo.iInUse)
       
   385 		{
       
   386 		if (aGpWinOpen.iClient!=gpWinInfo.iServerValue)
       
   387 			Fail();
       
   388 		else 
       
   389 			{
       
   390 			if (aGpWinOpen.iNumClientWindowGroups!=gpWinInfo.iNumGroups)
       
   391 				Fail();
       
   392 			++gpWinInfo.iNumGroups;
       
   393 			}
       
   394 		}
       
   395 	else
       
   396 		{
       
   397 		gpWinInfo.iInUse=ETrue;
       
   398 		gpWinInfo.iServerValue=aGpWinOpen.iClient;
       
   399 		gpWinInfo.iNumGroups=aGpWinOpen.iNumClientWindowGroups+1;
       
   400 		}
       
   401 	}
       
   402 
       
   403 void CEventClicks::CheckGpWinId(TInt aId)
       
   404 	{
       
   405 	if (iLastNewGpWinId!=aId)
       
   406 		Fail();
       
   407 	}
       
   408 
       
   409 void CEventClicks::ExpectCloseWindowGroup(TInt aId)
       
   410 	{
       
   411 	if (iExpectedEvent>0)
       
   412 		Fail();
       
   413 	iExpectedEvent=EEventGroupWindowClose;
       
   414 	iExpectedEventData=aId;
       
   415 	}
       
   416 
       
   417 void CEventClicks::CloseWindowGroup(TInt aId)
       
   418 	{
       
   419 	if (iExpectedEvent!=EEventGroupWindowClose || iExpectedEventData!=aId)
       
   420 		Fail();
       
   421 	if (iExpectedEvent==EEventGroupWindowClose)
       
   422 		iExpectedEvent=0;
       
   423 	RemoveGroupWindowId(aId);
       
   424 	}
       
   425 
       
   426 void CEventClicks::ExpectCloseWindow(TWindowCloseData& aCloseWin)
       
   427 	{
       
   428 	if (iExpectedEvent>0)
       
   429 		Fail();
       
   430 	iExpectedEvent=EEventWindowClose;
       
   431 	iExpectedEventData=aCloseWin.iWindowGroupId;
       
   432 	iExpectedHandle=aCloseWin.iClientHandle;
       
   433 	}
       
   434 
       
   435 void CEventClicks::CloseWindow(TWindowCloseData& aCloseWin)
       
   436 	{
       
   437 	if (iExpectedEvent!=EEventWindowClose || iExpectedEventData!=aCloseWin.iWindowGroupId || iExpectedHandle!=aCloseWin.iClientHandle)
       
   438 		Fail();
       
   439 	if (iExpectedEvent==EEventWindowClose)
       
   440 		iExpectedEvent=0;
       
   441 	}
       
   442 
       
   443 void CEventClicks::PointerEventInfo(TPointerEventInfo& aPointerEventInfo)
       
   444 	{
       
   445 	iExpectedPointerEventInfo=aPointerEventInfo;
       
   446 	}
       
   447 
       
   448 TBool CEventClicks::GetEvent(TWsEvent& aEvent)
       
   449 	{
       
   450 	++iEventsTested;
       
   451 	if (iEventBuffer.Remove(&aEvent)<1)
       
   452 		{
       
   453 		Fail();
       
   454 		return ETrue;
       
   455 		}
       
   456 	return EFalse;
       
   457 	}
       
   458 
       
   459 void CEventClicks::Fail()
       
   460 	{
       
   461 	if (!iFailed)
       
   462 		{
       
   463 		iFailed=iEventsTested;
       
   464 		}
       
   465 	}
       
   466 
       
   467 void CEventClicks::AddGroupWindowId(TInt aClient,TInt aGpWinId)
       
   468 	{
       
   469 	TInt ii=0;
       
   470 	while (ii<EMaxGroupWinIdData && iGroupWinIds[ii].iId>0)
       
   471 		++ii;
       
   472 	if (ii<EMaxGroupWinIdData)
       
   473 		{
       
   474 		iGroupWinIds[ii].iId=aGpWinId;
       
   475 		iGroupWinIds[ii].iClient=aClient;
       
   476 		}
       
   477 	}
       
   478 
       
   479 void CEventClicks::RemoveGroupWindowId(TInt aGpWinId)
       
   480 	{
       
   481 	TInt ii=0;
       
   482 	while (ii<EMaxGroupWinIdData && iGroupWinIds[ii].iId!=aGpWinId)
       
   483 		++ii;
       
   484 	if (ii<EMaxGroupWinIdData)
       
   485 		{
       
   486 		--iGroupWins[iGroupWinIds[ii].iClient].iNumGroups;
       
   487 		iGroupWinIds[ii].iId=0;
       
   488 		}
       
   489 	}
       
   490 
       
   491 #define MODIFIER_FLAGS_TO_IGNOR EModifierNumLock
       
   492 #pragma warning(disable : 4245)		//'initializing' : conversion from 'int' to 'unsigned int', signed/unsigned mismatch
       
   493 void CEventClicks::KeyEvent(TEventCode aType,const TKeyEvent& aEvent)
       
   494 	{
       
   495 	TBool pass;
       
   496 	TEventCode eType=aType;
       
   497 	switch (aType)
       
   498 		{
       
   499 	case EEventKey:
       
   500 		pass=(aEvent.iRepeats==0);
       
   501 		break;
       
   502 	case EEventKeyUp:
       
   503 	case EEventKeyDown:
       
   504 		pass=(aEvent.iCode==0) && (aEvent.iRepeats==0);
       
   505 		break;
       
   506 	case EEventKeyRepeat:
       
   507 		pass=(aEvent.iRepeats>0);
       
   508 		eType=EEventKey;
       
   509 		break;
       
   510 	default:
       
   511 		pass=EFalse;
       
   512 		}
       
   513 	if (!pass)
       
   514 		{
       
   515 		Fail();
       
   516 		return;
       
   517 		}
       
   518 	TWsEvent eEvent;
       
   519 	if (GetEvent(eEvent))
       
   520 		return;
       
   521 	if (eEvent.Type()!=eType)
       
   522 		{
       
   523 		Fail();
       
   524 		return;
       
   525 		}
       
   526 	TKeyEvent keyEvent=*eEvent.Key();
       
   527 	TUint mask=~(EModifierAutorepeatable|MODIFIER_FLAGS_TO_IGNOR);
       
   528 	if (keyEvent.iCode!=aEvent.iCode || (keyEvent.iModifiers&mask)!=(aEvent.iModifiers&mask) || keyEvent.iScanCode!=aEvent.iScanCode
       
   529 																						|| (keyEvent.iRepeats==0)!=(aEvent.iRepeats==0))
       
   530 		{
       
   531 		Fail();
       
   532 		return;
       
   533 		}
       
   534 	}
       
   535 
       
   536 void CEventClicks::PointerEvent(const TPointerEvent& aEvent)
       
   537 	{
       
   538 	// Click events are now all advanced events so in order to test the modifier bits
       
   539 	// appropriately we need to copy them as TAdvancedPointerEvent not TPointerEvent
       
   540 	if(!aEvent.IsAdvancedPointerEvent())
       
   541 		{
       
   542 		Fail();
       
   543 		return;
       
   544 		}
       
   545 	iLastPointerEvent=*aEvent.AdvancedPointerEvent();
       
   546 		
       
   547 	if (iExpectingExtendedPointer)
       
   548 		Fail();
       
   549 	else
       
   550 		iExpectingExtendedPointer=ETrue;
       
   551 	TWsEvent eEvent;
       
   552 	if (GetEvent(eEvent))
       
   553 		return;
       
   554 	TAdvancedPointerEvent pEvent=*eEvent.Pointer();
       
   555 	TUint mask=~(MODIFIER_FLAGS_TO_IGNOR);
       
   556 	if (pEvent.iType!=aEvent.iType || (pEvent.iModifiers&mask)!=(aEvent.iModifiers&mask)
       
   557 												|| pEvent.iPosition!=aEvent.iPosition || pEvent.iParentPosition!=aEvent.iParentPosition)
       
   558 		{
       
   559 		Fail();
       
   560 		return;
       
   561 		}
       
   562 	}
       
   563 
       
   564 void CEventClicks::OtherEvent(TInt aType,TAny* aParam)
       
   565 	{
       
   566 	TBool pass=ETrue;
       
   567 	if (aType!=EEventPointer)
       
   568 		++iEventsTested;
       
   569 	switch (aType)
       
   570 		{
       
   571 	case EEventPointer:
       
   572 		ExtendedPointerEvent(*static_cast<TPointerEventData*>(aParam));
       
   573 		break;
       
   574 	case EEventScreenDeviceChanged:
       
   575 		break;
       
   576 	case EEventGroupWindowOpen:
       
   577 		NewWindowGroup(*static_cast<TGroupWindowOpenData*>(aParam));
       
   578 		break;
       
   579 	case EEventGroupWindowClose:
       
   580 		CloseWindowGroup(reinterpret_cast<TInt>(aParam));
       
   581 		break;
       
   582 	case EEventWindowClose:
       
   583 		CloseWindow(*static_cast<TWindowCloseData*>(aParam));
       
   584 		break;
       
   585 	default:
       
   586 		pass=EFalse;
       
   587 		}
       
   588 	if (!pass)
       
   589 		Fail();
       
   590 	//GetEvent() is not call here because CWsGroupWindow::EnableScreenChangeEvents() could not be 
       
   591 	//been called.This mean that no EEventScreenDeviceChanged will be put in the client queue.
       
   592 	//Instead this event will be always passed to the click plugin if this is present.
       
   593 	}
       
   594 #pragma warning(default : 4245)
       
   595 
       
   596 
       
   597 /*CMyClickMaker*/
       
   598 
       
   599 CMyClickMaker::~CMyClickMaker()
       
   600 	{
       
   601 	delete iEventClicks;
       
   602 	}
       
   603 
       
   604 void CMyClickMaker::ConstructL()
       
   605 	{
       
   606 	iMode=EClickNone;
       
   607 	iEventClicks=new(ELeave) CEventClicks();
       
   608 	iEventClicks->ConstructL();
       
   609 	}
       
   610 
       
   611 void CMyClickMaker::KeyEvent(TEventCode aType,const TKeyEvent& aEvent)
       
   612 	{
       
   613 	if (iCurrentClick)
       
   614 		iCurrentClick->KeyEvent(aType,aEvent);
       
   615 	}
       
   616 
       
   617 void CMyClickMaker::PointerEvent(const TPointerEvent& aEvent)
       
   618 	{
       
   619 	if (iCurrentClick)
       
   620 		iCurrentClick->PointerEvent(aEvent);
       
   621 	}
       
   622 
       
   623 void CMyClickMaker::OtherEvent(TInt aType,TAny* aParam)
       
   624 	{
       
   625 	if (iCurrentClick)
       
   626 		iCurrentClick->OtherEvent(aType,aParam);
       
   627 	}
       
   628 
       
   629 TInt CMyClickMaker::CommandReplyL(TInt aOpcode,TAny* aArgs)
       
   630 	{
       
   631 	switch (aOpcode)
       
   632 		{
       
   633 	case EClickCommandToggleOutput:
       
   634 		switch (iMode)
       
   635 			{
       
   636 		case EClickNone:
       
   637 			LogToWindowL();
       
   638 			break;
       
   639 		case EClickCheck:
       
   640 		case EClickToWindow:
       
   641 			iMode=EClickNone;
       
   642 			iCurrentClick=NULL;
       
   643 			break;
       
   644 			}
       
   645 		break;
       
   646 	case EClickCommandSetOutput:
       
   647 		iMode=*STATIC_CAST(TClickOutputModes*,aArgs);
       
   648 		switch (iMode)
       
   649 			{
       
   650 		case EClickNone:
       
   651 			iCurrentClick=NULL;
       
   652 			break;
       
   653 		case EClickCheck:
       
   654 			iCurrentClick=iEventClicks;
       
   655 			iEventClicks->Reset();
       
   656 			break;
       
   657 		case EClickToWindow:
       
   658 			LogToWindowL();
       
   659 			break;
       
   660 			}
       
   661 		break;
       
   662 	case EClickEventAdd:
       
   663 		return iEventClicks->Add(STATIC_CAST(TWsEvent*,aArgs));
       
   664 	case EClickFailed:
       
   665 		return iEventClicks->Failed();
       
   666 	case EClickEvents:
       
   667 		return iEventClicks->Events();
       
   668 	case EClickReset:
       
   669 		iEventClicks->Reset();
       
   670 		break;
       
   671 	case EClickCreateGroupWin:
       
   672 		iEventClicks->ExpectNewWindowGroup(*static_cast<TInt*>(aArgs));
       
   673 		break;
       
   674 	case EClickCheckGpWinId:
       
   675 		iEventClicks->CheckGpWinId(*static_cast<TInt*>(aArgs));
       
   676 		break;
       
   677 	case EClickCloseGroupWin:
       
   678 		iEventClicks->ExpectCloseWindowGroup(*static_cast<TInt*>(aArgs));
       
   679 		break;
       
   680 	case EClickCloseWin:
       
   681 		iEventClicks->ExpectCloseWindow(*static_cast<TWindowCloseData*>(aArgs));
       
   682 		break;
       
   683 	case EClickPointerEvent:
       
   684 		iEventClicks->PointerEventInfo(*static_cast<TPointerEventInfo*>(aArgs));
       
   685 		break;
       
   686 	default:;
       
   687 		}
       
   688 	return KErrNone;
       
   689 	}
       
   690 
       
   691 void CMyClickMaker::LogToWindowL()
       
   692 	{
       
   693 	iMode=EClickNone;
       
   694 	iCurrentClick=NULL;
       
   695 	iLogClicks.StartLoggingL();
       
   696 	iMode=EClickToWindow;
       
   697 	iCurrentClick=&iLogClicks;
       
   698 	}
       
   699 
       
   700 
       
   701 EXPORT_C CClickMaker* CreateClickMakerL()
       
   702 	{
       
   703 	CMyClickMaker* plugIn=new(ELeave) CMyClickMaker;
       
   704 	CleanupStack::PushL(plugIn);
       
   705 	plugIn->ConstructL();
       
   706 	CleanupStack::Pop(plugIn);
       
   707 	return plugIn;
       
   708 	}