windowing/windowserver/nga/SERVER/POINTER.CPP
changeset 36 01a6848ebfd7
parent 0 5d03bc08d59c
child 110 7f25ef56562d
child 136 62bb7c97884c
--- a/windowing/windowserver/nga/SERVER/POINTER.CPP	Tue Feb 02 01:47:50 2010 +0200
+++ b/windowing/windowserver/nga/SERVER/POINTER.CPP	Fri Apr 16 16:21:04 2010 +0300
@@ -1,4 +1,4 @@
-// Copyright (c) 1995-2009 Nokia Corporation and/or its subsidiary(-ies).
+// Copyright (c) 1995-2010 Nokia Corporation and/or its subsidiary(-ies).
 // All rights reserved.
 // This component and the accompanying materials are made available
 // under the terms of "Eclipse Public License v1.0"
@@ -35,7 +35,7 @@
 TInt 			   TWsPointer::iDoubleClickMaxDistance;
 CWsPointerCursor*  TWsPointer::iCursorSprite;
 TPointerCursorMode TWsPointer::iPointerCursorMode=EPointerCursorNormal;
-TXYInputType 	   TWsPointer::iXyInputType;
+TXYInputType       TWsPointer::iXyInputType;
 TBool 			   TWsPointer::iTimerQueued;
 TBool 			   TWsPointer::iUpdateRequired;
 CPeriodic* 		   TWsPointer::iPeriodicTimer;
@@ -54,6 +54,9 @@
 CCirBuf<TPoint>*   CWsPointerBuffer::iPointerBuffer=NULL;
 TSglQue<CWsPointerBuffer> CWsPointerBuffer::iList(_FOFF(CWsPointerBuffer,iQue));
 TInt                TWsPointer::iYOffset;
+#if defined(__WINS__)
+TBool               TWsPointer::iEmulatorRotatePointerCoords;
+#endif
 
 static _LIT_SECURITY_POLICY_C1(KSecurityPolicy_SwEvent,ECapabilitySwEvent);
 
@@ -70,7 +73,14 @@
        {
        iYOffset = 0;
        }
-	
+
+#if defined(__WINS__)    
+	//An emulator may or may not deploy a renderchain or displaydriver that supports rotated drawing.
+	//On a real device target the coordinate system is always rotated together with wserv's screendevice.
+	_LIT( KWSERVIniFileVarEmulatorRotPointCoords, "EMULATOR_ROTATE_POINTER_COORDS");
+	iEmulatorRotatePointerCoords = WsIniFile->FindVar(KWSERVIniFileVarEmulatorRotPointCoords);
+#endif
+
 	iRootWindow = CWsTop::Screen()->RootWindow();
 	
 	TMachineInfoV1Buf machineInfo;
@@ -679,23 +689,17 @@
 			}
 		else
 			{
-			CScreen* screen=iRootWindow->Screen();
 	#if !defined(__WINS__)
-			TSize screenSize=screen->SizeInPixels()-TSize(1,1);		//This is in the current rotation
-			switch (screen->Orientation())
+			TranslateCoordsOnRotation(xy);
+	#else
+			if(iEmulatorRotatePointerCoords)
 				{
-				case CFbsBitGc::EGraphicsOrientationRotated90:
-					xy.SetXY(xy.iY,screenSize.iHeight-xy.iX);
-					break;
-				case CFbsBitGc::EGraphicsOrientationRotated180:
-					xy=-(xy-screenSize);
-					break;
-				case CFbsBitGc::EGraphicsOrientationRotated270:
-					xy.SetXY(screenSize.iWidth-xy.iY,xy.iX);
-					break;
-				default:;		//To stop warning
+				//emulators that support rotated drawing and touch may want to enable 
+				//rotation of pointer events in wsini.
+				TranslateCoordsOnRotation(xy);
 				}
 	#endif
+			CScreen* screen=iRootWindow->Screen();
 			ShiftYCoordinate(xy.iY);
 			// Move the raw event position by shifting it by Origin and scale
 			xy=screen->PhysicalToLogical(xy);
@@ -707,6 +711,25 @@
 	return ETrue;
 	}
 
+void TWsPointer::TranslateCoordsOnRotation(TPoint& aPoint)
+	{
+	CScreen* screen=iRootWindow->Screen();
+	TSize screenSize=screen->SizeInPixels()-TSize(1,1);     //This is in the current rotation
+	switch (screen->Orientation())
+		{
+		case CFbsBitGc::EGraphicsOrientationRotated90:
+			aPoint.SetXY(aPoint.iY,screenSize.iHeight-aPoint.iX);
+			break;
+		case CFbsBitGc::EGraphicsOrientationRotated180:
+			aPoint=-(aPoint-screenSize);
+			break;
+		case CFbsBitGc::EGraphicsOrientationRotated270:
+			aPoint.SetXY(screenSize.iWidth-aPoint.iY,aPoint.iX);
+			break;
+		default:;       //To stop warning
+		}
+	}
+
 /**
  * Validates events sent to the Window Server by its Client (Anim or Window Group).
  * May overwrite aRawEvent's Z coordinate and/or pointer number if Client or digitizer driver