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