os/graphics/windowing/windowserver/nonnga/SERVER/scrdev.cpp
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
sl@0
     1
// Copyright (c) 1995-2009 Nokia Corporation and/or its subsidiary(-ies).
sl@0
     2
// All rights reserved.
sl@0
     3
// This component and the accompanying materials are made available
sl@0
     4
// under the terms of "Eclipse Public License v1.0"
sl@0
     5
// which accompanies this distribution, and is available
sl@0
     6
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0
     7
//
sl@0
     8
// Initial Contributors:
sl@0
     9
// Nokia Corporation - initial contribution.
sl@0
    10
//
sl@0
    11
// Contributors:
sl@0
    12
//
sl@0
    13
// Description:
sl@0
    14
// Screen device
sl@0
    15
// 
sl@0
    16
//
sl@0
    17
sl@0
    18
#include "ScrDev.H"
sl@0
    19
#include "Direct.H"
sl@0
    20
sl@0
    21
#include <e32hal.h>
sl@0
    22
#include <hal.h>
sl@0
    23
#include "server.h"
sl@0
    24
#include "gc.h"
sl@0
    25
#include "rootwin.h"
sl@0
    26
#include "windowgroup.h"
sl@0
    27
#include "wstop.h"
sl@0
    28
#include "EVENT.H"
sl@0
    29
#include "panics.h"
sl@0
    30
#include "../CLIENT/w32comm.h"
sl@0
    31
#include <w32std.h>
sl@0
    32
sl@0
    33
const TInt KEikSrvsSid=0x10003a4a;
sl@0
    34
sl@0
    35
static _LIT_SECURITY_POLICY_C1(KSecurityPolicy_WriteDeviceData,ECapabilityWriteDeviceData);
sl@0
    36
	
sl@0
    37
/*DWsScreenDevice*/
sl@0
    38
sl@0
    39
DWsScreenDevice::DWsScreenDevice(CWsClient* aOwner, TInt aDefaultScreenNumber, TUint aClientScreenDevicePointer) 
sl@0
    40
		: CWsScreenObject(aOwner, WS_HANDLE_SCREEN_DEVICE, CWsTop::Screen( aDefaultScreenNumber )), 
sl@0
    41
		  iClientScreenDevicePointer(aClientScreenDevicePointer)
sl@0
    42
	{}
sl@0
    43
sl@0
    44
DWsScreenDevice::~DWsScreenDevice()
sl@0
    45
	{}
sl@0
    46
sl@0
    47
void DWsScreenDevice::CopyScreenToBitmapL(const TRect &aRect, TInt aHandle)
sl@0
    48
	{
sl@0
    49
	CFbsBitmap *bitmap=new(ELeave) CFbsBitmap();
sl@0
    50
	CleanupStack::PushL(bitmap);
sl@0
    51
	TInt ret = bitmap->Duplicate(aHandle);
sl@0
    52
	if (ret == KErrNoMemory)
sl@0
    53
		{
sl@0
    54
		User::Leave(ret);
sl@0
    55
		}
sl@0
    56
	if (ret != KErrNone)
sl@0
    57
		OwnerPanic(EWservPanicBitmap);
sl@0
    58
sl@0
    59
	CFbsBitmapDevice *device=CFbsBitmapDevice::NewL(bitmap);
sl@0
    60
	CleanupStack::PushL(device);
sl@0
    61
	CFbsBitGc *gc;
sl@0
    62
	User::LeaveIfError(device->CreateContext(gc));
sl@0
    63
	CleanupStack::PushL(gc);			//Don't need to push this, but this is probably the eaiest way to delete it
sl@0
    64
	gc->SetDrawMode( CGraphicsContext::EDrawModeWriteAlpha );
sl@0
    65
	gc->BitBlt(TPoint(), *iScreen->ScreenGdi(), aRect);
sl@0
    66
	CleanupStack::PopAndDestroy(3);
sl@0
    67
	}
sl@0
    68
sl@0
    69
