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