os/graphics/windowing/windowserverplugins/openwfc/src/rsdisplaychangeao.cpp
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/graphics/windowing/windowserverplugins/openwfc/src/rsdisplaychangeao.cpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,135 @@
     1.4 +// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.5 +// All rights reserved.
     1.6 +// This component and the accompanying materials are made available
     1.7 +// under the terms of "Eclipse Public License v1.0"
     1.8 +// which accompanies this distribution, and is available
     1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.10 +//
    1.11 +// Initial Contributors:
    1.12 +// Nokia Corporation - initial contribution.
    1.13 +//
    1.14 +// Contributors:
    1.15 +//
    1.16 +// Description:
    1.17 +//
    1.18 +
    1.19 +#include "rsdisplaychangeao.h"
    1.20 +#include "displaypolicy.h"
    1.21 +
    1.22 +CRsDisplayChangeNotifier::CRsDisplayChangeNotifier(MWsDisplayControl* aNextLevelInterface, CDisplayPolicy* aDisplayPolicy)
    1.23 +:CActive(EPriorityHigh),iWsStatus(NULL)
    1.24 +	{
    1.25 +	CActiveScheduler::Add(this);
    1.26 +	iNextLevelInterface = aNextLevelInterface;
    1.27 +	iDisplayPolicy = aDisplayPolicy;
    1.28 +	}
    1.29 +
    1.30 +CRsDisplayChangeNotifier* CRsDisplayChangeNotifier::NewL(MWsDisplayControl* aNextLevelInterface, CDisplayPolicy* aDisplayPolicy)
    1.31 +	{
    1.32 +	CRsDisplayChangeNotifier* self = new(ELeave) CRsDisplayChangeNotifier(aNextLevelInterface, aDisplayPolicy);
    1.33 +	return self;
    1.34 +	}
    1.35 +
    1.36 +void CRsDisplayChangeNotifier::IssueNotificationRequest()
    1.37 +	{
    1.38 +	iNextLevelInterface->NotifyOnDisplayChange(iStatus);
    1.39 +	SetActive();
    1.40 +	}
    1.41 +void CRsDisplayChangeNotifier::RegisterActiveStatus(TRequestStatus &aStatus)
    1.42 +	{
    1.43 +	iWsStatus = &aStatus;
    1.44 +	}
    1.45 +
    1.46 +void CRsDisplayChangeNotifier::CancelNotificationRequest()
    1.47 +	{
    1.48 +	Cancel();
    1.49 +	}
    1.50 +
    1.51 +void CRsDisplayChangeNotifier::RunL()
    1.52 +	{
    1.53 +	//IssueNotificationRequest will overwrite iStatus, save a copy first;
    1.54 +	TInt result = iStatus.Int();
    1.55 +	IssueNotificationRequest();
    1.56 +	
    1.57 +	//calculate min UI buffer size depending on physical resolutions
    1.58 +	TInt ret = iNextLevelInterface->NumberOfResolutions();
    1.59 +	RArray<MDisplayControlBase::TResolution> resolutions;
    1.60 +	CleanupClosePushL(resolutions);
    1.61 +	if(ret > 0)
    1.62 +		{
    1.63 +		//just ignore the error. if there's an error, an empty resolution list is passed in, and uibuffer
    1.64 +		//will remain the previous size
    1.65 +		iNextLevelInterface->GetResolutions(resolutions);
    1.66 +		}
    1.67 +	iDisplayPolicy->CalculateMinBufferSize(resolutions, ret);				
    1.68 +	CleanupStack::PopAndDestroy(&resolutions);
    1.69 +	
    1.70 +	if(iWsStatus && *iWsStatus == KRequestPending)
    1.71 +		{
    1.72 +		User::RequestComplete(iWsStatus, result);
    1.73 +		}
    1.74 +	}
    1.75 +
    1.76 +void CRsDisplayChangeNotifier::DoCancel()
    1.77 +	{
    1.78 +	iNextLevelInterface->NotifyOnDisplayChangeCancel();
    1.79 +	if(iWsStatus && *iWsStatus == KRequestPending)
    1.80 +		User::RequestComplete(iWsStatus, KErrCancel);
    1.81 +	}
    1.82 +
    1.83 +CRsDisplayChangeNotifier::~CRsDisplayChangeNotifier()
    1.84 +	{
    1.85 +	Cancel();
    1.86 +	}
    1.87 +
    1.88 +CRsConfigChangeNotifier::CRsConfigChangeNotifier(MWsDisplayControl* aNextLevelInterface)
    1.89 +:CActive(EPriorityHigh), iWsStatus(NULL)
    1.90 +	{
    1.91 +	CActiveScheduler::Add(this);
    1.92 +	iNextLevelInterface = aNextLevelInterface;
    1.93 +	}
    1.94 +
    1.95 +CRsConfigChangeNotifier* CRsConfigChangeNotifier::NewL(MWsDisplayControl* aNextLevelInterface)
    1.96 +	{
    1.97 +	CRsConfigChangeNotifier* self = new(ELeave) CRsConfigChangeNotifier(aNextLevelInterface);
    1.98 +	return self;
    1.99 +	}
   1.100 +
   1.101 +void CRsConfigChangeNotifier::IssueNotificationRequest()
   1.102 +	{
   1.103 +	iNextLevelInterface->NotifyOnConfigChange(iStatus);
   1.104 +	SetActive();
   1.105 +	}
   1.106 +
   1.107 +void CRsConfigChangeNotifier::RegisterActiveStatus(TRequestStatus &aStatus)
   1.108 +	{
   1.109 +	iWsStatus = &aStatus;
   1.110 +	}
   1.111 +
   1.112 +void CRsConfigChangeNotifier::CancelNotificationRequest()
   1.113 +	{
   1.114 +	Cancel();
   1.115 +	}
   1.116 +
   1.117 +void CRsConfigChangeNotifier::RunL()
   1.118 +	{
   1.119 +	//IssueNotificationRequest will overwrite iStatus, save a copy first;
   1.120 +	TInt result = iStatus.Int();
   1.121 +	IssueNotificationRequest();
   1.122 +	if(iWsStatus && *iWsStatus == KRequestPending)
   1.123 +		{
   1.124 +		User::RequestComplete(iWsStatus, result);
   1.125 +		}
   1.126 +	}
   1.127 +
   1.128 +void CRsConfigChangeNotifier::DoCancel()
   1.129 +	{
   1.130 +	iNextLevelInterface->NotifyOnConfigChangeCancel();
   1.131 +	if(iWsStatus && *iWsStatus == KRequestPending)
   1.132 +		User::RequestComplete(iWsStatus, KErrCancel);
   1.133 +	}
   1.134 +
   1.135 +CRsConfigChangeNotifier::~CRsConfigChangeNotifier()
   1.136 +	{
   1.137 +	Cancel();
   1.138 +	}