void DWsScreenDevice::CommandL(TInt aOpcode, const TAny *aCmdData)
sl@0
    70
	{
sl@0
    71
	TWsSdCmdUnion pData;
sl@0
    72
	pData.any=aCmdData;
sl@0
    73
	switch(aOpcode)
sl@0
    74
		{
sl@0
    75
		case EWsSdOpGetNumScreenModes:
sl@0
    76
			SetReply(iScreen->NumScreenSizeModes());
sl@0
    77
			break;
sl@0
    78
		case EWsSdOpGetScreenMode:
sl@0
    79
			SetReply(iScreen->ScreenSizeMode());
sl@0
    80
			break;
sl@0
    81
		case EWsSdOpSetScreenMode:
sl@0
    82
			{
sl@0
    83
			if(!KSecurityPolicy_WriteDeviceData().CheckPolicy(iWsOwner->ClientMessage(),__PLATSEC_DIAGNOSTIC_STRING("Capability check failed for CWsScreenDevice::SetScreenMode API")))
sl@0
    84
				{
sl@0
    85
				iWsOwner->PPanic(EWservPanicPermissionDenied);
sl@0
    86
				}
sl@0
    87
			SetScreenMode(*pData.Int);
sl@0
    88
			}
sl@0
    89
			break;
sl@0
    90
		case EWsSdOpSetModeRotation:
sl@0
    91
			{
sl@0
    92
			if(KSecurityPolicy_WriteDeviceData().CheckPolicy(iWsOwner->ClientMessage(),__PLATSEC_DIAGNOSTIC_STRING("Capability check failed for CWsScreenDevice::SetModeRotation API")))
sl@0
    93
				{
sl@0
    94
				TClientPanic panic=iScreen->SetModeRotation(pData.SetScreenRotation->mode,pData.SetScreenRotation->rotation);
sl@0
    95
				if (panic)
sl@0
    96
					OwnerPanic(panic);
sl@0
    97
				}
sl@0
    98
			}
sl@0
    99
			break;
sl@0
   100
		case EWsSdOpGetRotationList:
sl@0
   101
			if (!iScreen->IsValidScreenSizeMode(*pData.Int))
sl@0
   102
				OwnerPanic(EWservPanicScreenModeNumber);
sl@0
   103
			SetReply(iScreen->ScreenSizeModeData(*pData.Int).iAlternativeRotations);
sl@0
   104
			break;
sl@0
   105
		case EWsSdOpGetScreenModeSizeAndRotation:
sl@0
   106
			GetScreenSizeAndRotationCmd(*pData.Int);
sl@0
   107
			break;
sl@0
   108
		case EWsSdOpGetScreenModeSizeAndRotation2:
sl@0
   109
			GetScreenSizeAndRotationCmd2(*pData.Int);
sl@0
   110
			break;
sl@0
   111
		case EWsSdOpSetScreenSizeAndRotation:
sl@0
   112
			SetScreenSizeAndRotation(*pData.PixelsTwipsAndRotation);
sl@0
   113
			break;
sl@0
   114
		case EWsSdOpSetScreenSizeAndRotation2:
sl@0
   115
			SetScreenSizeAndRotation(*pData.PixelsAndRotation);
sl@0
   116
			break;
sl@0
   117
		case EWsSdOpGetDefaultScreenSizeAndRotation:
sl@0
   118
			GetScreenSizeAndRotationCmd(iScreen->ScreenSizeMode());
sl@0
   119
			break;
sl@0
   120
		case EWsSdOpGetDefaultScreenSizeAndRotation2:
sl@0
   121
			GetScreenSizeAndRotationCmd2(iScreen->ScreenSizeMode());
sl@0
   122
			break;
sl@0
   123
		case EWsSdOpGetScreenModeDisplayMode:
sl@0
   124
			GetScreenModeDisplayMode(*pData.Int);
sl@0
   125
			break;
sl@0
   126
		case EWsSdOpGetScreenModeScale:
sl@0
   127
			GetScreenScale(*pData.Int);
sl@0
   128
			break;
sl@0
   129
		case EWsSdOpGetCurrentScreenModeScale:
sl@0
   130
			GetScreenScale(iScreen->ScreenSizeMode());
sl@0
   131
			break;
sl@0
   132
		case EWsSdOpSetAppScreenMode:
sl@0
   133
			SetAppScreenMode(*pData.Int);
sl@0
   134
			break;
sl@0
   135
		case EWsSdOpGetCurrentScreenModeScaledOrigin:
sl@0
   136
			CWsClient::ReplyPoint(iScreen->CurrentScreenModeScaledOrigin());
sl@0
   137
			break;
sl@0
   138
		case EWsSdOpGetScreenModeScaledOrigin:
sl@0
   139
			if (!iScreen->IsValidScreenSizeMode(*pData.Int))
sl@0
   140
				OwnerPanic(EWservPanicScreenModeNumber);
sl@0
   141
			CWsClient::ReplyPoint(iScreen->ScreenModeScaledOrigin(*pData.Int));
sl@0
   142
			break;
sl@0
   143
		case EWsSdOpGetCurrentScreenModeAttributes:
sl@0
   144
			GetCurrentScreenModeAttributes();
sl@0
   145
			break;
sl@0
   146
		case EWsSdOpSetCurrentScreenModeAttributes:
sl@0
   147
			if(!KSecurityPolicy_WriteDeviceData().CheckPolicy(iWsOwner->ClientMessage(),__PLATSEC_DIAGNOSTIC_STRING("Capability check failed for CWsScreenDevice::SetCurrentScreenModeAttributes API, API should be used for test purposes only")))
sl@0
   148
				{
sl@0
   149
				iWsOwner->PPanic(EWservPanicPermissionDenied);
sl@0
   150
				}
sl@0
   151
			SetCurrentScreenModeAttributes(*pData.ScreenSizeMode);
sl@0
   152
			break;
sl@0
   153
		case EWsSdOpSetScreenModeEnforcement:
sl@0
   154
			{
sl@0
   155
			if(!KSecurityPolicy_WriteDeviceData().CheckPolicy(iWsOwner->ClientMessage(),__PLATSEC_DIAGNOSTIC_STRING("Capability check failed for CWsScreenDevice::SetScreenModeEnforcement API")))
sl@0
   156
				{
sl@0
   157
				iWsOwner->PPanic(EWservPanicPermissionDenied);
sl@0
   158
				}
sl@0
   159
			if (!iScreen->SetScreenModeEnforcement(*pData.Int))
sl@0
   160
				OwnerPanic(EWservPanicScreenEnforcementMode);
sl@0
   161
			}
sl@0
   162
			break;
sl@0
   163
		case EWsSdOpScreenModeEnforcement:
sl@0
   164
			SetReply(iScreen->SizeEnforcementMode());
sl@0
   165
			break;
sl@0
   166
		case EWsSdOpGetDefaultScreenModeOrigin:
sl@0
   167
			GetScreenModeOriginCmd(iScreen->ScreenSizeMode());
sl@0
   168
			break;
sl@0
   169
		case EWsSdOpGetScreenModeOrigin:
sl@0
   170
			GetScreenModeOriginCmd(*pData.Int);
sl@0
   171
			break;
sl@0
   172
		case EWsSdOpPixel:
sl@0
   173
			{
sl@0
   174
			TRgb rgb;
sl@0
   175
			iScreen->ScreenDevice()->GetPixel(rgb,*pData.Point);
sl@0
   176
			SetReply(rgb.Internal());
sl@0
   177
			}
sl@0
   178
			break;
sl@0
   179
		case EWsSdOpGetScanLine:
sl@0
   180
			iScreen->GetScanLine(pData.GetScanLine);
sl@0
   181
			break;
sl@0
   182
		case EWsSdOpTwipsSize:
sl@0
   183
			CWsClient::ReplySize(iAppScreenSizeInTwips);
sl@0
   184
			break;
sl@0
   185
		case EWsSdOpPixelSize:
sl@0
   186
			CWsClient::ReplySize(iAppScreenSizeInPixels);
sl@0
   187
			break;
sl@0
   188
		case EWsSdOpHorizontalTwipsToPixels:
sl@0
   189
			SetReply(iScreen->ScreenDevice()->HorizontalTwipsToPixels(*pData.UInt));
sl@0
   190
			break;
sl@0
   191
		case EWsSdOpVerticalTwipsToPixels:
sl@0
   192
			SetReply(iScreen->ScreenDevice()->VerticalTwipsToPixels(*pData.UInt));
sl@0
   193
			break;
sl@0
   194
		case EWsSdOpHorizontalPixelsToTwips:
sl@0
   195
			SetReply(iScreen->ScreenDevice()->HorizontalPixelsToTwips(*pData.UInt));
sl@0
   196
			break;
sl@0
   197
		case EWsSdOpVerticalPixelsToTwips:
sl@0
   198
			SetReply(iScreen->ScreenDevice()->VerticalPixelsToTwips(*pData.UInt));
sl@0
   199
			break;
sl@0
   200
		case EWsSdOpPointerRect:
sl@0
   201
			{
sl@0
   202
			TMachineInfoV1Buf macInfo;
sl@0
   203
			UserHal::MachineInfo(macInfo);
sl@0
   204
			TRect rect(-macInfo().iOffsetToDisplayInPixels,macInfo().iXYInputSizeInPixels);
sl@0
   205
			CWsClient::ReplyRect(rect);
sl@0
   206
			}
sl@0
   207
			break;
sl@0
   208
		case EWsSdOpFree:
sl@0
   209
			{
sl@0
   210
			// Mark any group windows associated with the screen device being deleted
sl@0
   211
			CWsRootWindow* root=iScreen->RootWindow();
sl@0
   212
			for (CWsWindowGroup* grp = root->Child(); grp; grp = grp->NextSibling())
sl@0
   213
				{
sl@0
   214
				if (grp->Device() == this)
sl@0
   215
					{
sl@0
   216
#if defined(_DEBUG)
sl@0
   217
 					grp->SetScreenDeviceDeleted();
sl@0
   218
#endif
sl@0
   219
					grp->SetScreenDevice(NULL);
sl@0
   220
					}
sl@0
   221
				}
sl@0
   222
			}
sl@0
   223
			// Let our owner (CWsClient) know that a screen device is being deleted so it
sl@0
   224
			// can check whether to reset its iPrimaryScreenDevice member or not
sl@0
   225
   			if (WsOwner())	
sl@0
   226
 				WsOwner()->NotifyScreenDeviceDeleted(this);
sl@0
   227
			delete this;
sl@0
   228
			break;
sl@0
   229
		case EWsSdOpDisplayMode:
sl@0
   230
			iScreen->ScreenGdi();	// To force display mode update if required
sl@0
   231
			SetReply(iScreen->CurrentDisplayMode());
sl@0
   232
			break;
sl@0
   233
		case EWsSdOpRectCompare:
sl@0
   234
			{
sl@0
   235
//			if (pData.RectCompare->flags&CWsScreenDevice::EIncludeSprite)
sl@0
   236
//				{
sl@0
   237
//				SpriteManager()->IncrementProcessingSprites();
sl@0
   238
//				}
sl@0
   239
sl@0
   240
			RWsTextCursor * cursor = 0;
sl@0
   241
			if (!pData.RectCompare->flags&CWsScreenDevice::EIncludeTextCursor)	
sl@0
   242
				cursor = CWsTop::CurrentTextCursor();
sl@0
   243
			if (cursor)
sl@0
   244
				cursor->Disable();
sl@0
   245
			
sl@0
   246
			SetReply(iScreen->ScreenDevice()->RectCompare(pData.RectCompare->rect1,*iScreen->ScreenDevice(),pData.RectCompare->rect2));
sl@0
   247
sl@0
   248
			if (cursor)
sl@0
   249
				cursor->Enable();
sl@0
   250
			
sl@0
   251
//			if (pData.RectCompare->flags&CWsScreenDevice::EIncludeSprite)
sl@0
   252
//				{
sl@0
   253
//				SpriteManager()->DecrementProcessingSprites();
sl@0
   254
//				}
sl@0
   255
			}
sl@0
   256
			break;
sl@0
   257
		case EWsSdOpCopyScreenToBitmap:
sl@0
   258
			CopyScreenToBitmapL(TRect(iScreen->ScreenDevice()->SizeInPixels()),pData.CopyScreenToBitmap->handle);
sl@0
   259
			break;
sl@0
   260
		case EWsSdOpCopyScreenToBitmap2:
sl@0
   261
			CopyScreenToBitmapL(pData.CopyScreenToBitmap2->rect,pData.CopyScreenToBitmap2->handle);
sl@0
   262
			break;
sl@0
   263
		case EWsSdOpPaletteAttributes:
sl@0
   264
			{
sl@0
   265
			TBool modifiable;
sl@0
   266
			TInt numEntries;
sl@0
   267
			iScreen->ScreenDevice()->PaletteAttributes(modifiable,numEntries);
sl@0
   268
			if (modifiable)
sl@0
   269
				numEntries|=EWsSdSetableBitFlag;
sl@0
   270
			SetReply(numEntries);
sl@0
   271
			}
sl@0
   272
			break;
sl@0
   273
		case EWsSdOpSetPalette:
sl@0
   274
			{
sl@0
   275
			if(!KSecurityPolicy_WriteDeviceData().CheckPolicy(iWsOwner->ClientMessage(),__PLATSEC_DIAGNOSTIC_STRING("Capability check failed for CWsScreenDevice::SetPalette API")))
sl@0
   276
				{
sl@0
   277
				User::Leave(KErrPermissionDenied);
sl@0
   278
				}
sl@0
   279
			SetPaletteL();
sl@0
   280
			}
sl@0
   281
			break;
sl@0
   282
		case EWsSdOpGetPalette:
sl@0
   283
			GetPalette(*pData.Int);
sl@0
   284
			break;
sl@0
   285
			
sl@0
   286
		case EWsSdOpGetScreenNumber:
sl@0
   287
			SetReply(iScreen->ScreenNumber());
sl@0
   288
			break;
sl@0
   289
		case EWsSdOpGetScreenSizeModeList:
sl@0
   290
			SetReply(iScreen->GetScreenSizeModeListL());
sl@0
   291
			break;
sl@0
   292
		case EWsClOpSetBackLight:
sl@0
   293
			{
sl@0
   294
			TInt err=KErrNone;
sl@0
   295
			if(Screen()->BackLightFlag() && iWsOwner->ClientMessage().SecureId()==KEikSrvsSid)
sl@0
   296
				{
sl@0
   297
				TWindowServerEvent::ProcessErrorMessages(TWsErrorMessage::EBackLight, err=HAL::Set(iScreen->ScreenNumber(),HALData::EBacklightState,*pData.Int));
sl@0
   298
				SetReply(err);
sl@0
   299
				}
sl@0
   300
			else
sl@0
   301
				{
sl@0
   302
				User::Leave(KErrPermissionDenied);				
sl@0
   303
				}
sl@0
   304
			}
sl@0
   305
			break;
sl@0
   306
		default:
sl@0
   307
			OwnerPanic(EWservPanicOpcode);
sl@0
   308
			break;
sl@0
   309
		}
sl@0
   310
	}
