windowing/windowserver/nga/CLIENT/RWS.CPP
changeset 0 5d03bc08d59c
child 11 fed1595b188e
child 36 01a6848ebfd7
equal deleted inserted replaced
-1:000000000000 0:5d03bc08d59c
       
     1 // Copyright (c) 1995-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 // IPC implementation of client side code
       
    15 // 
       
    16 //
       
    17 
       
    18 #include "../SERVER/w32cmd.h"
       
    19 #include "w32comm.h"
       
    20 #include <e32std.h>
       
    21 #include <w32std.h>
       
    22 #include "CLIENT.H"
       
    23 #include "graphics/windowserverconstants.h"
       
    24 
       
    25 const TInt KMaxWSERVMessagesSlot=-1;
       
    26 
       
    27 class RWsCustomTextCursor : public RWsSpriteBase
       
    28 	{
       
    29 	public:
       
    30 		RWsCustomTextCursor(RWsSession aWs, TInt aHandle) : RWsSpriteBase(aWs)
       
    31 			{ iWsHandle = aHandle; }
       
    32 	};
       
    33 
       
    34 
       
    35 EXPORT_C RWsSession::RWsSession()
       
    36 /** Default C++ constructor.
       
    37 
       
    38 Constructs an uninitialised window server session. Note that it does not establish 
       
    39 a connection to the window server - this must be done explicitly by calling 
       
    40 the session's Connect() function. Before Connect() is called, no corresponding 
       
    41 session object exists in the server, and the RWsSession contains no meaningful 
       
    42 handle. */
       
    43 	{}
       
    44 
       
    45 void RWsSession::connectL()
       
    46 	{
       
    47 	iBuffer=new(ELeave) RWsBuffer(this);
       
    48 	iBuffer->SetBufferSizeL(RWsBuffer::EDefBufferSize);
       
    49 	User::LeaveIfError(CreateSession(KWSERVServerName,Version(),KMaxWSERVMessagesSlot));
       
    50 	iWsHandle=User::LeaveIfError(SendReceive(EWservMessInit,TIpcArgs()));
       
    51 	}
       
    52 
       
    53 EXPORT_C TInt RWsSession::Connect()
       
    54 /** Connects the client session to the window server.
       
    55 
       
    56 Connect() should be the first function called on an RWsSession object after 
       
    57 it is created. The function establishes a connection to the window server, 
       
    58 creating a corresponding session object in the server. Each session has one 
       
    59 and only one connection to the server. Attempting to call Connect() when 
       
    60 a connection has already been made will cause a panic.
       
    61 
       
    62 After a connection has been successfully established, all events are delivered 
       
    63 to the client application through the RWsSession object.
       
    64 
       
    65 @return KErrNone if successful, otherwise another of the system-wide error 
       
    66 codes. */
       
    67 	{
       
    68 	TInt ret;
       
    69 
       
    70 	if (iBuffer!=NULL)
       
    71 		Panic(EW32PanicReConnect);
       
    72  	if ((ret=RFbsSession::Connect())==KErrNone)
       
    73 		{
       
    74 		TRAP(ret,connectL());
       
    75 		if (ret!=KErrNone)
       
    76 			{
       
    77 			if (!iBuffer)
       
    78 				RFbsSession::Disconnect();
       
    79 			Close();
       
    80 			}
       
    81 		else
       
    82 			iBuffer->SetCallBack();
       
    83 		}
       
    84 	return(ret);
       
    85 	}
       
    86 
       
    87 EXPORT_C TInt RWsSession::Connect(RFs& aFileServer)
       
    88 /** Connects the client session to the window server using pre constructed file server
       
    89 session.
       
    90 
       
    91 Connect() should be the first function called on an RWsSession object after 
       
    92 it is created. The function establishes a connection to the window server, 
       
    93 creating a corresponding session object in the server. Each session has one 
       
    94 and only one connection to the server. Attempting to call Connect() when 
       
    95 a connection has already been made will cause a panic.
       
    96 
       
    97 After a connection has been successfully established, all events are delivered 
       
    98 to the client application through the RWsSession object.
       
    99 
       
   100 @param aFileServer A fully constructed file server session
       
   101 @return KErrNone if successful, otherwise another of the system-wide error 
       
   102 codes. */
       
   103 	{
       
   104 	TInt ret;
       
   105 
       
   106 	if (iBuffer!=NULL)
       
   107 		Panic(EW32PanicReConnect);
       
   108  	if ((ret=RFbsSession::Connect(aFileServer))==KErrNone)
       
   109 		{
       
   110 		TRAP(ret,connectL());
       
   111 		if (ret!=KErrNone)
       
   112 			{
       
   113 			if (!iBuffer)
       
   114 				RFbsSession::Disconnect();
       
   115 			Close();
       
   116 			}
       
   117 		else
       
   118 			iBuffer->SetCallBack();
       
   119 		}
       
   120 	return(ret);
       
   121 	}
       
   122 
       
   123 EXPORT_C void RWsSession::Close()
       
   124 /** Closes the window server session. 
       
   125 
       
   126 This function cleans up all resources in the RWsSession and disconnects it 
       
   127 from the server. Prior to disconnecting from the window server, the client-side 
       
   128 window server buffer is destroyed without being flushed. This function should 
       
   129 be called when the RWsSession is no longer needed - normally just before 
       
   130 it is destroyed. */
       
   131 	{
       
   132 	if (iBuffer)
       
   133 		{
       
   134 		__ASSERT_ALWAYS(iBuffer->iDirectAcessCount==0,Panic(EW32PanicDirectMisuse));
       
   135 		iBuffer->CancelCallBack();
       
   136 		iBuffer->Destroy();
       
   137 		iBuffer=NULL;
       
   138 		RFbsSession::Disconnect();
       
   139 		}
       
   140 	RSessionBase::Close();
       
   141 	}
       
   142 
       
   143 // Private function(s)
       
   144 
       
   145 TInt RWsSession::DoSyncMsgBuf(const TIpcArgs& aIpcArgs)
       
   146 	{
       
   147 	return (SendReceive(EWservMessSyncMsgBuf,aIpcArgs));
       
   148 	}
       
   149 	
       
   150 TInt RWsSession::DoFlush(const TIpcArgs& aIpcArgs)
       
   151 	{
       
   152 	return (SendReceive(EWservMessCommandBuffer,aIpcArgs));
       
   153 	}
       
   154 
       
   155 EXPORT_C TVersion RWsSession::Version() const
       
   156 /** Gets the window server version.
       
   157 
       
   158 @return Window server version containing major and minor version numbers, 
       
   159 and build number. */
       
   160 	{
       
   161 
       
   162 	TVersion v(KWservMajorVersionNumber,KWservMinorVersionNumber,KWservBuildVersionNumber);
       
   163 	return(v);
       
   164 	}
       
   165 
       
   166 TInt RWsSession::doSetHotKey(TInt aOpcode, TInt aType, TUint aKeycode, TUint aModifierMask, TUint aModifiers)
       
   167 	{
       
   168 	TWsClCmdSetHotKey setHotKey;
       
   169 
       
   170 	setHotKey.type=aType;
       
   171 	setHotKey.keycode=(TUint16)aKeycode;
       
   172 	setHotKey.modifiers=aModifiers;
       
   173 	setHotKey.modifierMask=aModifierMask;
       
   174 	return(WriteReply(&setHotKey,sizeof(setHotKey),aOpcode));
       
   175 	}
       
   176 
       
   177 EXPORT_C TInt RWsSession::SetHotKey(THotKey aType, TUint aKeycode, TUint aModifierMask, TUint aModifiers)
       
   178 /** Sets the hot keys.
       
   179 
       
   180 Hot keys allow standard functions to be performed by application-defined key 
       
   181 combinations. 
       
   182 
       
   183 This function maps any key press (with optional modifiers) to one of the hot 
       
   184 keys defined in THotKey. More than one key combination may be mapped to each 
       
   185 hot key: a new mapping is added each time the function is called.
       
   186 
       
   187 Modifier key states are defined in TEventModifier. The modifiers that you 
       
   188 want to be in a particular state should be specified in aModifierMask and 
       
   189 the ones of these you want to be set should be specified in aModifiers. For 
       
   190 example, if you want to capture FN-A and you want the SHIFT modifier unset, 
       
   191 but you don't care about the state of the other modifiers then set both the 
       
   192 flags for SHIFT and FN in aModiferMask and only set FN in aModifiers.
       
   193 
       
   194 Note: default hotkey settings exist, but this function can be used for customisation. 
       
   195 Typically it might be be used by a shell application or other application 
       
   196 that controls system-wide settings.
       
   197 
       
   198 This function always causes a flush of the window server buffer.
       
   199 
       
   200 @param aType The hot key to be mapped
       
   201 @param aKeyCode The keycode to be mapped to the hot key
       
   202 @param aModifierMask Modifier keys to test for a match
       
   203 @param aModifiers Modifier keys to be tested for "on" state 
       
   204 @return KErrNone value if successful, otherwise another of the system-wide 
       
   205 error codes.
       
   206 @capability SwEvent */
       
   207 	{
       
   208 	return(doSetHotKey(EWsClOpSetHotKey, aType, aKeycode, aModifierMask, aModifiers));
       
   209 	}
       
   210 
       
   211 EXPORT_C TInt RWsSession::ClearHotKeys(THotKey aType)
       
   212 /** Clears all mappings for the specified hotkey, including the default mapping.
       
   213 
       
   214 Hotkeys allow standard functions to be performed by application-defined key 
       
   215 combinations. 
       
   216 
       
   217 This function always causes a flush of the window server buffer.
       
   218 
       
   219 @param aType The hot key to be cleared 
       
   220 @return KErrNone if successful, otherwise one of the system-wide error codes. 
       
   221 @see SetHotKey()
       
   222 @see RestoreDefaultHotKey()
       
   223 @capability SwEvent */
       
   224 	{
       
   225 	return(WriteReplyInt(aType,EWsClOpClearHotKeys));
       
   226 	}
       
   227 
       
   228 EXPORT_C TInt RWsSession::RestoreDefaultHotKey(THotKey aType)
       
   229 /** Restores the default mapping for a hot key.
       
   230 
       
   231 The function clears current mappings for a hot key and restores the default 
       
   232 mapping. See THotKey for the default.
       
   233 
       
   234 This function always causes a flush of the window server buffer.
       
   235 
       
   236 @param aType The hot key to restore to its default value 
       
   237 @return KErrNone if successful, otherwise another of the system-wide error 
       
   238 codes. 
       
   239 @see ClearHotKeys() */
       
   240 	{
       
   241 	return(WriteReplyInt(aType,EWsClOpRestoreDefaultHotKey));
       
   242 	}
       
   243 
       
   244 EXPORT_C void RWsSession::ComputeMode(TComputeMode aMode)
       
   245 /** Sets the mode used to control process priorities.
       
   246 
       
   247 The default window server behaviour is that the application that owns the 
       
   248 window with keyboard focus gets foreground process priority (EPriorityForeground) 
       
   249 while all other clients get background priority (EPriorityBackground). This 
       
   250 function can be used to over-ride this default behaviour, as discussed in 
       
   251 TComputeMode.
       
   252 
       
   253 Note:
       
   254 
       
   255 Unlike real Symbian phones, the Emulator runs on a single process. As a result, 
       
   256 on the Emulator this function sets the priority of individual threads rather 
       
   257 than of processes. The values used for thread priorities are EPriorityLess 
       
   258 instead of EPriorityBackground, and EPriorityNormal instead of EPriorityForeground.
       
   259 
       
   260 @param aMode The compute mode. */
       
   261 	{
       
   262 	WriteInt(aMode,EWsClOpComputeMode);
       
   263 	}
       
   264 
       
   265 /**
       
   266 This method has been deprecated. Shadowing of a window is no longer supported. 
       
   267 Calling it has no effect.
       
   268 @param aVector Ignored.
       
   269 @deprecated
       
   270 */
       
   271 EXPORT_C void RWsSession::SetShadowVector(const TPoint& /*aVector*/)
       
   272 	{
       
   273 	}
       
   274 
       
   275 /**
       
   276 This method has been deprecated. Shadowing of a window is no longer supported.
       
   277 Calling it has no effect.
       
   278 @return TPoint(0, 0)
       
   279 @deprecated
       
   280 */
       
   281 EXPORT_C TPoint RWsSession::ShadowVector() const
       
   282 	{
       
   283 	return TPoint();
       
   284 	}
       
   285 
       
   286 void RWsSession::doReadEvent(TRequestStatus *aStat, TInt aOpcode)
       
   287 	{
       
   288 	*aStat=KRequestPending;
       
   289 	if (iBuffer)
       
   290 		{
       
   291 		iBuffer->Flush(); //ignore error since this flushing should not return any error
       
   292 		}
       
   293 	__ASSERT_DEBUG(EWservMessAsynchronousService>=aOpcode, Assert(EW32AssertIllegalOpcode));
       
   294 	const TInt function=EWservMessAsynchronousService|aOpcode;
       
   295 	SendReceive(function,TIpcArgs(),*aStat);
       
   296 	}
       
   297 
       
   298 EXPORT_C void RWsSession::EventReady(TRequestStatus* aStat)
       
   299 /** Requests standard events from the window server.
       
   300 
       
   301 Standard events include all events except redraws and priority key events.
       
   302 
       
   303 The client application will typically handle the completed request using the 
       
   304 RunL() function of an active object, and in this case the request status aStat 
       
   305 should be the iStatus member of that CActive object.
       
   306 
       
   307 Notes:
       
   308 
       
   309 - The active object runs when an event is waiting. You should call GetEvent() 
       
   310 in the RunL() function to get the event.
       
   311 
       
   312 - You should not call this function again until you have either called GetEvent() 
       
   313 or EventReadyCancel().
       
   314 
       
   315 - Because this function is asynchronous, there is no guarantee that the Window 
       
   316 Server will process the request before the function returns. However, on single 
       
   317 core systems it is unusual for this function to return before the Window Server 
       
   318 has processed the request, because the client generally runs in a lower priority 
       
   319 thread than the Window Server. You should therefore expect the use of this 
       
   320 function to give rise to different behaviour between single and multicore systems.
       
   321 
       
   322 @param aStat Request status. On successful completion contains KErrNone, otherwise 
       
   323 another of the system-wide error codes.
       
   324 @see CActive
       
   325 @see GetEvent() */
       
   326 	{
       
   327 	doReadEvent(aStat,EWsClOpEventReady);
       
   328 	}
       
   329 
       
   330 EXPORT_C void RWsSession::RedrawReady(TRequestStatus* aStat)
       
   331 /** Requests redraw events from the window server.
       
   332 
       
   333 Typically, a client will create an active object for redraw events with a 
       
   334 lower priority than the active objects for standard events. The client will 
       
   335 then typically handle completed redraw requests in the active object's RunL() 
       
   336 function.
       
   337 
       
   338 As in EventReady(), the request status aStat should be used as the iStatus 
       
   339 member of an active object. When a redraw event occurs the active object's 
       
   340 RunL() function is called. The redraw event can be obtained by calling 
       
   341 GetRedraw() in the RunL().
       
   342 
       
   343 Notes:
       
   344 
       
   345 - You should not call this function again until you have either called 
       
   346 GetRedraw() or RedrawReadyCancel().
       
   347 
       
   348 - Because this function is asynchronous, there is no guarantee that the Window 
       
   349 Server will process the request before the function returns. However, on single 
       
   350 core systems it is unusual for this function to return before the Window Server 
       
   351 has processed the request, because the client generally runs in a lower priority 
       
   352 thread than the Window Server. You should therefore expect the use of this 
       
   353 function to give rise to different behaviour between single and multicore systems.
       
   354 
       
   355 @param aStat The request status. On successful completion contains KErrNone, 
       
   356 otherwise another of the system-wide error codes. 
       
   357 @see RedrawReadyCancel()
       
   358 @see GetRedraw()
       
   359 @see CActive */
       
   360 	{
       
   361 	doReadEvent(aStat,EWsClOpRedrawReady);
       
   362 	}
       
   363 	
       
   364 void RWsSession::GraphicMessageReady(TRequestStatus *aStat)
       
   365 	{
       
   366 	doReadEvent(aStat,EWsClOpGraphicMessageReady);
       
   367 	}
       
   368 	
       
   369 void RWsSession::GetGraphicMessage(TDes8& aData) const
       
   370 	{
       
   371 	WriteReplyP(TWriteDescriptorType(&aData),EWsClOpGetGraphicMessage);
       
   372 	}
       
   373 	
       
   374 void RWsSession::GraphicMessageCancel()
       
   375 	{
       
   376 	WriteReply(EWsClOpGraphicMessageCancel);
       
   377 	}
       
   378 
       
   379 void RWsSession::GraphicAbortMessage(TInt aError)
       
   380 	{
       
   381 	WriteReplyInt(aError, EWsClOpGraphicAbortMessage);
       
   382 	}
       
   383 
       
   384 TInt RWsSession::GraphicFetchHeaderMessage()
       
   385 	{
       
   386 	return WriteReply(EWsClOpGraphicFetchHeaderMessage);
       
   387 	}
       
   388 	
       
   389 EXPORT_C void RWsSession::PriorityKeyReady(TRequestStatus *aStat)
       
   390 /** Requests priority key events from the window server. 
       
   391 
       
   392 Typically, an client will create an active object for priority key events 
       
   393 with a higher priority than the active objects for standard events. The client 
       
   394 will then normally handle completed priority key requests in the active object's 
       
   395 RunL() function.
       
   396 
       
   397 As in EventReady(), the request status argument should be the set to the iStatus 
       
   398 member of CActive. When priority key events occur, they are obtained using 
       
   399 GetPriorityKey().
       
   400 
       
   401 Notes:
       
   402 
       
   403 - You should not call this function again until you have either called 
       
   404 GetPriorityKey() or PriorityKeyReadyCancel().
       
   405 
       
   406 - Because this function is asynchronous, there is no guarantee that the Window 
       
   407 Server will process the request before the function returns. However, on single 
       
   408 core systems it is unusual for this function to return before the Window Server 
       
   409 has processed the request, because the client generally runs in a lower priority 
       
   410 thread than the Window Server. You should therefore expect the use of this 
       
   411 function to give rise to different behaviour between single and multicore systems.
       
   412 
       
   413 @param aStat Request status. On successful completion contains KErrNone, otherwise 
       
   414 another of the system-wide error codes. 
       
   415 @see PriorityKeyReadyCancel()
       
   416 @see GetPriorityKey()
       
   417 @see CActive */
       
   418 	{
       
   419 	doReadEvent(aStat,EWsClOpPriorityKeyReady);
       
   420 	}
       
   421 
       
   422 EXPORT_C void RWsSession::GetEvent(TWsEvent &aEvent) const
       
   423 /** Gets a standard event from the session for processing.
       
   424 
       
   425 The type of event returned by GetEvent() may be any of those listed in TEventCode. 
       
   426 To access the data within an event, the event should be converted to the appropriate 
       
   427 type, using functions provided by the TWsEvent class. TWsEvent also provides 
       
   428 a function to find out the type of the event.
       
   429 
       
   430 Notes:
       
   431 
       
   432 It is possible that the returned event is of type EEventNull. Clients should 
       
   433 normally ignore these events.
       
   434 
       
   435 This function should only be called in response to notification that an event 
       
   436 has occurred, otherwise the client will be panicked.
       
   437 
       
   438 This function would normally be called in the RunL() function of an active 
       
   439 object which completes with the EventReady() function's request status.
       
   440 
       
   441 This function always causes a flush of the window server buffer.
       
   442 
       
   443 @param aEvent On return, contains the event that occurred 
       
   444 @see TEventCode
       
   445 @see EventReady() */
       
   446 	{
       
   447 	TPckgBuf<TWsEvent> event;
       
   448 	WriteReplyP(&event,EWsClOpGetEvent);
       
   449 	aEvent=event();
       
   450 	}
       
   451 
       
   452 EXPORT_C void RWsSession::PurgePointerEvents()
       
   453 /** Removes all pointer events waiting to be delivered to this session. 
       
   454 
       
   455 The events are removed from the event queue without being processed. This 
       
   456 might occur, for example, at application startup. */
       
   457 	{
       
   458 	Write(EWsClOpPurgePointerEvents);
       
   459 	}
       
   460 
       
   461 EXPORT_C void RWsSession::GetRedraw(TWsRedrawEvent &aEvent)
       
   462 /** Gets the redraw event from the session.
       
   463 
       
   464 This function is similar to GetEvent(), except that the event is returned 
       
   465 as a TWsRedrawEvent, and hence there is no need to convert it from a TWsEvent.
       
   466 
       
   467 The function should only be called after notification that a redraw is waiting.
       
   468 
       
   469 It always causes a flush of the window server buffer.
       
   470 
       
   471 @param aEvent On return, contains the redraw event that occurred 
       
   472 @see RedrawReady()
       
   473 @see GetEvent()
       
   474 @see CActive */
       
   475 	{
       
   476 	TPckgBuf<TWsRedrawEvent> redraw;
       
   477 	WriteReplyP(&redraw,EWsClOpGetRedraw);
       
   478 	aEvent=redraw();
       
   479 	}
       
   480 
       
   481 EXPORT_C void RWsSession::GetPriorityKey(TWsPriorityKeyEvent &aEvent) const
       
   482 /** Gets the completed priority key event from the window server session.
       
   483 
       
   484 Priority key events are typically used for providing "Abort" or "Escape" keys 
       
   485 for an application.
       
   486 
       
   487 This function is similar to GetEvent(), except that it returns a TWsPriorityKeyEvent 
       
   488 instead of a TWsEvent.
       
   489 
       
   490 Note: this should only be called after notification that a priority key event has 
       
   491 occurred.
       
   492 
       
   493 This function always causes a flush of the window server buffer.
       
   494 
       
   495 @param aEvent On return, contains the priority key event that occurred. 
       
   496 @see PriorityKeyReady()
       
   497 @see PriorityKeyReadyCancel() */
       
   498 	{
       
   499 	TPckgBuf<TWsPriorityKeyEvent> abortEvent;
       
   500 	WriteReplyP(&abortEvent,EWsClOpGetPriorityKey);
       
   501 	aEvent=abortEvent();
       
   502 	}
       
   503 
       
   504 EXPORT_C void RWsSession::EventReadyCancel()
       
   505 /** Cancels a request for standard events from the window server.
       
   506 
       
   507 This request was made using EventReady().
       
   508 
       
   509 The client application will typically use an active object to handle standard 
       
   510 events, and this function should be called from the active object's DoCancel() 
       
   511 function.
       
   512 
       
   513 This function always causes a flush of the window server buffer.
       
   514 
       
   515 @see EventReady() */
       
   516 	{
       
   517 	if (iWsHandle)
       
   518 		WriteReply(EWsClOpEventReadyCancel);
       
   519 	}
       
   520 
       
   521 EXPORT_C void RWsSession::RedrawReadyCancel()
       
   522 /** Cancels a redraw event request. 
       
   523 
       
   524 If active objects are used, this function should be called from the active 
       
   525 object's DoCancel() function.
       
   526 
       
   527 This function always causes a flush of the window server buffer.
       
   528 
       
   529 @see RedrawReady() */
       
   530 	{
       
   531 	if (iWsHandle)
       
   532 		WriteReply(EWsClOpRedrawReadyCancel);
       
   533 	}
       
   534 
       
   535 EXPORT_C void RWsSession::PriorityKeyReadyCancel()
       
   536 /** Cancels a priority key event request.
       
   537 
       
   538 If active objects are used, this function should be called from the active 
       
   539 object's DoCancel() function.
       
   540 
       
   541 This function always causes a flush of the window server buffer.
       
   542 
       
   543 @see PriorityKeyReady()
       
   544 @see CActive */
       
   545 	{
       
   546 	if (iWsHandle)
       
   547 		WriteReply(EWsClOpPriorityKeyReadyCancel);
       
   548 	}
       
   549 
       
   550 EXPORT_C void RWsSession::Flush()
       
   551 /** Sends all pending commands in the buffer to the window server. 
       
   552 
       
   553 Delivering a command to the window server requires a context switch, and so 
       
   554 it is more efficient to deliver several commands in one go. Hence all client 
       
   555 commands are normally first placed into a buffer for delivery to the window 
       
   556 server. 
       
   557 
       
   558 The buffer is delivered when it gets full, or when a command that returns a value 
       
   559 is called (there are a few exceptions to this), or when this function is called.
       
   560 
       
   561 Note: this function is called when a prompt response is required from the window 
       
   562 server, e.g. after doing some drawing.
       
   563 
       
   564 @see RWsSession::SetAutoFlush()
       
   565 @see RWsSession::SetBufferSizeL()
       
   566 @see RWsSession::SetMaxBufferSizeL()
       
   567 */
       
   568 	{
       
   569 	if (iBuffer)
       
   570 		iBuffer->Flush(NULL,ETrue);
       
   571 	}
       
   572 
       
   573 EXPORT_C TBool RWsSession::SetAutoFlush(TBool aState)
       
   574 /** Sets a session's auto-flush state. 
       
   575 
       
   576 If auto-flush is set to ETrue, the window server buffer is flushed immediately 
       
   577 anything is put into it, instead of waiting until it becomes full. This setting 
       
   578 is normally used only in a debugging environment. 
       
   579 
       
   580 If the auto-flush state is EFalse, the window server buffer is flushed normally.
       
   581 
       
   582 @param aState ETrue to set auto-flushing on, EFalse to disable auto-flushing. 
       
   583 @return Previous auto-flush state
       
   584 
       
   585 @see RWsSession::Flush()
       
   586 @see RWsSession::SetBufferSizeL()
       
   587 @see RWsSession::SetMaxBufferSizeL()
       
   588 */
       
   589 	{
       
   590 	return(iBuffer->SetAutoFlush(aState));
       
   591 	}
       
   592 
       
   593 EXPORT_C TInt RWsSession::NumWindowGroups() const
       
   594 /** Gets the total number of window groups currently running in the window server. 
       
   595 
       
   596 This includes all the groups running in all sessions.
       
   597 
       
   598 This function always causes a flush of the window server buffer.
       
   599 
       
   600 @return Total number of window groups running in the server */
       
   601 	{
       
   602 	return(WriteReply(EWsClOpNumWindowGroupsAllPriorities));
       
   603 	}
       
   604 
       
   605 EXPORT_C TInt RWsSession::NumWindowGroups(TInt aPriority) const
       
   606 /** Gets the number of window groups of a given window group priority running in 
       
   607 all sessions in the window server.
       
   608 
       
   609 This function always causes a flush of the window server buffer.
       
   610 
       
   611 @param aPriority Window group priority 
       
   612 @return Number of window groups of priority aPriority */
       
   613 	{
       
   614 	return(WriteReplyInt(aPriority,EWsClOpNumWindowGroups));
       
   615 	}
       
   616 
       
   617 EXPORT_C TInt RWsSession::NumWindowGroups(TInt aScreenNumber,TInt aPriority) const
       
   618 /** Gets the number of window groups of a given window group priority running on a specified screen
       
   619 
       
   620 This function always causes a flush of the window server buffer.
       
   621 
       
   622 @param aScreenNumber specifies the screen. 
       
   623 @param aPriority Window group priority. EAllPriorities is the enum for all priorities 
       
   624 @return Number of window groups of priority aPriority on the specified screen */
       
   625 	{
       
   626 	TWsClCmdNumWindowGroups params;
       
   627 	params.screenNumber = aScreenNumber;
       
   628 	params.priority = aPriority;
       
   629 	return(WriteReply(&params,sizeof(params),EWsClOpNumWindowGroupsOnScreen));	
       
   630 	}
       
   631 
       
   632 TInt RWsSession::doWindowGroupList(TInt aScreenNumber, TInt aPriority, CArrayFixFlat<TInt>* aWindowList, TInt aNumOpcode, TInt aListOpcode) const
       
   633 /** Gets the id of window groups of specified priority running on a specified screen.
       
   634 
       
   635 This function always causes a flush of the window server buffer.
       
   636 
       
   637 @param aScreenNumber specifies the screen.
       
   638 @param aPriority Window group priority 
       
   639 @param aWindowList List of identifiers
       
   640 @return KErrNone if successful, otherwise another of the system-wide error 
       
   641 codes.*/
       
   642 	{
       
   643 	TWsClCmdWindowGroupList params;
       
   644 	params.priority = aPriority;		
       
   645 	params.screenNumber = aScreenNumber;
       
   646 	if(aScreenNumber!=KDummyScreenNumber)
       
   647 		{
       
   648 		TWsClCmdNumWindowGroups numWinGrp;
       
   649 		numWinGrp.screenNumber = aScreenNumber;
       
   650 		numWinGrp.priority = aPriority;	
       
   651 		params.count=WriteReply(&numWinGrp,sizeof(numWinGrp),aNumOpcode);
       
   652 		}
       
   653 	else
       
   654 		params.count=WriteReplyInt(aPriority,aNumOpcode);
       
   655 
       
   656 	TRAPD(err,aWindowList->ResizeL(params.count));
       
   657 	if (err!=KErrNone || params.count==0)
       
   658 		return(err);
       
   659 	TPtr8 listPtr(reinterpret_cast<TUint8*>(&(*aWindowList)[0]),params.count*sizeof((*aWindowList)[0]));
       
   660 	TInt actualCount=WriteReplyP(&params, sizeof(params), &listPtr, aListOpcode);
       
   661 	err=KErrNone;
       
   662 	if (actualCount<0)
       
   663 		{
       
   664 		err=actualCount;
       
   665 		actualCount=0;
       
   666 		}
       
   667 	if (actualCount<params.count)
       
   668 		aWindowList->ResizeL(actualCount);	// Can't fail, only shrinking it
       
   669 	return(err);
       
   670 	}
       
   671 
       
   672 TInt RWsSession::doWindowGroupList(TInt aPriority, RArray<TWindowGroupChainInfo>* aWindowListCh, TInt aNumOpcode, TInt aListOpcode) const
       
   673 /** Gets the id of window groups and id of its parent window group of specified priority running in 
       
   674 all sessions in the window server.
       
   675 
       
   676 This function always causes a flush of the window server buffer.
       
   677 
       
   678 @param aPriority Window group priority 
       
   679 @param aWindowList List of identifiers
       
   680 @return KErrNone if successful else KErrNoMemory if there is insufficient memory to create the array. 
       
   681 This function will panic if aWindowListCh is Null.*/
       
   682 	{
       
   683 	__ASSERT_ALWAYS(aWindowListCh,Panic(EW32PanicNullArray));
       
   684 	TWsClCmdWindowGroupList params;
       
   685 	params.priority=aPriority;
       
   686 	params.count=WriteReplyInt(aPriority,aNumOpcode);
       
   687 	aWindowListCh->Reset();
       
   688 	TUint8* WindowList=static_cast<TUint8*>(User::Alloc(params.count*sizeof(TWindowGroupChainInfo)));
       
   689 	if(WindowList==NULL)
       
   690 		{
       
   691 		return KErrNoMemory;
       
   692 		}	
       
   693 	TPtr8 listPtr(WindowList,params.count*sizeof(TWindowGroupChainInfo));
       
   694 	WriteReplyP(&params, sizeof(params), &listPtr, aListOpcode);
       
   695 	new(aWindowListCh) RArray<TWindowGroupChainInfo>(sizeof(TWindowGroupChainInfo),(TWindowGroupChainInfo*)WindowList,params.count);
       
   696 	return KErrNone;
       
   697 	}
       
   698 
       
   699 EXPORT_C TInt RWsSession::WindowGroupList(CArrayFixFlat<TInt>* aWindowList) const
       
   700 /** Gets a list of identifiers of all window groups in all window server sessions.
       
   701 
       
   702 An array buffer must be created to store the resultant list.
       
   703 
       
   704 This function always causes a flush of the window server buffer.
       
   705 
       
   706 @param aWindowList List of identifiers of all window groups in the server.
       
   707 @return KErrNone if successful, otherwise another of the system-wide error 
       
   708 codes. */
       
   709 	{
       
   710 	return(doWindowGroupList(KDummyScreenNumber,0,aWindowList,EWsClOpNumWindowGroupsAllPriorities,EWsClOpWindowGroupListAllPriorities));
       
   711 	}
       
   712 
       
   713 EXPORT_C TInt RWsSession::WindowGroupList(CArrayFixFlat<TInt>* aWindowList,TInt aScreenNumber,TInt aPriority) const
       
   714 /** Lists the number of window groups of a given window group priority running on a specified screen.
       
   715 
       
   716 This function is the same as WindowGroupList() described above, but allows 
       
   717 the application to restrict the list of window groups to those of a particular 
       
   718 window group priority.
       
   719 
       
   720 This function always causes a flush of the window server buffer.
       
   721 
       
   722 @param aScreenNumber specifies the screen
       
   723 @param aPriority Window group priority . Enum for all priorities is EAllPriorities
       
   724 @param aWindowList List of identifiers of all window groups on the specified screen with the given priority 
       
   725 aPriority.
       
   726 @return KErrNone if successful, otherwise another of the system-wide error 
       
   727 codes. */
       
   728 	{
       
   729 	return(doWindowGroupList(aScreenNumber,aPriority,aWindowList,EWsClOpNumWindowGroupsOnScreen,EWsClOpWindowGroupList));	
       
   730 	}
       
   731 
       
   732 EXPORT_C TInt RWsSession::WindowGroupList(RArray<TWindowGroupChainInfo>* aWindowList) const
       
   733 /** Gets a list of identifier of window group and parent identifier of window group of
       
   734  all window groups in all window server sessions.
       
   735 
       
   736 An array buffer must be created to store the resultant list.
       
   737 
       
   738 This function always causes a flush of the window server buffer.
       
   739 
       
   740 @param aWindowList List of identifiers of all window groups in the server.
       
   741 @return KErrNone if successful otherwise KErrNoMemory if there is insufficient memory to create the array,
       
   742 Panics if aWindowList is NULL. */
       
   743 	{
       
   744 	return(doWindowGroupList(0,aWindowList,EWsClOpNumWindowGroupsAllPriorities,EWsClOpWindowGroupListAndChainAllPriorities));
       
   745 	}
       
   746 
       
   747 EXPORT_C TInt RWsSession::WindowGroupList(TInt aPriority,CArrayFixFlat<TInt>* aWindowList) const
       
   748 /** Lists the number of window groups of a given window group priority running 
       
   749 in all window server sessions.
       
   750 
       
   751 This function is the same as WindowGroupList() described above, but allows 
       
   752 the application to restrict the list of window groups to those of a particular 
       
   753 window group priority.
       
   754 
       
   755 This function always causes a flush of the window server buffer.
       
   756 
       
   757 @param aPriority Window group priority 
       
   758 @param aWindowList List of identifiers of all window groups in the server of priority 
       
   759 aPriority.
       
   760 @return KErrNone if successful, otherwise another of the system-wide error 
       
   761 codes. */
       
   762 	{
       
   763 	return(doWindowGroupList(KDummyScreenNumber,aPriority,aWindowList,EWsClOpNumWindowGroups,EWsClOpWindowGroupList));
       
   764 	}
       
   765 
       
   766 EXPORT_C TInt RWsSession::WindowGroupList(TInt aPriority, RArray<TWindowGroupChainInfo>* aWindowList) const
       
   767 /** Lists the number of window groups of a given window group priority running 
       
   768 in all window server sessions.
       
   769 
       
   770 This function is the same as WindowGroupList() described above, but allows 
       
   771 the application to restrict the list of window groups to those of a particular 
       
   772 window group priority.
       
   773 
       
   774 This function always causes a flush of the window server buffer.
       
   775 
       
   776 @param aPriority Window group priority 
       
   777 @param aWindowList List of identifiers of all window groups in the server of priority 
       
   778 aPriority.
       
   779 @return KErrNone if successful otherwise KErrNoMemory if there is insufficient memory to create the array, 
       
   780 Panics if aWindowList is NULL. */	
       
   781 	{
       
   782 	return(doWindowGroupList(aPriority,aWindowList,EWsClOpNumWindowGroups,EWsClOpWindowGroupListAndChain));
       
   783 	}
       
   784 
       
   785 EXPORT_C TInt RWsSession::GetDefaultOwningWindow() const
       
   786 /** Gets the identifier of the current default owning window group.
       
   787 
       
   788 This function always causes a flush of the window server buffer.
       
   789 
       
   790 @return Identifier of current default owning window group. Returns 0 if there 
       
   791 isn't one. */
       
   792 	{
       
   793 	return GetDefaultOwningWindow(KDummyScreenNumber);
       
   794 	}
       
   795 
       
   796 EXPORT_C TInt RWsSession::GetDefaultOwningWindow(TInt aScreenNumber) const
       
   797 /** Gets the identifier of the current default owning window group on a specified screen.
       
   798 
       
   799 This function always causes a flush of the window server buffer.
       
   800 
       
   801 @param aScreenNumber specifies the screen.
       
   802 @return Identifier of current default owning window group on the specified screen. Returns 0 if there 
       
   803 isn't one. */
       
   804 	{
       
   805 	return(WriteReplyInt(aScreenNumber,EWsClOpGetDefaultOwningWindow));	
       
   806 	}
       
   807 
       
   808 EXPORT_C TInt RWsSession::GetFocusWindowGroup() const
       
   809 /** Gets the identifier of the window group that currently has the keyboard focus.
       
   810 
       
   811 Note: this might not necessarily be the front-most window group, as window groups 
       
   812 can disable keyboard focus.
       
   813 
       
   814 This function always causes a flush of the window server buffer.
       
   815 
       
   816 @return Identifier of window group with keyboard focus. */
       
   817 	{
       
   818 	return GetFocusWindowGroup(KDummyScreenNumber);
       
   819 	}
       
   820 
       
   821 EXPORT_C TInt RWsSession::GetFocusWindowGroup(TInt aScreenNumber) const
       
   822 /** Gets the identifier of the window group on a specified screen that currently has the keyboard focus.
       
   823 
       
   824 Note: this might not necessarily be the front-most window group, as window groups 
       
   825 can disable keyboard focus.
       
   826 
       
   827 This function always causes a flush of the window server buffer.
       
   828 
       
   829 @param aScreenNumber specifies the screen.
       
   830 @return Identifier of window group with keyboard focus. */
       
   831 	{
       
   832 	return WriteReplyInt(aScreenNumber,EWsClOpGetFocusWindowGroup);	
       
   833 	}
       
   834 
       
   835 EXPORT_C TInt RWsSession::SetWindowGroupOrdinalPosition(TInt aIdentifier, TInt aPosition)
       
   836 /** Sets the ordinal position of a window group.
       
   837 
       
   838 This function allows the caller to change the ordinal position of an existing 
       
   839 window group. It would typically be used by a shell application.
       
   840 
       
   841 This function always causes a flush of the window server buffer.
       
   842 
       
   843 @param aIdentifier The window group. 
       
   844 @param aPosition Ordinal position for the window group. 
       
   845 @return KErrNone if successful, otherwise another of the system-wide error 
       
   846 codes. */
       
   847 	{
       
   848 	TWsClCmdSetWindowGroupOrdinalPosition params(aIdentifier,aPosition);
       
   849 	return(WriteReply(&params, sizeof(params),EWsClOpSetWindowGroupOrdinalPosition));
       
   850 	}
       
   851 
       
   852 EXPORT_C TInt RWsSession::GetWindowGroupClientThreadId(TInt aIdentifier, TThreadId &aThreadId) const
       
   853 /** Gets the thread ID of the client that owns the window group specified by the 
       
   854 window group identifier.
       
   855 
       
   856 This function always causes a flush of the window server buffer.
       
   857 
       
   858 @param aIdentifier The window group identifier. 
       
   859 @param aThreadId On return, contains the thread ID. 
       
   860 @return KErrNone if successful, otherwise another of the system-wide error 
       
   861 codes. */
       
   862 	{
       
   863 	TPtr8 ptr(reinterpret_cast<TUint8*>(&aThreadId),sizeof(aThreadId));
       
   864 	return(WriteReplyIntP(aIdentifier,&ptr,EWsClOpGetWindowGroupClientThreadId));
       
   865 	}
       
   866 
       
   867 EXPORT_C TInt RWsSession::GetWindowGroupHandle(TInt aIdentifier) const
       
   868 /** Gets the handle of the window specified by the window group identifier. 
       
   869 
       
   870 This is the handle that was passed as an argument to RWindowGroup::Construct().
       
   871 
       
   872 This function always causes a flush of the window server buffer.
       
   873 
       
   874 @param aIdentifier The window group identifier.
       
   875 @return Handle of the window group */
       
   876 	{
       
   877 	return(WriteReplyInt(aIdentifier,EWsClOpGetWindowGroupHandle));
       
   878 	}
       
   879 
       
   880 EXPORT_C TInt RWsSession::GetWindowGroupOrdinalPriority(TInt aIdentifier) const
       
   881 /** Gets a window group's priority.
       
   882 
       
   883 This function always causes a flush of the window server buffer.
       
   884 
       
   885 @param aIdentifier The window group identifier. 
       
   886 @return The window group priority. */
       
   887 	{
       
   888 	return(WriteReplyInt(aIdentifier,EWsClOpGetWindowGroupOrdinalPriority));
       
   889 	}
       
   890 
       
   891 EXPORT_C TInt RWsSession::SendEventToWindowGroup(TInt aIdentifier, const TWsEvent &aEvent)
       
   892 /** Sends an event to a window group.
       
   893 
       
   894 This function always causes a flush of the window server buffer.
       
   895 
       
   896 @param aIdentifier Window group identifier.
       
   897 @param aEvent Event to send to the window group.
       
   898 @return KErrNone if successful, KErrPermissionDenied if the client does not have 
       
   899 the required capability, KErrNoMemory if there is not enough room to add the 
       
   900 event to the event queue and otherwise another of the system-wide error codes.
       
   901 @capability SwEvent Required when aEvent.Type() < EEventUser unless the event 
       
   902 is for a window group owned by this session.
       
   903 
       
   904 @deprecated */
       
   905 	{
       
   906 	TWsClCmdSendEventToWindowGroup params(aIdentifier,aEvent);
       
   907 	return(WriteReply(&params, sizeof(params),EWsClOpSendEventToWindowGroup));
       
   908 	}
       
   909 
       
   910 EXPORT_C TInt RWsSession::SendEventToAllWindowGroups(const TWsEvent &aEvent)
       
   911 /** Sends the specified event to all existing window groups.
       
   912 
       
   913 This function always causes a flush of the window server buffer.
       
   914 
       
   915 @param aEvent The event to be sent to all window groups. 
       
   916 @return KErrNone if successful, KErrPermissionDenied if the client does not have 
       
   917 the required capability, KErrNoMemory if there is not enough room to add the 
       
   918 event to all the required event queues (although it may have been added to some 
       
   919 of them) and otherwise another of the system-wide error codes.
       
   920 @capability SwEvent Required when aEvent.Type() < EEventUser
       
   921 
       
   922 @deprecated */
       
   923 	{
       
   924 	TWsClCmdSendEventToWindowGroup params(0,aEvent);
       
   925 	return(WriteReply(&params, sizeof(params),EWsClOpSendEventToAllWindowGroup));
       
   926 	}
       
   927 
       
   928 EXPORT_C TInt RWsSession::SendEventToAllWindowGroups(TInt aPriority, const TWsEvent &aEvent)
       
   929 /** Sends the specified event to all window groups with the specified priority.
       
   930 
       
   931 This function always causes a flush of the window server buffer.
       
   932 
       
   933 @param aPriority The priority which window groups must have to be sent the 
       
   934 message.
       
   935 @param aEvent The event to be sent to the specified window groups.
       
   936 @return KErrNone if successful, KErrPermissionDenied if the client does not have 
       
   937 the required capability, KErrNoMemory if there is not enough room to add the 
       
   938 event to all the required event queues (although it may have been added to some 
       
   939 of them) and otherwise another of the system-wide error codes.
       
   940 @capability SwEvent Required when aEvent.Type() < EEventUser
       
   941 
       
   942 @deprecated  */
       
   943 	{
       
   944 	TWsClCmdSendEventToWindowGroup params(aPriority,aEvent);
       
   945 	return(WriteReply(&params, sizeof(params),EWsClOpSendEventToAllWindowGroupPriority));
       
   946 	}
       
   947 
       
   948 EXPORT_C TInt RWsSession::SendEventToOneWindowGroupsPerClient(const TWsEvent &aEvent)
       
   949 /** This function always causes a flush of the window server buffer.
       
   950 @capability SwEvent Required when aEvent.Type() < EEventUser 
       
   951 
       
   952 @deprecated  */
       
   953 	{
       
   954 	TWsClCmdSendEventToWindowGroup params(0,aEvent);
       
   955 	return(WriteReply(&params, sizeof(params),EWsClOpSendEventToOneWindowGroupPerClient));
       
   956 	}
       
   957 
       
   958 EXPORT_C TInt RWsSession::GetWindowGroupNameFromIdentifier(TInt aIdentifier, TDes &aWindowName) const
       
   959 /** Gets the name of a window group from its identifier. 
       
   960 
       
   961 Using the list of identifiers returned by WindowGroupList(), it is possible 
       
   962 to get the names of all window groups in the system. Note that window names 
       
   963 are a zero length string by default.
       
   964 
       
   965 Note that the window group name must have been previously set using RWindowGroup::SetName() 
       
   966 to contain a meaningful value.
       
   967 
       
   968 This function always causes a flush of the window server buffer.
       
   969 
       
   970 @param aIdentifier The identifier of the window group whose name is to be 
       
   971 inquired.
       
   972 @param aWindowName On return, contains the window group name.
       
   973 @return KErrNone if successful, otherwise another of the system-wide error 
       
   974 codes. */
       
   975 	{
       
   976 	TWsClCmdGetWindowGroupNameFromIdentifier params(aIdentifier,aWindowName.MaxLength());
       
   977 	return(WriteReplyP(&params,sizeof(params),&aWindowName,EWsClOpGetWindowGroupNameFromIdentifier));
       
   978 	}
       
   979 
       
   980 EXPORT_C TInt RWsSession::FindWindowGroupIdentifier(TInt aPreviousIdentifier,const TDesC& aMatch,TInt aOffset) const
       
   981 /** Gets all window groups whose names match a given string, which can contain 
       
   982 wildcards.
       
   983 
       
   984 An example use of this function might be to find all the currently 
       
   985 running instances of a particular application, assuming that the window group 
       
   986 name contains the application name. An optional argument, aOffset, specifies 
       
   987 the number of characters to be ignored at the beginning of the window group 
       
   988 name. As several window group names may match the given string, and the function 
       
   989 can return only one at a time, there is an argument, aPreviousIdentifier, 
       
   990 which gives the identifier for the previous match that was returned. In other 
       
   991 words, it means, "get me the next match after this one." The first time the 
       
   992 function is called, give 0 as the previous identifier.
       
   993 
       
   994 Matching is done using TDesC::MatchF(), which does a folded match. Wildcards 
       
   995 '*' and '?' can be used to denote one or more characters and exactly one character, 
       
   996 respectively. Windows are searched in front to back order.
       
   997 
       
   998 This function always causes a flush of the window server buffer.
       
   999 
       
  1000 @param aPreviousIdentifier Identifier of the last window group returned. If 
       
  1001 the value passed is not a valid identifier, the function returns KErrNotFound. 
       
  1002 @param aMatch String to match window group name against: may contain wildcards 
       
  1003 @param aOffset The first aOffset characters of the window group name are ignored 
       
  1004 when doing the match.
       
  1005 @return The next window group, after the one identified by aPreviousIdentifier, 
       
  1006 whose name matches aMatch. KErrNotFound if no window group matched or aPreviousIdentifier 
       
  1007 was not a valid identifier. */
       
  1008 	{
       
  1009 	TWsClCmdFindWindowGroupIdentifier params(aPreviousIdentifier,aOffset, aMatch.Length());
       
  1010 	return(WriteReply(&params,sizeof(params),aMatch.Ptr(),aMatch.Size(),EWsClOpFindWindowGroupIdentifier));
       
  1011 	}
       
  1012 
       
  1013 EXPORT_C TInt RWsSession::FindWindowGroupIdentifier(TInt aPreviousIdentifier,TThreadId aThreadId) const
       
  1014 /** Gets the identifiers of window groups belonging to a client which is owned 
       
  1015 by a thread with the specified thread ID.
       
  1016 
       
  1017 The thread may own more than one window group, so the identifier returned 
       
  1018 is the one after aPreviousIdentifier. The first time the function is called, 
       
  1019 use 0 for the previous identifier.
       
  1020 
       
  1021 This function always causes a flush of the window server buffer.
       
  1022 
       
  1023 @param aPreviousIdentifier Identifier returned by previous call 
       
  1024 @param aThreadId Thread owning the window group or groups. 
       
  1025 @return Next window group identifier after the one identified by aPreviousIdentifier */
       
  1026 	{
       
  1027 	TWsClCmdFindWindowGroupIdentifierThread params(aPreviousIdentifier, aThreadId);
       
  1028 	return(WriteReply(&params,sizeof(params),EWsClOpFindWindowGroupIdentifierThread));
       
  1029 	}
       
  1030 
       
  1031 EXPORT_C TInt RWsSession::SendMessageToWindowGroup(TInt aIdentifier, TUid aUid, const TDesC8 &aParams)
       
  1032 /** Sends a message to a window group. 
       
  1033 
       
  1034 The window group will then receive an event of type EEventMessageReady notifying 
       
  1035 it that a message has been received. The window group can belong to this or 
       
  1036 another session.
       
  1037 
       
  1038 In order to receive messages sent using this function you will need to implement 
       
  1039 the MCoeMessageObserver interface which is defined in the UI Control Framework API.
       
  1040 
       
  1041 This function always causes a flush of the window server buffer.
       
  1042 
       
  1043 @param aIdentifier The identifier of the window group to receive the message. 
       
  1044 @param aUid A UID which uniquely identifies the session sending the message. 
       
  1045 @param aParams The message data. An unlimited amount of data can be passed 
       
  1046 in this argument. 
       
  1047 @return KErrNone if successful, otherwise another of the system-wide error 
       
  1048 codes. 
       
  1049 @see MCoeMessageObserver 
       
  1050 
       
  1051 @deprecated  */
       
  1052 	{
       
  1053 	TWsClCmdSendMessageToWindowGroup params(aIdentifier, aUid, aParams.Length(),&aParams);
       
  1054 	return(WriteReplyByProvidingRemoteReadAccess(&params,sizeof(params),&aParams,EWsClOpSendMessageToWindowGroup));
       
  1055 	}
       
  1056 
       
  1057 EXPORT_C TInt RWsSession::SendMessageToAllWindowGroups(TUid aUid, const TDesC8& aParams)
       
  1058 /** Sends a message to all window groups.
       
  1059 
       
  1060 In order to receive messages sent using this function you will need to implement 
       
  1061 the MCoeMessageObserver interface which is defined in the UI Control Framework 
       
  1062 API.
       
  1063 
       
  1064 This function always causes a flush of the window server buffer.
       
  1065 
       
  1066 @param aUid A UID which uniquely identifies the session sending the message. 
       
  1067 @param aParams The message data. An unlimited amount of data can be passed 
       
  1068 in this argument. 
       
  1069 @return KErrNone if successful, otherwise another of the system-wide error 
       
  1070 codes. 
       
  1071 
       
  1072 @deprecated  */
       
  1073 	{
       
  1074 	TWsClCmdSendMessageToWindowGroup params(0, aUid, aParams.Length(),&aParams);
       
  1075 	return(WriteReplyByProvidingRemoteReadAccess(&params,sizeof(params),&aParams,EWsClOpSendMessageToAllWindowGroups));
       
  1076 	}
       
  1077 
       
  1078 EXPORT_C TInt RWsSession::SendMessageToAllWindowGroups(TInt aPriority, TUid aUid, const TDesC8& aParams)
       
  1079 /** Sends a message to all window groups with the specified priority.
       
  1080 
       
  1081 In order to receive messages sent using this function you will need to implement 
       
  1082 the MCoeMessageObserver interface which is defined in the UI Control Framework 
       
  1083 API.
       
  1084 
       
  1085 This function always causes a flush of the window server buffer.
       
  1086 
       
  1087 @param aPriority The priority which window groups must have to be sent the 
       
  1088 message. 
       
  1089 @param aUid A UID which uniquely identifies the session sending the message. 
       
  1090 @param aParams The message data. An unlimited amount of data can be passed 
       
  1091 in this argument. 
       
  1092 @return KErrNone if successful, otherwise another of the system-wide error 
       
  1093 codes. 
       
  1094 
       
  1095 @deprecated  */
       
  1096 	{
       
  1097 	TWsClCmdSendMessageToWindowGroup params(aPriority, aUid, aParams.Length(),&aParams);
       
  1098 	return(WriteReplyByProvidingRemoteReadAccess(&params,sizeof(params),&aParams,EWsClOpSendMessageToAllWindowGroupsPriority));
       
  1099 	}
       
  1100 
       
  1101 
       
  1102 /** Called by the client in response to an EEventMessageReady event to receive the message data.
       
  1103 
       
  1104 This function always causes a flush of the window server buffer.
       
  1105 
       
  1106 @param aUid A UID which uniquely identifies the session sending the message.
       
  1107 @param aParams The message data. An unlimited amount of data can be passed 
       
  1108 in this argument.
       
  1109 @param aMessageEvent The event sent from the server to the client to identify the message.
       
  1110 @return KErrNone if successful, KErrNoMemory if there is insufficient memory for
       
  1111 the message data, otherwise another of the system-wide error codes.
       
  1112 */
       
  1113 EXPORT_C TInt RWsSession::FetchMessage(TUid& aUid, TPtr8& aParams, const TWsEvent& aMessageEvent) const
       
  1114 	{
       
  1115 	const SEventMessageReady& eventMessageReady=*(SEventMessageReady*)aMessageEvent.EventData();
       
  1116 	TUint8* ptr=(TUint8*)User::Alloc(eventMessageReady.iMessageParametersSize);
       
  1117 	if (ptr==NULL)
       
  1118 		{
       
  1119 		aParams.Set(NULL, 0, 0);
       
  1120 		return KErrNoMemory;
       
  1121 		}
       
  1122 	aUid=eventMessageReady.iMessageUid;
       
  1123 	aParams.Set(ptr, eventMessageReady.iMessageParametersSize, eventMessageReady.iMessageParametersSize);
       
  1124 	TWsClCmdFetchMessage outGoingParams(eventMessageReady.iWindowGroupIdentifier);
       
  1125 	const TInt error=WriteReplyP(&outGoingParams, sizeof(outGoingParams), &aParams, EWsClOpFetchMessage); // must be called even if eventMessageReady.iMessageParametersSize==0
       
  1126 	if (error!=KErrNone)
       
  1127 		{
       
  1128 		delete ptr;
       
  1129 		aParams.Set(NULL, 0, 0);
       
  1130 		}
       
  1131 	return error;
       
  1132 	}
       
  1133 
       
  1134 EXPORT_C TInt RWsSession::SetKeyboardRepeatRate(const TTimeIntervalMicroSeconds32 &aInitialTime, const TTimeIntervalMicroSeconds32 &aTime)
       
  1135 /** Sets the system-wide keyboard repeat rate. 
       
  1136 
       
  1137 This is the rate at which keyboard events are generated when a key is held 
       
  1138 down.
       
  1139 
       
  1140 The default settings for the keyboard repeat rate are 0.3 seconds for the 
       
  1141 initial delay, and 0.1 seconds for the interval between subsequent repeats. 
       
  1142 However, since the settings are system-wide, these will not necessarily be 
       
  1143 the current settings when an application is launched: the settings may have 
       
  1144 been over-ridden by another module.
       
  1145 
       
  1146 This function always causes a flush of the window server buffer.
       
  1147 
       
  1148 @param aInitialTime Time before first repeat key event 
       
  1149 @param aTime Time between subsequent repeat key events 
       
  1150 @return KErrNone if successful, otherwise another of the system-wide error 
       
  1151 codes. 
       
  1152 @see GetKeyboardRepeatRate()
       
  1153 @capability WriteDeviceData */
       
  1154 	{
       
  1155 	TWsClCmdSetKeyboardRepeatRate repeat(aInitialTime,aTime);
       
  1156 	return(WriteReply(&repeat,sizeof(repeat),EWsClOpSetKeyboardRepeatRate));
       
  1157 	}
       
  1158 
       
  1159 EXPORT_C void RWsSession::GetKeyboardRepeatRate(TTimeIntervalMicroSeconds32 &aInitialTime, TTimeIntervalMicroSeconds32 &aTime) const
       
  1160 /** Gets the current system-wide settings for the keyboard repeat rate.
       
  1161 
       
  1162 This function always causes a flush of the window server buffer.
       
  1163 
       
  1164 @param aInitialTime Time before first repeat key event 
       
  1165 @param aTime Time between subsequent repeat key events 
       
  1166 @see SetKeyboardRepeatRate() */
       
  1167 	{
       
  1168 	TPckgBuf<SKeyRepeatSettings> settings;
       
  1169 	WriteReplyP(&settings,EWsClOpGetKeyboardRepeatRate);
       
  1170 	aInitialTime=settings().iInitialTime;
       
  1171 	aTime=settings().iTime;
       
  1172 	}
       
  1173 
       
  1174 EXPORT_C TInt RWsSession::SetDoubleClick(const TTimeIntervalMicroSeconds32 &aInterval, TInt aDistance)
       
  1175 /** Sets the system-wide double click settings.
       
  1176 
       
  1177 Double click distance is measured, in pixels, as the sum of the X distance 
       
  1178 moved and the Y distance moved between clicks. For example: a first click 
       
  1179 at 10, 20 and a second click at 13,19 gives a distance of (13-10)+(21-20) = 4.
       
  1180 
       
  1181 This function always causes a flush of the window server buffer.
       
  1182 
       
  1183 @param aInterval Maximum interval between clicks that constitutes a double 
       
  1184 click 
       
  1185 @param aDistance Maximum distance between clicks that constitutes a double 
       
  1186 click
       
  1187 @return KErrNone if successful, otherwise another of the system-wide error 
       
  1188 codes.
       
  1189 @see GetDoubleClickSettings()
       
  1190 @capability WriteDeviceData */
       
  1191 	{
       
  1192 	TWsClCmdSetDoubleClick dblClick(aInterval,aDistance);
       
  1193 	return(WriteReply(&dblClick,sizeof(dblClick),EWsClOpSetDoubleClick));
       
  1194 	}
       
  1195 
       
  1196 EXPORT_C void RWsSession::GetDoubleClickSettings(TTimeIntervalMicroSeconds32 &aInterval, TInt &aDistance) const
       
  1197 /** Gets the current system-wide settings for pointer double clicks.
       
  1198 
       
  1199 Double click distances are measured in pixels as the sum of the X distance 
       
  1200 moved and the Y distance moved between clicks. For example: a first click 
       
  1201 at 10, 20 and a second click at 13,19 gives a distance of (13-10)+(21-20) = 4.
       
  1202 
       
  1203 This function always causes a flush of the window server buffer.
       
  1204 
       
  1205 @param aInterval Maximum interval between clicks that constitutes a double 
       
  1206 click 
       
  1207 @param aDistance Maximum distance between clicks that constitutes a double 
       
  1208 click 
       
  1209 @see SetDoubleClick() */
       
  1210 	{
       
  1211 	TPckgBuf<SDoubleClickSettings> settings;
       
  1212 	WriteReplyP(&settings,EWsClOpGetDoubleClickSettings);
       
  1213 	aInterval=settings().iInterval;
       
  1214 	aDistance=settings().iDistance;
       
  1215 	}
       
  1216 
       
  1217 EXPORT_C void RWsSession::SetBackgroundColor(TRgb aColor)
       
  1218 /** Sets the background colour for the window server. 
       
  1219 
       
  1220 This background can only be seen in areas of the display that have no windows 
       
  1221 on them: so for many applications it will never be seen. It affects no 
       
  1222 other windows.
       
  1223 
       
  1224 @param aColor Background colour */
       
  1225 	{
       
  1226 	WriteInt(aColor.Internal(),EWsClOpSetBackgroundColor);
       
  1227 	}
       
  1228 
       
  1229 EXPORT_C TRgb RWsSession::GetBackgroundColor() const
       
  1230 /** Gets the window server's background colour.
       
  1231 
       
  1232 This function always causes a flush of the window server buffer.
       
  1233 
       
  1234 @return Background colour */
       
  1235 	{
       
  1236 	TRgb col;
       
  1237 	col.SetInternal((TUint32)WriteReply(EWsClOpGetBackgroundColor));
       
  1238 	return col;
       
  1239 	}
       
  1240 
       
  1241 EXPORT_C TInt RWsSession::RegisterSurface(TInt aScreenNumber, const TSurfaceId& aSurface)
       
  1242 /**
       
  1243 This function registers a surface for use in composition on the screen associated 
       
  1244 with this device within this session.
       
  1245 
       
  1246 A surface may be registered as a separate step before it is added as a background surface 
       
  1247 for a window created in the same session and that is displayed on this screen. This then 
       
  1248 allows content to be provisioned before the surface is displayed for the first time, and 
       
  1249 to be kept "live" while not assigned to any window.
       
  1250 
       
  1251 A surface can be successfully registered in multiple sessions and on multiple screens, but 
       
  1252 only once for a given combination of session and screen.
       
  1253 
       
  1254 The client should call UnregisterSurface when finished with the surface registered using 
       
  1255 this method. The surface will be automatically unregistered if necessary when the session closes.
       
  1256 
       
  1257 @param aScreenNumber The screen to which to register.
       
  1258 @param aSurface The surface to be registered.
       
  1259 @return KErrNone on success or a system-wide error code
       
  1260 	- KErrNoMemory if registration fails due to low memory.
       
  1261 	- KErrInUse if the surface ID is already registered for this session and screen.
       
  1262 @pre aSurface has been initialized and is compatible with being composited on this device's 
       
  1263 screen; otherwise the client thread is panicked with code EWservPanicIncompatibleSurface.
       
  1264 @pre aScreenNumber is an acceptable screen number. Otherwise the client thread is panicked 
       
  1265 with code EWservPanicScreenNumber.
       
  1266 @post The surface has been successfully registered for use in composition on this device's screen.
       
  1267 @post The surface’s content is in an undefined state, but the surface remains initialized.
       
  1268 @post This function always causes a flush of the WServ session buffer.
       
  1269 @see UnregisterSurface
       
  1270 
       
  1271 @publishedPartner
       
  1272 @prototype
       
  1273 */
       
  1274 	{
       
  1275 	TWsClCmdSurfaceRegister surfaceRegister(aScreenNumber,aSurface);
       
  1276 	return(WriteReply(&surfaceRegister,sizeof(surfaceRegister),EWsClOpRegisterSurface));
       
  1277 	}
       
  1278 
       
  1279 EXPORT_C void RWsSession::UnregisterSurface(TInt aScreenNumber, const TSurfaceId& aSurface)
       
  1280 /**
       
  1281 This function removes the surface from the session's register of surfaces that are used in 
       
  1282 composition on the screen associated with this device.
       
  1283 
       
  1284 Calling this function with a surface that is not currently explicitly registered on this screen 
       
  1285 in this session by RegisterSurface() will have no effect.
       
  1286 
       
  1287 Calling this function while the surface is still assigned to a window will have no immediate 
       
  1288 effect. However, when the surface is unassigned from the window, and is not held by another 
       
  1289 session it will then be automatically unregistered.
       
  1290 
       
  1291 An unregistered surface can be re-registered again, if necessary.
       
  1292 
       
  1293 This function does not explicitly force a flush of the WServ session buffer. Internal reference 
       
  1294 counting will keep the Surface ID "live" until the client code has released any handles and 
       
  1295 provisioners, and WServ processes the buffered remove command, and the final frame containing 
       
  1296 this surface has finished being displayed.
       
  1297 
       
  1298 @param aScreenNumber The screen to which to unregister.
       
  1299 @param aSurface The surface to be unregistered.
       
  1300 @pre aSurface has been initialized; otherwise the client thread is panicked with 
       
  1301 code EWservPanicIncompatibleSurface.
       
  1302 @pre aScreenNumber is an acceptable screen number. Otherwise the client thread is 
       
  1303 panicked with code EWservPanicScreenNumber.
       
  1304 @post If no window is using the surface, then it is unregistered on this screen in this session.
       
  1305 @see RegisterSurface
       
  1306 
       
  1307 @publishedPartner
       
  1308 @prototype
       
  1309 */
       
  1310 	{
       
  1311 	TWsClCmdSurfaceRegister surfaceRegister(aScreenNumber,aSurface);
       
  1312 	Write(&surfaceRegister,sizeof(surfaceRegister),EWsClOpUnregisterSurface);
       
  1313 	}
       
  1314 
       
  1315 EXPORT_C TInt RWsSession::PreferredSurfaceConfigurationSize() const
       
  1316 /**
       
  1317 Returns the window server's preferred size for the TSurfaceConfiguration object, used 
       
  1318 for RWindow::SetBackgroundSurface.
       
  1319 
       
  1320 Client code is permitted to present any defined version of the TSurfaceConfiguration 
       
  1321 class, distinguished by its size. If smaller, earlier versions are presented, the server 
       
  1322 will substitute the stated default values. If later, larger, structures are presented to 
       
  1323 the server then the additional data will be ignored.
       
  1324 
       
  1325 However, by using this method, the client can fine-tune its use of the interface, avoiding 
       
  1326 generating attribute data that may not be supported, or reduce the options presented to users.
       
  1327 
       
  1328 @return The preferred size in bytes
       
  1329 	- Should match one of the TSurfaceConfiguration classes defined in the client's header 
       
  1330 	file, or be larger than them all, indicating a version newer that the client is compiled for.
       
  1331 	- If the server does not support surface configuration 
       
  1332 		- Return KErrNotSupported.
       
  1333 
       
  1334 @publishedPartner
       
  1335 @prototype
       
  1336 */
       
  1337 	{
       
  1338 	return sizeof(TSurfaceConfiguration);
       
  1339 	}
       
  1340 
       
  1341 EXPORT_C TInt RWsSession::SetSystemPointerCursor(const RWsPointerCursor &aPointerCursor,TInt aCursorNumber)
       
  1342 /** Sets a cursor in the system pointer cursor list. 
       
  1343 
       
  1344 To gain access to the list, the client must first call ClaimSystemPointerCursorList().
       
  1345 
       
  1346 This function always causes a flush of the window server buffer.
       
  1347 
       
  1348 @param aPointerCursor Pointer cursor to set in the list 
       
  1349 @param aCursorNumber Cursor number in the list 
       
  1350 @return KErrNone if successful, otherwise another of the system-wide error 
       
  1351 codes. */
       
  1352 	{
       
  1353 	TWsClCmdSetSystemPointerCursor setpc;
       
  1354 	setpc.handle=aPointerCursor.WsHandle();
       
  1355 	setpc.number=aCursorNumber;
       
  1356 	return(WriteReply(&setpc,sizeof(setpc),EWsClOpSetSystemPointerCursor));
       
  1357 	}
       
  1358 
       
  1359 EXPORT_C void RWsSession::ClearSystemPointerCursor(TInt aCursorNumber)
       
  1360 /** Clears a system pointer cursor from the list. 
       
  1361 
       
  1362 Before calling this function, the client must first gain access to the list 
       
  1363 by calling ClaimSystemPointerCursorList().
       
  1364 
       
  1365 @param aCursorNumber Cursor number to clear */
       
  1366 	{
       
  1367 	WriteInt(aCursorNumber,EWsClOpClearSystemPointerCursor);
       
  1368 	}
       
  1369 
       
  1370 EXPORT_C TInt RWsSession::ClaimSystemPointerCursorList()
       
  1371 /** Claims the system pointer cursor list.
       
  1372 
       
  1373 You must call this function before you can call SetSystemPointerCursor() or 
       
  1374 ClearSystemPointerCursor().
       
  1375 
       
  1376 This function always causes a flush of the window server buffer.
       
  1377 
       
  1378 @return KErrNone if successful, KErrInUse if another client is already using 
       
  1379 the system pointer cursor list, otherwise another of the system-wide error 
       
  1380 codes. 
       
  1381 @see FreeSystemPointerCursorList()
       
  1382 @capability WriteDeviceData */
       
  1383 	{
       
  1384 	return(WriteReply(EWsClOpClaimSystemPointerCursorList));
       
  1385 	}
       
  1386 
       
  1387 EXPORT_C void RWsSession::FreeSystemPointerCursorList()
       
  1388 /** Releases the system pointer cursor list and deletes all the entries in it. 
       
  1389 
       
  1390 A client should call this function when it no longer needs the system pointer 
       
  1391 cursor list. */
       
  1392 	{
       
  1393 	if (iWsHandle)
       
  1394 		Write(EWsClOpFreeSystemPointerCursorList);
       
  1395 	}
       
  1396 
       
  1397 EXPORT_C TInt RWsSession::SetCustomTextCursor(TInt aIdentifier, const TArray<TSpriteMember>& aSpriteMemberArray, TUint aSpriteFlags, TCustomTextCursorAlignment aAlignment)
       
  1398 /** Adds a custom text cursor to the server's list of cursors.
       
  1399 
       
  1400 After adding a custom text cursor, it can be selected for use by calling 
       
  1401 RWindowGroup::SetTextCursor().
       
  1402 
       
  1403 Note that once added, custom text cursors cannot be removed.
       
  1404 
       
  1405 This function always causes a flush of the window server buffer.
       
  1406 
       
  1407 @param aIdentifier The unique identifier for the cursor.
       
  1408 @param aSpriteMemberArray An array defining the bitmap(s) that make up the 
       
  1409 cursor. Typically, this array will contain a single element for a static, 
       
  1410 non-animated cursor.
       
  1411 @param aSpriteFlags Flags affecting the sprite behaviour. For possible values 
       
  1412 see TSpriteFlags.
       
  1413 @param aAlignment The vertical alignment of the cursor sprite.
       
  1414 @return KErrNone if successful, KErrAlreadyExists if a custom cursor with the 
       
  1415 specified identifier already exists, or another of the standard system wide 
       
  1416 error codes. */
       
  1417 	{
       
  1418 	// Create the cursor
       
  1419 	TWsClCmdCustomTextCursorData params;
       
  1420 	params.identifier = aIdentifier;
       
  1421 	params.flags = aSpriteFlags;
       
  1422 	params.alignment = aAlignment;
       
  1423 	const TInt handle = iBuffer->WriteReplyWs(&params, sizeof(params), EWsClOpStartSetCustomTextCursor);
       
  1424 	if (handle < 0)
       
  1425 		{
       
  1426 		return handle; // Failed to create
       
  1427 		}
       
  1428 
       
  1429 	RWsCustomTextCursor cursor(*this, handle);
       
  1430 	TInt err = KErrNone;
       
  1431 	for (TInt ii = 0; ii < aSpriteMemberArray.Count(); ii++)
       
  1432 		{
       
  1433 		err = cursor.AppendMember(aSpriteMemberArray[ii]);
       
  1434 		if (err != KErrNone)
       
  1435 			{
       
  1436 			break;
       
  1437 			}
       
  1438 		}
       
  1439 	cursor.Close();
       
  1440 	err = iBuffer->WriteReplyWs(&err, sizeof(err), EWsClOpCompleteSetCustomTextCursor);
       
  1441 	return err;
       
  1442 	}
       
  1443 
       
  1444 EXPORT_C TInt RWsSession::SetModifierState(TEventModifier aModifier,TModifierState aState)
       
  1445 /** Sets the state of the modifier keys. 
       
  1446 
       
  1447 This function is typically used for permanent modifier states such as Caps 
       
  1448 Lock or Num Lock, but other possible uses include on-screen function key simulation, 
       
  1449 or the implementation of a Shift Lock key.
       
  1450 
       
  1451 This function always causes a flush of the window server buffer.
       
  1452 
       
  1453 @param aModifier Modifier to set. 
       
  1454 @param aState Modifier state.
       
  1455 @return KErrNone if successful, otherwise another of the system-wide error 
       
  1456 codes. 
       
  1457 @see GetModifierState()
       
  1458 @capability WriteDeviceData */
       
  1459 	{
       
  1460 	TWsClCmdSetModifierState params;
       
  1461 	params.modifier=aModifier;
       
  1462 	params.state=aState;
       
  1463 	return(WriteReply(&params,sizeof(params),EWsClOpSetModifierState));
       
  1464 	}
       
  1465 
       
  1466 EXPORT_C TInt RWsSession::GetModifierState() const
       
  1467 /** Gets the state of the modifier keys.
       
  1468 
       
  1469 The state of each modifier key (defined in TEventModifier) is returned in 
       
  1470 a bitmask.
       
  1471 
       
  1472 This function always causes a flush of the window server buffer.
       
  1473 
       
  1474 @return Modifier state 
       
  1475 @see TEventModifier */
       
  1476 	{
       
  1477 	return(WriteReply(EWsClOpGetModifierState));
       
  1478 	}
       
  1479 
       
  1480 EXPORT_C TInt RWsSession::HeapCount() const
       
  1481 /** Gets the heap count.
       
  1482 
       
  1483 This function calls RHeap::Count() on the window server's heap, after throwing 
       
  1484 away all the temporary objects allocated for each window.
       
  1485 
       
  1486 This function always causes a flush of the window server buffer.
       
  1487 
       
  1488 @return The window server's heap count. */
       
  1489 	{
       
  1490 	return(WriteReply(EWsClOpHeapCount));
       
  1491 	}
       
  1492 
       
  1493 EXPORT_C TInt RWsSession::DebugInfo(TInt aFunction, TInt aParam) const
       
  1494 	{
       
  1495 	TWsClCmdDebugInfo params(aFunction,aParam);
       
  1496 	return(WriteReply(&params,sizeof(params),EWsClOpDebugInfo));
       
  1497 	}
       
  1498 
       
  1499 EXPORT_C TInt RWsSession::DebugInfo(TInt aFunction, TDes8& aReturnBuf, TInt aParam) const
       
  1500 	{
       
  1501 	TWsClCmdDebugInfo params(aFunction,aParam);
       
  1502 	return(WriteReplyP(&params,sizeof(params),TWriteDescriptorType(&aReturnBuf),EWsClOpDebugInfoReplyBuf));
       
  1503 	}
       
  1504 
       
  1505 EXPORT_C TInt RWsSession::ResourceCount() const
       
  1506 /** Gets the number of objects that the server has allocated for that client.
       
  1507 
       
  1508 This function can be used to check that the client has correctly cleaned up 
       
  1509 all of its objects.
       
  1510 
       
  1511 It always causes a flush of the window server buffer.
       
  1512 
       
  1513 @return The number of resources allocated to the client. */
       
  1514 	{
       
  1515 	return(iWsHandle ? WriteReply(EWsClOpResourceCount) : 0);
       
  1516 	}
       
  1517 
       
  1518 EXPORT_C void RWsSession::PasswordEntered()
       
  1519 /** Disables the window server password mode.
       
  1520 
       
  1521 This function must be called by the session which owns the password window 
       
  1522 when the correct machine password has been entered. 
       
  1523 
       
  1524 @deprecated */
       
  1525 	{
       
  1526 	Write(EWsClOpPasswordEntered);
       
  1527 	}
       
  1528 
       
  1529 EXPORT_C void RWsSession::HeapSetFail(TInt aTAllocFail,TInt aValue)
       
  1530 /** Sets the heap failure mode in the window server.
       
  1531 
       
  1532 The release version of the base does not support simulated heap failure functionality, 
       
  1533 and the result of this function is additional error messages. In the debug 
       
  1534 version the clients are notified of the simulated failure and handle it. See 
       
  1535 RHeap::__DbgSetAllocFail() for more information.
       
  1536 
       
  1537 Note:
       
  1538 
       
  1539 It is unlikely, but possible to create a ROM with a mixture of Release and 
       
  1540 Debug versions of the Base and Window Server DLLs, which results in different 
       
  1541 behaviour to that described above. If you run a debug Window Server with a 
       
  1542 release version of the Base, then calling this function will result in neither 
       
  1543 extra error messages (e.g. EDrawingRegion) nor simulated heap failures. However 
       
  1544 if you have a release Window Server with a debug Base then you will get both 
       
  1545 simulated heap failures and the extra error messages.
       
  1546 
       
  1547 This function always causes a flush of the window server buffer.
       
  1548 
       
  1549 @param aTAllocFail A value from the RHeap::TAllocFail enumeration which 
       
  1550 indicates how to simulate heap allocation failure. 
       
  1551 @param aValue The rate of failure; when aType is RHeap::EDeterministic, heap 
       
  1552 allocation fails every aRate attempt 
       
  1553 @see RHeap::__DbgSetAllocFail()
       
  1554 @capability WriteDeviceData */
       
  1555 	{
       
  1556 	TWsClCmdHeapSetFail params;
       
  1557 	params.type=(RHeap::TAllocFail)aTAllocFail;
       
  1558 	params.value=aValue;
       
  1559 	params.burst=-1;
       
  1560 	WriteReply(&params,sizeof(params),EWsClOpHeapSetFail);
       
  1561 	}
       
  1562 
       
  1563 EXPORT_C void RWsSession::HeapSetBurstFail(TInt aTAllocFail,TInt aRate,TInt aBurst)
       
  1564 /** Sets the heap failure burst mode in the window server.
       
  1565 
       
  1566 The release version of the base does not support simulated heap failure functionality, 
       
  1567 and the result of this function is additional error messages. In the debug 
       
  1568 version the clients are notified of the simulated failure and handle it. See 
       
  1569 RHeap::__DbgSetBurstAllocFail() for more information.
       
  1570 
       
  1571 Note:
       
  1572 
       
  1573 It is unlikely, but possible to create a ROM with a mixture of Release and 
       
  1574 Debug versions of the Base and Window Server DLLs, which results in different 
       
  1575 behaviour to that described above. If you run a debug Window Server with a 
       
  1576 release version of the Base, then calling this function will result in neither 
       
  1577 extra error messages (e.g. EDrawingRegion) nor simulated heap failures. However 
       
  1578 if you have a release Window Server with a debug Base then you will get both 
       
  1579 simulated heap failures and the extra error messages.
       
  1580 
       
  1581 This function always causes a flush of the window server buffer.
       
  1582 
       
  1583 @param aTAllocFail A value from the RHeap::TAllocFail enumeration which 
       
  1584 indicates how to simulate heap allocation failure. 
       
  1585 @param aRate The rate of failure; when aType is RHeap::EDeterministic, heap 
       
  1586 allocation fails every aRate attempt.
       
  1587 @param aBurst The number of consecutive allocations that should fail.
       
  1588 @see RHeap::__DbgSetBurstAllocFail()
       
  1589 @capability WriteDeviceData */
       
  1590 	{
       
  1591 	TWsClCmdHeapSetFail params;
       
  1592 	params.type=(RHeap::TAllocFail)aTAllocFail;
       
  1593 	params.value=aRate;
       
  1594 	params.burst=aBurst;
       
  1595 	WriteReply(&params,sizeof(params),EWsClOpHeapSetFail);
       
  1596 	}
       
  1597 
       
  1598 EXPORT_C TInt RWsSession::RequestOffEvents(TBool aOn,RWindowTreeNode *aWin/*=NULL*/)
       
  1599 /** Requests the window server to send OFF events to a window. 
       
  1600 
       
  1601 After calling this function, the window server sends OFF events to the window 
       
  1602 when an event occurs which requires power down, rather than handling powering 
       
  1603 down itself.
       
  1604 
       
  1605 Notes:
       
  1606 
       
  1607 Any client can ask for OFF events, but only one window in the system can be 
       
  1608 set to receive them. If this function is called when another window is set 
       
  1609 to receive OFF events then the client will be panicked. The exception is the 
       
  1610 shell, which is allowed to take receipt of OFF events from other clients.
       
  1611 
       
  1612 The window server identifies the shell client by comparing the process name 
       
  1613 of the client with the process name of the shell. Only the first client created 
       
  1614 by the shell is guaranteed to have the extra shell client privileges.
       
  1615 
       
  1616 If the shell dies or terminates just before the action requiring power down 
       
  1617 happens then the window server will handle it rather than passing it on to 
       
  1618 the shell.
       
  1619 
       
  1620 The window server has a queue of messages that it is waiting to send to clients. 
       
  1621 If the shell's client's queue is full and the window server cannot make room 
       
  1622 for the OFF message then it will power down the machine itself.
       
  1623 
       
  1624 This function always causes a flush of the window server buffer.
       
  1625 
       
  1626 @param aOn ETrue to get the window server to send EEventShellSwitchOff messages 
       
  1627 to the shell (rather than powering down). EFalse makes the window server switch 
       
  1628 back to powering down the machine itself. 
       
  1629 @param aWin The handle to the window or window group of the shell to which 
       
  1630 the message is to be sent. This may be NULL only if aOn=EFalse, in other words, 
       
  1631 the window server is handling power down itself. If aOn=ETrue then this must not 
       
  1632 be NULL, or the Window Server will panic the shell. Note that as far as the window 
       
  1633 server is concerned the handle must exist when this function is called.
       
  1634 @return KErrNone if successful, otherwise one of the system-wide error codes. 
       
  1635 @panic WSERV 51 aOn is true, but no window was specified (aWin is NULL). 
       
  1636 @capability PowerMgmt */
       
  1637 	{
       
  1638 	TWsClCmdOffEventsToShell OffEventsToShell(aOn,(aWin ? aWin->WsHandle():0));
       
  1639 	return WriteReply(&OffEventsToShell,sizeof(OffEventsToShell),EWsClOpSendOffEventsToShell);
       
  1640 	}
       
  1641 
       
  1642 EXPORT_C TDisplayMode RWsSession::GetDefModeMaxNumColors(TInt& aColor,TInt& aGray) const
       
  1643 /** Gets the number of colours available in the richest supported colour mode, the 
       
  1644 number of greys available in the richest grey mode, and returns the default 
       
  1645 display mode.
       
  1646 
       
  1647 This function always causes a flush of the window server buffer.
       
  1648 
       
  1649 @param aColor The number of colours in the richest supported colour mode. 
       
  1650 @param aGray The number of greys in the richest supported grey mode. 
       
  1651 @return The default display mode. */
       
  1652 	{
       
  1653 	return GetDefModeMaxNumColors(KDummyScreenNumber,aColor,aGray);
       
  1654 	}
       
  1655 
       
  1656 EXPORT_C TDisplayMode RWsSession::GetDefModeMaxNumColors(TInt aScreenNumber,TInt& aColor,TInt& aGray) const
       
  1657 /** Gets the number of colours available in the richest supported colour mode, the 
       
  1658 number of greys available in the richest grey mode, and returns the default 
       
  1659 display mode, on the specified screen.
       
  1660 
       
  1661 This function always causes a flush of the window server buffer.
       
  1662 
       
  1663 @param aScreenNumber specifies the screen.
       
  1664 @param aColor The number of colours in the richest supported colour mode. 
       
  1665 @param aGray The number of greys in the richest supported grey mode. 
       
  1666 @return The default display mode. */
       
  1667 	{
       
  1668 	TPckgBuf<SDefModeMaxNumColors> colors;	
       
  1669 	WriteReplyIntP(aScreenNumber,&colors,EWsClOpGetDefModeMaxNumColors);
       
  1670 	aColor=colors().iColors;
       
  1671 	aGray=colors().iGrays;
       
  1672 	return colors().iDisplayMode;
       
  1673 	}
       
  1674 
       
  1675 #define MODE_TO_FLAG(x) 1<<(x-1)
       
  1676 
       
  1677 LOCAL_C void HandleColorMode(CArrayFix<TInt>* aModeList,TUint aModeBits, TInt& aNumberOfModes, TInt aMode)
       
  1678 	{
       
  1679 	if (aModeBits&(MODE_TO_FLAG(aMode)))
       
  1680 		{
       
  1681 		if (aModeList!=NULL)
       
  1682 			{
       
  1683 			(*aModeList)[aNumberOfModes]=aMode;
       
  1684 			}
       
  1685 		++aNumberOfModes;
       
  1686 		}
       
  1687 	}
       
  1688 
       
  1689 LOCAL_C TInt DoGetColorModeList(CArrayFix<TInt>* aModeList,TUint aModeBits)
       
  1690 	{
       
  1691 	TInt numberOfModes=0;
       
  1692 	for (TInt mode=EGray2; mode<=EColor256; ++mode)
       
  1693 		{
       
  1694 		HandleColorMode(aModeList,aModeBits,numberOfModes,mode);
       
  1695 		}
       
  1696 	HandleColorMode(aModeList,aModeBits,numberOfModes,EColor4K);
       
  1697 	HandleColorMode(aModeList,aModeBits,numberOfModes,EColor64K);
       
  1698 	HandleColorMode(aModeList,aModeBits,numberOfModes,EColor16M);
       
  1699 	HandleColorMode(aModeList,aModeBits,numberOfModes,EColor16MU);
       
  1700 	HandleColorMode(aModeList,aModeBits,numberOfModes,EColor16MA);
       
  1701 	HandleColorMode(aModeList,aModeBits,numberOfModes,EColor16MAP);
       
  1702 	return numberOfModes;
       
  1703 	}
       
  1704 
       
  1705 EXPORT_C TInt RWsSession::GetColorModeList(CArrayFixFlat<TInt> *aModeList) const
       
  1706 /** Gets the list of available colour modes.
       
  1707 
       
  1708 Note that this function should usually be called within User::LeaveIfError(). 
       
  1709 The only time that an error can be generated is when the array gets resized 
       
  1710 to the number of display modes. Thus if you make the size of your array equal 
       
  1711 to the maximum number of display modes over all hardware (this is the number 
       
  1712 of different values in TDisplayMode) then this function will never leave.
       
  1713 
       
  1714 This function always causes a flush of the window server buffer.
       
  1715 
       
  1716 @param aModeList On return, contains a TDisplayMode entry for each of the 
       
  1717 available display modes. Note that the array's contents are deleted prior 
       
  1718 to filling with display mode information. 
       
  1719 @return The number of color modes if the parameter is passed NULL. Otherwise KErrNone or KErrNoMemory. */
       
  1720 	{
       
  1721 	return GetColorModeList(KDummyScreenNumber,aModeList);
       
  1722 	}
       
  1723 
       
  1724 EXPORT_C TInt RWsSession::GetColorModeList(TInt aScreenNumber,CArrayFixFlat<TInt>* aModeList) const
       
  1725 /** Gets the list of available colour modes on a particular screen.
       
  1726 
       
  1727 Note that this function should usually be called within User::LeaveIfError(). 
       
  1728 The only time that an error can be generated is when the array gets resized 
       
  1729 to the number of display modes. Thus if you make the size of your array equal 
       
  1730 to the maximum number of display modes over all hardware (this is the number 
       
  1731 of different values in TDisplayMode) then this function will never leave.
       
  1732 
       
  1733 This function always causes a flush of the window server buffer.
       
  1734 
       
  1735 @param aModeList On return, contains a TDisplayMode entry for each of the 
       
  1736 available display modes. Note that the array's contents are deleted prior 
       
  1737 to filling with display mode information.
       
  1738 @param aScreenNumber specifies the screen.  
       
  1739 @return The number of color modes if the parameter is passed NULL. Otherwise KErrNone or KErrNoMemory. */
       
  1740 	{
       
  1741 	const TUint modeList=STATIC_CAST(TUint,WriteReplyInt(aScreenNumber,EWsClOpGetColorModeList));	
       
  1742 	const TInt numberOfModes=DoGetColorModeList(NULL, modeList);
       
  1743 	if (aModeList==NULL)
       
  1744 		{
       
  1745 		return numberOfModes;
       
  1746 		}
       
  1747 	TRAPD(error,aModeList->ResizeL(numberOfModes));
       
  1748 	if (error!=KErrNone)
       
  1749 		{
       
  1750 		return error;
       
  1751 		}
       
  1752 	DoGetColorModeList(aModeList, modeList);
       
  1753 	return KErrNone;
       
  1754 	}
       
  1755 
       
  1756 EXPORT_C void RWsSession::SetPointerCursorArea(const TRect& aArea)
       
  1757 /** 
       
  1758 @publishedPartner
       
  1759 @released
       
  1760 
       
  1761 Sets the area of the screen in which the virtual cursor can be used while in 
       
  1762 relative mouse mode, for the first screen display mode. 
       
  1763 
       
  1764 This function sets the area for the first screen mode - the one with index 
       
  1765 0, which in most devices will be the only screen mode. The other function 
       
  1766 overload can be used to set the screen area for other modes. The area is set 
       
  1767 and stored independently on each screen mode, so that it is not necessary 
       
  1768 to call this function again when switching back to the first screen mode.
       
  1769 
       
  1770 The default area is the full digitiser area. When you set the area it will 
       
  1771 come into immediate affect, i.e. if necessary the current pointer position 
       
  1772 will be updated to be within the new area. 
       
  1773 
       
  1774 Notes:
       
  1775 
       
  1776 Relative mouse mode is where the events received from the base by window server 
       
  1777 are deltas from the last position of the pointer, as opposed to absolute co-ordinates.
       
  1778 
       
  1779 This function is honoured even if there is a mouse or pen (e.g. on the emulator), 
       
  1780 by mapping the co-ordinates of where you click into the area set using this 
       
  1781 function. However the function does not restrict clicks outside of the 'drawing 
       
  1782 area' on the Emulator, to allow you to select items on the fascia.
       
  1783 
       
  1784 @param aArea The area of the screen in which the virtual cursor can be used. 
       
  1785 @capability WriteDeviceData */
       
  1786 	{
       
  1787 	SetPointerCursorArea(0,aArea);
       
  1788 	}
       
  1789 
       
  1790 EXPORT_C void RWsSession::SetPointerCursorArea(TInt aScreenSizeMode,const TRect& aArea)
       
  1791 /** Sets the area of the screen in which the virtual cursor can be used while in 
       
  1792 relative mouse mode, for a specified screen display mode. 
       
  1793 
       
  1794 The default area is the full digitiser area for the given mode. When you set 
       
  1795 the area it will come into immediate affect, i.e. if necessary the current 
       
  1796 pointer position will be updated to be within the new area. 
       
  1797 
       
  1798 The area is set and stored independently on each screen mode, so that it is 
       
  1799 not necessary to call this function again when switching back to a mode. 
       
  1800 
       
  1801 Notes:
       
  1802 
       
  1803 Relative mouse mode is where the events received from the base by window server 
       
  1804 are deltas from the last position of the pointer, as opposed to absolute co-ordinates.
       
  1805 
       
  1806 The previous function overload may be used to set the screen area for only 
       
  1807 the first mode.
       
  1808 
       
  1809 This function is honoured even if there is a mouse or pen (e.g. on the emulator), 
       
  1810 by mapping the co-ordinates of where you click into the area set using this 
       
  1811 function. However the function does not restrict clicks outside of the 'drawing 
       
  1812 area' on the Emulator, to allow you to select items on the fascia.
       
  1813 
       
  1814 @param aScreenSizeMode The screen mode to which the new area applies. 
       
  1815 @param aArea The area of the screen, in the aScreenSizeMode screen mode, within 
       
  1816 which the virtual cursor can be used.
       
  1817 @capability WriteDeviceData */
       
  1818 	{
       
  1819 	TWsClCmdSetPointerCursorArea SetPointerCursorArea(aScreenSizeMode,aArea);
       
  1820 	Write(&SetPointerCursorArea,sizeof(SetPointerCursorArea),EWsClOpSetPointerCursorArea);
       
  1821 	}
       
  1822 
       
  1823 EXPORT_C TRect RWsSession::PointerCursorArea() const
       
  1824 /** Gets the pointer cursor area for the first screen display mode.
       
  1825 
       
  1826 This is the area of the screen in which the virtual cursor can be used while 
       
  1827 in relative mouse mode. While in pen or mouse mode the event co-ordinates 
       
  1828 are forced to be within this area unless you click outside the drawable area.
       
  1829 
       
  1830 This function always causes a flush of the window server buffer.
       
  1831 
       
  1832 @return The pointer cursor area for the first screen display mode.
       
  1833 @see SetPointerCursorArea() */
       
  1834 	{
       
  1835 	return PointerCursorArea(0);
       
  1836 	}
       
  1837 
       
  1838 EXPORT_C TRect RWsSession::PointerCursorArea(TInt aScreenSizeMode) const
       
  1839 /** Gets the pointer cursor area for the specified screen display mode. 
       
  1840 
       
  1841 This is the area of the screen in which the virtual cursor can be used while 
       
  1842 in relative mouse mode. While in pen or mouse mode the event co-ordinates 
       
  1843 are forced to be within this area unless you click outside the drawable area.
       
  1844 
       
  1845 This function always causes a flush of the window server buffer.
       
  1846 
       
  1847 @param aScreenSizeMode The screen mode for which the pointer cursor area is 
       
  1848 required. 
       
  1849 @return The pointer cursor area for the specified screen display mode. 
       
  1850 @see SetPointerCursorArea() */
       
  1851 	{
       
  1852 	TPckgBuf<TRect> rectPkg;
       
  1853   	WriteReplyP(&aScreenSizeMode,sizeof(aScreenSizeMode),&rectPkg,EWsClOpPointerCursorArea);
       
  1854 	return(rectPkg());
       
  1855 	}
       
  1856 
       
  1857 EXPORT_C void RWsSession::SetPointerCursorMode(TPointerCursorMode aMode)
       
  1858 /** Sets the current mode for the pointer cursor.
       
  1859 
       
  1860 The mode determines which sprite is used for the pointer cursor at any point. 
       
  1861 The request is ignored unless the calling application is the application 
       
  1862 that currently has keyboard focus.
       
  1863 See TPointerCursorMode for more information.
       
  1864 
       
  1865 @param aMode The new mode for the pointer cursor. 
       
  1866 @see TPointerCursorMode */
       
  1867 	{
       
  1868 	WriteInt(aMode,EWsClOpSetPointerCursorMode);
       
  1869 	}
       
  1870 	
       
  1871 EXPORT_C TInt RWsSession::SetClientCursorMode(TPointerCursorMode aMode)
       
  1872 /** Sets the current mode for the pointer cursor.
       
  1873 
       
  1874 The mode determines which sprite is used for the pointer cursor at any point. 
       
  1875 See TPointerCursorMode for more information.
       
  1876 
       
  1877 This function always causes a flush of the window server buffer.
       
  1878 
       
  1879 @param aMode The new mode for the pointer cursor. 
       
  1880 @see TPointerCursorMode
       
  1881 @return KErrNone if successful, otherwise returns system wide errors. Returns
       
  1882 KErrPermissionDenied if calling thread lacks WriteDeviceData capability
       
  1883 @capability WriteDeviceData */
       
  1884 	{
       
  1885 	return(WriteReplyInt(aMode,EWsClOpSetClientCursorMode));
       
  1886 	}
       
  1887 
       
  1888 EXPORT_C TPointerCursorMode RWsSession::PointerCursorMode() const
       
  1889 /** Gets the current mode for the pointer cursor.
       
  1890 
       
  1891 The mode determines which sprite is used for the pointer cursor at any point.
       
  1892 
       
  1893 This function always causes a flush of the window server buffer.
       
  1894 
       
  1895 @return The current mode for the pointer cursor. */
       
  1896 	{
       
  1897 	return(STATIC_CAST(TPointerCursorMode,WriteReply(EWsClOpPointerCursorMode)));
       
  1898 	}
       
  1899 
       
  1900 EXPORT_C void RWsSession::SetDefaultSystemPointerCursor(TInt aCursorNumber)
       
  1901 /** Sets the default system pointer cursor.
       
  1902 
       
  1903 This function can only be called by the owner of the system pointer cursor 
       
  1904 list. By default the 0th entry in the pointer cursor list is assigned as the 
       
  1905 system pointer. The function allows any cursor from the list or even no cursor 
       
  1906 to be set as the system pointer cursor.
       
  1907 
       
  1908 Note: ownership of the system pointer cursor list can be obtained by calling 
       
  1909 ClaimSystemPointerCursorList() when no-one else has ownership.
       
  1910 
       
  1911 @param aCursorNumber The index of the new default system pointer cursor within 
       
  1912 the system cursor list. */
       
  1913 	{
       
  1914 	WriteInt(aCursorNumber,EWsClOpSetDefaultSystemPointerCursor);
       
  1915 	}
       
  1916 
       
  1917 EXPORT_C void RWsSession::ClearDefaultSystemPointerCursor()
       
  1918 /** Clears the default system pointer cursor.
       
  1919 
       
  1920 This sets the pointer to the current default system pointer cursor to NULL. 
       
  1921 
       
  1922 @panic WSERV 42 If this function is called by a client other than the owner of the 
       
  1923 system pointer cursor list. */
       
  1924 	{
       
  1925 	Write(EWsClOpClearDefaultSystemPointerCursor);
       
  1926 	}
       
  1927 
       
  1928 EXPORT_C TInt RWsSession::SetPointerCursorPosition(const TPoint& aPosition)
       
  1929 /** Sets the pointer cursor position.
       
  1930 
       
  1931 This function allows an application to move the virtual cursor. It works in 
       
  1932 all modes, not just relative mouse mode.
       
  1933 
       
  1934 Note: the function works in screen co-ordinates and honours the pointer cursor area 
       
  1935 exactly as pen presses do, i.e. only when they are in the drawing area 
       
  1936 on the Emulator.
       
  1937 
       
  1938 This function always causes a flush of the window server buffer.
       
  1939 
       
  1940 @param aPosition The new pointer cursor position.
       
  1941 @return KErrNone if successful, otherwise another of the system-wide error 
       
  1942 codes. 
       
  1943 @capability WriteDeviceData required, if the client calling the function doesn't have keyboard focus.
       
  1944 However, if the client have keyboard focus then he doesn't need any capability to call this function.  */
       
  1945 	{
       
  1946 	return(WriteReply(&aPosition,sizeof(aPosition),EWsClOpSetPointerCursorPosition));
       
  1947 	}
       
  1948 
       
  1949 EXPORT_C TPoint RWsSession::PointerCursorPosition() const
       
  1950 /** Gets the pointer cursor position.
       
  1951 
       
  1952 This function allows an application to determine the position of the virtual 
       
  1953 cursor.
       
  1954 
       
  1955 It always causes a flush of the window server buffer.
       
  1956 
       
  1957 Please note that on devices with multiple pointers (for example with multi-touch screen)
       
  1958 the pointer cursor's position will be equal to the last known position of the emulated pointer.
       
  1959 More information about the emulated pointer can be found in description of method
       
  1960 RWindowBase::EnableAdvancedPointers().
       
  1961 
       
  1962 @return The position of the virtual cursor. 
       
  1963 @see RWindowBase::EnableAdvancedPointers() */
       
  1964 	{
       
  1965 	TPckgBuf<TPoint> pointPkg;
       
  1966   	WriteReplyP(&pointPkg,EWsClOpPointerCursorPosition);
       
  1967 	return(pointPkg());
       
  1968 	}
       
  1969 
       
  1970 EXPORT_C void RWsSession::SetDefaultFadingParameters(TUint8 aBlackMap,TUint8 aWhiteMap)
       
  1971 /**
       
  1972 @publishedPartner
       
  1973 @released
       
  1974 
       
  1975 Sets the default fading parameters.
       
  1976 
       
  1977 Fading is used to change the colour of windows to be either closer 
       
  1978 to white or closer to black, so that another window stands out. For example, 
       
  1979 when displaying a dialogue you could fade all visible windows, then unfade 
       
  1980 the dialog window. This function sets whether, and the amount by which, faded 
       
  1981 windows appear closer to white or closer to black.
       
  1982 
       
  1983 The white and black mapping values define the range over which colours are 
       
  1984 re-mapped when a window is faded. If aBlackMap=0 and aWhiteMap=255 then the 
       
  1985 colours are mapped unchanged. As the two values get closer together, all colours 
       
  1986 in the faded window becomes more similar - creating the fading effect. When 
       
  1987 the numbers cross over (so that the black value is greater than the white 
       
  1988 value) the colours in the faded window start to invert - i.e. colours that 
       
  1989 were closer to white in the unfaded window are mapped to a darker colour in 
       
  1990 the faded window.
       
  1991 
       
  1992 Changing the default will automatically apply to current graphics contexts 
       
  1993 but will not have any affect on windows that are already faded. 
       
  1994 
       
  1995 Note: RWindowTreeNode::SetFaded(), CWindowGc::SetFaded() and RWsSession::SetSystemFaded() 
       
  1996 use these fading parameters, and in addition allow the default fading value 
       
  1997 to be overridden.
       
  1998 
       
  1999 @param aBlackMap Black map fading parameter.
       
  2000 @param aWhiteMap White map fading parameter. 
       
  2001 @see RWindowTreeNode::SetFaded()
       
  2002 @see CWindowGc::SetFadingParameters() 
       
  2003 @capability WriteDeviceData */
       
  2004 	{
       
  2005 	WriteInt(WservEncoding::Encode8BitValues(aBlackMap,aWhiteMap),EWsClOpSetDefaultFadingParams);
       
  2006 	}
       
  2007 
       
  2008 /**
       
  2009 @publishedPartner
       
  2010 @released
       
  2011 
       
  2012 Prepares for switch off. 
       
  2013 
       
  2014 This stops the window server heart beat timer if running.
       
  2015 
       
  2016 @capability PowerMgmt
       
  2017 */
       
  2018 EXPORT_C void RWsSession::PrepareForSwitchOff()
       
  2019 	{
       
  2020 	Write(EWsClOpPrepareForSwitchOff);
       
  2021 	}
       
  2022 
       
  2023 #if defined(__WINS__)
       
  2024 EXPORT_C void RWsSession::SetRemoveKeyCode(TBool aRemove)
       
  2025 /** Sets whether to remove the top 16 bits of a key code (Emulator builds only).
       
  2026 
       
  2027 This function allows the Emulator to use Windows to translate keypresses into 
       
  2028 the correct key code for each locale, rather than having to do the translation 
       
  2029 for each international keyboard itself. 
       
  2030 
       
  2031 The top 16 bits of a keypress code contains the keycode that Windows would 
       
  2032 produce if the key had been pressed in a typical Windows program. If aRemove 
       
  2033 is EFalse the client can get these top 16 bits. If the value is non-zero 
       
  2034 the CKeyTranslator uses it rather than calculating it's own value. If aRemove 
       
  2035 is ETrue the window server strips the top 16 bits of the scan code before 
       
  2036 passing the value on to the client. 
       
  2037 
       
  2038 Note: this function is intended for Java but it will be useful to any client who 
       
  2039 creates their own CKeyTranslator and processes keyups and downs.
       
  2040 
       
  2041 @param aRemove ETrue to remove the code (default), EFalse to pass it to the 
       
  2042 client. */
       
  2043 	{
       
  2044 	WriteInt(aRemove,EWsClOpRemoveKeyCode);
       
  2045 	}
       
  2046 
       
  2047 EXPORT_C void RWsSession::SimulateXyInputType(TXYInputType aInputType)
       
  2048 	{
       
  2049 	WriteInt(aInputType,EWsClOpSimulateXyInput);
       
  2050 	}
       
  2051 #endif
       
  2052 
       
  2053 EXPORT_C void RWsSession::LogCommand(TLoggingCommand aCommand)
       
  2054 /** Allows the window server client to enable or disable logging of window server 
       
  2055 events.
       
  2056 
       
  2057 The type of logging that takes place (e.g. whether to file or to serial port) 
       
  2058 depends on the settings specified in the wsini.ini file.
       
  2059 
       
  2060 Clients can also force a dump of the window tree or information about the 
       
  2061 window server's heap size and usage. 
       
  2062 
       
  2063 For logging to work, the wsini.ini file has to specify the type of logging 
       
  2064 required and the DLLs for that type of logging must have been correctly installed. 
       
  2065 Otherwise, calling this function will have no effect.
       
  2066 
       
  2067 @param aCommand The logging command. */
       
  2068 	{
       
  2069 	WriteInt(aCommand,EWsClOpLogCommand);
       
  2070 	}
       
  2071 
       
  2072 EXPORT_C void RWsSession::LogMessage(const TLogMessageText &aMessage)
       
  2073 /** Adds a message to the window server debug log if one is currently in operation.
       
  2074 
       
  2075 This function always causes a flush of the window server buffer.
       
  2076 
       
  2077 @param aMessage The text added to the message log. */
       
  2078 	{
       
  2079 	TInt len=aMessage.Length();
       
  2080 	WriteReply(&len,sizeof(len),aMessage.Ptr(),aMessage.Size(),EWsClOpLogMessage);
       
  2081 	}
       
  2082 
       
  2083 EXPORT_C void RWsSession::SimulateRawEvent(TRawEvent aEvent)
       
  2084 /** 
       
  2085 @internalAll
       
  2086 
       
  2087 Simulates raw events.
       
  2088 
       
  2089 For most purposes, RWsSession::SimulateKeyEvent() should be used instead to 
       
  2090 simulate key events because low-level scan-code up/down events are not meaningful 
       
  2091 to anything other than the keyboard to which they apply.
       
  2092 
       
  2093 For example, the driver for an external keyboard should do its own conversion from 
       
  2094 raw scan-codes to higher-level character code key events and pass these to the 
       
  2095 window server using SimulateKeyEvent().
       
  2096 
       
  2097 @param aEvent The raw event.
       
  2098 @capability SwEvent */
       
  2099 	{
       
  2100 	Write(&aEvent,sizeof(aEvent),EWsClOpRawEvent);
       
  2101 	}
       
  2102 
       
  2103 EXPORT_C void RWsSession::SimulateKeyEvent(TKeyEvent aEvent)
       
  2104 /** 
       
  2105 @internalAll
       
  2106 
       
  2107 Sends a simulated key event to the window server.
       
  2108 
       
  2109 All the fields in TKeyEvent are honoured except iRepeats, which is overridden 
       
  2110 with zero.
       
  2111 
       
  2112 @param aEvent The key event to be simulated.
       
  2113 @capability SwEvent */
       
  2114 	{
       
  2115 	Write(&aEvent,sizeof(aEvent),EWsClOpKeyEvent);
       
  2116 	}
       
  2117 
       
  2118 
       
  2119 EXPORT_C void RWsSession::SystemInfo(TInt &aSystemInfoNumber, SSystemInfo &aSystemInfo)
       
  2120 /** @internalComponent */
       
  2121 	{
       
  2122 	TPckgBuf<SSystemInfo> systemInfoPckg;
       
  2123 	WriteReplyP(&aSystemInfoNumber,sizeof(aSystemInfoNumber),&systemInfoPckg,EWsClOpSystemInfo);
       
  2124 	aSystemInfo=systemInfoPckg();
       
  2125 	}
       
  2126 
       
  2127 void RWsSession::DirectAcessActivation(TBool aIsNowActive)
       
  2128 	{
       
  2129 	if (aIsNowActive)
       
  2130 		++iBuffer->iDirectAcessCount;
       
  2131 	else
       
  2132 		{
       
  2133 		--iBuffer->iDirectAcessCount;
       
  2134 		__ASSERT_DEBUG(iBuffer->iDirectAcessCount>=0,Assert(EW32AssertDirectMisuse));
       
  2135 		}
       
  2136 	}
       
  2137 
       
  2138 EXPORT_C void RWsSession::TestWrite(TInt aHandle,TInt aOpcode,const TAny *pData, TInt aLength)
       
  2139 /** @internalComponent */
       
  2140 	{
       
  2141 	iBuffer->Write(aHandle,aOpcode,pData,aLength);
       
  2142 	}
       
  2143 
       
  2144 EXPORT_C void RWsSession::TestWriteReply(TInt aHandle,TInt aOpcode,const TAny *pData, TInt aLength)
       
  2145 /** @internalComponent */
       
  2146 	{
       
  2147 	iBuffer->WriteReply(aHandle,aOpcode,pData,aLength);
       
  2148 	}
       
  2149 
       
  2150 EXPORT_C void RWsSession::TestWriteReplyP(TInt aHandle,TInt aOpcode,const TAny *pData,TInt aLength,TDes8 *aReplyPackage)
       
  2151 /** @internalComponent */
       
  2152 	{
       
  2153 	iBuffer->WriteReplyP(aHandle,aOpcode,pData,aLength,aReplyPackage);
       
  2154 	}
       
  2155 
       
  2156 EXPORT_C TInt RWsSession::TestWriteReplyByProvidingRemoteReadAccess(TInt aHandle,TInt aOpcode,const TDesC8& aData,const TDesC8& aRemoteReadBuffer)
       
  2157 /** @internalComponent */
       
  2158 	{
       
  2159 	return iBuffer->WriteReplyByProvidingRemoteReadAccess(aHandle,aOpcode,aData.Ptr(),aData.Length(),&aRemoteReadBuffer);
       
  2160 	}
       
  2161 
       
  2162 EXPORT_C TInt RWsSession::TestWriteReplyByProvidingRemoteReadAccess(TInt aHandle,TInt aOpcode,const TDesC8& aData,const TDesC16& aRemoteReadBuffer)
       
  2163 /** @internalComponent */
       
  2164 	{
       
  2165 	return iBuffer->WriteReplyByProvidingRemoteReadAccess(aHandle,aOpcode,aData.Ptr(),aData.Length(),&aRemoteReadBuffer);
       
  2166 	}
       
  2167 
       
  2168 /** Sets both the buffer size and maximum buffer size for queuing commands to send to the Windows Server.
       
  2169 The value should be at least the size of the largest message that will be sent, 
       
  2170 otherwise a panic of the client may occur.
       
  2171 
       
  2172 The minimum possible buffer size is 640 and the maximum possible size is 16384 bytes.
       
  2173 The default size of 640 bytes is sufficient for most uses.
       
  2174 
       
  2175 Larger buffers can reduce drawing flicker by allowing more drawing commands to be
       
  2176 collected in the buffer before being sent to the server.
       
  2177 
       
  2178 Smaller buffers conserve system memory.
       
  2179 
       
  2180 Can be used to set a minimum buffer size, sufficient for largest drawing command used,
       
  2181 before calling RWsSession::SetMaxBufferSizeL() to set a maximum buffer size for queuing commands.
       
  2182 
       
  2183 @param aBufSize The desired buffer size in bytes, at least the size of largest message to be sent.
       
  2184 @leave KErrNoMemory Could not allocate the required memory.
       
  2185 
       
  2186 @panic TW32Panic 5 Occurs during the session if a single drawing command is too big to fit in the buffer.
       
  2187 
       
  2188 @see RWsSession::Flush()
       
  2189 @see RWsSession::SetAutoFlush()
       
  2190 @see RWsSession::SetMaxBufferSizeL()
       
  2191 */
       
  2192 EXPORT_C void RWsSession::SetBufferSizeL(TInt aBufSize)
       
  2193 	{
       
  2194 	iBuffer->SetBufferSizeL(aBufSize);
       
  2195 	}
       
  2196 
       
  2197 /** Sets the maximum size that the buffer for queuing commands to send to the Windows Server can expand to.
       
  2198 
       
  2199 The minimum possible buffer size is 640 and the maximum possible size is 16384 bytes.
       
  2200 
       
  2201 If the buffer size is larger than the new maximum it is reduced.
       
  2202 
       
  2203 A minimum size is calculated to be one quarter the maximum size, but in any case at least 640 bytes.
       
  2204 If the buffer size is smaller than the calculated minimum it is expanded.
       
  2205 
       
  2206 RWsSession::SetBufferSizeL() can be used to set a specific minimum size >640 bytes before setting a maximum size.
       
  2207 This is useful if you will send very large drawing commands.
       
  2208 
       
  2209 After calling this function the buffer size will be between the specified maximum and calculated minimum sizes.
       
  2210 
       
  2211 The algorithm for growing the buffer up to the maximum is chosen to balance the cost of expanding the buffer 
       
  2212 with the waste of an excessively large buffer that is never filled.
       
  2213 
       
  2214 If the buffer becomes too full to add a new drawing command, and the buffer size is less than the maximum,
       
  2215 the buffer size will be expanded.
       
  2216 If the buffer is already at the maximum size, or the expansion fails due to low memory, 
       
  2217 the buffer will be emptied with RWsSession::Flush().
       
  2218 If there is not enough space now for the new command a panic occurs.
       
  2219 
       
  2220 @param aMaxBufSize The desired maximum buffer size in bytes.
       
  2221 @leave KErrNoMemory Could not allocate the required minimum memory.
       
  2222 
       
  2223 @panic TW32Panic 5 Occurs during the session if a single drawing command is too big to fit in the buffer.
       
  2224 
       
  2225 @see RWsSession::Flush()
       
  2226 @see RWsSession::SetAutoFlush()
       
  2227 @see RWsSession::SetBufferSizeL()
       
  2228 */
       
  2229 EXPORT_C void RWsSession::SetMaxBufferSizeL(TInt aMaxBufSize)
       
  2230 	{
       
  2231 	iBuffer->SetMaxBufferSizeL(aMaxBufSize);
       
  2232 	}
       
  2233 
       
  2234 EXPORT_C TInt RWsSession::SetSystemFaded(TBool aFaded)
       
  2235 /** Sets all windows in the system as faded or unfaded, using the default fading 
       
  2236 parameters.
       
  2237 
       
  2238 This function allows all windows that currently exist, not just those in a 
       
  2239 single window group, to be faded or unfaded.
       
  2240 
       
  2241 Notes: The window server generates a redraw to un-fade a window, because information 
       
  2242 is lost during fading. Blank (RBlankWindow) and backup (RBackupWindow) windows 
       
  2243 deal with this themselves. Areas in shadow when the window is faded will also 
       
  2244 have redraw events generated for them by the window server. While a window 
       
  2245 is faded, all drawing to that window will be adjusted appropriately by the 
       
  2246 window server.
       
  2247 
       
  2248 This function always causes a flush of the window server buffer.
       
  2249 
       
  2250 @param aFaded ETrue to fade all windows, EFalse to un-fade all windows.
       
  2251 @return KErrNone if successful, otherwise another of the system-wide error 
       
  2252 codes. 
       
  2253 @capability WriteDeviceData */
       
  2254 	{
       
  2255 	TWsClCmdSetSystemFaded params(aFaded);
       
  2256 	return WriteReply(&params,sizeof(params),EWsClOpSetFaded);
       
  2257 	}
       
  2258 
       
  2259 EXPORT_C TInt RWsSession::SetSystemFaded(TBool aFaded,TUint8 aBlackMap,TUint8 aWhiteMap)
       
  2260 /** Sets all windows in the system as faded or unfaded, overriding the default 
       
  2261 fading parameters (as set by SetDefaultFadingParameters()).
       
  2262 
       
  2263 This function allows all windows that currently exist, not just those in the 
       
  2264 same window group, to be faded or unfaded.
       
  2265 
       
  2266 Notes: Fading a window for a second time (that is fading it when it is already 
       
  2267 faded) will not change the fading map used. The window server generates a 
       
  2268 redraw to un-fade a window, because information is lost during fading. Blank 
       
  2269 (RBlankWindow) and backup (RBackupWindow) windows deal with this themselves. 
       
  2270 Areas in shadow when the window is faded will also have redraw events generated 
       
  2271 for them by the window server. While a window is faded, all drawing to that 
       
  2272 window will be adjusted appropriately by the window server.
       
  2273 
       
  2274 This function always causes a flush of the window server buffer.
       
  2275 
       
  2276 @param aFaded ETrue to fade all windows, EFalse to un-fade all windows.
       
  2277 @param aBlackMap Black map fading parameter.
       
  2278 @param aWhiteMap White map fading parameter.
       
  2279 @return KErrNone if successful, otherwise another of the system-wide error 
       
  2280 codes. 
       
  2281 @capability WriteDeviceData */
       
  2282 	{
       
  2283 	TWsClCmdSetSystemFaded params(aFaded,EFalse,aBlackMap,aWhiteMap);
       
  2284 	return WriteReply(&params,sizeof(params),EWsClOpSetFaded);
       
  2285 	}
       
  2286 
       
  2287 EXPORT_C TInt RWsSession::SetFocusScreen(TInt aScreenNumber)
       
  2288 /** Set focus screen  
       
  2289 @param aScreenNumber The new focus screen.
       
  2290 @return KErrNone if successful, otherwise another of the system-wide error 
       
  2291 codes. */
       
  2292 	{
       
  2293 	return WriteReplyInt(aScreenNumber,EWsClOpSetFocusScreen);
       
  2294 	}
       
  2295 
       
  2296 EXPORT_C TInt RWsSession::GetFocusScreen() const
       
  2297 /** Get focus screen
       
  2298 @return The screen number of current focus screen */
       
  2299 	{
       
  2300 	return WriteReply(EWsClOpGetFocusScreen);
       
  2301 	}
       
  2302 
       
  2303 EXPORT_C TInt RWsSession::NumberOfScreens() const
       
  2304 /** Number Of Screens
       
  2305 @return The number of screens on the phone */
       
  2306 	{
       
  2307 	return WriteReply(EWsClOpGetNumberOfScreens);	
       
  2308 	}
       
  2309 	
       
  2310 EXPORT_C void RWsSession::ClearAllRedrawStores()
       
  2311 /** Clear the redraw store for all windows in the system
       
  2312 By default Windows will recorded the drawing commands used during a redraw and use them latter if the window needs to be redrawn.
       
  2313 Calling this function will cause all these stores to be thrown away redraw will then be sent to all window, visible windows will recieve them first.
       
  2314 
       
  2315 This function always causes a flush of the window server buffer.*/
       
  2316 	{
       
  2317 	Write(EWsClOpClearAllRedrawStores);
       
  2318 	}
       
  2319 
       
  2320 EXPORT_C TInt RWsSession::Finish()
       
  2321 /** 
       
  2322 Blocks until all outstanding window server rendering has been completed.
       
  2323 @return KErrNone if successful 
       
  2324 */
       
  2325 	{
       
  2326 	SyncMsgBuf();
       
  2327 	return SendReceive(EWservMessFinish);
       
  2328 	}
       
  2329 
       
  2330 EXPORT_C void RWsSession::SyncMsgBuf()
       
  2331 /** 
       
  2332 Sends all pending commands in the buffer to the window server. 
       
  2333 */
       
  2334 	{
       
  2335 	if (iBuffer)
       
  2336 		iBuffer->Flush();
       
  2337 	}
       
  2338 
       
  2339 EXPORT_C TInt RWsSession::SetCloseProximityThresholds(TInt aEnterCloseProximityThreshold, TInt aExitCloseProximityThreshold)
       
  2340 /** Sets Z coordinate threshold values for TPointerEvent::EEnterCloseProximity 
       
  2341 and TPointerEvent::EExitCloseProximity events. 
       
  2342 As proximity occupies the negative range of Z coordinates, on most platforms
       
  2343 threshold values for these events should be specified as negative.
       
  2344 
       
  2345 However, all possible Z coordinate values are accepted by this method
       
  2346 regardless of the fact that positive Z coordinate values are interpreted as 
       
  2347 pressure and only negative Z coordinate values are interpreted as proximity.
       
  2348 This means that if a particular platform supports an Up pointer state while a pointer is
       
  2349 touching the screen, it is possible to base the firing of 
       
  2350 EnterCloseProximity/ExitCloseProximity events on pressure readings by specifying 
       
  2351 positive threshold values.
       
  2352 
       
  2353 EnterCloseProximity/ExitCloseProximity event generation can be switched off completely by 
       
  2354 specifying the following thresholds: aEnterCloseProximityThreshold = KMaxTInt, 
       
  2355 aExitCloseProximityThreshold = KMinTInt.
       
  2356 
       
  2357 This method is supposed to be used only by the UI platform or device's configuration tool.
       
  2358 
       
  2359 Modified thresholds will be persisted across system reboots in the following HAL
       
  2360 attributes: HALData::EPointer3DEnterCloseProximityThreshold, HALData::EPointer3DExitCloseProximityThreshold. 
       
  2361 
       
  2362 If this method is never called on a particular device, the default threshold values defined by this device's 
       
  2363 manufacturer are used.
       
  2364 
       
  2365 @param aEnterCloseProximityThreshold a new threshold for TPointerEvent::EEnterCloseProximity
       
  2366                                      to be set, specified as Z coordinate value
       
  2367 @param aExitCloseProximityThreshold a new threshold for TPointerEvent::EExitCloseProximity
       
  2368                                     to be set, specified as Z coordinate value
       
  2369 @return KErrNone if successful, 
       
  2370         KErrNotSupported if the platform doesn't support threshold values for 
       
  2371                          Close Proximity events,
       
  2372         KErrArgument if aEnterCloseProximityThreshold is less than aExitCloseProximityThreshold;
       
  2373                      when this error occurs, threshold values are not changed. 
       
  2374 @capability WriteDeviceData
       
  2375 @see TPointerEvent::EEnterCloseProximity
       
  2376 @see TPointerEvent::EExitCloseProximity
       
  2377 @see HALData::EPointer3DEnterCloseProximityThreshold
       
  2378 @see HALData::EPointer3DExitCloseProximityThreshold
       
  2379 @publishedPartner
       
  2380 @prototype To become released with WSERV NGA APIs */
       
  2381 	{
       
  2382 	TWsClCmdZThresholdPair params(aEnterCloseProximityThreshold, aExitCloseProximityThreshold);
       
  2383 	return WriteReply(&params,sizeof(params),EWsClOpSetCloseProximityThresholds);
       
  2384 	}
       
  2385 
       
  2386 EXPORT_C TInt RWsSession::GetEnterCloseProximityThreshold() const
       
  2387 /**
       
  2388 @return Z coordinate threshold value for TPointerEvent::EEnterCloseProximity events.
       
  2389 @see TPointerEvent::EEnterCloseProximity
       
  2390 @publishedPartner To become publishedAll with WSERV NGA APIs
       
  2391 @prototype To become released with WSERV NGA APIs */
       
  2392 	{
       
  2393 	return WriteReply(EWsClOpGetEnterCloseProximityThreshold);	
       
  2394 	}
       
  2395 
       
  2396 EXPORT_C TInt RWsSession::GetExitCloseProximityThreshold() const
       
  2397 /**
       
  2398 @return Z coordinate threshold value for TPointerEvent::EExitCloseProximity events
       
  2399 @see TPointerEvent::EExitCloseProximity
       
  2400 @publishedPartner To become publishedAll with WSERV NGA APIs
       
  2401 @prototype To become released with WSERV NGA APIs */
       
  2402 	{
       
  2403 	return WriteReply(EWsClOpGetExitCloseProximityThreshold);	
       
  2404 	}
       
  2405 
       
  2406 EXPORT_C TInt RWsSession::SetHighPressureThresholds(TInt aEnterHighPressureThreshold, TInt aExitHighPressureThreshold)
       
  2407 /** Sets Z coordinate threshold values for TPointerEvent::EEnterHighPressure 
       
  2408 and TPointerEvent::EExitHighPressure events. 
       
  2409 As pressure occupies the positive range of Z coordinates, on most platforms
       
  2410 threshold values for these events should be specified as positive values.
       
  2411 
       
  2412 However, all possible Z coordinate values are accepted by this method
       
  2413 regardless of the fact that only the positive Z coordinate values are interpreted as 
       
  2414 pressure and the negative Z coordinate values are interpreted as proximity.
       
  2415 This means that if a particular platform supports the Down pointer state while a pointer is
       
  2416 in proximity to the screen, it is possible to base the firing of 
       
  2417 EnterHighPressure/ExitHighPressure events on proximity readings by specifying 
       
  2418 negative threshold values.
       
  2419 
       
  2420 EnterHighPressure/ExitHighPressure event generation can be switched off completely by 
       
  2421 specifying the following thresholds: aEnterHighPressureThreshold = KMaxTInt, 
       
  2422 aExitHighPressureThreshold = KMinTInt.
       
  2423 
       
  2424 This method is supposed to be used only by the UI platform or device's configuration tool.
       
  2425 
       
  2426 Modified thresholds will be persisted across system reboots in the following HAL
       
  2427 attributes: HALData::EPointer3DEnterHighPressureThreshold, HALData::EPointer3DExitHighPressureThreshold. 
       
  2428 
       
  2429 If this method is never called on a particular device, the default threshold values defined by this device's 
       
  2430 manufacturer are used.
       
  2431 
       
  2432 @param aEnterHighPressureThreshold a new threshold for TPointerEvent::EEnterHighPressure
       
  2433                                    to be set, specified as Z coordinate value
       
  2434 @param aExitHighPressureThreshold a new threshold for TPointerEvent::EExitHighPressure
       
  2435                                   to be set, specified as Z coordinate value
       
  2436 @return KErrNone if successful, 
       
  2437         KErrNotSupported if the platform doesn't support threshold values for 
       
  2438                          High Pressure events,
       
  2439         KErrArgument if aEnterHighPressureThreshold is less than aExitHighPressureThreshold; 
       
  2440                      when this error occurs, threshold values are not changed. 
       
  2441 @capability WriteDeviceData
       
  2442 @see TPointerEvent::EEnterHighPressure
       
  2443 @see TPointerEvent::EExitHighPressure
       
  2444 @see HALData::EPointer3DEnterHighPressureThreshold
       
  2445 @see HALData::EPointer3DExitHighPressureThreshold
       
  2446 @publishedPartner
       
  2447 @prototype To become released with WSERV NGA APIs */
       
  2448 	{
       
  2449 	TWsClCmdZThresholdPair params(aEnterHighPressureThreshold, aExitHighPressureThreshold);
       
  2450 	return WriteReply(&params,sizeof(params),EWsClOpSetHighPressureThresholds);
       
  2451 	}
       
  2452 
       
  2453 EXPORT_C TInt RWsSession::GetEnterHighPressureThreshold() const
       
  2454 /**
       
  2455 @return Z coordinate threshold value for TPointerEvent::EEnterHighPressure events
       
  2456 @see TPointerEvent::EEnterHighPressure
       
  2457 @publishedPartner To become publishedAll with WSERV NGA APIs
       
  2458 @prototype To become released with WSERV NGA APIs */
       
  2459 	{
       
  2460 	return WriteReply(EWsClOpGetEnterHighPressureThreshold);	
       
  2461 	}
       
  2462 
       
  2463 EXPORT_C TInt RWsSession::GetExitHighPressureThreshold() const
       
  2464 /**
       
  2465 @return Z coordinate threshold value for TPointerEvent::EExitHighPressure events
       
  2466 @see TPointerEvent::EExitHighPressure
       
  2467 @publishedPartner To become publishedAll with WSERV NGA APIs
       
  2468 @prototype To become released with WSERV NGA APIs */
       
  2469 	{
       
  2470 	return WriteReply(EWsClOpGetExitHighPressureThreshold);	
       
  2471 	}
       
  2472 
       
  2473 EXPORT_C void RWsSession::EnableWindowSizeCacheL()
       
  2474 /**
       
  2475 Enables client side cache of window size to reduce client-server 
       
  2476 activity triggered by calls to RWindowBase::Size()
       
  2477 @leave KErrNoMemory Could not allocate the required memory.
       
  2478 @internalAll */
       
  2479     {
       
  2480     iBuffer->EnableWindowSizeCacheL();
       
  2481     }