os/graphics/windowing/windowserver/nga/CLIENT/RWS.CPP
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/graphics/windowing/windowserver/nga/CLIENT/RWS.CPP	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,2600 @@
     1.4 +// Copyright (c) 1995-2010 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 +// IPC implementation of client side code
    1.18 +// 
    1.19 +//
    1.20 +
    1.21 +#include "../SERVER/w32cmd.h"
    1.22 +#include "w32comm.h"
    1.23 +#include <e32std.h>
    1.24 +#include <w32std.h>
    1.25 +#include "CLIENT.H"
    1.26 +#include "graphics/windowserverconstants.h"
    1.27 +#include "rtfxeffect.h"
    1.28 +#include <wspublishandsubscribedata.h>
    1.29 +
    1.30 +const TInt KMaxWSERVMessagesSlot=-1;
    1.31 +
    1.32 +class RWsCustomTextCursor : public RWsSpriteBase
    1.33 +	{
    1.34 +	public:
    1.35 +		RWsCustomTextCursor(RWsSession aWs, TInt aHandle) : RWsSpriteBase(aWs)
    1.36 +			{ iWsHandle = aHandle; }
    1.37 +	};
    1.38 +
    1.39 +
    1.40 +EXPORT_C RWsSession::RWsSession()
    1.41 +/** Default C++ constructor.
    1.42 +
    1.43 +Constructs an uninitialised window server session. Note that it does not establish 
    1.44 +a connection to the window server - this must be done explicitly by calling 
    1.45 +the session's Connect() function. Before Connect() is called, no corresponding 
    1.46 +session object exists in the server, and the RWsSession contains no meaningful 
    1.47 +handle. */
    1.48 +	{}
    1.49 +
    1.50 +void RWsSession::connectL()
    1.51 +	{
    1.52 +	iBuffer=new(ELeave) RWsBuffer(this);
    1.53 +	iBuffer->SetBufferSizeL(RWsBuffer::EDefBufferSize);
    1.54 +	User::LeaveIfError(CreateSession(KWSERVServerName,Version(),KMaxWSERVMessagesSlot));
    1.55 +	iWsHandle=User::LeaveIfError(SendReceive(EWservMessInit,TIpcArgs()));
    1.56 +	}
    1.57 +
    1.58 +EXPORT_C TInt RWsSession::Connect()
    1.59 +/** Connects the client session to the window server.
    1.60 +
    1.61 +Connect() should be the first function called on an RWsSession object after 
    1.62 +it is created. The function establishes a connection to the window server, 
    1.63 +creating a corresponding session object in the server. Each session has one 
    1.64 +and only one connection to the server. Attempting to call Connect() when 
    1.65 +a connection has already been made will cause a panic.
    1.66 +
    1.67 +After a connection has been successfully established, all events are delivered 
    1.68 +to the client application through the RWsSession object.
    1.69 +
    1.70 +@return KErrNone if successful, otherwise another of the system-wide error 
    1.71 +codes. */
    1.72 +	{
    1.73 +	TInt ret;
    1.74 +
    1.75 +	if (iBuffer!=NULL)
    1.76 +		Panic(EW32PanicReConnect);
    1.77 + 	if ((ret=RFbsSession::Connect())==KErrNone)
    1.78 +		{
    1.79 +		TRAP(ret,connectL());
    1.80 +		if (ret!=KErrNone)
    1.81 +			{
    1.82 +			if (!iBuffer)
    1.83 +				RFbsSession::Disconnect();
    1.84 +			Close();
    1.85 +			}
    1.86 +		else
    1.87 +			iBuffer->SetCallBack();
    1.88 +		}
    1.89 +	return(ret);
    1.90 +	}
    1.91 +
    1.92 +EXPORT_C TInt RWsSession::Connect(RFs& aFileServer)
    1.93 +/** Connects the client session to the window server using pre constructed file server
    1.94 +session.
    1.95 +
    1.96 +Connect() should be the first function called on an RWsSession object after 
    1.97 +it is created. The function establishes a connection to the window server, 
    1.98 +creating a corresponding session object in the server. Each session has one 
    1.99 +and only one connection to the server. Attempting to call Connect() when 
   1.100 +a connection has already been made will cause a panic.
   1.101 +
   1.102 +After a connection has been successfully established, all events are delivered 
   1.103 +to the client application through the RWsSession object.
   1.104 +
   1.105 +@param aFileServer A fully constructed file server session
   1.106 +@return KErrNone if successful, otherwise another of the system-wide error 
   1.107 +codes. */
   1.108 +	{
   1.109 +	TInt ret;
   1.110 +
   1.111 +	if (iBuffer!=NULL)
   1.112 +		Panic(EW32PanicReConnect);
   1.113 + 	if ((ret=RFbsSession::Connect(aFileServer))==KErrNone)
   1.114 +		{
   1.115 +		TRAP(ret,connectL());
   1.116 +		if (ret!=KErrNone)
   1.117 +			{
   1.118 +			if (!iBuffer)
   1.119 +				RFbsSession::Disconnect();
   1.120 +			Close();
   1.121 +			}
   1.122 +		else
   1.123 +			iBuffer->SetCallBack();
   1.124 +		}
   1.125 +	return(ret);
   1.126 +	}
   1.127 +
   1.128 +EXPORT_C void RWsSession::Close()
   1.129 +/** Closes the window server session. 
   1.130 +
   1.131 +This function cleans up all resources in the RWsSession and disconnects it 
   1.132 +from the server. Prior to disconnecting from the window server, the client-side 
   1.133 +window server buffer is destroyed without being flushed. This function should 
   1.134 +be called when the RWsSession is no longer needed - normally just before 
   1.135 +it is destroyed. */
   1.136 +	{
   1.137 +	if (iBuffer)
   1.138 +		{
   1.139 +		__ASSERT_ALWAYS(iBuffer->iDirectAcessCount==0,Panic(EW32PanicDirectMisuse));
   1.140 +		iBuffer->CancelCallBack();
   1.141 +		iBuffer->Destroy();
   1.142 +		iBuffer=NULL;
   1.143 +		RFbsSession::Disconnect();
   1.144 +		}
   1.145 +	RSessionBase::Close();
   1.146 +	}
   1.147 +
   1.148 +// Private function(s)
   1.149 +
   1.150 +TInt RWsSession::DoSyncMsgBuf(const TIpcArgs& aIpcArgs)
   1.151 +	{
   1.152 +	return (SendReceive(EWservMessSyncMsgBuf,aIpcArgs));
   1.153 +	}
   1.154 +	
   1.155 +TInt RWsSession::DoFlush(const TIpcArgs& aIpcArgs)
   1.156 +	{
   1.157 +	return (SendReceive(EWservMessCommandBuffer,aIpcArgs));
   1.158 +	}
   1.159 +
   1.160 +EXPORT_C TVersion RWsSession::Version() const
   1.161 +/** Gets the window server version.
   1.162 +
   1.163 +@return Window server version containing major and minor version numbers, 
   1.164 +and build number. */
   1.165 +	{
   1.166 +
   1.167 +	TVersion v(KWservMajorVersionNumber,KWservMinorVersionNumber,KWservBuildVersionNumber);
   1.168 +	return(v);
   1.169 +	}
   1.170 +
   1.171 +TInt RWsSession::doSetHotKey(TInt aOpcode, TInt aType, TUint aKeycode, TUint aModifierMask, TUint aModifiers)
   1.172 +	{
   1.173 +	TWsClCmdSetHotKey setHotKey;
   1.174 +
   1.175 +	setHotKey.type=aType;
   1.176 +	setHotKey.keycode=(TUint16)aKeycode;
   1.177 +	setHotKey.modifiers=aModifiers;
   1.178 +	setHotKey.modifierMask=aModifierMask;
   1.179 +	return(WriteReply(&setHotKey,sizeof(setHotKey),aOpcode));
   1.180 +	}
   1.181 +
   1.182 +EXPORT_C TInt RWsSession::SetHotKey(THotKey aType, TUint aKeycode, TUint aModifierMask, TUint aModifiers)
   1.183 +/** Sets the hot keys.
   1.184 +
   1.185 +Hot keys allow standard functions to be performed by application-defined key 
   1.186 +combinations. 
   1.187 +
   1.188 +This function maps any key press (with optional modifiers) to one of the hot 
   1.189 +keys defined in THotKey. More than one key combination may be mapped to each 
   1.190 +hot key: a new mapping is added each time the function is called.
   1.191 +
   1.192 +Modifier key states are defined in TEventModifier. The modifiers that you 
   1.193 +want to be in a particular state should be specified in aModifierMask and 
   1.194 +the ones of these you want to be set should be specified in aModifiers. For 
   1.195 +example, if you want to capture FN-A and you want the SHIFT modifier unset, 
   1.196 +but you don't care about the state of the other modifiers then set both the 
   1.197 +flags for SHIFT and FN in aModiferMask and only set FN in aModifiers.
   1.198 +
   1.199 +Note: default hotkey settings exist, but this function can be used for customisation. 
   1.200 +Typically it might be be used by a shell application or other application 
   1.201 +that controls system-wide settings.
   1.202 +
   1.203 +This function always causes a flush of the window server buffer.
   1.204 +
   1.205 +@param aType The hot key to be mapped
   1.206 +@param aKeyCode The keycode to be mapped to the hot key
   1.207 +@param aModifierMask Modifier keys to test for a match
   1.208 +@param aModifiers Modifier keys to be tested for "on" state 
   1.209 +@return KErrNone value if successful, otherwise another of the system-wide 
   1.210 +error codes.
   1.211 +@capability SwEvent */
   1.212 +	{
   1.213 +	return(doSetHotKey(EWsClOpSetHotKey, aType, aKeycode, aModifierMask, aModifiers));
   1.214 +	}
   1.215 +
   1.216 +EXPORT_C TInt RWsSession::ClearHotKeys(THotKey aType)
   1.217 +/** Clears all mappings for the specified hotkey, including the default mapping.
   1.218 +
   1.219 +Hotkeys allow standard functions to be performed by application-defined key 
   1.220 +combinations. 
   1.221 +
   1.222 +This function always causes a flush of the window server buffer.
   1.223 +
   1.224 +@param aType The hot key to be cleared 
   1.225 +@return KErrNone if successful, otherwise one of the system-wide error codes. 
   1.226 +@see SetHotKey()
   1.227 +@see RestoreDefaultHotKey()
   1.228 +@capability SwEvent */
   1.229 +	{
   1.230 +	return(WriteReplyInt(aType,EWsClOpClearHotKeys));
   1.231 +	}
   1.232 +
   1.233 +EXPORT_C TInt RWsSession::RestoreDefaultHotKey(THotKey aType)
   1.234 +/** Restores the default mapping for a hot key.
   1.235 +
   1.236 +The function clears current mappings for a hot key and restores the default 
   1.237 +mapping. See THotKey for the default.
   1.238 +
   1.239 +This function always causes a flush of the window server buffer.
   1.240 +
   1.241 +@param aType The hot key to restore to its default value 
   1.242 +@return KErrNone if successful, otherwise another of the system-wide error 
   1.243 +codes. 
   1.244 +@see ClearHotKeys() */
   1.245 +	{
   1.246 +	return(WriteReplyInt(aType,EWsClOpRestoreDefaultHotKey));
   1.247 +	}
   1.248 +
   1.249 +EXPORT_C void RWsSession::ComputeMode(TComputeMode aMode)
   1.250 +/** Sets the mode used to control process priorities.
   1.251 +
   1.252 +The default window server behaviour is that the application that owns the 
   1.253 +window with keyboard focus gets foreground process priority (EPriorityForeground) 
   1.254 +while all other clients get background priority (EPriorityBackground). This 
   1.255 +function can be used to over-ride this default behaviour, as discussed in 
   1.256 +TComputeMode.
   1.257 +
   1.258 +Note:
   1.259 +
   1.260 +Unlike real Symbian phones, the Emulator runs on a single process. As a result, 
   1.261 +on the Emulator this function sets the priority of individual threads rather 
   1.262 +than of processes. The values used for thread priorities are EPriorityLess 
   1.263 +instead of EPriorityBackground, and EPriorityNormal instead of EPriorityForeground.
   1.264 +
   1.265 +@param aMode The compute mode. */
   1.266 +	{
   1.267 +	WriteInt(aMode,EWsClOpComputeMode);
   1.268 +	}
   1.269 +
   1.270 +/**
   1.271 +This method has been deprecated. Shadowing of a window is no longer supported. 
   1.272 +Calling it has no effect.
   1.273 +@param aVector Ignored.
   1.274 +@deprecated
   1.275 +*/
   1.276 +EXPORT_C void RWsSession::SetShadowVector(const TPoint& /*aVector*/)
   1.277 +	{
   1.278 +	}
   1.279 +
   1.280 +/**
   1.281 +This method has been deprecated. Shadowing of a window is no longer supported.
   1.282 +Calling it has no effect.
   1.283 +@return TPoint(0, 0)
   1.284 +@deprecated
   1.285 +*/
   1.286 +EXPORT_C TPoint RWsSession::ShadowVector() const
   1.287 +	{
   1.288 +	return TPoint();
   1.289 +	}
   1.290 +
   1.291 +void RWsSession::doReadEvent(TRequestStatus *aStat, TInt aOpcode)
   1.292 +	{
   1.293 +	*aStat=KRequestPending;
   1.294 +	if (iBuffer)
   1.295 +		{
   1.296 +		iBuffer->Flush(); //ignore error since this flushing should not return any error
   1.297 +		}
   1.298 +	__ASSERT_DEBUG(EWservMessAsynchronousService>=aOpcode, Assert(EW32AssertIllegalOpcode));
   1.299 +	const TInt function=EWservMessAsynchronousService|aOpcode;
   1.300 +	SendReceive(function,TIpcArgs(),*aStat);
   1.301 +	}
   1.302 +
   1.303 +EXPORT_C void RWsSession::EventReady(TRequestStatus* aStat)
   1.304 +/** Requests standard events from the window server.
   1.305 +
   1.306 +Standard events include all events except redraws and priority key events.
   1.307 +
   1.308 +The client application will typically handle the completed request using the 
   1.309 +RunL() function of an active object, and in this case the request status aStat 
   1.310 +should be the iStatus member of that CActive object.
   1.311 +
   1.312 +Notes:
   1.313 +
   1.314 +- The active object runs when an event is waiting. You should call GetEvent() 
   1.315 +in the RunL() function to get the event.
   1.316 +
   1.317 +- You should not call this function again until you have either called GetEvent() 
   1.318 +or EventReadyCancel().
   1.319 +
   1.320 +- Because this function is asynchronous, there is no guarantee that the Window 
   1.321 +Server will process the request before the function returns. However, on single 
   1.322 +core systems it is unusual for this function to return before the Window Server 
   1.323 +has processed the request, because the client generally runs in a lower priority 
   1.324 +thread than the Window Server. You should therefore expect the use of this 
   1.325 +function to give rise to different behaviour between single and multicore systems.
   1.326 +
   1.327 +@param aStat Request status. On successful completion contains KErrNone, otherwise 
   1.328 +another of the system-wide error codes.
   1.329 +@see CActive
   1.330 +@see GetEvent() */
   1.331 +	{
   1.332 +	doReadEvent(aStat,EWsClOpEventReady);
   1.333 +	}
   1.334 +
   1.335 +EXPORT_C void RWsSession::RedrawReady(TRequestStatus* aStat)
   1.336 +/** Requests redraw events from the window server.
   1.337 +
   1.338 +Typically, a client will create an active object for redraw events with a 
   1.339 +lower priority than the active objects for standard events. The client will 
   1.340 +then typically handle completed redraw requests in the active object's RunL() 
   1.341 +function.
   1.342 +
   1.343 +As in EventReady(), the request status aStat should be used as the iStatus 
   1.344 +member of an active object. When a redraw event occurs the active object's 
   1.345 +RunL() function is called. The redraw event can be obtained by calling 
   1.346 +GetRedraw() in the RunL().
   1.347 +
   1.348 +Notes:
   1.349 +
   1.350 +- You should not call this function again until you have either called 
   1.351 +GetRedraw() or RedrawReadyCancel().
   1.352 +
   1.353 +- Because this function is asynchronous, there is no guarantee that the Window 
   1.354 +Server will process the request before the function returns. However, on single 
   1.355 +core systems it is unusual for this function to return before the Window Server 
   1.356 +has processed the request, because the client generally runs in a lower priority 
   1.357 +thread than the Window Server. You should therefore expect the use of this 
   1.358 +function to give rise to different behaviour between single and multicore systems.
   1.359 +
   1.360 +@param aStat The request status. On successful completion contains KErrNone, 
   1.361 +otherwise another of the system-wide error codes. 
   1.362 +@see RedrawReadyCancel()
   1.363 +@see GetRedraw()
   1.364 +@see CActive */
   1.365 +	{
   1.366 +	doReadEvent(aStat,EWsClOpRedrawReady);
   1.367 +	}
   1.368 +	
   1.369 +void RWsSession::GraphicMessageReady(TRequestStatus *aStat)
   1.370 +	{
   1.371 +	doReadEvent(aStat,EWsClOpGraphicMessageReady);
   1.372 +	}
   1.373 +	
   1.374 +void RWsSession::GetGraphicMessage(TDes8& aData) const
   1.375 +	{
   1.376 +	WriteReplyP(TWriteDescriptorType(&aData),EWsClOpGetGraphicMessage);
   1.377 +	}
   1.378 +	
   1.379 +void RWsSession::GraphicMessageCancel()
   1.380 +	{
   1.381 +	WriteReply(EWsClOpGraphicMessageCancel);
   1.382 +	}
   1.383 +
   1.384 +void RWsSession::GraphicAbortMessage(TInt aError)
   1.385 +	{
   1.386 +	WriteReplyInt(aError, EWsClOpGraphicAbortMessage);
   1.387 +	}
   1.388 +
   1.389 +TInt RWsSession::GraphicFetchHeaderMessage()
   1.390 +	{
   1.391 +	return WriteReply(EWsClOpGraphicFetchHeaderMessage);
   1.392 +	}
   1.393 +	
   1.394 +EXPORT_C void RWsSession::PriorityKeyReady(TRequestStatus *aStat)
   1.395 +/** Requests priority key events from the window server. 
   1.396 +
   1.397 +Typically, an client will create an active object for priority key events 
   1.398 +with a higher priority than the active objects for standard events. The client 
   1.399 +will then normally handle completed priority key requests in the active object's 
   1.400 +RunL() function.
   1.401 +
   1.402 +As in EventReady(), the request status argument should be the set to the iStatus 
   1.403 +member of CActive. When priority key events occur, they are obtained using 
   1.404 +GetPriorityKey().
   1.405 +
   1.406 +Notes:
   1.407 +
   1.408 +- You should not call this function again until you have either called 
   1.409 +GetPriorityKey() or PriorityKeyReadyCancel().
   1.410 +
   1.411 +- Because this function is asynchronous, there is no guarantee that the Window 
   1.412 +Server will process the request before the function returns. However, on single 
   1.413 +core systems it is unusual for this function to return before the Window Server 
   1.414 +has processed the request, because the client generally runs in a lower priority 
   1.415 +thread than the Window Server. You should therefore expect the use of this 
   1.416 +function to give rise to different behaviour between single and multicore systems.
   1.417 +
   1.418 +@param aStat Request status. On successful completion contains KErrNone, otherwise 
   1.419 +another of the system-wide error codes. 
   1.420 +@see PriorityKeyReadyCancel()
   1.421 +@see GetPriorityKey()
   1.422 +@see CActive */
   1.423 +	{
   1.424 +	doReadEvent(aStat,EWsClOpPriorityKeyReady);
   1.425 +	}
   1.426 +
   1.427 +EXPORT_C void RWsSession::GetEvent(TWsEvent &aEvent) const
   1.428 +/** Gets a standard event from the session for processing.
   1.429 +
   1.430 +The type of event returned by GetEvent() may be any of those listed in TEventCode. 
   1.431 +To access the data within an event, the event should be converted to the appropriate 
   1.432 +type, using functions provided by the TWsEvent class. TWsEvent also provides 
   1.433 +a function to find out the type of the event.
   1.434 +
   1.435 +Notes:
   1.436 +
   1.437 +It is possible that the returned event is of type EEventNull. Clients should 
   1.438 +normally ignore these events.
   1.439 +
   1.440 +This function should only be called in response to notification that an event 
   1.441 +has occurred, otherwise the client will be panicked.
   1.442 +
   1.443 +This function would normally be called in the RunL() function of an active 
   1.444 +object which completes with the EventReady() function's request status.
   1.445 +
   1.446 +This function always causes a flush of the window server buffer.
   1.447 +
   1.448 +@param aEvent On return, contains the event that occurred 
   1.449 +@see TEventCode
   1.450 +@see EventReady() */
   1.451 +	{
   1.452 +	TPckgBuf<TWsEvent> event;
   1.453 +	WriteReplyP(&event,EWsClOpGetEvent);
   1.454 +	aEvent=event();
   1.455 +	}
   1.456 +
   1.457 +EXPORT_C void RWsSession::PurgePointerEvents()
   1.458 +/** Removes all pointer events waiting to be delivered to this session. 
   1.459 +
   1.460 +The events are removed from the event queue without being processed. This 
   1.461 +might occur, for example, at application startup. */
   1.462 +	{
   1.463 +	Write(EWsClOpPurgePointerEvents);
   1.464 +	}
   1.465 +
   1.466 +EXPORT_C void RWsSession::GetRedraw(TWsRedrawEvent &aEvent)
   1.467 +/** Gets the redraw event from the session.
   1.468 +
   1.469 +This function is similar to GetEvent(), except that the event is returned 
   1.470 +as a TWsRedrawEvent, and hence there is no need to convert it from a TWsEvent.
   1.471 +
   1.472 +The function should only be called after notification that a redraw is waiting.
   1.473 +
   1.474 +It always causes a flush of the window server buffer.
   1.475 +
   1.476 +@param aEvent On return, contains the redraw event that occurred 
   1.477 +@see RedrawReady()
   1.478 +@see GetEvent()
   1.479 +@see CActive */
   1.480 +	{
   1.481 +	TPckgBuf<TWsRedrawEvent> redraw;
   1.482 +	WriteReplyP(&redraw,EWsClOpGetRedraw);
   1.483 +	aEvent=redraw();
   1.484 +	}
   1.485 +
   1.486 +EXPORT_C void RWsSession::GetPriorityKey(TWsPriorityKeyEvent &aEvent) const
   1.487 +/** Gets the completed priority key event from the window server session.
   1.488 +
   1.489 +Priority key events are typically used for providing "Abort" or "Escape" keys 
   1.490 +for an application.
   1.491 +
   1.492 +This function is similar to GetEvent(), except that it returns a TWsPriorityKeyEvent 
   1.493 +instead of a TWsEvent.
   1.494 +
   1.495 +Note: this should only be called after notification that a priority key event has 
   1.496 +occurred.
   1.497 +
   1.498 +This function always causes a flush of the window server buffer.
   1.499 +
   1.500 +@param aEvent On return, contains the priority key event that occurred. 
   1.501 +@see PriorityKeyReady()
   1.502 +@see PriorityKeyReadyCancel() */
   1.503 +	{
   1.504 +	TPckgBuf<TWsPriorityKeyEvent> abortEvent;
   1.505 +	WriteReplyP(&abortEvent,EWsClOpGetPriorityKey);
   1.506 +	aEvent=abortEvent();
   1.507 +	}
   1.508 +
   1.509 +EXPORT_C void RWsSession::EventReadyCancel()
   1.510 +/** Cancels a request for standard events from the window server.
   1.511 +
   1.512 +This request was made using EventReady().
   1.513 +
   1.514 +The client application will typically use an active object to handle standard 
   1.515 +events, and this function should be called from the active object's DoCancel() 
   1.516 +function.
   1.517 +
   1.518 +This function always causes a flush of the window server buffer.
   1.519 +
   1.520 +@see EventReady() */
   1.521 +	{
   1.522 +	if (iWsHandle)
   1.523 +		WriteReply(EWsClOpEventReadyCancel);
   1.524 +	}
   1.525 +
   1.526 +EXPORT_C void RWsSession::RedrawReadyCancel()
   1.527 +/** Cancels a redraw event request. 
   1.528 +
   1.529 +If active objects are used, this function should be called from the active 
   1.530 +object's DoCancel() function.
   1.531 +
   1.532 +This function always causes a flush of the window server buffer.
   1.533 +
   1.534 +@see RedrawReady() */
   1.535 +	{
   1.536 +	if (iWsHandle)
   1.537 +		WriteReply(EWsClOpRedrawReadyCancel);
   1.538 +	}
   1.539 +
   1.540 +EXPORT_C void RWsSession::PriorityKeyReadyCancel()
   1.541 +/** Cancels a priority key event request.
   1.542 +
   1.543 +If active objects are used, this function should be called from the active 
   1.544 +object's DoCancel() function.
   1.545 +
   1.546 +This function always causes a flush of the window server buffer.
   1.547 +
   1.548 +@see PriorityKeyReady()
   1.549 +@see CActive */
   1.550 +	{
   1.551 +	if (iWsHandle)
   1.552 +		WriteReply(EWsClOpPriorityKeyReadyCancel);
   1.553 +	}
   1.554 +
   1.555 +EXPORT_C void RWsSession::Flush()
   1.556 +/** Sends all pending commands in the buffer to the window server. 
   1.557 +
   1.558 +Delivering a command to the window server requires a context switch, and so 
   1.559 +it is more efficient to deliver several commands in one go. Hence all client 
   1.560 +commands are normally first placed into a buffer for delivery to the window 
   1.561 +server. 
   1.562 +
   1.563 +The buffer is delivered when it gets full, or when a command that returns a value 
   1.564 +is called (there are a few exceptions to this), or when this function is called.
   1.565 +
   1.566 +Note: this function is called when a prompt response is required from the window 
   1.567 +server, e.g. after doing some drawing.
   1.568 +
   1.569 +@see RWsSession::SetAutoFlush()
   1.570 +@see RWsSession::SetBufferSizeL()
   1.571 +@see RWsSession::SetMaxBufferSizeL()
   1.572 +*/
   1.573 +	{
   1.574 +	if (iBuffer)
   1.575 +		iBuffer->Flush(NULL,ETrue);
   1.576 +	}
   1.577 +
   1.578 +EXPORT_C TBool RWsSession::SetAutoFlush(TBool aState)
   1.579 +/** Sets a session's auto-flush state. 
   1.580 +
   1.581 +If auto-flush is set to ETrue, the window server buffer is flushed immediately 
   1.582 +anything is put into it, instead of waiting until it becomes full. This setting 
   1.583 +is normally used only in a debugging environment. 
   1.584 +
   1.585 +If the auto-flush state is EFalse, the window server buffer is flushed normally.
   1.586 +
   1.587 +@param aState ETrue to set auto-flushing on, EFalse to disable auto-flushing. 
   1.588 +@return Previous auto-flush state
   1.589 +
   1.590 +@see RWsSession::Flush()
   1.591 +@see RWsSession::SetBufferSizeL()
   1.592 +@see RWsSession::SetMaxBufferSizeL()
   1.593 +*/
   1.594 +	{
   1.595 +	return(iBuffer->SetAutoFlush(aState));
   1.596 +	}
   1.597 +
   1.598 +EXPORT_C TInt RWsSession::NumWindowGroups() const
   1.599 +/** Gets the total number of window groups currently running in the window server. 
   1.600 +
   1.601 +This includes all the groups running in all sessions.
   1.602 +
   1.603 +This function always causes a flush of the window server buffer.
   1.604 +
   1.605 +@return Total number of window groups running in the server */
   1.606 +	{
   1.607 +	return(WriteReply(EWsClOpNumWindowGroupsAllPriorities));
   1.608 +	}
   1.609 +
   1.610 +EXPORT_C TInt RWsSession::NumWindowGroups(TInt aPriority) const
   1.611 +/** Gets the number of window groups of a given window group priority running in 
   1.612 +all sessions in the window server.
   1.613 +
   1.614 +This function always causes a flush of the window server buffer.
   1.615 +
   1.616 +@param aPriority Window group priority 
   1.617 +@return Number of window groups of priority aPriority */
   1.618 +	{
   1.619 +	return(WriteReplyInt(aPriority,EWsClOpNumWindowGroups));
   1.620 +	}
   1.621 +
   1.622 +EXPORT_C TInt RWsSession::NumWindowGroups(TInt aScreenNumber,TInt aPriority) const
   1.623 +/** Gets the number of window groups of a given window group priority running on a specified screen
   1.624 +
   1.625 +This function always causes a flush of the window server buffer.
   1.626 +
   1.627 +@param aScreenNumber specifies the screen. 
   1.628 +@param aPriority Window group priority. EAllPriorities is the enum for all priorities 
   1.629 +@return Number of window groups of priority aPriority on the specified screen */
   1.630 +	{
   1.631 +	TWsClCmdNumWindowGroups params;
   1.632 +	params.screenNumber = aScreenNumber;
   1.633 +	params.priority = aPriority;
   1.634 +	return(WriteReply(&params,sizeof(params),EWsClOpNumWindowGroupsOnScreen));	
   1.635 +	}
   1.636 +
   1.637 +TInt RWsSession::doWindowGroupList(TInt aScreenNumber, TInt aPriority, CArrayFixFlat<TInt>* aWindowList, TInt aNumOpcode, TInt aListOpcode) const
   1.638 +/** Gets the id of window groups of specified priority running on a specified screen.
   1.639 +
   1.640 +This function always causes a flush of the window server buffer.
   1.641 +
   1.642 +@param aScreenNumber specifies the screen.
   1.643 +@param aPriority Window group priority 
   1.644 +@param aWindowList List of identifiers
   1.645 +@return KErrNone if successful, otherwise another of the system-wide error 
   1.646 +codes.*/
   1.647 +	{
   1.648 +	TWsClCmdWindowGroupList params;
   1.649 +	params.priority = aPriority;		
   1.650 +	params.screenNumber = aScreenNumber;
   1.651 +	if(aScreenNumber!=KDummyScreenNumber)
   1.652 +		{
   1.653 +		TWsClCmdNumWindowGroups numWinGrp;
   1.654 +		numWinGrp.screenNumber = aScreenNumber;
   1.655 +		numWinGrp.priority = aPriority;	
   1.656 +		params.count=WriteReply(&numWinGrp,sizeof(numWinGrp),aNumOpcode);
   1.657 +		}
   1.658 +	else
   1.659 +		params.count=WriteReplyInt(aPriority,aNumOpcode);
   1.660 +
   1.661 +	TRAPD(err,aWindowList->ResizeL(params.count));
   1.662 +	if (err!=KErrNone || params.count==0)
   1.663 +		return(err);
   1.664 +	TPtr8 listPtr(reinterpret_cast<TUint8*>(&(*aWindowList)[0]),params.count*sizeof((*aWindowList)[0]));
   1.665 +	TInt actualCount=WriteReplyP(&params, sizeof(params), &listPtr, aListOpcode);
   1.666 +	err=KErrNone;
   1.667 +	if (actualCount<0)
   1.668 +		{
   1.669 +		err=actualCount;
   1.670 +		actualCount=0;
   1.671 +		}
   1.672 +	if (actualCount<params.count)
   1.673 +		aWindowList->ResizeL(actualCount);	// Can't fail, only shrinking it
   1.674 +	return(err);
   1.675 +	}
   1.676 +
   1.677 +TInt RWsSession::doWindowGroupList(TInt aPriority, RArray<TWindowGroupChainInfo>* aWindowListCh, TInt aNumOpcode, TInt aListOpcode) const
   1.678 +/** Gets the id of window groups and id of its parent window group of specified priority running in 
   1.679 +all sessions in the window server.
   1.680 +
   1.681 +This function always causes a flush of the window server buffer.
   1.682 +
   1.683 +@param aPriority Window group priority 
   1.684 +@param aWindowList List of identifiers
   1.685 +@return KErrNone if successful else KErrNoMemory if there is insufficient memory to create the array. 
   1.686 +This function will panic if aWindowListCh is Null.*/
   1.687 +	{
   1.688 +	__ASSERT_ALWAYS(aWindowListCh,Panic(EW32PanicNullArray));
   1.689 +	TWsClCmdWindowGroupList params;
   1.690 +	params.priority=aPriority;
   1.691 +	params.count=WriteReplyInt(aPriority,aNumOpcode);
   1.692 +	aWindowListCh->Reset();
   1.693 +	TUint8* WindowList=static_cast<TUint8*>(User::Alloc(params.count*sizeof(TWindowGroupChainInfo)));
   1.694 +	if(WindowList==NULL)
   1.695 +		{
   1.696 +		return KErrNoMemory;
   1.697 +		}	
   1.698 +	TPtr8 listPtr(WindowList,params.count*sizeof(TWindowGroupChainInfo));
   1.699 +	WriteReplyP(&params, sizeof(params), &listPtr, aListOpcode);
   1.700 +	new(aWindowListCh) RArray<TWindowGroupChainInfo>(sizeof(TWindowGroupChainInfo),(TWindowGroupChainInfo*)WindowList,params.count);
   1.701 +	return KErrNone;
   1.702 +	}
   1.703 +
   1.704 +EXPORT_C TInt RWsSession::WindowGroupList(CArrayFixFlat<TInt>* aWindowList) const
   1.705 +/** Gets a list of identifiers of all window groups in all window server sessions.
   1.706 +
   1.707 +An array buffer must be created to store the resultant list.
   1.708 +
   1.709 +This function always causes a flush of the window server buffer.
   1.710 +
   1.711 +@param aWindowList List of identifiers of all window groups in the server.
   1.712 +@return KErrNone if successful, otherwise another of the system-wide error 
   1.713 +codes. */
   1.714 +	{
   1.715 +	return(doWindowGroupList(KDummyScreenNumber,0,aWindowList,EWsClOpNumWindowGroupsAllPriorities,EWsClOpWindowGroupListAllPriorities));
   1.716 +	}
   1.717 +
   1.718 +EXPORT_C TInt RWsSession::WindowGroupList(CArrayFixFlat<TInt>* aWindowList,TInt aScreenNumber,TInt aPriority) const
   1.719 +/** Lists the number of window groups of a given window group priority running on a specified screen.
   1.720 +
   1.721 +This function is the same as WindowGroupList() described above, but allows 
   1.722 +the application to restrict the list of window groups to those of a particular 
   1.723 +window group priority.
   1.724 +
   1.725 +This function always causes a flush of the window server buffer.
   1.726 +
   1.727 +@param aScreenNumber specifies the screen
   1.728 +@param aPriority Window group priority . Enum for all priorities is EAllPriorities
   1.729 +@param aWindowList List of identifiers of all window groups on the specified screen with the given priority 
   1.730 +aPriority.
   1.731 +@return KErrNone if successful, otherwise another of the system-wide error 
   1.732 +codes. */
   1.733 +	{
   1.734 +	return(doWindowGroupList(aScreenNumber,aPriority,aWindowList,EWsClOpNumWindowGroupsOnScreen,EWsClOpWindowGroupList));	
   1.735 +	}
   1.736 +
   1.737 +EXPORT_C TInt RWsSession::WindowGroupList(RArray<TWindowGroupChainInfo>* aWindowList) const
   1.738 +/** Gets a list of identifier of window group and parent identifier of window group of
   1.739 + all window groups in all window server sessions.
   1.740 +
   1.741 +An array buffer must be created to store the resultant list.
   1.742 +
   1.743 +This function always causes a flush of the window server buffer.
   1.744 +
   1.745 +@param aWindowList List of identifiers of all window groups in the server.
   1.746 +@return KErrNone if successful otherwise KErrNoMemory if there is insufficient memory to create the array,
   1.747 +Panics if aWindowList is NULL. */
   1.748 +	{
   1.749 +	return(doWindowGroupList(0,aWindowList,EWsClOpNumWindowGroupsAllPriorities,EWsClOpWindowGroupListAndChainAllPriorities));
   1.750 +	}
   1.751 +
   1.752 +EXPORT_C TInt RWsSession::WindowGroupList(TInt aPriority,CArrayFixFlat<TInt>* aWindowList) const
   1.753 +/** Lists the number of window groups of a given window group priority running 
   1.754 +in all window server sessions.
   1.755 +
   1.756 +This function is the same as WindowGroupList() described above, but allows 
   1.757 +the application to restrict the list of window groups to those of a particular 
   1.758 +window group priority.
   1.759 +
   1.760 +This function always causes a flush of the window server buffer.
   1.761 +
   1.762 +@param aPriority Window group priority 
   1.763 +@param aWindowList List of identifiers of all window groups in the server of priority 
   1.764 +aPriority.
   1.765 +@return KErrNone if successful, otherwise another of the system-wide error 
   1.766 +codes. */
   1.767 +	{
   1.768 +	return(doWindowGroupList(KDummyScreenNumber,aPriority,aWindowList,EWsClOpNumWindowGroups,EWsClOpWindowGroupList));
   1.769 +	}
   1.770 +
   1.771 +EXPORT_C TInt RWsSession::WindowGroupList(TInt aPriority, RArray<TWindowGroupChainInfo>* aWindowList) const
   1.772 +/** Lists the number of window groups of a given window group priority running 
   1.773 +in all window server sessions.
   1.774 +
   1.775 +This function is the same as WindowGroupList() described above, but allows 
   1.776 +the application to restrict the list of window groups to those of a particular 
   1.777 +window group priority.
   1.778 +
   1.779 +This function always causes a flush of the window server buffer.
   1.780 +
   1.781 +@param aPriority Window group priority 
   1.782 +@param aWindowList List of identifiers of all window groups in the server of priority 
   1.783 +aPriority.
   1.784 +@return KErrNone if successful otherwise KErrNoMemory if there is insufficient memory to create the array, 
   1.785 +Panics if aWindowList is NULL. */	
   1.786 +	{
   1.787 +	return(doWindowGroupList(aPriority,aWindowList,EWsClOpNumWindowGroups,EWsClOpWindowGroupListAndChain));
   1.788 +	}
   1.789 +
   1.790 +EXPORT_C TInt RWsSession::GetDefaultOwningWindow() const
   1.791 +/** Gets the identifier of the current default owning window group.
   1.792 +
   1.793 +This function always causes a flush of the window server buffer.
   1.794 +
   1.795 +@return Identifier of current default owning window group. Returns 0 if there 
   1.796 +isn't one. */
   1.797 +	{
   1.798 +	return GetDefaultOwningWindow(KDummyScreenNumber);
   1.799 +	}
   1.800 +
   1.801 +EXPORT_C TInt RWsSession::GetDefaultOwningWindow(TInt aScreenNumber) const
   1.802 +/** Gets the identifier of the current default owning window group on a specified screen.
   1.803 +
   1.804 +This function always causes a flush of the window server buffer.
   1.805 +
   1.806 +@param aScreenNumber specifies the screen.
   1.807 +@return Identifier of current default owning window group on the specified screen. Returns 0 if there 
   1.808 +isn't one. */
   1.809 +	{
   1.810 +	return(WriteReplyInt(aScreenNumber,EWsClOpGetDefaultOwningWindow));	
   1.811 +	}
   1.812 +
   1.813 +EXPORT_C TInt RWsSession::GetFocusWindowGroup() const
   1.814 +/** Gets the identifier of the window group that currently has the keyboard focus.
   1.815 +
   1.816 +Note: this might not necessarily be the front-most window group, as window groups 
   1.817 +can disable keyboard focus.
   1.818 +
   1.819 +This function always causes a flush of the window server buffer.
   1.820 +
   1.821 +@return Identifier of window group with keyboard focus. */
   1.822 +	{
   1.823 +	return GetFocusWindowGroup(KDummyScreenNumber);
   1.824 +	}
   1.825 +
   1.826 +EXPORT_C TInt RWsSession::GetFocusWindowGroup(TInt aScreenNumber) const
   1.827 +/** Gets the identifier of the window group on a specified screen that currently has the keyboard focus.
   1.828 +
   1.829 +Note: this might not necessarily be the front-most window group, as window groups 
   1.830 +can disable keyboard focus.
   1.831 +
   1.832 +This function always causes a flush of the window server buffer.
   1.833 +
   1.834 +@param aScreenNumber specifies the screen.
   1.835 +@return Identifier of window group with keyboard focus. */
   1.836 +	{
   1.837 +	return WriteReplyInt(aScreenNumber,EWsClOpGetFocusWindowGroup);	
   1.838 +	}
   1.839 +
   1.840 +EXPORT_C TInt RWsSession::SetWindowGroupOrdinalPosition(TInt aIdentifier, TInt aPosition)
   1.841 +/** Sets the ordinal position of a window group.
   1.842 +
   1.843 +This function allows the caller to change the ordinal position of an existing 
   1.844 +window group. It would typically be used by a shell application.
   1.845 +
   1.846 +This function always causes a flush of the window server buffer.
   1.847 +
   1.848 +@param aIdentifier The window group. 
   1.849 +@param aPosition Ordinal position for the window group. 
   1.850 +@return KErrNone if successful, otherwise another of the system-wide error 
   1.851 +codes. */
   1.852 +	{
   1.853 +	TWsClCmdSetWindowGroupOrdinalPosition params(aIdentifier,aPosition);
   1.854 +	return(WriteReply(&params, sizeof(params),EWsClOpSetWindowGroupOrdinalPosition));
   1.855 +	}
   1.856 +
   1.857 +EXPORT_C TInt RWsSession::GetWindowGroupClientThreadId(TInt aIdentifier, TThreadId &aThreadId) const
   1.858 +/** Gets the thread ID of the client that owns the window group specified by the 
   1.859 +window group identifier.
   1.860 +
   1.861 +This function always causes a flush of the window server buffer.
   1.862 +
   1.863 +@param aIdentifier The window group identifier. 
   1.864 +@param aThreadId On return, contains the thread ID. 
   1.865 +@return KErrNone if successful, otherwise another of the system-wide error 
   1.866 +codes. */
   1.867 +	{
   1.868 +	TPtr8 ptr(reinterpret_cast<TUint8*>(&aThreadId),sizeof(aThreadId));
   1.869 +	return(WriteReplyIntP(aIdentifier,&ptr,EWsClOpGetWindowGroupClientThreadId));
   1.870 +	}
   1.871 +
   1.872 +EXPORT_C TInt RWsSession::GetWindowGroupHandle(TInt aIdentifier) const
   1.873 +/** Gets the handle of the window specified by the window group identifier. 
   1.874 +
   1.875 +This is the handle that was passed as an argument to RWindowGroup::Construct().
   1.876 +
   1.877 +This function always causes a flush of the window server buffer.
   1.878 +
   1.879 +@param aIdentifier The window group identifier.
   1.880 +@return Handle of the window group */
   1.881 +	{
   1.882 +	return(WriteReplyInt(aIdentifier,EWsClOpGetWindowGroupHandle));
   1.883 +	}
   1.884 +
   1.885 +EXPORT_C TInt RWsSession::GetWindowGroupOrdinalPriority(TInt aIdentifier) const
   1.886 +/** Gets a window group's priority.
   1.887 +
   1.888 +This function always causes a flush of the window server buffer.
   1.889 +
   1.890 +@param aIdentifier The window group identifier. 
   1.891 +@return The window group priority. */
   1.892 +	{
   1.893 +	return(WriteReplyInt(aIdentifier,EWsClOpGetWindowGroupOrdinalPriority));
   1.894 +	}
   1.895 +
   1.896 +EXPORT_C TInt RWsSession::SendEventToWindowGroup(TInt aIdentifier, const TWsEvent &aEvent)
   1.897 +/** Sends an event to a window group.
   1.898 +
   1.899 +This function always causes a flush of the window server buffer.
   1.900 +
   1.901 +@param aIdentifier Window group identifier.
   1.902 +@param aEvent Event to send to the window group.
   1.903 +@return KErrNone if successful, KErrPermissionDenied if the client does not have 
   1.904 +the required capability, KErrNoMemory if there is not enough room to add the 
   1.905 +event to the event queue and otherwise another of the system-wide error codes.
   1.906 +@capability SwEvent Required when aEvent.Type() < EEventUser unless the event 
   1.907 +is for a window group owned by this session.
   1.908 +
   1.909 +@deprecated */
   1.910 +	{
   1.911 +	TWsClCmdSendEventToWindowGroup params(aIdentifier,aEvent);
   1.912 +	return(WriteReply(&params, sizeof(params),EWsClOpSendEventToWindowGroup));
   1.913 +	}
   1.914 +
   1.915 +EXPORT_C TInt RWsSession::SendEventToAllWindowGroups(const TWsEvent &aEvent)
   1.916 +/** Sends the specified event to all existing window groups.
   1.917 +
   1.918 +This function always causes a flush of the window server buffer.
   1.919 +
   1.920 +@param aEvent The event to be sent to all window groups. 
   1.921 +@return KErrNone if successful, KErrPermissionDenied if the client does not have 
   1.922 +the required capability, KErrNoMemory if there is not enough room to add the 
   1.923 +event to all the required event queues (although it may have been added to some 
   1.924 +of them) and otherwise another of the system-wide error codes.
   1.925 +@capability SwEvent Required when aEvent.Type() < EEventUser
   1.926 +
   1.927 +@deprecated */
   1.928 +	{
   1.929 +	TWsClCmdSendEventToWindowGroup params(0,aEvent);
   1.930 +	return(WriteReply(&params, sizeof(params),EWsClOpSendEventToAllWindowGroup));
   1.931 +	}
   1.932 +
   1.933 +EXPORT_C TInt RWsSession::SendEventToAllWindowGroups(TInt aPriority, const TWsEvent &aEvent)
   1.934 +/** Sends the specified event to all window groups with the specified priority.
   1.935 +
   1.936 +This function always causes a flush of the window server buffer.
   1.937 +
   1.938 +@param aPriority The priority which window groups must have to be sent the 
   1.939 +message.
   1.940 +@param aEvent The event to be sent to the specified window groups.
   1.941 +@return KErrNone if successful, KErrPermissionDenied if the client does not have 
   1.942 +the required capability, KErrNoMemory if there is not enough room to add the 
   1.943 +event to all the required event queues (although it may have been added to some 
   1.944 +of them) and otherwise another of the system-wide error codes.
   1.945 +@capability SwEvent Required when aEvent.Type() < EEventUser
   1.946 +
   1.947 +@deprecated  */
   1.948 +	{
   1.949 +	TWsClCmdSendEventToWindowGroup params(aPriority,aEvent);
   1.950 +	return(WriteReply(&params, sizeof(params),EWsClOpSendEventToAllWindowGroupPriority));
   1.951 +	}
   1.952 +
   1.953 +EXPORT_C TInt RWsSession::SendEventToOneWindowGroupsPerClient(const TWsEvent &aEvent)
   1.954 +/** This function always causes a flush of the window server buffer.
   1.955 +@capability SwEvent Required when aEvent.Type() < EEventUser 
   1.956 +
   1.957 +@deprecated  */
   1.958 +	{
   1.959 +	TWsClCmdSendEventToWindowGroup params(0,aEvent);
   1.960 +	return(WriteReply(&params, sizeof(params),EWsClOpSendEventToOneWindowGroupPerClient));
   1.961 +	}
   1.962 +
   1.963 +EXPORT_C TInt RWsSession::GetWindowGroupNameFromIdentifier(TInt aIdentifier, TDes &aWindowName) const
   1.964 +/** Gets the name of a window group from its identifier. 
   1.965 +
   1.966 +Using the list of identifiers returned by WindowGroupList(), it is possible 
   1.967 +to get the names of all window groups in the system. Note that window names 
   1.968 +are a zero length string by default.
   1.969 +
   1.970 +Note that the window group name must have been previously set using RWindowGroup::SetName() 
   1.971 +to contain a meaningful value.
   1.972 +
   1.973 +This function always causes a flush of the window server buffer.
   1.974 +
   1.975 +@param aIdentifier The identifier of the window group whose name is to be 
   1.976 +inquired.
   1.977 +@param aWindowName On return, contains the window group name.
   1.978 +@return KErrNone if successful, otherwise another of the system-wide error 
   1.979 +codes. */
   1.980 +	{
   1.981 +	TWsClCmdGetWindowGroupNameFromIdentifier params(aIdentifier,aWindowName.MaxLength());
   1.982 +	return(WriteReplyP(&params,sizeof(params),&aWindowName,EWsClOpGetWindowGroupNameFromIdentifier));
   1.983 +	}
   1.984 +
   1.985 +EXPORT_C TInt RWsSession::FindWindowGroupIdentifier(TInt aPreviousIdentifier,const TDesC& aMatch,TInt aOffset) const
   1.986 +/** Gets all window groups whose names match a given string, which can contain 
   1.987 +wildcards.
   1.988 +
   1.989 +An example use of this function might be to find all the currently 
   1.990 +running instances of a particular application, assuming that the window group 
   1.991 +name contains the application name. An optional argument, aOffset, specifies 
   1.992 +the number of characters to be ignored at the beginning of the window group 
   1.993 +name. As several window group names may match the given string, and the function 
   1.994 +can return only one at a time, there is an argument, aPreviousIdentifier, 
   1.995 +which gives the identifier for the previous match that was returned. In other 
   1.996 +words, it means, "get me the next match after this one." The first time the 
   1.997 +function is called, give 0 as the previous identifier.
   1.998 +
   1.999 +Matching is done using TDesC::MatchF(), which does a folded match. Wildcards 
  1.1000 +'*' and '?' can be used to denote one or more characters and exactly one character, 
  1.1001 +respectively. Windows are searched in front to back order.
  1.1002 +
  1.1003 +This function always causes a flush of the window server buffer.
  1.1004 +
  1.1005 +@param aPreviousIdentifier Identifier of the last window group returned. If 
  1.1006 +the value passed is not a valid identifier, the function returns KErrNotFound. 
  1.1007 +@param aMatch String to match window group name against: may contain wildcards 
  1.1008 +@param aOffset The first aOffset characters of the window group name are ignored 
  1.1009 +when doing the match.
  1.1010 +@return The next window group, after the one identified by aPreviousIdentifier, 
  1.1011 +whose name matches aMatch. KErrNotFound if no window group matched or aPreviousIdentifier 
  1.1012 +was not a valid identifier. */
  1.1013 +	{
  1.1014 +	TWsClCmdFindWindowGroupIdentifier params(aPreviousIdentifier,aOffset, aMatch.Length());
  1.1015 +	return(WriteReply(&params,sizeof(params),aMatch.Ptr(),aMatch.Size(),EWsClOpFindWindowGroupIdentifier));
  1.1016 +	}
  1.1017 +
  1.1018 +EXPORT_C TInt RWsSession::FindWindowGroupIdentifier(TInt aPreviousIdentifier,TThreadId aThreadId) const
  1.1019 +/** Gets the identifiers of window groups belonging to a client which is owned 
  1.1020 +by a thread with the specified thread ID.
  1.1021 +
  1.1022 +The thread may own more than one window group, so the identifier returned 
  1.1023 +is the one after aPreviousIdentifier. The first time the function is called, 
  1.1024 +use 0 for the previous identifier.
  1.1025 +
  1.1026 +This function always causes a flush of the window server buffer.
  1.1027 +
  1.1028 +@param aPreviousIdentifier Identifier returned by previous call 
  1.1029 +@param aThreadId Thread owning the window group or groups. 
  1.1030 +@return Next window group identifier after the one identified by aPreviousIdentifier */
  1.1031 +	{
  1.1032 +	TWsClCmdFindWindowGroupIdentifierThread params(aPreviousIdentifier, aThreadId);
  1.1033 +	return(WriteReply(&params,sizeof(params),EWsClOpFindWindowGroupIdentifierThread));
  1.1034 +	}
  1.1035 +
  1.1036 +EXPORT_C TInt RWsSession::SendMessageToWindowGroup(TInt aIdentifier, TUid aUid, const TDesC8 &aParams)
  1.1037 +/** Sends a message to a window group. 
  1.1038 +
  1.1039 +The window group will then receive an event of type EEventMessageReady notifying 
  1.1040 +it that a message has been received. The window group can belong to this or 
  1.1041 +another session.
  1.1042 +
  1.1043 +In order to receive messages sent using this function you will need to implement 
  1.1044 +the MCoeMessageObserver interface which is defined in the UI Control Framework API.
  1.1045 +
  1.1046 +This function always causes a flush of the window server buffer.
  1.1047 +
  1.1048 +@param aIdentifier The identifier of the window group to receive the message. 
  1.1049 +@param aUid A UID which uniquely identifies the session sending the message. 
  1.1050 +@param aParams The message data. An unlimited amount of data can be passed 
  1.1051 +in this argument. 
  1.1052 +@return KErrNone if successful, otherwise another of the system-wide error 
  1.1053 +codes. 
  1.1054 +@see MCoeMessageObserver 
  1.1055 +
  1.1056 +@deprecated  */
  1.1057 +	{
  1.1058 +	TWsClCmdSendMessageToWindowGroup params(aIdentifier, aUid, aParams.Length(),&aParams);
  1.1059 +	return(WriteReplyByProvidingRemoteReadAccess(&params,sizeof(params),&aParams,EWsClOpSendMessageToWindowGroup));
  1.1060 +	}
  1.1061 +
  1.1062 +EXPORT_C TInt RWsSession::SendMessageToAllWindowGroups(TUid aUid, const TDesC8& aParams)
  1.1063 +/** Sends a message to all window groups.
  1.1064 +
  1.1065 +In order to receive messages sent using this function you will need to implement 
  1.1066 +the MCoeMessageObserver interface which is defined in the UI Control Framework 
  1.1067 +API.
  1.1068 +
  1.1069 +This function always causes a flush of the window server buffer.
  1.1070 +
  1.1071 +@param aUid A UID which uniquely identifies the session sending the message. 
  1.1072 +@param aParams The message data. An unlimited amount of data can be passed 
  1.1073 +in this argument. 
  1.1074 +@return KErrNone if successful, otherwise another of the system-wide error 
  1.1075 +codes. 
  1.1076 +
  1.1077 +@deprecated  */
  1.1078 +	{
  1.1079 +	TWsClCmdSendMessageToWindowGroup params(0, aUid, aParams.Length(),&aParams);
  1.1080 +	return(WriteReplyByProvidingRemoteReadAccess(&params,sizeof(params),&aParams,EWsClOpSendMessageToAllWindowGroups));
  1.1081 +	}
  1.1082 +
  1.1083 +EXPORT_C TInt RWsSession::SendMessageToAllWindowGroups(TInt aPriority, TUid aUid, const TDesC8& aParams)
  1.1084 +/** Sends a message to all window groups with the specified priority.
  1.1085 +
  1.1086 +In order to receive messages sent using this function you will need to implement 
  1.1087 +the MCoeMessageObserver interface which is defined in the UI Control Framework 
  1.1088 +API.
  1.1089 +
  1.1090 +This function always causes a flush of the window server buffer.
  1.1091 +
  1.1092 +@param aPriority The priority which window groups must have to be sent the 
  1.1093 +message. 
  1.1094 +@param aUid A UID which uniquely identifies the session sending the message. 
  1.1095 +@param aParams The message data. An unlimited amount of data can be passed 
  1.1096 +in this argument. 
  1.1097 +@return KErrNone if successful, otherwise another of the system-wide error 
  1.1098 +codes. 
  1.1099 +
  1.1100 +@deprecated  */
  1.1101 +	{
  1.1102 +	TWsClCmdSendMessageToWindowGroup params(aPriority, aUid, aParams.Length(),&aParams);
  1.1103 +	return(WriteReplyByProvidingRemoteReadAccess(&params,sizeof(params),&aParams,EWsClOpSendMessageToAllWindowGroupsPriority));
  1.1104 +	}
  1.1105 +
  1.1106 +
  1.1107 +/** Called by the client in response to an EEventMessageReady event to receive the message data.
  1.1108 +
  1.1109 +This function always causes a flush of the window server buffer.
  1.1110 +
  1.1111 +@param aUid A UID which uniquely identifies the session sending the message.
  1.1112 +@param aParams The message data. An unlimited amount of data can be passed 
  1.1113 +in this argument.
  1.1114 +@param aMessageEvent The event sent from the server to the client to identify the message.
  1.1115 +@return KErrNone if successful, KErrNoMemory if there is insufficient memory for
  1.1116 +the message data, otherwise another of the system-wide error codes.
  1.1117 +*/
  1.1118 +EXPORT_C TInt RWsSession::FetchMessage(TUid& aUid, TPtr8& aParams, const TWsEvent& aMessageEvent) const
  1.1119 +	{
  1.1120 +	const SEventMessageReady& eventMessageReady=*(SEventMessageReady*)aMessageEvent.EventData();
  1.1121 +	TUint8* ptr=(TUint8*)User::Alloc(eventMessageReady.iMessageParametersSize);
  1.1122 +	if (ptr==NULL)
  1.1123 +		{
  1.1124 +		aParams.Set(NULL, 0, 0);
  1.1125 +		return KErrNoMemory;
  1.1126 +		}
  1.1127 +	aUid=eventMessageReady.iMessageUid;
  1.1128 +	aParams.Set(ptr, eventMessageReady.iMessageParametersSize, eventMessageReady.iMessageParametersSize);
  1.1129 +	TWsClCmdFetchMessage outGoingParams(eventMessageReady.iWindowGroupIdentifier);
  1.1130 +	const TInt error=WriteReplyP(&outGoingParams, sizeof(outGoingParams), &aParams, EWsClOpFetchMessage); // must be called even if eventMessageReady.iMessageParametersSize==0
  1.1131 +	if (error!=KErrNone)
  1.1132 +		{
  1.1133 +		delete ptr;
  1.1134 +		aParams.Set(NULL, 0, 0);
  1.1135 +		}
  1.1136 +	return error;
  1.1137 +	}
  1.1138 +
  1.1139 +EXPORT_C TInt RWsSession::SetKeyboardRepeatRate(const TTimeIntervalMicroSeconds32 &aInitialTime, const TTimeIntervalMicroSeconds32 &aTime)
  1.1140 +/** Sets the system-wide keyboard repeat rate. 
  1.1141 +
  1.1142 +This is the rate at which keyboard events are generated when a key is held 
  1.1143 +down.
  1.1144 +
  1.1145 +The default settings for the keyboard repeat rate are 0.3 seconds for the 
  1.1146 +initial delay, and 0.1 seconds for the interval between subsequent repeats. 
  1.1147 +However, since the settings are system-wide, these will not necessarily be 
  1.1148 +the current settings when an application is launched: the settings may have 
  1.1149 +been over-ridden by another module.
  1.1150 +
  1.1151 +This function always causes a flush of the window server buffer.
  1.1152 +
  1.1153 +@param aInitialTime Time before first repeat key event 
  1.1154 +@param aTime Time between subsequent repeat key events 
  1.1155 +@return KErrNone if successful, otherwise another of the system-wide error 
  1.1156 +codes. 
  1.1157 +@see GetKeyboardRepeatRate()
  1.1158 +@capability WriteDeviceData */
  1.1159 +	{
  1.1160 +	TWsClCmdSetKeyboardRepeatRate repeat(aInitialTime,aTime);
  1.1161 +	return(WriteReply(&repeat,sizeof(repeat),EWsClOpSetKeyboardRepeatRate));
  1.1162 +	}
  1.1163 +
  1.1164 +EXPORT_C void RWsSession::GetKeyboardRepeatRate(TTimeIntervalMicroSeconds32 &aInitialTime, TTimeIntervalMicroSeconds32 &aTime) const
  1.1165 +/** Gets the current system-wide settings for the keyboard repeat rate.
  1.1166 +
  1.1167 +This function always causes a flush of the window server buffer.
  1.1168 +
  1.1169 +@param aInitialTime Time before first repeat key event 
  1.1170 +@param aTime Time between subsequent repeat key events 
  1.1171 +@see SetKeyboardRepeatRate() */
  1.1172 +	{
  1.1173 +	TPckgBuf<SKeyRepeatSettings> settings;
  1.1174 +	WriteReplyP(&settings,EWsClOpGetKeyboardRepeatRate);
  1.1175 +	aInitialTime=settings().iInitialTime;
  1.1176 +	aTime=settings().iTime;
  1.1177 +	}
  1.1178 +
  1.1179 +EXPORT_C TInt RWsSession::SetDoubleClick(const TTimeIntervalMicroSeconds32 &aInterval, TInt aDistance)
  1.1180 +/** Sets the system-wide double click settings.
  1.1181 +
  1.1182 +Double click distance is measured, in pixels, as the sum of the X distance 
  1.1183 +moved and the Y distance moved between clicks. For example: a first click 
  1.1184 +at 10, 20 and a second click at 13,19 gives a distance of (13-10)+(21-20) = 4.
  1.1185 +
  1.1186 +This function always causes a flush of the window server buffer.
  1.1187 +
  1.1188 +@param aInterval Maximum interval between clicks that constitutes a double 
  1.1189 +click 
  1.1190 +@param aDistance Maximum distance between clicks that constitutes a double 
  1.1191 +click
  1.1192 +@return KErrNone if successful, otherwise another of the system-wide error 
  1.1193 +codes.
  1.1194 +@see GetDoubleClickSettings()
  1.1195 +@capability WriteDeviceData */
  1.1196 +	{
  1.1197 +	TWsClCmdSetDoubleClick dblClick(aInterval,aDistance);
  1.1198 +	return(WriteReply(&dblClick,sizeof(dblClick),EWsClOpSetDoubleClick));
  1.1199 +	}
  1.1200 +
  1.1201 +EXPORT_C void RWsSession::GetDoubleClickSettings(TTimeIntervalMicroSeconds32 &aInterval, TInt &aDistance) const
  1.1202 +/** Gets the current system-wide settings for pointer double clicks.
  1.1203 +
  1.1204 +Double click distances are measured in pixels as the sum of the X distance 
  1.1205 +moved and the Y distance moved between clicks. For example: a first click 
  1.1206 +at 10, 20 and a second click at 13,19 gives a distance of (13-10)+(21-20) = 4.
  1.1207 +
  1.1208 +This function always causes a flush of the window server buffer.
  1.1209 +
  1.1210 +@param aInterval Maximum interval between clicks that constitutes a double 
  1.1211 +click 
  1.1212 +@param aDistance Maximum distance between clicks that constitutes a double 
  1.1213 +click 
  1.1214 +@see SetDoubleClick() */
  1.1215 +	{
  1.1216 +	TPckgBuf<SDoubleClickSettings> settings;
  1.1217 +	WriteReplyP(&settings,EWsClOpGetDoubleClickSettings);
  1.1218 +	aInterval=settings().iInterval;
  1.1219 +	aDistance=settings().iDistance;
  1.1220 +	}
  1.1221 +
  1.1222 +EXPORT_C void RWsSession::SetBackgroundColor(TRgb aColor)
  1.1223 +/** Sets the background colour for the window server. 
  1.1224 +
  1.1225 +This background can only be seen in areas of the display that have no windows 
  1.1226 +on them: so for many applications it will never be seen. It affects no 
  1.1227 +other windows.
  1.1228 +
  1.1229 +@param aColor Background colour */
  1.1230 +	{
  1.1231 +	WriteInt(aColor.Internal(),EWsClOpSetBackgroundColor);
  1.1232 +	}
  1.1233 +
  1.1234 +EXPORT_C TRgb RWsSession::GetBackgroundColor() const
  1.1235 +/** Gets the window server's background colour.
  1.1236 +
  1.1237 +This function always causes a flush of the window server buffer.
  1.1238 +
  1.1239 +@return Background colour */
  1.1240 +	{
  1.1241 +	TRgb col;
  1.1242 +	col.SetInternal((TUint32)WriteReply(EWsClOpGetBackgroundColor));
  1.1243 +	return col;
  1.1244 +	}
  1.1245 +
  1.1246 +EXPORT_C TInt RWsSession::RegisterSurface(TInt aScreenNumber, const TSurfaceId& aSurface)
  1.1247 +/**
  1.1248 +This function registers a surface for use in composition on the screen associated 
  1.1249 +with this device within this session.
  1.1250 +
  1.1251 +A surface may be registered as a separate step before it is added as a background surface 
  1.1252 +for a window created in the same session and that is displayed on this screen. This then 
  1.1253 +allows content to be provisioned before the surface is displayed for the first time, and 
  1.1254 +to be kept "live" while not assigned to any window.
  1.1255 +
  1.1256 +A surface can be successfully registered in multiple sessions and on multiple screens, but 
  1.1257 +only once for a given combination of session and screen.
  1.1258 +
  1.1259 +The client should call UnregisterSurface when finished with the surface registered using 
  1.1260 +this method. The surface will be automatically unregistered if necessary when the session closes.
  1.1261 +
  1.1262 +@param aScreenNumber The screen to which to register.
  1.1263 +@param aSurface The surface to be registered.
  1.1264 +@return KErrNone on success or a system-wide error code
  1.1265 +	- KErrNoMemory if registration fails due to low memory.
  1.1266 +	- KErrInUse if the surface ID is already registered for this session and screen.
  1.1267 +@pre aSurface has been initialized and is compatible with being composited on this device's 
  1.1268 +screen; otherwise the client thread is panicked with code EWservPanicIncompatibleSurface.
  1.1269 +@pre aScreenNumber is an acceptable screen number. Otherwise the client thread is panicked 
  1.1270 +with code EWservPanicScreenNumber.
  1.1271 +@post The surface has been successfully registered for use in composition on this device's screen.
  1.1272 +@post The surface’s content is in an undefined state, but the surface remains initialized.
  1.1273 +@post This function always causes a flush of the WServ session buffer.
  1.1274 +@see UnregisterSurface
  1.1275 +
  1.1276 +@publishedPartner
  1.1277 +@prototype
  1.1278 +*/
  1.1279 +	{
  1.1280 +	TWsClCmdSurfaceRegister surfaceRegister(aScreenNumber,aSurface);
  1.1281 +	return(WriteReply(&surfaceRegister,sizeof(surfaceRegister),EWsClOpRegisterSurface));
  1.1282 +	}
  1.1283 +
  1.1284 +EXPORT_C void RWsSession::UnregisterSurface(TInt aScreenNumber, const TSurfaceId& aSurface)
  1.1285 +/**
  1.1286 +This function removes the surface from the session's register of surfaces that are used in 
  1.1287 +composition on the screen associated with this device.
  1.1288 +
  1.1289 +Calling this function with a surface that is not currently explicitly registered on this screen 
  1.1290 +in this session by RegisterSurface() will have no effect.
  1.1291 +
  1.1292 +Calling this function while the surface is still assigned to a window will have no immediate 
  1.1293 +effect. However, when the surface is unassigned from the window, and is not held by another 
  1.1294 +session it will then be automatically unregistered.
  1.1295 +
  1.1296 +An unregistered surface can be re-registered again, if necessary.
  1.1297 +
  1.1298 +This function does not explicitly force a flush of the WServ session buffer. Internal reference 
  1.1299 +counting will keep the Surface ID "live" until the client code has released any handles and 
  1.1300 +provisioners, and WServ processes the buffered remove command, and the final frame containing 
  1.1301 +this surface has finished being displayed.
  1.1302 +
  1.1303 +@param aScreenNumber The screen to which to unregister.
  1.1304 +@param aSurface The surface to be unregistered.
  1.1305 +@pre aSurface has been initialized; otherwise the client thread is panicked with 
  1.1306 +code EWservPanicIncompatibleSurface.
  1.1307 +@pre aScreenNumber is an acceptable screen number. Otherwise the client thread is 
  1.1308 +panicked with code EWservPanicScreenNumber.
  1.1309 +@post If no window is using the surface, then it is unregistered on this screen in this session.
  1.1310 +@see RegisterSurface
  1.1311 +
  1.1312 +@publishedPartner
  1.1313 +@prototype
  1.1314 +*/
  1.1315 +	{
  1.1316 +	TWsClCmdSurfaceRegister surfaceRegister(aScreenNumber,aSurface);
  1.1317 +	Write(&surfaceRegister,sizeof(surfaceRegister),EWsClOpUnregisterSurface);
  1.1318 +	}
  1.1319 +
  1.1320 +EXPORT_C TInt RWsSession::PreferredSurfaceConfigurationSize() const
  1.1321 +/**
  1.1322 +Returns the window server's preferred size for the TSurfaceConfiguration object, used 
  1.1323 +for RWindow::SetBackgroundSurface.
  1.1324 +
  1.1325 +Client code is permitted to present any defined version of the TSurfaceConfiguration 
  1.1326 +class, distinguished by its size. If smaller, earlier versions are presented, the server 
  1.1327 +will substitute the stated default values. If later, larger, structures are presented to 
  1.1328 +the server then the additional data will be ignored.
  1.1329 +
  1.1330 +However, by using this method, the client can fine-tune its use of the interface, avoiding 
  1.1331 +generating attribute data that may not be supported, or reduce the options presented to users.
  1.1332 +
  1.1333 +@return The preferred size in bytes
  1.1334 +	- Should match one of the TSurfaceConfiguration classes defined in the client's header 
  1.1335 +	file, or be larger than them all, indicating a version newer that the client is compiled for.
  1.1336 +	- If the server does not support surface configuration 
  1.1337 +		- Return KErrNotSupported.
  1.1338 +
  1.1339 +@publishedPartner
  1.1340 +@prototype
  1.1341 +*/
  1.1342 +	{
  1.1343 +	return sizeof(TSurfaceConfiguration);
  1.1344 +	}
  1.1345 +
  1.1346 +EXPORT_C TInt RWsSession::SetSystemPointerCursor(const RWsPointerCursor &aPointerCursor,TInt aCursorNumber)
  1.1347 +/** Sets a cursor in the system pointer cursor list. 
  1.1348 +
  1.1349 +To gain access to the list, the client must first call ClaimSystemPointerCursorList().
  1.1350 +
  1.1351 +This function always causes a flush of the window server buffer.
  1.1352 +
  1.1353 +@param aPointerCursor Pointer cursor to set in the list 
  1.1354 +@param aCursorNumber Cursor number in the list 
  1.1355 +@return KErrNone if successful, otherwise another of the system-wide error 
  1.1356 +codes. */
  1.1357 +	{
  1.1358 +	TWsClCmdSetSystemPointerCursor setpc;
  1.1359 +	setpc.handle=aPointerCursor.WsHandle();
  1.1360 +	setpc.number=aCursorNumber;
  1.1361 +	return(WriteReply(&setpc,sizeof(setpc),EWsClOpSetSystemPointerCursor));
  1.1362 +	}
  1.1363 +
  1.1364 +EXPORT_C void RWsSession::ClearSystemPointerCursor(TInt aCursorNumber)
  1.1365 +/** Clears a system pointer cursor from the list. 
  1.1366 +
  1.1367 +Before calling this function, the client must first gain access to the list 
  1.1368 +by calling ClaimSystemPointerCursorList().
  1.1369 +
  1.1370 +@param aCursorNumber Cursor number to clear */
  1.1371 +	{
  1.1372 +	WriteInt(aCursorNumber,EWsClOpClearSystemPointerCursor);
  1.1373 +	}
  1.1374 +
  1.1375 +EXPORT_C TInt RWsSession::ClaimSystemPointerCursorList()
  1.1376 +/** Claims the system pointer cursor list.
  1.1377 +
  1.1378 +You must call this function before you can call SetSystemPointerCursor() or 
  1.1379 +ClearSystemPointerCursor().
  1.1380 +
  1.1381 +This function always causes a flush of the window server buffer.
  1.1382 +
  1.1383 +@return KErrNone if successful, KErrInUse if another client is already using 
  1.1384 +the system pointer cursor list, otherwise another of the system-wide error 
  1.1385 +codes. 
  1.1386 +@see FreeSystemPointerCursorList()
  1.1387 +@capability WriteDeviceData */
  1.1388 +	{
  1.1389 +	return(WriteReply(EWsClOpClaimSystemPointerCursorList));
  1.1390 +	}
  1.1391 +
  1.1392 +EXPORT_C void RWsSession::FreeSystemPointerCursorList()
  1.1393 +/** Releases the system pointer cursor list and deletes all the entries in it. 
  1.1394 +
  1.1395 +A client should call this function when it no longer needs the system pointer 
  1.1396 +cursor list. */
  1.1397 +	{
  1.1398 +	if (iWsHandle)
  1.1399 +		Write(EWsClOpFreeSystemPointerCursorList);
  1.1400 +	}
  1.1401 +
  1.1402 +EXPORT_C TInt RWsSession::SetCustomTextCursor(TInt aIdentifier, const TArray<TSpriteMember>& aSpriteMemberArray, TUint aSpriteFlags, TCustomTextCursorAlignment aAlignment)
  1.1403 +/** Adds a custom text cursor to the server's list of cursors.
  1.1404 +
  1.1405 +After adding a custom text cursor, it can be selected for use by calling 
  1.1406 +RWindowGroup::SetTextCursor().
  1.1407 +
  1.1408 +Note that once added, custom text cursors cannot be removed.
  1.1409 +
  1.1410 +This function always causes a flush of the window server buffer.
  1.1411 +
  1.1412 +@param aIdentifier The unique identifier for the cursor.
  1.1413 +@param aSpriteMemberArray An array defining the bitmap(s) that make up the 
  1.1414 +cursor. Typically, this array will contain a single element for a static, 
  1.1415 +non-animated cursor.
  1.1416 +@param aSpriteFlags Flags affecting the sprite behaviour. For possible values 
  1.1417 +see TSpriteFlags.
  1.1418 +@param aAlignment The vertical alignment of the cursor sprite.
  1.1419 +@return KErrNone if successful, KErrAlreadyExists if a custom cursor with the 
  1.1420 +specified identifier already exists, or another of the standard system wide 
  1.1421 +error codes. */
  1.1422 +	{
  1.1423 +	// Create the cursor
  1.1424 +	TWsClCmdCustomTextCursorData params;
  1.1425 +	params.identifier = aIdentifier;
  1.1426 +	params.flags = aSpriteFlags;
  1.1427 +	params.alignment = aAlignment;
  1.1428 +	const TInt handle = iBuffer->WriteReplyWs(&params, sizeof(params), EWsClOpStartSetCustomTextCursor);
  1.1429 +	if (handle < 0)
  1.1430 +		{
  1.1431 +		return handle; // Failed to create
  1.1432 +		}
  1.1433 +
  1.1434 +	RWsCustomTextCursor cursor(*this, handle);
  1.1435 +	TInt err = KErrNone;
  1.1436 +	for (TInt ii = 0; ii < aSpriteMemberArray.Count(); ii++)
  1.1437 +		{
  1.1438 +		err = cursor.AppendMember(aSpriteMemberArray[ii]);
  1.1439 +		if (err != KErrNone)
  1.1440 +			{
  1.1441 +			break;
  1.1442 +			}
  1.1443 +		}
  1.1444 +	cursor.Close();
  1.1445 +	err = iBuffer->WriteReplyWs(&err, sizeof(err), EWsClOpCompleteSetCustomTextCursor);
  1.1446 +	return err;
  1.1447 +	}
  1.1448 +
  1.1449 +EXPORT_C TInt RWsSession::SetModifierState(TEventModifier aModifier,TModifierState aState)
  1.1450 +/** Sets the state of the modifier keys. 
  1.1451 +
  1.1452 +This function is typically used for permanent modifier states such as Caps 
  1.1453 +Lock or Num Lock, but other possible uses include on-screen function key simulation, 
  1.1454 +or the implementation of a Shift Lock key.
  1.1455 +
  1.1456 +This function always causes a flush of the window server buffer.
  1.1457 +
  1.1458 +@param aModifier Modifier to set. 
  1.1459 +@param aState Modifier state.
  1.1460 +@return KErrNone if successful, otherwise another of the system-wide error 
  1.1461 +codes. 
  1.1462 +@see GetModifierState()
  1.1463 +@capability WriteDeviceData */
  1.1464 +	{
  1.1465 +	TWsClCmdSetModifierState params;
  1.1466 +	params.modifier=aModifier;
  1.1467 +	params.state=aState;
  1.1468 +	return(WriteReply(&params,sizeof(params),EWsClOpSetModifierState));
  1.1469 +	}
  1.1470 +
  1.1471 +EXPORT_C TInt RWsSession::GetModifierState() const
  1.1472 +/** Gets the state of the modifier keys.
  1.1473 +
  1.1474 +The state of each modifier key (defined in TEventModifier) is returned in 
  1.1475 +a bitmask.
  1.1476 +
  1.1477 +This function always causes a flush of the window server buffer.
  1.1478 +
  1.1479 +@return Modifier state 
  1.1480 +@see TEventModifier */
  1.1481 +	{
  1.1482 +	return(WriteReply(EWsClOpGetModifierState));
  1.1483 +	}
  1.1484 +
  1.1485 +EXPORT_C TInt RWsSession::HeapCount() const
  1.1486 +/** Gets the heap count.
  1.1487 +
  1.1488 +This function calls RHeap::Count() on the window server's heap, after throwing 
  1.1489 +away all the temporary objects allocated for each window.
  1.1490 +
  1.1491 +This function always causes a flush of the window server buffer.
  1.1492 +
  1.1493 +@return The window server's heap count. */
  1.1494 +	{
  1.1495 +	return(WriteReply(EWsClOpHeapCount));
  1.1496 +	}
  1.1497 +
  1.1498 +EXPORT_C TInt RWsSession::DebugInfo(TInt aFunction, TInt aParam) const
  1.1499 +	{
  1.1500 +	TWsClCmdDebugInfo params(aFunction,aParam);
  1.1501 +	return(WriteReply(&params,sizeof(params),EWsClOpDebugInfo));
  1.1502 +	}
  1.1503 +
  1.1504 +EXPORT_C TInt RWsSession::DebugInfo(TInt aFunction, TDes8& aReturnBuf, TInt aParam) const
  1.1505 +	{
  1.1506 +	TWsClCmdDebugInfo params(aFunction,aParam);
  1.1507 +	return(WriteReplyP(&params,sizeof(params),TWriteDescriptorType(&aReturnBuf),EWsClOpDebugInfoReplyBuf));
  1.1508 +	}
  1.1509 +
  1.1510 +EXPORT_C TInt RWsSession::ResourceCount() const
  1.1511 +/** Gets the number of objects that the server has allocated for that client.
  1.1512 +
  1.1513 +This function can be used to check that the client has correctly cleaned up 
  1.1514 +all of its objects.
  1.1515 +
  1.1516 +It always causes a flush of the window server buffer.
  1.1517 +
  1.1518 +@return The number of resources allocated to the client. */
  1.1519 +	{
  1.1520 +	return(iWsHandle ? WriteReply(EWsClOpResourceCount) : 0);
  1.1521 +	}
  1.1522 +
  1.1523 +EXPORT_C void RWsSession::PasswordEntered()
  1.1524 +/** Disables the window server password mode.
  1.1525 +
  1.1526 +This function must be called by the session which owns the password window 
  1.1527 +when the correct machine password has been entered. 
  1.1528 +
  1.1529 +@deprecated */
  1.1530 +	{
  1.1531 +	Write(EWsClOpPasswordEntered);
  1.1532 +	}
  1.1533 +
  1.1534 +EXPORT_C void RWsSession::HeapSetFail(TInt aTAllocFail,TInt aValue)
  1.1535 +/** Sets the heap failure mode in the window server.
  1.1536 +
  1.1537 +The release version of the base does not support simulated heap failure functionality, 
  1.1538 +and the result of this function is additional error messages. In the debug 
  1.1539 +version the clients are notified of the simulated failure and handle it. See 
  1.1540 +RHeap::__DbgSetAllocFail() for more information.
  1.1541 +
  1.1542 +Note:
  1.1543 +
  1.1544 +It is unlikely, but possible to create a ROM with a mixture of Release and 
  1.1545 +Debug versions of the Base and Window Server DLLs, which results in different 
  1.1546 +behaviour to that described above. If you run a debug Window Server with a 
  1.1547 +release version of the Base, then calling this function will result in neither 
  1.1548 +extra error messages (e.g. EDrawingRegion) nor simulated heap failures. However 
  1.1549 +if you have a release Window Server with a debug Base then you will get both 
  1.1550 +simulated heap failures and the extra error messages.
  1.1551 +
  1.1552 +This function always causes a flush of the window server buffer.
  1.1553 +
  1.1554 +@param aTAllocFail A value from the RHeap::TAllocFail enumeration which 
  1.1555 +indicates how to simulate heap allocation failure. 
  1.1556 +@param aValue The rate of failure; when aType is RHeap::EDeterministic, heap 
  1.1557 +allocation fails every aRate attempt 
  1.1558 +@see RHeap::__DbgSetAllocFail()
  1.1559 +@capability WriteDeviceData */
  1.1560 +	{
  1.1561 +	TWsClCmdHeapSetFail params;
  1.1562 +	params.type=(RHeap::TAllocFail)aTAllocFail;
  1.1563 +	params.value=aValue;
  1.1564 +	params.burst=-1;
  1.1565 +	WriteReply(&params,sizeof(params),EWsClOpHeapSetFail);
  1.1566 +	}
  1.1567 +
  1.1568 +EXPORT_C void RWsSession::HeapSetBurstFail(TInt aTAllocFail,TInt aRate,TInt aBurst)
  1.1569 +/** Sets the heap failure burst mode in the window server.
  1.1570 +
  1.1571 +The release version of the base does not support simulated heap failure functionality, 
  1.1572 +and the result of this function is additional error messages. In the debug 
  1.1573 +version the clients are notified of the simulated failure and handle it. See 
  1.1574 +RHeap::__DbgSetBurstAllocFail() for more information.
  1.1575 +
  1.1576 +Note:
  1.1577 +
  1.1578 +It is unlikely, but possible to create a ROM with a mixture of Release and 
  1.1579 +Debug versions of the Base and Window Server DLLs, which results in different 
  1.1580 +behaviour to that described above. If you run a debug Window Server with a 
  1.1581 +release version of the Base, then calling this function will result in neither 
  1.1582 +extra error messages (e.g. EDrawingRegion) nor simulated heap failures. However 
  1.1583 +if you have a release Window Server with a debug Base then you will get both 
  1.1584 +simulated heap failures and the extra error messages.
  1.1585 +
  1.1586 +This function always causes a flush of the window server buffer.
  1.1587 +
  1.1588 +@param aTAllocFail A value from the RHeap::TAllocFail enumeration which 
  1.1589 +indicates how to simulate heap allocation failure. 
  1.1590 +@param aRate The rate of failure; when aType is RHeap::EDeterministic, heap 
  1.1591 +allocation fails every aRate attempt.
  1.1592 +@param aBurst The number of consecutive allocations that should fail.
  1.1593 +@see RHeap::__DbgSetBurstAllocFail()
  1.1594 +@capability WriteDeviceData */
  1.1595 +	{
  1.1596 +	TWsClCmdHeapSetFail params;
  1.1597 +	params.type=(RHeap::TAllocFail)aTAllocFail;
  1.1598 +	params.value=aRate;
  1.1599 +	params.burst=aBurst;
  1.1600 +	WriteReply(&params,sizeof(params),EWsClOpHeapSetFail);
  1.1601 +	}
  1.1602 +
  1.1603 +EXPORT_C TInt RWsSession::RequestOffEvents(TBool aOn,RWindowTreeNode *aWin/*=NULL*/)
  1.1604 +/** Requests the window server to send OFF events to a window. 
  1.1605 +
  1.1606 +After calling this function, the window server sends OFF events to the window 
  1.1607 +when an event occurs which requires power down, rather than handling powering 
  1.1608 +down itself.
  1.1609 +
  1.1610 +Notes:
  1.1611 +
  1.1612 +Any client can ask for OFF events, but only one window in the system can be 
  1.1613 +set to receive them. If this function is called when another window is set 
  1.1614 +to receive OFF events then the client will be panicked. The exception is the 
  1.1615 +shell, which is allowed to take receipt of OFF events from other clients.
  1.1616 +
  1.1617 +The window server identifies the shell client by comparing the process name 
  1.1618 +of the client with the process name of the shell. Only the first client created 
  1.1619 +by the shell is guaranteed to have the extra shell client privileges.
  1.1620 +
  1.1621 +If the shell dies or terminates just before the action requiring power down 
  1.1622 +happens then the window server will handle it rather than passing it on to 
  1.1623 +the shell.
  1.1624 +
  1.1625 +The window server has a queue of messages that it is waiting to send to clients. 
  1.1626 +If the shell's client's queue is full and the window server cannot make room 
  1.1627 +for the OFF message then it will power down the machine itself.
  1.1628 +
  1.1629 +This function always causes a flush of the window server buffer.
  1.1630 +
  1.1631 +@param aOn ETrue to get the window server to send EEventShellSwitchOff messages 
  1.1632 +to the shell (rather than powering down). EFalse makes the window server switch 
  1.1633 +back to powering down the machine itself. 
  1.1634 +@param aWin The handle to the window or window group of the shell to which 
  1.1635 +the message is to be sent. This may be NULL only if aOn=EFalse, in other words, 
  1.1636 +the window server is handling power down itself. If aOn=ETrue then this must not 
  1.1637 +be NULL, or the Window Server will panic the shell. Note that as far as the window 
  1.1638 +server is concerned the handle must exist when this function is called.
  1.1639 +@return KErrNone if successful, otherwise one of the system-wide error codes. 
  1.1640 +@panic WSERV 51 aOn is true, but no window was specified (aWin is NULL). 
  1.1641 +@capability PowerMgmt */
  1.1642 +	{
  1.1643 +	TWsClCmdOffEventsToShell OffEventsToShell(aOn,(aWin ? aWin->WsHandle():0));
  1.1644 +	return WriteReply(&OffEventsToShell,sizeof(OffEventsToShell),EWsClOpSendOffEventsToShell);
  1.1645 +	}
  1.1646 +
  1.1647 +EXPORT_C TDisplayMode RWsSession::GetDefModeMaxNumColors(TInt& aColor,TInt& aGray) const
  1.1648 +/** Gets the number of colours available in the richest supported colour mode, the 
  1.1649 +number of greys available in the richest grey mode, and returns the default 
  1.1650 +display mode.
  1.1651 +
  1.1652 +This function always causes a flush of the window server buffer.
  1.1653 +
  1.1654 +@param aColor The number of colours in the richest supported colour mode. 
  1.1655 +@param aGray The number of greys in the richest supported grey mode. 
  1.1656 +@return The default display mode. */
  1.1657 +	{
  1.1658 +	return GetDefModeMaxNumColors(KDummyScreenNumber,aColor,aGray);
  1.1659 +	}
  1.1660 +
  1.1661 +EXPORT_C TDisplayMode RWsSession::GetDefModeMaxNumColors(TInt aScreenNumber,TInt& aColor,TInt& aGray) const
  1.1662 +/** Gets the number of colours available in the richest supported colour mode, the 
  1.1663 +number of greys available in the richest grey mode, and returns the default 
  1.1664 +display mode, on the specified screen.
  1.1665 +
  1.1666 +This function always causes a flush of the window server buffer.
  1.1667 +
  1.1668 +@param aScreenNumber specifies the screen.
  1.1669 +@param aColor The number of colours in the richest supported colour mode. 
  1.1670 +@param aGray The number of greys in the richest supported grey mode. 
  1.1671 +@return The default display mode. */
  1.1672 +	{
  1.1673 +	TPckgBuf<SDefModeMaxNumColors> colors;	
  1.1674 +	WriteReplyIntP(aScreenNumber,&colors,EWsClOpGetDefModeMaxNumColors);
  1.1675 +	aColor=colors().iColors;
  1.1676 +	aGray=colors().iGrays;
  1.1677 +	return colors().iDisplayMode;
  1.1678 +	}
  1.1679 +
  1.1680 +#define MODE_TO_FLAG(x) 1<<(x-1)
  1.1681 +
  1.1682 +LOCAL_C void HandleColorMode(CArrayFix<TInt>* aModeList,TUint aModeBits, TInt& aNumberOfModes, TInt aMode)
  1.1683 +	{
  1.1684 +	if (aModeBits&(MODE_TO_FLAG(aMode)))
  1.1685 +		{
  1.1686 +		if (aModeList!=NULL)
  1.1687 +			{
  1.1688 +			(*aModeList)[aNumberOfModes]=aMode;
  1.1689 +			}
  1.1690 +		++aNumberOfModes;
  1.1691 +		}
  1.1692 +	}
  1.1693 +
  1.1694 +LOCAL_C TInt DoGetColorModeList(CArrayFix<TInt>* aModeList,TUint aModeBits)
  1.1695 +	{
  1.1696 +	TInt numberOfModes=0;
  1.1697 +	for (TInt mode=EGray2; mode<=EColor256; ++mode)
  1.1698 +		{
  1.1699 +		HandleColorMode(aModeList,aModeBits,numberOfModes,mode);
  1.1700 +		}
  1.1701 +	HandleColorMode(aModeList,aModeBits,numberOfModes,EColor4K);
  1.1702 +	HandleColorMode(aModeList,aModeBits,numberOfModes,EColor64K);
  1.1703 +	HandleColorMode(aModeList,aModeBits,numberOfModes,EColor16M);
  1.1704 +	HandleColorMode(aModeList,aModeBits,numberOfModes,EColor16MU);
  1.1705 +	HandleColorMode(aModeList,aModeBits,numberOfModes,EColor16MA);
  1.1706 +	HandleColorMode(aModeList,aModeBits,numberOfModes,EColor16MAP);
  1.1707 +	return numberOfModes;
  1.1708 +	}
  1.1709 +
  1.1710 +EXPORT_C TInt RWsSession::GetColorModeList(CArrayFixFlat<TInt> *aModeList) const
  1.1711 +/** Gets the list of available colour modes.
  1.1712 +
  1.1713 +Note that this function should usually be called within User::LeaveIfError(). 
  1.1714 +The only time that an error can be generated is when the array gets resized 
  1.1715 +to the number of display modes. Thus if you make the size of your array equal 
  1.1716 +to the maximum number of display modes over all hardware (this is the number 
  1.1717 +of different values in TDisplayMode) then this function will never leave.
  1.1718 +
  1.1719 +This function always causes a flush of the window server buffer.
  1.1720 +
  1.1721 +@param aModeList On return, contains a TDisplayMode entry for each of the 
  1.1722 +available display modes. Note that the array's contents are deleted prior 
  1.1723 +to filling with display mode information. 
  1.1724 +@return The number of color modes if the parameter is passed NULL. Otherwise KErrNone or KErrNoMemory. */
  1.1725 +	{
  1.1726 +	return GetColorModeList(KDummyScreenNumber,aModeList);
  1.1727 +	}
  1.1728 +
  1.1729 +EXPORT_C TInt RWsSession::GetColorModeList(TInt aScreenNumber,CArrayFixFlat<TInt>* aModeList) const
  1.1730 +/** Gets the list of available colour modes on a particular screen.
  1.1731 +
  1.1732 +Note that this function should usually be called within User::LeaveIfError(). 
  1.1733 +The only time that an error can be generated is when the array gets resized 
  1.1734 +to the number of display modes. Thus if you make the size of your array equal 
  1.1735 +to the maximum number of display modes over all hardware (this is the number 
  1.1736 +of different values in TDisplayMode) then this function will never leave.
  1.1737 +
  1.1738 +This function always causes a flush of the window server buffer.
  1.1739 +
  1.1740 +@param aModeList On return, contains a TDisplayMode entry for each of the 
  1.1741 +available display modes. Note that the array's contents are deleted prior 
  1.1742 +to filling with display mode information.
  1.1743 +@param aScreenNumber specifies the screen.  
  1.1744 +@return The number of color modes if the parameter is passed NULL. Otherwise KErrNone or KErrNoMemory. */
  1.1745 +	{
  1.1746 +	const TUint modeList=STATIC_CAST(TUint,WriteReplyInt(aScreenNumber,EWsClOpGetColorModeList));	
  1.1747 +	const TInt numberOfModes=DoGetColorModeList(NULL, modeList);
  1.1748 +	if (aModeList==NULL)
  1.1749 +		{
  1.1750 +		return numberOfModes;
  1.1751 +		}
  1.1752 +	TRAPD(error,aModeList->ResizeL(numberOfModes));
  1.1753 +	if (error!=KErrNone)
  1.1754 +		{
  1.1755 +		return error;
  1.1756 +		}
  1.1757 +	DoGetColorModeList(aModeList, modeList);
  1.1758 +	return KErrNone;
  1.1759 +	}
  1.1760 +
  1.1761 +EXPORT_C void RWsSession::SetPointerCursorArea(const TRect& aArea)
  1.1762 +/** 
  1.1763 +@publishedPartner
  1.1764 +@released
  1.1765 +
  1.1766 +Sets the area of the screen in which the virtual cursor can be used while in 
  1.1767 +relative mouse mode, for the first screen display mode. 
  1.1768 +
  1.1769 +This function sets the area for the first screen mode - the one with index 
  1.1770 +0, which in most devices will be the only screen mode. The other function 
  1.1771 +overload can be used to set the screen area for other modes. The area is set 
  1.1772 +and stored independently on each screen mode, so that it is not necessary 
  1.1773 +to call this function again when switching back to the first screen mode.
  1.1774 +
  1.1775 +The default area is the full digitiser area. When you set the area it will 
  1.1776 +come into immediate affect, i.e. if necessary the current pointer position 
  1.1777 +will be updated to be within the new area. 
  1.1778 +
  1.1779 +Notes:
  1.1780 +
  1.1781 +Relative mouse mode is where the events received from the base by window server 
  1.1782 +are deltas from the last position of the pointer, as opposed to absolute co-ordinates.
  1.1783 +
  1.1784 +This function is honoured even if there is a mouse or pen (e.g. on the emulator), 
  1.1785 +by mapping the co-ordinates of where you click into the area set using this 
  1.1786 +function. However the function does not restrict clicks outside of the 'drawing 
  1.1787 +area' on the Emulator, to allow you to select items on the fascia.
  1.1788 +
  1.1789 +@param aArea The area of the screen in which the virtual cursor can be used. 
  1.1790 +@capability WriteDeviceData */
  1.1791 +	{
  1.1792 +	SetPointerCursorArea(0,aArea);
  1.1793 +	}
  1.1794 +
  1.1795 +EXPORT_C void RWsSession::SetPointerCursorArea(TInt aScreenSizeMode,const TRect& aArea)
  1.1796 +/** Sets the area of the screen in which the virtual cursor can be used while in 
  1.1797 +relative mouse mode, for a specified screen display mode. 
  1.1798 +
  1.1799 +The default area is the full digitiser area for the given mode. When you set 
  1.1800 +the area it will come into immediate affect, i.e. if necessary the current 
  1.1801 +pointer position will be updated to be within the new area. 
  1.1802 +
  1.1803 +The area is set and stored independently on each screen mode, so that it is 
  1.1804 +not necessary to call this function again when switching back to a mode. 
  1.1805 +
  1.1806 +Notes:
  1.1807 +
  1.1808 +Relative mouse mode is where the events received from the base by window server 
  1.1809 +are deltas from the last position of the pointer, as opposed to absolute co-ordinates.
  1.1810 +
  1.1811 +The previous function overload may be used to set the screen area for only 
  1.1812 +the first mode.
  1.1813 +
  1.1814 +This function is honoured even if there is a mouse or pen (e.g. on the emulator), 
  1.1815 +by mapping the co-ordinates of where you click into the area set using this 
  1.1816 +function. However the function does not restrict clicks outside of the 'drawing 
  1.1817 +area' on the Emulator, to allow you to select items on the fascia.
  1.1818 +
  1.1819 +@param aScreenSizeMode The screen mode to which the new area applies. 
  1.1820 +@param aArea The area of the screen, in the aScreenSizeMode screen mode, within 
  1.1821 +which the virtual cursor can be used.
  1.1822 +@capability WriteDeviceData */
  1.1823 +	{
  1.1824 +	TWsClCmdSetPointerCursorArea SetPointerCursorArea(aScreenSizeMode,aArea);
  1.1825 +	Write(&SetPointerCursorArea,sizeof(SetPointerCursorArea),EWsClOpSetPointerCursorArea);
  1.1826 +	}
  1.1827 +
  1.1828 +EXPORT_C TRect RWsSession::PointerCursorArea() const
  1.1829 +/** Gets the pointer cursor area for the first screen display mode.
  1.1830 +
  1.1831 +This is the area of the screen in which the virtual cursor can be used while 
  1.1832 +in relative mouse mode. While in pen or mouse mode the event co-ordinates 
  1.1833 +are forced to be within this area unless you click outside the drawable area.
  1.1834 +
  1.1835 +This function always causes a flush of the window server buffer.
  1.1836 +
  1.1837 +@return The pointer cursor area for the first screen display mode.
  1.1838 +@see SetPointerCursorArea() */
  1.1839 +	{
  1.1840 +	return PointerCursorArea(0);
  1.1841 +	}
  1.1842 +
  1.1843 +EXPORT_C TRect RWsSession::PointerCursorArea(TInt aScreenSizeMode) const
  1.1844 +/** Gets the pointer cursor area for the specified screen display mode. 
  1.1845 +
  1.1846 +This is the area of the screen in which the virtual cursor can be used while 
  1.1847 +in relative mouse mode. While in pen or mouse mode the event co-ordinates 
  1.1848 +are forced to be within this area unless you click outside the drawable area.
  1.1849 +
  1.1850 +This function always causes a flush of the window server buffer.
  1.1851 +
  1.1852 +@param aScreenSizeMode The screen mode for which the pointer cursor area is 
  1.1853 +required. 
  1.1854 +@return The pointer cursor area for the specified screen display mode. 
  1.1855 +@see SetPointerCursorArea() */
  1.1856 +	{
  1.1857 +	TPckgBuf<TRect> rectPkg;
  1.1858 +  	WriteReplyP(&aScreenSizeMode,sizeof(aScreenSizeMode),&rectPkg,EWsClOpPointerCursorArea);
  1.1859 +	return(rectPkg());
  1.1860 +	}
  1.1861 +
  1.1862 +EXPORT_C void RWsSession::SetPointerCursorMode(TPointerCursorMode aMode)
  1.1863 +/** Sets the current mode for the pointer cursor.
  1.1864 +
  1.1865 +The mode determines which sprite is used for the pointer cursor at any point. 
  1.1866 +The request is ignored unless the calling application is the application 
  1.1867 +that currently has keyboard focus.
  1.1868 +See TPointerCursorMode for more information.
  1.1869 +
  1.1870 +@param aMode The new mode for the pointer cursor. 
  1.1871 +@see TPointerCursorMode */
  1.1872 +	{
  1.1873 +	WriteInt(aMode,EWsClOpSetPointerCursorMode);
  1.1874 +	}
  1.1875 +	
  1.1876 +EXPORT_C TInt RWsSession::SetClientCursorMode(TPointerCursorMode aMode)
  1.1877 +/** Sets the current mode for the pointer cursor.
  1.1878 +
  1.1879 +The mode determines which sprite is used for the pointer cursor at any point. 
  1.1880 +See TPointerCursorMode for more information.
  1.1881 +
  1.1882 +This function always causes a flush of the window server buffer.
  1.1883 +
  1.1884 +@param aMode The new mode for the pointer cursor. 
  1.1885 +@see TPointerCursorMode
  1.1886 +@return KErrNone if successful, otherwise returns system wide errors. Returns
  1.1887 +KErrPermissionDenied if calling thread lacks WriteDeviceData capability
  1.1888 +@capability WriteDeviceData */
  1.1889 +	{
  1.1890 +	return(WriteReplyInt(aMode,EWsClOpSetClientCursorMode));
  1.1891 +	}
  1.1892 +
  1.1893 +EXPORT_C TPointerCursorMode RWsSession::PointerCursorMode() const
  1.1894 +/** Gets the current mode for the pointer cursor.
  1.1895 +
  1.1896 +The mode determines which sprite is used for the pointer cursor at any point.
  1.1897 +
  1.1898 +This function always causes a flush of the window server buffer.
  1.1899 +
  1.1900 +@return The current mode for the pointer cursor. */
  1.1901 +	{
  1.1902 +	return(STATIC_CAST(TPointerCursorMode,WriteReply(EWsClOpPointerCursorMode)));
  1.1903 +	}
  1.1904 +
  1.1905 +EXPORT_C void RWsSession::SetDefaultSystemPointerCursor(TInt aCursorNumber)
  1.1906 +/** Sets the default system pointer cursor.
  1.1907 +
  1.1908 +This function can only be called by the owner of the system pointer cursor 
  1.1909 +list. By default the 0th entry in the pointer cursor list is assigned as the 
  1.1910 +system pointer. The function allows any cursor from the list or even no cursor 
  1.1911 +to be set as the system pointer cursor.
  1.1912 +
  1.1913 +Note: ownership of the system pointer cursor list can be obtained by calling 
  1.1914 +ClaimSystemPointerCursorList() when no-one else has ownership.
  1.1915 +
  1.1916 +@param aCursorNumber The index of the new default system pointer cursor within 
  1.1917 +the system cursor list. */
  1.1918 +	{
  1.1919 +	WriteInt(aCursorNumber,EWsClOpSetDefaultSystemPointerCursor);
  1.1920 +	}
  1.1921 +
  1.1922 +EXPORT_C void RWsSession::ClearDefaultSystemPointerCursor()
  1.1923 +/** Clears the default system pointer cursor.
  1.1924 +
  1.1925 +This sets the pointer to the current default system pointer cursor to NULL. 
  1.1926 +
  1.1927 +@panic WSERV 42 If this function is called by a client other than the owner of the 
  1.1928 +system pointer cursor list. */
  1.1929 +	{
  1.1930 +	Write(EWsClOpClearDefaultSystemPointerCursor);
  1.1931 +	}
  1.1932 +
  1.1933 +EXPORT_C TInt RWsSession::SetPointerCursorPosition(const TPoint& aPosition)
  1.1934 +/** Sets the pointer cursor position.
  1.1935 +
  1.1936 +This function allows an application to move the virtual cursor. It works in 
  1.1937 +all modes, not just relative mouse mode.
  1.1938 +
  1.1939 +Note: the function works in screen co-ordinates and honours the pointer cursor area 
  1.1940 +exactly as pen presses do, i.e. only when they are in the drawing area 
  1.1941 +on the Emulator.
  1.1942 +
  1.1943 +This function always causes a flush of the window server buffer.
  1.1944 +
  1.1945 +@param aPosition The new pointer cursor position.
  1.1946 +@return KErrNone if successful, otherwise another of the system-wide error 
  1.1947 +codes. 
  1.1948 +@capability WriteDeviceData required, if the client calling the function doesn't have keyboard focus.
  1.1949 +However, if the client have keyboard focus then he doesn't need any capability to call this function.  */
  1.1950 +	{
  1.1951 +	return(WriteReply(&aPosition,sizeof(aPosition),EWsClOpSetPointerCursorPosition));
  1.1952 +	}
  1.1953 +
  1.1954 +EXPORT_C TPoint RWsSession::PointerCursorPosition() const
  1.1955 +/** Gets the pointer cursor position.
  1.1956 +
  1.1957 +This function allows an application to determine the position of the virtual 
  1.1958 +cursor.
  1.1959 +
  1.1960 +It always causes a flush of the window server buffer.
  1.1961 +
  1.1962 +Please note that on devices with multiple pointers (for example with multi-touch screen)
  1.1963 +the pointer cursor's position will be equal to the last known position of the emulated pointer.
  1.1964 +More information about the emulated pointer can be found in description of method
  1.1965 +RWindowBase::EnableAdvancedPointers().
  1.1966 +
  1.1967 +@return The position of the virtual cursor. 
  1.1968 +@see RWindowBase::EnableAdvancedPointers() */
  1.1969 +	{
  1.1970 +	TPckgBuf<TPoint> pointPkg;
  1.1971 +  	WriteReplyP(&pointPkg,EWsClOpPointerCursorPosition);
  1.1972 +	return(pointPkg());
  1.1973 +	}
  1.1974 +
  1.1975 +EXPORT_C void RWsSession::SetDefaultFadingParameters(TUint8 aBlackMap,TUint8 aWhiteMap)
  1.1976 +/**
  1.1977 +@publishedPartner
  1.1978 +@released
  1.1979 +
  1.1980 +Sets the default fading parameters.
  1.1981 +
  1.1982 +Fading is used to change the colour of windows to be either closer 
  1.1983 +to white or closer to black, so that another window stands out. For example, 
  1.1984 +when displaying a dialogue you could fade all visible windows, then unfade 
  1.1985 +the dialog window. This function sets whether, and the amount by which, faded 
  1.1986 +windows appear closer to white or closer to black.
  1.1987 +
  1.1988 +The white and black mapping values define the range over which colours are 
  1.1989 +re-mapped when a window is faded. If aBlackMap=0 and aWhiteMap=255 then the 
  1.1990 +colours are mapped unchanged. As the two values get closer together, all colours 
  1.1991 +in the faded window becomes more similar - creating the fading effect. When 
  1.1992 +the numbers cross over (so that the black value is greater than the white 
  1.1993 +value) the colours in the faded window start to invert - i.e. colours that 
  1.1994 +were closer to white in the unfaded window are mapped to a darker colour in 
  1.1995 +the faded window.
  1.1996 +
  1.1997 +Changing the default will automatically apply to current graphics contexts 
  1.1998 +but will not have any affect on windows that are already faded. 
  1.1999 +
  1.2000 +Note: RWindowTreeNode::SetFaded(), CWindowGc::SetFaded() and RWsSession::SetSystemFaded() 
  1.2001 +use these fading parameters, and in addition allow the default fading value 
  1.2002 +to be overridden.
  1.2003 +
  1.2004 +@param aBlackMap Black map fading parameter.
  1.2005 +@param aWhiteMap White map fading parameter. 
  1.2006 +@see RWindowTreeNode::SetFaded()
  1.2007 +@see CWindowGc::SetFadingParameters() 
  1.2008 +@capability WriteDeviceData */
  1.2009 +	{
  1.2010 +	WriteInt(WservEncoding::Encode8BitValues(aBlackMap,aWhiteMap),EWsClOpSetDefaultFadingParams);
  1.2011 +	}
  1.2012 +
  1.2013 +/**
  1.2014 +@publishedPartner
  1.2015 +@released
  1.2016 +
  1.2017 +Prepares for switch off. 
  1.2018 +
  1.2019 +This stops the window server heart beat timer if running.
  1.2020 +
  1.2021 +@capability PowerMgmt
  1.2022 +*/
  1.2023 +EXPORT_C void RWsSession::PrepareForSwitchOff()
  1.2024 +	{
  1.2025 +	Write(EWsClOpPrepareForSwitchOff);
  1.2026 +	}
  1.2027 +
  1.2028 +#if defined(__WINS__)
  1.2029 +EXPORT_C void RWsSession::SetRemoveKeyCode(TBool aRemove)
  1.2030 +/** Sets whether to remove the top 16 bits of a key code (Emulator builds only).
  1.2031 +
  1.2032 +This function allows the Emulator to use Windows to translate keypresses into 
  1.2033 +the correct key code for each locale, rather than having to do the translation 
  1.2034 +for each international keyboard itself. 
  1.2035 +
  1.2036 +The top 16 bits of a keypress code contains the keycode that Windows would 
  1.2037 +produce if the key had been pressed in a typical Windows program. If aRemove 
  1.2038 +is EFalse the client can get these top 16 bits. If the value is non-zero 
  1.2039 +the CKeyTranslator uses it rather than calculating it's own value. If aRemove 
  1.2040 +is ETrue the window server strips the top 16 bits of the scan code before 
  1.2041 +passing the value on to the client. 
  1.2042 +
  1.2043 +Note: this function is intended for Java but it will be useful to any client who 
  1.2044 +creates their own CKeyTranslator and processes keyups and downs.
  1.2045 +
  1.2046 +@param aRemove ETrue to remove the code (default), EFalse to pass it to the 
  1.2047 +client. */
  1.2048 +	{
  1.2049 +	WriteInt(aRemove,EWsClOpRemoveKeyCode);
  1.2050 +	}
  1.2051 +
  1.2052 +EXPORT_C void RWsSession::SimulateXyInputType(TInt aInputType)
  1.2053 +	{
  1.2054 +	WriteInt(aInputType,EWsClOpSimulateXyInput);
  1.2055 +	}
  1.2056 +#endif
  1.2057 +
  1.2058 +EXPORT_C void RWsSession::LogCommand(TLoggingCommand aCommand)
  1.2059 +/** Allows the window server client to enable or disable logging of window server 
  1.2060 +events.
  1.2061 +
  1.2062 +The type of logging that takes place (e.g. whether to file or to serial port) 
  1.2063 +depends on the settings specified in the wsini.ini file.
  1.2064 +
  1.2065 +Clients can also force a dump of the window tree or information about the 
  1.2066 +window server's heap size and usage. 
  1.2067 +
  1.2068 +For logging to work, the wsini.ini file has to specify the type of logging 
  1.2069 +required and the DLLs for that type of logging must have been correctly installed. 
  1.2070 +Otherwise, calling this function will have no effect.
  1.2071 +
  1.2072 +@param aCommand The logging command. */
  1.2073 +	{
  1.2074 +	WriteInt(aCommand,EWsClOpLogCommand);
  1.2075 +	}
  1.2076 +
  1.2077 +EXPORT_C void RWsSession::LogMessage(const TLogMessageText &aMessage)
  1.2078 +/** Adds a message to the window server debug log if one is currently in operation.
  1.2079 +
  1.2080 +This function always causes a flush of the window server buffer.
  1.2081 +
  1.2082 +@param aMessage The text added to the message log. */
  1.2083 +	{
  1.2084 +	TInt len=aMessage.Length();
  1.2085 +	WriteReply(&len,sizeof(len),aMessage.Ptr(),aMessage.Size(),EWsClOpLogMessage);
  1.2086 +	}
  1.2087 +
  1.2088 +EXPORT_C void RWsSession::SimulateRawEvent(TRawEvent aEvent)
  1.2089 +/** 
  1.2090 +@internalAll
  1.2091 +
  1.2092 +Simulates raw events.
  1.2093 +
  1.2094 +For most purposes, RWsSession::SimulateKeyEvent() should be used instead to 
  1.2095 +simulate key events because low-level scan-code up/down events are not meaningful 
  1.2096 +to anything other than the keyboard to which they apply.
  1.2097 +
  1.2098 +For example, the driver for an external keyboard should do its own conversion from 
  1.2099 +raw scan-codes to higher-level character code key events and pass these to the 
  1.2100 +window server using SimulateKeyEvent().
  1.2101 +
  1.2102 +@param aEvent The raw event.
  1.2103 +@capability SwEvent */
  1.2104 +	{
  1.2105 +	Write(&aEvent,sizeof(aEvent),EWsClOpRawEvent);
  1.2106 +	}
  1.2107 +
  1.2108 +EXPORT_C void RWsSession::SimulateKeyEvent(TKeyEvent aEvent)
  1.2109 +/** 
  1.2110 +@internalAll
  1.2111 +
  1.2112 +Sends a simulated key event to the window server.
  1.2113 +
  1.2114 +All the fields in TKeyEvent are honoured except iRepeats, which is overridden 
  1.2115 +with zero.
  1.2116 +
  1.2117 +@param aEvent The key event to be simulated.
  1.2118 +@capability SwEvent */
  1.2119 +	{
  1.2120 +	Write(&aEvent,sizeof(aEvent),EWsClOpKeyEvent);
  1.2121 +	}
  1.2122 +
  1.2123 +
  1.2124 +EXPORT_C void RWsSession::SystemInfo(TInt &aSystemInfoNumber, SSystemInfo &aSystemInfo)
  1.2125 +/** @internalComponent */
  1.2126 +	{
  1.2127 +	TPckgBuf<SSystemInfo> systemInfoPckg;
  1.2128 +	WriteReplyP(&aSystemInfoNumber,sizeof(aSystemInfoNumber),&systemInfoPckg,EWsClOpSystemInfo);
  1.2129 +	aSystemInfo=systemInfoPckg();
  1.2130 +	}
  1.2131 +
  1.2132 +void RWsSession::DirectAcessActivation(TBool aIsNowActive)
  1.2133 +	{
  1.2134 +	if (aIsNowActive)
  1.2135 +		++iBuffer->iDirectAcessCount;
  1.2136 +	else
  1.2137 +		{
  1.2138 +		--iBuffer->iDirectAcessCount;
  1.2139 +		__ASSERT_DEBUG(iBuffer->iDirectAcessCount>=0,Assert(EW32AssertDirectMisuse));
  1.2140 +		}
  1.2141 +	}
  1.2142 +
  1.2143 +EXPORT_C void RWsSession::TestWrite(TInt aHandle,TInt aOpcode,const TAny *pData, TInt aLength)
  1.2144 +/** @internalComponent */
  1.2145 +	{
  1.2146 +	iBuffer->Write(aHandle,aOpcode,pData,aLength);
  1.2147 +	}
  1.2148 +
  1.2149 +EXPORT_C void RWsSession::TestWriteReply(TInt aHandle,TInt aOpcode,const TAny *pData, TInt aLength)
  1.2150 +/** @internalComponent */
  1.2151 +	{
  1.2152 +	iBuffer->WriteReply(aHandle,aOpcode,pData,aLength);
  1.2153 +	}
  1.2154 +
  1.2155 +EXPORT_C void RWsSession::TestWriteReplyP(TInt aHandle,TInt aOpcode,const TAny *pData,TInt aLength,TDes8 *aReplyPackage)
  1.2156 +/** @internalComponent */
  1.2157 +	{
  1.2158 +	iBuffer->WriteReplyP(aHandle,aOpcode,pData,aLength,aReplyPackage);
  1.2159 +	}
  1.2160 +
  1.2161 +EXPORT_C TInt RWsSession::TestWriteReplyByProvidingRemoteReadAccess(TInt aHandle,TInt aOpcode,const TDesC8& aData,const TDesC8& aRemoteReadBuffer)
  1.2162 +/** @internalComponent */
  1.2163 +	{
  1.2164 +	return iBuffer->WriteReplyByProvidingRemoteReadAccess(aHandle,aOpcode,aData.Ptr(),aData.Length(),&aRemoteReadBuffer);
  1.2165 +	}
  1.2166 +
  1.2167 +EXPORT_C TInt RWsSession::TestWriteReplyByProvidingRemoteReadAccess(TInt aHandle,TInt aOpcode,const TDesC8& aData,const TDesC16& aRemoteReadBuffer)
  1.2168 +/** @internalComponent */
  1.2169 +	{
  1.2170 +	return iBuffer->WriteReplyByProvidingRemoteReadAccess(aHandle,aOpcode,aData.Ptr(),aData.Length(),&aRemoteReadBuffer);
  1.2171 +	}
  1.2172 +
  1.2173 +/** Sets both the buffer size and maximum buffer size for queuing commands to send to the Windows Server.
  1.2174 +The value should be at least the size of the largest message that will be sent, 
  1.2175 +otherwise a panic of the client may occur.
  1.2176 +
  1.2177 +The minimum possible buffer size is 640 and the maximum possible size is 16384 bytes.
  1.2178 +The default size of 640 bytes is sufficient for most uses.
  1.2179 +
  1.2180 +Larger buffers can reduce drawing flicker by allowing more drawing commands to be
  1.2181 +collected in the buffer before being sent to the server.
  1.2182 +
  1.2183 +Smaller buffers conserve system memory.
  1.2184 +
  1.2185 +Can be used to set a minimum buffer size, sufficient for largest drawing command used,
  1.2186 +before calling RWsSession::SetMaxBufferSizeL() to set a maximum buffer size for queuing commands.
  1.2187 +
  1.2188 +@param aBufSize The desired buffer size in bytes, at least the size of largest message to be sent.
  1.2189 +@leave KErrNoMemory Could not allocate the required memory.
  1.2190 +
  1.2191 +@panic TW32Panic 5 Occurs during the session if a single drawing command is too big to fit in the buffer.
  1.2192 +
  1.2193 +@see RWsSession::Flush()
  1.2194 +@see RWsSession::SetAutoFlush()
  1.2195 +@see RWsSession::SetMaxBufferSizeL()
  1.2196 +*/
  1.2197 +EXPORT_C void RWsSession::SetBufferSizeL(TInt aBufSize)
  1.2198 +	{
  1.2199 +	iBuffer->SetBufferSizeL(aBufSize);
  1.2200 +	}
  1.2201 +
  1.2202 +/** Sets the maximum size that the buffer for queuing commands to send to the Windows Server can expand to.
  1.2203 +
  1.2204 +The minimum possible buffer size is 640 and the maximum possible size is 16384 bytes.
  1.2205 +
  1.2206 +If the buffer size is larger than the new maximum it is reduced.
  1.2207 +
  1.2208 +A minimum size is calculated to be one quarter the maximum size, but in any case at least 640 bytes.
  1.2209 +If the buffer size is smaller than the calculated minimum it is expanded.
  1.2210 +
  1.2211 +RWsSession::SetBufferSizeL() can be used to set a specific minimum size >640 bytes before setting a maximum size.
  1.2212 +This is useful if you will send very large drawing commands.
  1.2213 +
  1.2214 +After calling this function the buffer size will be between the specified maximum and calculated minimum sizes.
  1.2215 +
  1.2216 +The algorithm for growing the buffer up to the maximum is chosen to balance the cost of expanding the buffer 
  1.2217 +with the waste of an excessively large buffer that is never filled.
  1.2218 +
  1.2219 +If the buffer becomes too full to add a new drawing command, and the buffer size is less than the maximum,
  1.2220 +the buffer size will be expanded.
  1.2221 +If the buffer is already at the maximum size, or the expansion fails due to low memory, 
  1.2222 +the buffer will be emptied with RWsSession::Flush().
  1.2223 +If there is not enough space now for the new command a panic occurs.
  1.2224 +
  1.2225 +@param aMaxBufSize The desired maximum buffer size in bytes.
  1.2226 +@leave KErrNoMemory Could not allocate the required minimum memory.
  1.2227 +
  1.2228 +@panic TW32Panic 5 Occurs during the session if a single drawing command is too big to fit in the buffer.
  1.2229 +
  1.2230 +@see RWsSession::Flush()
  1.2231 +@see RWsSession::SetAutoFlush()
  1.2232 +@see RWsSession::SetBufferSizeL()
  1.2233 +*/
  1.2234 +EXPORT_C void RWsSession::SetMaxBufferSizeL(TInt aMaxBufSize)
  1.2235 +	{
  1.2236 +	iBuffer->SetMaxBufferSizeL(aMaxBufSize);
  1.2237 +	}
  1.2238 +
  1.2239 +EXPORT_C TInt RWsSession::SetSystemFaded(TBool aFaded)
  1.2240 +/** Sets all windows in the system as faded or unfaded, using the default fading 
  1.2241 +parameters.
  1.2242 +
  1.2243 +This function allows all windows that currently exist, not just those in a 
  1.2244 +single window group, to be faded or unfaded.
  1.2245 +
  1.2246 +Notes: The window server generates a redraw to un-fade a window, because information 
  1.2247 +is lost during fading. Blank (RBlankWindow) and backup (RBackupWindow) windows 
  1.2248 +deal with this themselves. Areas in shadow when the window is faded will also 
  1.2249 +have redraw events generated for them by the window server. While a window 
  1.2250 +is faded, all drawing to that window will be adjusted appropriately by the 
  1.2251 +window server.
  1.2252 +
  1.2253 +This function always causes a flush of the window server buffer.
  1.2254 +
  1.2255 +@param aFaded ETrue to fade all windows, EFalse to un-fade all windows.
  1.2256 +@return KErrNone if successful, otherwise another of the system-wide error 
  1.2257 +codes. 
  1.2258 +@capability WriteDeviceData */
  1.2259 +	{
  1.2260 +	TWsClCmdSetSystemFaded params(aFaded);
  1.2261 +	return WriteReply(&params,sizeof(params),EWsClOpSetFaded);
  1.2262 +	}
  1.2263 +
  1.2264 +EXPORT_C TInt RWsSession::SetSystemFaded(TBool aFaded,TUint8 aBlackMap,TUint8 aWhiteMap)
  1.2265 +/** Sets all windows in the system as faded or unfaded, overriding the default 
  1.2266 +fading parameters (as set by SetDefaultFadingParameters()).
  1.2267 +
  1.2268 +This function allows all windows that currently exist, not just those in the 
  1.2269 +same window group, to be faded or unfaded.
  1.2270 +
  1.2271 +Notes: Fading a window for a second time (that is fading it when it is already 
  1.2272 +faded) will not change the fading map used. The window server generates a 
  1.2273 +redraw to un-fade a window, because information is lost during fading. Blank 
  1.2274 +(RBlankWindow) and backup (RBackupWindow) windows deal with this themselves. 
  1.2275 +Areas in shadow when the window is faded will also have redraw events generated 
  1.2276 +for them by the window server. While a window is faded, all drawing to that 
  1.2277 +window will be adjusted appropriately by the window server.
  1.2278 +
  1.2279 +This function always causes a flush of the window server buffer.
  1.2280 +
  1.2281 +@param aFaded ETrue to fade all windows, EFalse to un-fade all windows.
  1.2282 +@param aBlackMap Black map fading parameter.
  1.2283 +@param aWhiteMap White map fading parameter.
  1.2284 +@return KErrNone if successful, otherwise another of the system-wide error 
  1.2285 +codes. 
  1.2286 +@capability WriteDeviceData */
  1.2287 +	{
  1.2288 +	TWsClCmdSetSystemFaded params(aFaded,EFalse,aBlackMap,aWhiteMap);
  1.2289 +	return WriteReply(&params,sizeof(params),EWsClOpSetFaded);
  1.2290 +	}
  1.2291 +
  1.2292 +EXPORT_C TInt RWsSession::SetFocusScreen(TInt aScreenNumber)
  1.2293 +/** Set focus screen  
  1.2294 +@param aScreenNumber The new focus screen.
  1.2295 +@return KErrNone if successful, otherwise another of the system-wide error 
  1.2296 +codes. */
  1.2297 +	{
  1.2298 +	return WriteReplyInt(aScreenNumber,EWsClOpSetFocusScreen);
  1.2299 +	}
  1.2300 +
  1.2301 +EXPORT_C TInt RWsSession::GetFocusScreen() const
  1.2302 +/** Get focus screen
  1.2303 +@return The screen number of current focus screen */
  1.2304 +	{
  1.2305 +	return WriteReply(EWsClOpGetFocusScreen);
  1.2306 +	}
  1.2307 +
  1.2308 +EXPORT_C TInt RWsSession::NumberOfScreens() const
  1.2309 +/** Number Of Screens
  1.2310 +@return The number of screens on the phone */
  1.2311 +	{
  1.2312 +	return WriteReply(EWsClOpGetNumberOfScreens);	
  1.2313 +	}
  1.2314 +	
  1.2315 +EXPORT_C void RWsSession::ClearAllRedrawStores()
  1.2316 +/** Clear the redraw store for all windows in the system.
  1.2317 +By default Windows will record the drawing commands used during a redraw and re-use them later if the window needs to be redrawn.
  1.2318 +Calling this function will cause all these server-side stores to be thrown away, redraw requests will then be sent to all client-side windows. Visible windows will receive them first.
  1.2319 +
  1.2320 +In most cases you should be using RWindow::ClearRedrawStore instead of this function. 
  1.2321 +
  1.2322 +This function always causes a flush of the window server buffer.*/
  1.2323 +	{
  1.2324 +	Write(EWsClOpClearAllRedrawStores);
  1.2325 +	}
  1.2326 +
  1.2327 +EXPORT_C TInt RWsSession::Finish()
  1.2328 +/** 
  1.2329 +Blocks until all outstanding window server rendering has been completed.
  1.2330 +@return KErrNone if successful 
  1.2331 +*/
  1.2332 +	{
  1.2333 +	SyncMsgBuf();
  1.2334 +	return SendReceive(EWservMessFinish);
  1.2335 +	}
  1.2336 +
  1.2337 +EXPORT_C void RWsSession::SyncMsgBuf()
  1.2338 +/** 
  1.2339 +Sends all pending commands in the buffer to the window server. 
  1.2340 +*/
  1.2341 +	{
  1.2342 +	if (iBuffer)
  1.2343 +		iBuffer->Flush();
  1.2344 +	}
  1.2345 +
  1.2346 +EXPORT_C TInt RWsSession::SetCloseProximityThresholds(TInt aEnterCloseProximityThreshold, TInt aExitCloseProximityThreshold)
  1.2347 +/** Sets Z coordinate threshold values for TPointerEvent::EEnterCloseProximity 
  1.2348 +and TPointerEvent::EExitCloseProximity events. 
  1.2349 +As proximity occupies the negative range of Z coordinates, on most platforms
  1.2350 +threshold values for these events should be specified as negative.
  1.2351 +
  1.2352 +However, all possible Z coordinate values are accepted by this method
  1.2353 +regardless of the fact that positive Z coordinate values are interpreted as 
  1.2354 +pressure and only negative Z coordinate values are interpreted as proximity.
  1.2355 +This means that if a particular platform supports an Up pointer state while a pointer is
  1.2356 +touching the screen, it is possible to base the firing of 
  1.2357 +EnterCloseProximity/ExitCloseProximity events on pressure readings by specifying 
  1.2358 +positive threshold values.
  1.2359 +
  1.2360 +EnterCloseProximity/ExitCloseProximity event generation can be switched off completely by 
  1.2361 +specifying the following thresholds: aEnterCloseProximityThreshold = KMaxTInt, 
  1.2362 +aExitCloseProximityThreshold = KMinTInt.
  1.2363 +
  1.2364 +This method is supposed to be used only by the UI platform or device's configuration tool.
  1.2365 +
  1.2366 +Modified thresholds will be persisted across system reboots in the following HAL
  1.2367 +attributes: HALData::EPointer3DEnterCloseProximityThreshold, HALData::EPointer3DExitCloseProximityThreshold. 
  1.2368 +
  1.2369 +If this method is never called on a particular device, the default threshold values defined by this device's 
  1.2370 +manufacturer are used.
  1.2371 +
  1.2372 +@param aEnterCloseProximityThreshold a new threshold for TPointerEvent::EEnterCloseProximity
  1.2373 +                                     to be set, specified as Z coordinate value
  1.2374 +@param aExitCloseProximityThreshold a new threshold for TPointerEvent::EExitCloseProximity
  1.2375 +                                    to be set, specified as Z coordinate value
  1.2376 +@return KErrNone if successful, 
  1.2377 +        KErrNotSupported if the platform doesn't support threshold values for 
  1.2378 +                         Close Proximity events,
  1.2379 +        KErrArgument if aEnterCloseProximityThreshold is less than aExitCloseProximityThreshold;
  1.2380 +                     when this error occurs, threshold values are not changed. 
  1.2381 +@capability WriteDeviceData
  1.2382 +@see TPointerEvent::EEnterCloseProximity
  1.2383 +@see TPointerEvent::EExitCloseProximity
  1.2384 +@see HALData::EPointer3DEnterCloseProximityThreshold
  1.2385 +@see HALData::EPointer3DExitCloseProximityThreshold
  1.2386 +@publishedPartner
  1.2387 +@prototype To become released with WSERV NGA APIs */
  1.2388 +	{
  1.2389 +	TWsClCmdZThresholdPair params(aEnterCloseProximityThreshold, aExitCloseProximityThreshold);
  1.2390 +	return WriteReply(&params,sizeof(params),EWsClOpSetCloseProximityThresholds);
  1.2391 +	}
  1.2392 +
  1.2393 +EXPORT_C TInt RWsSession::GetEnterCloseProximityThreshold() const
  1.2394 +/**
  1.2395 +@return Z coordinate threshold value for TPointerEvent::EEnterCloseProximity events.
  1.2396 +@see TPointerEvent::EEnterCloseProximity
  1.2397 +@publishedPartner To become publishedAll with WSERV NGA APIs
  1.2398 +@prototype To become released with WSERV NGA APIs */
  1.2399 +	{
  1.2400 +	return WriteReply(EWsClOpGetEnterCloseProximityThreshold);	
  1.2401 +	}
  1.2402 +
  1.2403 +EXPORT_C TInt RWsSession::GetExitCloseProximityThreshold() const
  1.2404 +/**
  1.2405 +@return Z coordinate threshold value for TPointerEvent::EExitCloseProximity events
  1.2406 +@see TPointerEvent::EExitCloseProximity
  1.2407 +@publishedPartner To become publishedAll with WSERV NGA APIs
  1.2408 +@prototype To become released with WSERV NGA APIs */
  1.2409 +	{
  1.2410 +	return WriteReply(EWsClOpGetExitCloseProximityThreshold);	
  1.2411 +	}
  1.2412 +
  1.2413 +EXPORT_C TInt RWsSession::SetHighPressureThresholds(TInt aEnterHighPressureThreshold, TInt aExitHighPressureThreshold)
  1.2414 +/** Sets Z coordinate threshold values for TPointerEvent::EEnterHighPressure 
  1.2415 +and TPointerEvent::EExitHighPressure events. 
  1.2416 +As pressure occupies the positive range of Z coordinates, on most platforms
  1.2417 +threshold values for these events should be specified as positive values.
  1.2418 +
  1.2419 +However, all possible Z coordinate values are accepted by this method
  1.2420 +regardless of the fact that only the positive Z coordinate values are interpreted as 
  1.2421 +pressure and the negative Z coordinate values are interpreted as proximity.
  1.2422 +This means that if a particular platform supports the Down pointer state while a pointer is
  1.2423 +in proximity to the screen, it is possible to base the firing of 
  1.2424 +EnterHighPressure/ExitHighPressure events on proximity readings by specifying 
  1.2425 +negative threshold values.
  1.2426 +
  1.2427 +EnterHighPressure/ExitHighPressure event generation can be switched off completely by 
  1.2428 +specifying the following thresholds: aEnterHighPressureThreshold = KMaxTInt, 
  1.2429 +aExitHighPressureThreshold = KMinTInt.
  1.2430 +
  1.2431 +This method is supposed to be used only by the UI platform or device's configuration tool.
  1.2432 +
  1.2433 +Modified thresholds will be persisted across system reboots in the following HAL
  1.2434 +attributes: HALData::EPointer3DEnterHighPressureThreshold, HALData::EPointer3DExitHighPressureThreshold. 
  1.2435 +
  1.2436 +If this method is never called on a particular device, the default threshold values defined by this device's 
  1.2437 +manufacturer are used.
  1.2438 +
  1.2439 +@param aEnterHighPressureThreshold a new threshold for TPointerEvent::EEnterHighPressure
  1.2440 +                                   to be set, specified as Z coordinate value
  1.2441 +@param aExitHighPressureThreshold a new threshold for TPointerEvent::EExitHighPressure
  1.2442 +                                  to be set, specified as Z coordinate value
  1.2443 +@return KErrNone if successful, 
  1.2444 +        KErrNotSupported if the platform doesn't support threshold values for 
  1.2445 +                         High Pressure events,
  1.2446 +        KErrArgument if aEnterHighPressureThreshold is less than aExitHighPressureThreshold; 
  1.2447 +                     when this error occurs, threshold values are not changed. 
  1.2448 +@capability WriteDeviceData
  1.2449 +@see TPointerEvent::EEnterHighPressure
  1.2450 +@see TPointerEvent::EExitHighPressure
  1.2451 +@see HALData::EPointer3DEnterHighPressureThreshold
  1.2452 +@see HALData::EPointer3DExitHighPressureThreshold
  1.2453 +@publishedPartner
  1.2454 +@prototype To become released with WSERV NGA APIs */
  1.2455 +	{
  1.2456 +	TWsClCmdZThresholdPair params(aEnterHighPressureThreshold, aExitHighPressureThreshold);
  1.2457 +	return WriteReply(&params,sizeof(params),EWsClOpSetHighPressureThresholds);
  1.2458 +	}
  1.2459 +
  1.2460 +EXPORT_C TInt RWsSession::GetEnterHighPressureThreshold() const
  1.2461 +/**
  1.2462 +@return Z coordinate threshold value for TPointerEvent::EEnterHighPressure events
  1.2463 +@see TPointerEvent::EEnterHighPressure
  1.2464 +@publishedPartner To become publishedAll with WSERV NGA APIs
  1.2465 +@prototype To become released with WSERV NGA APIs */
  1.2466 +	{
  1.2467 +	return WriteReply(EWsClOpGetEnterHighPressureThreshold);	
  1.2468 +	}
  1.2469 +
  1.2470 +EXPORT_C TInt RWsSession::GetExitHighPressureThreshold() const
  1.2471 +/**
  1.2472 +@return Z coordinate threshold value for TPointerEvent::EExitHighPressure events
  1.2473 +@see TPointerEvent::EExitHighPressure
  1.2474 +@publishedPartner To become publishedAll with WSERV NGA APIs
  1.2475 +@prototype To become released with WSERV NGA APIs */
  1.2476 +	{
  1.2477 +	return WriteReply(EWsClOpGetExitHighPressureThreshold);	
  1.2478 +	}
  1.2479 +
  1.2480 +EXPORT_C void RWsSession::EnableWindowSizeCacheL()
  1.2481 +/**
  1.2482 +Enables client side cache of window size to reduce client-server 
  1.2483 +activity triggered by calls to RWindowBase::Size()
  1.2484 +@leave KErrNoMemory Could not allocate the required memory.
  1.2485 +@internalAll */
  1.2486 +	{
  1.2487 +	iBuffer->EnableWindowSizeCacheL();
  1.2488 +	}
  1.2489 +
  1.2490 +EXPORT_C void RWsSession::SendEffectCommand(TInt aTfxCmd,const TDesC8& aTfxCmdData)
  1.2491 +/**
  1.2492 + Set the WServ session specific effect data or execute commands 
  1.2493 + to TFX Render Stage. The data or command passed by the client 
  1.2494 + API will be directed to MWsTfxApplication::SendEffectCommand.
  1.2495 + TFX Render Stage will accept only TFX application specific commands and data.
  1.2496 +@param aTfxCmd TFX Render Stage command.
  1.2497 +@param aTfxCmdData Structure related to the specified value of aTfxCmd, the default value is KNullDesC8.
  1.2498 +
  1.2499 +@capability WriteDeviceData Only if aTfxCmd has value ETfxCmdEnableAllTransitions or ETfxCmdDisableAllTransitions
  1.2500 +
  1.2501 +@publishedPartner
  1.2502 +*/
  1.2503 +	{
  1.2504 +	__ASSERT_ALWAYS(aTfxCmdData.Length()<=KMaxWservStringSize, Panic(EW32PanicStringTooLong));
  1.2505 +	TWsClCmdSendEffectCommand params(aTfxCmd,aTfxCmdData.Size(), NULL);
  1.2506 +	Write(&params,sizeof(params),aTfxCmdData.Ptr(),aTfxCmdData.Size(),EWsClOpSendEffectCommand);
  1.2507 +	}
  1.2508 +
  1.2509 +EXPORT_C void RWsSession::RegisterEffect(TInt aAction, TInt aPurpose, const TFileName& aResourceDir, const TFileName& aFilenameOutgoing, const TFileName& aFilenameIncoming, TUint aAppUid, TBitFlags aFlags)
  1.2510 +/**
  1.2511 +Sets a specific animation for a particular transition effect.
  1.2512 +
  1.2513 +Transition effect is represented by one of the values of enum TTfxTransitionActions.
  1.2514 +
  1.2515 +An animation is specified by a filename and directory; the file will contain a description of the animation 
  1.2516 +for that transition.  In fact each transition can have two animations associated with it, for example 
  1.2517 +an App shut down could have one animation with the old application disappearing and then another animation 
  1.2518 +for the App Launcher (or home screen) appearing.
  1.2519 +
  1.2520 +Animation can be applied to all App's Transition effect or to a specfic App by providing its AppUid.
  1.2521 +
  1.2522 +@param aAction Particular transition to register the animation for.
  1.2523 +@param aPurpose The purpose of the window.
  1.2524 +@param aResourceDir The name of the directory that contains the animation description files.
  1.2525 +@param aFilenameOutgoing The file containing the description of the animation for the outgoing phase of the transition. 
  1.2526 +						 Specify KNullDesC for no outgoing phase effect.
  1.2527 +@param aFilenameIncoming The file containing the description of the animation for the incoming phase of the transition. 
  1.2528 +						 Specify KNullDesC for no incoming phase effect.
  1.2529 +@param aAppUid The Application UID this effect applies to. Set to zero to specify that all apps will use default effect.
  1.2530 +@param aFlags Flag for the effect. Please see TTfxFlags for values this flag parameter can use.
  1.2531 +
  1.2532 +@capability WriteDeviceData This API does nothing if the client does not possess required Capability
  1.2533 +
  1.2534 +@publishedPartner
  1.2535 +*/
  1.2536 +	{
  1.2537 +	RTFXEffect tfxEffect(iWsHandle, iBuffer);
  1.2538 +	tfxEffect.RegisterTFXEffect(aAction, aPurpose, aResourceDir, aFilenameOutgoing, aFilenameIncoming, aAppUid, aFlags);
  1.2539 +	}
  1.2540 +
  1.2541 +EXPORT_C void RWsSession::UnregisterEffect(TInt aAction, TInt aPurpose, TUint aAppUid)
  1.2542 +/**
  1.2543 +Unregister already set animation for a particular transition effect
  1.2544 +
  1.2545 +@param aAction Particular transition to unregister the animation for.
  1.2546 +@param aPurpose The purpose of the window.
  1.2547 +@param aAppUid The Application UID this effect applies to. Set to 0 to specify the default effect will be unregistered.
  1.2548 +
  1.2549 +@capability WriteDeviceData This API does nothing if the client does not possess required Capability
  1.2550 +
  1.2551 +@publishedPartner
  1.2552 +*/
  1.2553 +	{
  1.2554 +	TWsClCmdUnRegisterEffect unregisterEffect(aAction, aPurpose, aAppUid);
  1.2555 +	Write(&unregisterEffect, sizeof(unregisterEffect), EWsClOpUnregisterTFXEffect);
  1.2556 +	}
  1.2557 +
  1.2558 +EXPORT_C void RWsSession::UnregisterAllEffects()
  1.2559 +/**
  1.2560 +Unregister animation for all transition effects.
  1.2561 +
  1.2562 +@capability WriteDeviceData This API does nothing if the client does not possess required Capability
  1.2563 +
  1.2564 +@publishedPartner
  1.2565 +*/
  1.2566 +	{
  1.2567 +	Write(EWsClOpUnregisterAllTFXEffect);
  1.2568 +	}
  1.2569 +	
  1.2570 +EXPORT_C void RWsSession::OverrideEffects(TInt aAction, TInt aPurpose, const TFileName& aResourceDir, const TFileName& aFilenameOutgoing, const TFileName& aFilenameIncoming, TBitFlags aFlags)
  1.2571 +/**
  1.2572 +Overides the default animation for given app's transition effect by sent animation description.
  1.2573 +Please refer RWsSession::RegisterEffect() comments for more information on animation description.
  1.2574 +
  1.2575 +@param aAction The particular transition to set the animation for.
  1.2576 +@param aPurpose This override only effects the window/layers owned by the application that have the specified purpose.
  1.2577 +@param aResourceDir The name of the directory that contains the animation description files.
  1.2578 +@param aFilenameOutgoing The file containing the description of the animation for the outgoing phase of the transition. 
  1.2579 +						 Specify KNullDesC for no outgoing phase effect.
  1.2580 +@param aFilenameIncoming The file containing the description of the animation for the incoming phase of the transition. 
  1.2581 +						 Specify KNullDesC for no incoming phase effect.
  1.2582 +@param aFlags Flag for the effect. Please see TTfxFlags for values this flag parameter can use.
  1.2583 +
  1.2584 +@capability WriteDeviceData This API does nothing if the client does not possess required Capability
  1.2585 +
  1.2586 +@publishedPartner
  1.2587 +*/
  1.2588 +	{
  1.2589 +	RTFXEffect tfxEffect(iWsHandle, iBuffer);
  1.2590 +	tfxEffect.OverrideTFXEffect(RTFXEffect::ETFXSession, aAction, aPurpose, aResourceDir, aFilenameOutgoing, aFilenameIncoming, aFlags);
  1.2591 +	}
  1.2592 +
  1.2593 +EXPORT_C void RWsSession::IndicateAppOrientation(TRenderOrientation aOrientation)
  1.2594 +/**
  1.2595 +Application informs window server the orientation of rendering it intends to use
  1.2596 +
  1.2597 +@param aOrientation The orientation the application intends to use
  1.2598 +
  1.2599 +@publishedPartner
  1.2600 +*/
  1.2601 +	{
  1.2602 +	return(WriteInt(aOrientation,EWsClOpIndicateAppOrientation));
  1.2603 +	}