sl@0
   311
sl@0
   312
sl@0
   313
void DWsScreenDevice::SetScreenMode(TInt aMode)
sl@0
   314
	{
sl@0
   315
	if (!iScreen->IsValidScreenSizeMode(aMode))
sl@0
   316
		OwnerPanic(EWservPanicScreenModeNumber);
sl@0
   317
	iScreen->doSetScreenMode(aMode);
sl@0
   318
	}
sl@0
   319
sl@0
   320
TBool DWsScreenDevice::ScreenDeviceValidState() const
sl@0
   321
	{
sl@0
   322
	WS_ASSERT_DEBUG(iScreen->IsValidScreenSizeMode(iScreen->ScreenSizeMode()), EWsPanicInvalidScreenSizeMode);
sl@0
   323
	const TSizeMode& currentMode=iScreen->ScreenSizeModeData();
sl@0
   324
	TBool state=ETrue;
sl@0
   325
	// In all enforcement modes scale should match, so check scale first
sl@0
   326
	if (currentMode.iScreenScale!=iAppScale)
sl@0
   327
		{
sl@0
   328
		state=EFalse;
sl@0
   329
		}
sl@0
   330
	else
sl@0
   331
		{
sl@0
   332
		if (iScreen->SizeEnforcementMode()!=ESizeEnforcementNone)
sl@0
   333
			{
sl@0
   334
			if (currentMode.iRotation!=iAppRotation)
sl@0
   335
				state=EFalse;
sl@0
   336
			else if (currentMode.iScreenSize!=iAppScreenSizeInPixels)
sl@0
   337
				state=EFalse;
sl@0
   338
			}
sl@0
   339
		if (iScreen->SizeEnforcementMode()==ESizeEnforcementPixelsTwipsAndRotation)
sl@0
   340
			{
sl@0
   341
			if (currentMode.iScreenTwipsSize!=iAppScreenSizeInTwips)
sl@0
   342
				state=EFalse;
sl@0
   343
			}
sl@0
   344
		}
sl@0
   345
	return(state);
sl@0
   346
	}
sl@0
   347
sl@0
   348
void DWsScreenDevice::ConstructL()
sl@0
   349
//
sl@0
   350
// App specific construct
sl@0
   351
//
sl@0
   352
	{
sl@0
   353
	NewObjL();
sl@0
   354
	const TSizeMode& mode=iScreen->ScreenSizeModeData(iScreen->ScreenSizeMode());
sl@0
   355
	iAppScreenSizeInPixels=mode.iScreenSize;
sl@0
   356
	iAppScreenSizeInTwips=mode.iScreenTwipsSize;
sl@0
   357
	iAppRotation=mode.iRotation;
sl@0
   358
	iAppMode=iScreen->ScreenSizeMode();
sl@0
   359
	iAppScale=mode.iScreenScale;
sl@0
   360
	}
sl@0
   361
sl@0
   362
void DWsScreenDevice::SetScreenSizeAndRotation(const TPixelsTwipsAndRotation &aSar)
sl@0
   363
	{
sl@0
   364
	iAppScreenSizeInPixels=aSar.iPixelSize;
sl@0
   365
	iAppScreenSizeInTwips=aSar.iTwipsSize;
sl@0
   366
	iAppRotation=aSar.iRotation;
sl@0
   367
	SetScreenDeviceValidStates(this);
sl@0
   368
	}
sl@0
   369
sl@0
   370
void DWsScreenDevice::SetScreenSizeAndRotation(const TPixelsAndRotation &aSar)
sl@0
   371
	{
sl@0
   372
	iAppScreenSizeInPixels=aSar.iPixelSize;
sl@0
   373
	iAppScreenSizeInTwips.iWidth=iScreen->ScreenDevice()->HorizontalPixelsToTwips(iAppScreenSizeInPixels.iWidth);
sl@0
   374
	iAppScreenSizeInTwips.iHeight=iScreen->ScreenDevice()->VerticalPixelsToTwips(iAppScreenSizeInPixels.iHeight);
sl@0
   375
	iAppRotation=aSar.iRotation;
sl@0
   376
	SetScreenDeviceValidStates(this);
sl@0
   377
	}
sl@0
   378
sl@0
   379
void DWsScreenDevice::GetScreenModeOriginCmd(TInt aMode)
sl@0
   380
	{
sl@0
   381
	if (!iScreen->IsValidScreenSizeMode(aMode))
sl@0
   382
		OwnerPanic(EWservPanicScreenModeNumber);
sl@0
   383
	CWsClient::ReplyPoint(iScreen->ScreenModeOrigin(aMode));
sl@0
   384
	}
sl@0
   385
sl@0
   386
void DWsScreenDevice::GetCurrentScreenModeAttributes()
sl@0
   387
	{
sl@0
   388
	TSizeMode aModeData=iScreen->ScreenSizeModeData();
sl@0
   389
	CWsClient::ReplyBuf(&aModeData,sizeof(aModeData));
sl@0
   390
	}
sl@0
   391
sl@0
   392
void DWsScreenDevice::SetCurrentScreenModeAttributes(const TSizeMode &aModeData)
sl@0
   393
	{
sl@0
   394
#if defined(_DEBUG)
sl@0
   395
	if (aModeData.iScreenScale.iWidth==0 || aModeData.iScreenScale.iHeight==0)
sl@0
   396
		OwnerPanic(EWservPanicScreenModeNumber);
sl@0
   397
#endif
sl@0
   398
	iScreen->SetCurrentScreenModeAttributes(aModeData);
sl@0
   399
	}
sl@0
   400
sl@0
   401
void DWsScreenDevice::GetScreenSizeAndRotationCmd(TInt aMode)
sl@0
   402
	{
sl@0
   403
	if (!iScreen->IsValidScreenSizeMode(aMode))
sl@0
   404
		OwnerPanic(EWservPanicScreenModeNumber);
sl@0
   405
	TPixelsTwipsAndRotation sar;
sl@0
   406
	iScreen->GetScreenSizeAndRotation(sar,aMode);
sl@0
   407
	CWsClient::ReplyBuf(&sar, sizeof(sar));
sl@0
   408
	}
sl@0
   409
sl@0
   410
void DWsScreenDevice::GetScreenSizeAndRotationCmd2(TInt aMode)
sl@0
   411
	{
sl@0
   412
	if (!iScreen->IsValidScreenSizeMode(aMode))
sl@0
   413
		OwnerPanic(EWservPanicScreenModeNumber);
sl@0
   414
	TPixelsAndRotation sar;
sl@0
   415
	iScreen->GetScreenSizeAndRotation(sar,aMode);
sl@0
   416
	CWsClient::ReplyBuf(&sar, sizeof(sar));
sl@0
   417
	}
sl@0
   418
sl@0
   419
void DWsScreenDevice::GetScreenModeDisplayMode(const TInt aMode)
sl@0
   420
	{
sl@0
   421
	if (!iScreen->IsValidScreenSizeMode(aMode))
sl@0
   422
		{
sl@0
   423
		OwnerPanic(EWservPanicScreenModeNumber);
sl@0
   424
		}
sl@0
   425
	SetReply(STATIC_CAST(TInt,iScreen->DefaultDisplayMode(aMode)));
sl@0
   426
	}
sl@0
   427
sl@0
   428
void DWsScreenDevice::GetScreenScale(TInt aMode)
sl@0
   429
	{
sl@0
   430
	if (!iScreen->IsValidScreenSizeMode(aMode))
sl@0
   431
		{
sl@0
   432
		OwnerPanic(EWservPanicScreenModeNumber);
sl@0
   433
		}
sl@0
   434
	CWsClient::ReplySize(iScreen->GetScreenScale(aMode));
sl@0
   435
	}
sl@0
   436
sl@0
   437
void DWsScreenDevice::SetAppScreenMode(TInt aMode)
sl@0
   438
	{
sl@0
   439
	if (!iScreen->IsValidScreenSizeMode(aMode))
sl@0
   440
		{
sl@0
   441
		OwnerPanic(EWservPanicScreenModeNumber);
sl@0
   442
		}
sl@0
   443
	const TSizeMode& sizeMode=iScreen->ScreenSizeModeData(aMode);
sl@0
   444
	iAppScreenSizeInPixels=sizeMode.iScreenSize;
sl@0
   445
	iAppScreenSizeInTwips=sizeMode.iScreenTwipsSize;
sl@0
   446
	iAppMode=aMode;
sl@0
   447
	iAppScale=sizeMode.iScreenScale;
sl@0
   448
	iAppRotation=sizeMode.iRotation;
sl@0
   449
	CWsWindowGroup::SetScreenDeviceValidStates(this);
sl@0
   450
	}
sl@0
   451
sl@0
   452
#define ROTATION_TO_FLAG(x) 1<<x
sl@0
   453
sl@0
   454
void DWsScreenDevice::SetScreenDeviceValidStates(const DWsScreenDevice *aDevice)
sl@0
   455
	{
sl@0
   456
	TInt modes=iScreen->NumScreenSizeModes();
sl@0
   457
	TInt mode;
sl@0
   458
	for (mode=0;mode<modes;++mode)
sl@0
   459
		{
sl@0
   460
		if (!iScreen->IsValidScreenSizeMode(mode))
sl@0
   461
			continue;
sl@0
   462
		const TSizeMode& sizeMode=iScreen->ScreenSizeModeData(mode);
sl@0
   463
		if (iAppScreenSizeInPixels==sizeMode.iScreenSize && ROTATION_TO_FLAG(iAppRotation)&sizeMode.iAlternativeRotations)
sl@0
   464
			{
sl@0
   465
			iAppMode=mode;
sl@0
   466
			iAppScale=sizeMode.iScreenScale;
sl@0
   467
			break;
sl@0
   468
			}
sl@0
   469
		}
sl@0
   470
	CWsWindowGroup::SetScreenDeviceValidStates(aDevice);
sl@0
   471
	}
sl@0
   472
sl@0
   473
void DWsScreenDevice::NewOrientation(TInt aMode,CFbsBitGc::TGraphicsOrientation aRotation)
sl@0
   474
	{
sl@0
   475
	if (iAppMode==aMode)
sl@0
   476
		iAppRotation=aRotation;
sl@0
   477
	}
sl@0
   478
sl@0
   479
void DWsScreenDevice::SetPaletteL()
sl@0
   480
	{
sl@0
   481
	const TInt size=iWsOwner->ClientMessage().GetDesLength(KRemoteBufferMessageSlot);
sl@0
   482
	TInt numEntries=size/sizeof(TRgb);
sl@0
   483
	CPalette* palette=CPalette::NewL(numEntries);
sl@0
   484
	CleanupStack::PushL(palette);
sl@0
   485
	TPtr8 paletteData(NULL,0);
sl@0
   486
	palette->GetDataPtr(0,numEntries,paletteData);
sl@0
   487
	iWsOwner->RemoteReadL(paletteData,0);
sl@0
   488
	SetReply(iScreen->ScreenDevice()->SetCustomPalette(palette));
sl@0
   489
	iScreen->Update((RWsRegion&)RootWindow()->WindowArea());
sl@0
   490
	CleanupStack::PopAndDestroy(palette);
sl@0
   491
	}
sl@0
   492
sl@0
   493
void DWsScreenDevice::GetPalette(TInt aNumColors)
sl@0
   494
	{
sl@0
   495
	CPalette* palette;
sl@0
   496
	TInt ret=iScreen->ScreenDevice()->GetPalette(palette);
sl@0
   497
	if (ret<KErrNone)
sl@0
   498
		goto Reply;
sl@0
   499
	ret=palette->Entries();
sl@0
   500
	if (ret!=aNumColors)
sl@0
   501
		{
sl@0
   502
		delete palette;
sl@0
   503
Reply:
sl@0
   504
		SetReply(ret);
sl@0
   505
		return;
sl@0
   506
		}
sl@0
   507
	TPtr8 paletteData(NULL,0);
sl@0
   508
	palette->GetDataPtr(0,ret,paletteData);
sl@0
   509
	CWsClient::ReplyBuf(paletteData);
sl@0
   510
	SetReply(KErrNone);
sl@0
   511
	delete palette;
sl@0
   512
	}
sl@0
   513
sl@0
   514
TUint DWsScreenDevice::ClientDevicePointer()
sl@0
   515
	{
sl@0
   516
	return iClientScreenDevicePointer;	
sl@0
   517
	}