1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/graphics/windowing/windowserver/nga/SERVER/openwfc/CLIENT.H Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,445 @@
1.4 +// Copyright (c) 1999-2010 Nokia Corporation and/or its subsidiary(-ies).
1.5 +// All rights reserved.
1.6 +// This component and the accompanying materials are made available
1.7 +// under the terms of "Eclipse Public License v1.0"
1.8 +// which accompanies this distribution, and is available
1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.10 +//
1.11 +// Initial Contributors:
1.12 +// Nokia Corporation - initial contribution.
1.13 +//
1.14 +// Contributors:
1.15 +//
1.16 +// Description:
1.17 +// Definition of classes for the class that deals with client communication
1.18 +//
1.19 +//
1.20 +
1.21 +#ifndef __CLIENT_H__
1.22 +#define __CLIENT_H__
1.23 +
1.24 +#include <graphics/WSGRAPHICDRAWERINTERFACE.H>
1.25 +#include "WSGRAPHICDRAWERARRAY.H"
1.26 +
1.27 +#include <e32std.h>
1.28 +#include <e32base.h>
1.29 +#include "W32STD.H"
1.30 +#include "w32cmd.h"
1.31 +#include "WSOBJIX.H"
1.32 +#include "EVQUEUE.H"
1.33 +#include "PRIKEY.H"
1.34 +#include "wstypes.h"
1.35 +#include <e32hashtab.h> //RHashMap
1.36 +
1.37 +class CWsWindowBase;
1.38 +class CWsClientWindow;
1.39 +class CWsPointerCursor;
1.40 +class CWsCustomTextCursor;
1.41 +class CWsSpriteBase;
1.42 +class DWsScreenDevice;
1.43 +class CScreen;
1.44 +class RHandleBase;
1.45 +class CWsGraphicDrawerObject;
1.46 +class CWsGraphicDrawer;
1.47 +class MWsElement;
1.48 +class TSurfaceConfiguration;
1.49 +class CWsRedrawMsgWindow;
1.50 +
1.51 +/** Server-side object for a client session.
1.52 +
1.53 +@internalComponent
1.54 +@released
1.55 +*/
1.56 +class CWsClient : public CSession2, public MWsClient
1.57 + {
1.58 +private:
1.59 + friend class CWsRedrawMsgWindow;
1.60 +private:
1.61 + class TWsCursorArrayItem;
1.62 + enum{EObjectGranularity=5};
1.63 + enum{ENoDefaultSystemPointerCursor=-1};
1.64 +public:
1.65 + enum{EPanicLeave=1};
1.66 +public: // from MWsClient
1.67 + TBool HasCapability(TCapability aCapability) const;
1.68 + TSecureId SecureId() const;
1.69 + TVendorId VendorId() const;
1.70 +public:
1.71 + CWsClient(RThread aClient);
1.72 + ~CWsClient();
1.73 + static void InitStaticsL();
1.74 + static void DeleteStatics();
1.75 + inline TBool NotClosing() const;
1.76 + inline CWsObjectIx* ObjectIndex();
1.77 +
1.78 + inline const RMessage2& ClientMessage() const;
1.79 +
1.80 + inline const RThread& Client() const;
1.81 + static inline CWsClient* CurrentClient();
1.82 + inline TInt ConnectionHandle() const;
1.83 + inline DWsScreenDevice* PrimaryScreenDevice();
1.84 + inline const DWsScreenDevice* PrimaryScreenDevice() const;
1.85 + inline CScreen* Screen();
1.86 + inline const CScreen* Screen() const;
1.87 + static CWsPointerCursor* SystemPointerCursor(TInt aIndex);
1.88 + static inline CWsPointerCursor* DefaultSystemPointerCursor();
1.89 + static CWsCustomTextCursor* FindCustomTextCursor(TInt aIdentifier);
1.90 + void SessionPanic(TClientPanic aReason) const;
1.91 +
1.92 + // Window object access from handle
1.93 + void HandleToWindow(TInt aHandle, CWsWindowBase** pWin);
1.94 + void HandleToClientWindow(TInt aHandle, CWsClientWindow** pWin);
1.95 +
1.96 + // Generic WsObject access from handle
1.97 + CWsObject* HandleToObj(TInt aHandle, WH_HANDLES aType);
1.98 + const CWsObject* HandleToObj(TInt aHandle, WH_HANDLES aType) const;
1.99 + CWsObject* HandleToObjUntyped(TInt aHandle);
1.100 + const CWsObject* HandleToObjUntyped(TInt aHandle) const;
1.101 +
1.102 + CWsGraphicDrawerObject* DrawerObject(const CWsGraphicDrawer* aDrawer);
1.103 + const CWsGraphicDrawerObject* DrawerObject(const CWsGraphicDrawer* aDrawer) const;
1.104 +
1.105 + // Handle from object
1.106 + inline TInt ObjectHandle(const CWsObject* aThis) const;
1.107 +
1.108 + // Queue access
1.109 + inline CEventQueue* EventQueue();
1.110 + inline const CEventQueue* EventQueue() const;
1.111 + inline CRedrawQueue* RedrawQueue();
1.112 + inline const CRedrawQueue* RedrawQueue() const;
1.113 +
1.114 + // Execute client command from buffer
1.115 + void ExecuteCommandL(TInt aOpcode, const TAny* aCmdData);
1.116 + static const TUint8* EndOfCommandBuffer();
1.117 + static const TPtrC BufferTPtr(TText* aStart,TInt aLen);
1.118 + static TBool BufferTPtrGc(TText* aStart,TInt aLen,TPtrC& aPtr);
1.119 + static const TPtrC8 BufferTPtr8(TUint8* aStart,TInt aLen);
1.120 +
1.121 + // Remote read data from client
1.122 + void RemoteRead(TDes16& aDes, TInt aOffset);
1.123 + void RemoteRead(TDes8& aDes, TInt aOffset);
1.124 + void RemoteReadL(TDes16& aDes, TInt aOffset);
1.125 + void RemoteReadL(TDes8& aDes, TInt aOffset);
1.126 +
1.127 + // Send the reply to the client's request
1.128 + void SetResponseHandle(RHandleBase* aHandle);
1.129 + static void ReplyBuf(const TAny* aSource, TInt aLength);
1.130 + static void ReplyBuf(const TDesC8 &aDes);
1.131 + static void ReplyBuf(const TDesC16 &aDes);
1.132 + static void ReplySize(const TSize &aSize);
1.133 + static void ReplyPoint(const TPoint &aPoint);
1.134 + static void ReplyRect(const TRect &aRect);
1.135 + static void ReplyGroupName(HBufC* aName, TInt aMaxLength);
1.136 + static void SetReply(TInt reply);
1.137 + void RequestComplete(TRequestStatus*& aStatus, TInt aErr);
1.138 +
1.139 + // Panic or terminate the client
1.140 + static void PanicCurrentClient(TClientPanic aPanic);
1.141 + static TInt ReplyBufSpace() ;
1.142 + void PPanic(TClientPanic aPanic) const;
1.143 + void SessionTerminate();
1.144 +
1.145 + // All events
1.146 + inline void EventReady(const RMessagePtr2& aEventMsg);
1.147 +
1.148 + // Pointer events
1.149 + inline void PurgePointerEvents();
1.150 +
1.151 + // Key events
1.152 + inline void PriorityKeyPressed(TInt aHandle, const TKeyEvent &aKeyEvent);
1.153 +
1.154 + // Notification of misc events
1.155 + void AddNotificationL(TInt aKey, const RMessage2& aClientMsg);
1.156 + void CompleteNotification(TInt aKey, TInt aReason);
1.157 + inline void NotifyScreenDeviceDeleted(DWsScreenDevice* aDeletedScreenDevice);
1.158 +
1.159 + // Redraw
1.160 + void TriggerRedraw();
1.161 +
1.162 + // Misc
1.163 + void UpdateWindowOrdinalPrioritys();
1.164 + void SetClientPriority(); // boost when in foreground
1.165 +
1.166 + void CreateDrawableSourceL(const TWsClCmdCreateDrawableSource& aDrawableSourceData);
1.167 +
1.168 + //retry putting events on event queue
1.169 + void SetRetryFlag(TEventCode aEventCode);
1.170 + void RemoveRetryFlag(TEventCode aEventCode);
1.171 + TBool RetryEvent(TEventCode aEventCode);
1.172 +
1.173 + inline void WgMsgQueueOverflow();// Set flag window group message queue is overflow and has pending messages
1.174 +
1.175 + //Get orientation value that app indicated
1.176 + TInt GetIndicatedAppOrientation();
1.177 +
1.178 +private: // from MWsClient
1.179 + TInt SendMessage(const CWsGraphicDrawer* aOnBehalfOf, const TDesC8& aData);
1.180 + TInt SendMessage(const CWsGraphicDrawer* aOnBehalfOf, CWsMessageData& aData);
1.181 +
1.182 +private: // from CSession2
1.183 + void ServiceL(const RMessage2 &aMessage);
1.184 + void ServiceError(const RMessage2& aMessage,TInt aError);
1.185 +private:
1.186 + // Construction and destruction
1.187 + inline TBool IsInitialised();
1.188 + void StartInitializationL(TUint aConnectionHandle);
1.189 + void CompleteInitializationL();
1.190 + void InitialiseScreenDevices();
1.191 +
1.192 + // Service client commands by dispatching them to the object associated with the op code
1.193 + void DoServiceL(const RMessage2& aMessage, TBool& aCompleteRequest);
1.194 + void DoServiceCommandBuf();
1.195 + void DispatchCommandsInBufL();
1.196 + void CompleteMessage(const RMessage2& aMessage,TInt aReason);
1.197 +
1.198 + // Execute async client commands
1.199 + void ExecuteAsyncClientCommandL(TInt aOpcode, const RMessage2& aMessage);
1.200 + static inline TBool CheckBuffer(TInt aLength, TInt aMaxLength);
1.201 + static TBool DebugEnforceRedrawCallingConvention();
1.202 +
1.203 + // Create new objects
1.204 + void CreateNewWindowGroupL(const TWsClCmdCreateWindowGroup &aCmd);
1.205 + void CreateNewWindowL(const TWsClCmdCreateWindow &aCmd);
1.206 + void CreateNewAnimDllL(const TWsClCmdUnion &aParams);
1.207 + void CreateNewSpriteL(const TWsClCmdCreateSprite &aCmd);
1.208 + void CreateNewPointerCursorL(const TWsClCmdCreatePointerCursor &aCmd);
1.209 + void CreateNewBitmapL(const TWsClCmdCreateBitmap &aCmd);
1.210 + void CreateNewClickHandlerL(const TUid& aUid);
1.211 + void CreateNewScreenDeviceL( TInt aDefaultScreenNumber, TUint aClientScreenDevicePointer);
1.212 +
1.213 + // Surface management
1.214 + TInt RegisterSurface(const TWsClCmdUnion& pData);
1.215 + void UnregisterSurface(const TWsClCmdUnion& pData);
1.216 +
1.217 + // Text cursor
1.218 + static inline CWsCustomTextCursor*& TextCursor (TInt aPosition);
1.219 + void StartSetCustomTextCursorL(const TWsClCmdCustomTextCursorData& aCmd);
1.220 + void CompleteSetCustomTextCursorL(TInt aErr);
1.221 +
1.222 + // Pointer cursor
1.223 + static inline CWsPointerCursor*& PointerCursor (TInt aPosition);
1.224 + void SetSystemPointerCursorL(TInt aIndex, CWsPointerCursor* aCursor);
1.225 + void ClearSystemPointerCursor(TInt aIndex);
1.226 + void ClaimSystemPointerCursorListL();
1.227 + void FreeSystemPointerCursorList();
1.228 + void SetDefaultSystemPointerCursor(TInt aIndex);
1.229 + static void DeleteSystemPointerListEntry(TInt aIndex);
1.230 +
1.231 + static TBool FindCursorArrayItem(CArrayFixFlat<TWsCursorArrayItem>* aCursorArray,
1.232 + TInt aIndex, TInt& aPosition);
1.233 +
1.234 + // Key events
1.235 + inline void CancelClientRequestForPriorityKeyEvent();
1.236 + inline void HandleClientRequestForPriorityKeyData();
1.237 + inline void PriorityKeyEventReady(const RMessagePtr2& aEventMsg);
1.238 +
1.239 + // Redraw events
1.240 + inline void CancelClientRequestForRedrawEvent();
1.241 + inline void HandleClientRequestForRedrawData();
1.242 + inline void RedrawEventReady(const RMessagePtr2& aEventMsg);
1.243 + inline TBool ClientProcessingRedrawEvent();
1.244 +
1.245 + // Client event requests
1.246 + inline void HandleClientRequestForEventData();
1.247 + inline void CancelClientRequestForEventData();
1.248 +
1.249 + // Debugging
1.250 + void DebugInfoL(TInt aFunction, TInt aParam, TBool aHasReplyBuf) const;
1.251 + void DebugInfoUnclassifiedL(TInt aFunction, TInt aParam, TBool aHasReplyBuf) const;
1.252 + TInt DebugInfoClassifiedL(TInt aFunction, TInt aParam, TBool aHasReplyBuf) const;
1.253 + TInt DebugInfoScreenUiL(TInt aFunction, TInt aParam, TInt aReplyBufSize, CScreen& aScreen) const;
1.254 + TInt DebugInfoScreenElementSetL(TInt aFunction, TInt aParam, TInt aReplyBufSize,const CScreen& aScreen) const;
1.255 + TInt DebugInfoElementSetWindowL(TInt aFunction, TInt aParam, TInt aReplyBufSize,const CScreen& aScreen) const;
1.256 + TInt DebugInfoElementSetElementL(TInt aFunction, TInt aParam, TInt aReplyBufSize,const CScreen& aScreen) const;
1.257 + TInt DebugReturnConfig(TInt aReplyBufSize, MWsElement* aElement, TInt aFlags=0)const;
1.258 + TInt DebugReturnBase(TInt aReplyBufSize, const MWsElement* aElement) const;
1.259 + TInt DebugReturnFlags(TInt aReplyBufSize, const MWsElement* aElement, TInt aFlags=0) const;
1.260 + TInt DebugReturnRegion(TInt aReplyBufSize, const TRegion* aRegion, TInt aErrCodeIfEmpty) const;
1.261 +
1.262 + // Misc
1.263 + void SetComputeMode(RWsSession::TComputeMode aComputeMode);
1.264 +
1.265 + //Set orientation that application indicated
1.266 + void IndicateAppOrientation(TRenderOrientation aOrientation);
1.267 +
1.268 +public:
1.269 + static TWsCmdHeaderBase iCurrentCommand;
1.270 +private:
1.271 + class TWsCursorArrayItem
1.272 + {
1.273 + public:
1.274 + CWsSpriteBase* iCursor;
1.275 + TInt iIndex;
1.276 + };
1.277 +
1.278 + enum TInternalFlags
1.279 + {
1.280 + EIsInitialised = 0x01,
1.281 + EPanicClientAsSoonAsPossible = 0x02, //The client should be panicked, but we have no way to panic him now
1.282 + EClientIsClosing = 0x04, //The client is closing down, so the screen device may no longer be valid
1.283 + EFinishedProcessingCommands=0x08, //Reached last command in command buffer or otherwised finihsed processing it
1.284 + ERemoveKeyCode=0x10, //Remove the Win32 keycode emulator only
1.285 + ERetryDisplayEvent=0x20,
1.286 + EIsPerformingRedrawEvent=0x40, //The client is performing a RedrawEvent
1.287 + EWgMsgQueueOverflow =0x80,
1.288 + };
1.289 +private:
1.290 + RThread iClient;
1.291 + CScreen* iScreen; //## This needs updating
1.292 + TUint iConnectionHandle; // Connection ID, only needed for logging, could bin this
1.293 + CEventQueue* iEventQueue;
1.294 + CRedrawQueue* iRedrawQueue;
1.295 + CPriorityKey* iPriorityKeyEvent;
1.296 + CWsGraphicMessageQueue iGraphicMessageQueue;
1.297 + RWsSession::TComputeMode iComputeMode;
1.298 + CWsObjectIx* iObjectIndex;
1.299 + DWsScreenDevice* iPrimaryScreenDevice;
1.300 + TWsCursorArrayItem iTempCustomTextCursor;
1.301 + mutable TInt iPanicReason;
1.302 + mutable TUint iInternalFlags;
1.303 + RMessage2 iClientMessage;
1.304 + RHandleBase* iResponseHandle;
1.305 + TInt iMessageIdSeq;
1.306 + TInt iIndicatedAppOrientation;
1.307 +
1.308 + //Members for procerssing command buffer
1.309 + static CWsClient* iCurrentClient; // Client who's buffer is currently being processed
1.310 + static TInt iReply; // Value to reply
1.311 + static TInt iReplyOffset; // Offset into reply to write next block of data
1.312 + static TBuf8<EClientBufferMaxSize> iCmdBuf; // Buffer contain a block of client commands
1.313 + static CWsObject* iDestObj; // Current object client command is for
1.314 + static const TUint8* iNextCmd; // Pointer in buffer to the next command to be processed
1.315 +
1.316 + static TInt iDefaultSystemPointerCursorIndex; // Negative when there isn't one
1.317 + static CWsPointerCursor* iDefaultSystemPointerCursor;
1.318 + static CArrayFixFlat<TWsCursorArrayItem>* iSystemPointerCursors;
1.319 + static CWsClient* iSystemPointerCursorListOwner;
1.320 + static CArrayFixFlat<TWsCursorArrayItem>* iTextCursorArray;
1.321 + static TUint iConnectionId;
1.322 + static TKeyArrayFix iCursorKey;
1.323 + static TBool iDebug_EnforceRedrawCallingConvention;
1.324 +#if defined(__WINS__)
1.325 +public:
1.326 + inline TBool RemoveKeyCode();
1.327 +#endif
1.328 + };
1.329 +
1.330 +
1.331 +//
1.332 +// inlines //
1.333 +//
1.334 +
1.335 +inline const RThread& CWsClient::Client() const
1.336 + {return iClient;}
1.337 +
1.338 +inline void CWsClient::EventReady(const RMessagePtr2& aEventMsg)
1.339 + {iEventQueue->EventReady(aEventMsg);}
1.340 +
1.341 +inline void CWsClient::HandleClientRequestForEventData()
1.342 + {iEventQueue->GetData();}
1.343 +
1.344 +inline void CWsClient::CancelClientRequestForEventData()
1.345 + {iEventQueue->CancelRead();}
1.346 +
1.347 +inline void CWsClient::PurgePointerEvents()
1.348 + {iEventQueue->PurgePointerEvents();}
1.349 +
1.350 +inline void CWsClient::RedrawEventReady(const RMessagePtr2& aEventMsg)
1.351 + {
1.352 + iInternalFlags&=~EIsPerformingRedrawEvent;
1.353 + iRedrawQueue->EventReady(aEventMsg);
1.354 + }
1.355 +
1.356 +inline TBool CWsClient::ClientProcessingRedrawEvent()
1.357 + {return !!(iInternalFlags&EIsPerformingRedrawEvent);}
1.358 +
1.359 +inline void CWsClient::HandleClientRequestForRedrawData()
1.360 + {
1.361 + iInternalFlags|=EIsPerformingRedrawEvent;
1.362 + iRedrawQueue->GetData();
1.363 + }
1.364 +
1.365 +inline void CWsClient::CancelClientRequestForRedrawEvent()
1.366 + {iRedrawQueue->CancelRead();}
1.367 +
1.368 +inline void CWsClient::PriorityKeyEventReady(const RMessagePtr2& aEventMsg)
1.369 + {iPriorityKeyEvent->EventReady(aEventMsg);}
1.370 +
1.371 +inline void CWsClient::CancelClientRequestForPriorityKeyEvent()
1.372 + {iPriorityKeyEvent->CancelRead();}
1.373 +
1.374 +inline void CWsClient::HandleClientRequestForPriorityKeyData()
1.375 + {iPriorityKeyEvent->GetData();}
1.376 +
1.377 +inline void CWsClient::PriorityKeyPressed(TInt aHandle, const TKeyEvent &aKeyEvent)
1.378 + {iPriorityKeyEvent->PriorityKey(aHandle, aKeyEvent);}
1.379 +
1.380 +inline TInt CWsClient::ObjectHandle(const CWsObject* aThis) const
1.381 + {return(iObjectIndex->At(aThis));}
1.382 +
1.383 +#if defined(__WINS__)
1.384 +inline TBool CWsClient::RemoveKeyCode()
1.385 + {return iInternalFlags&ERemoveKeyCode;}
1.386 +#endif
1.387 +
1.388 +inline CEventQueue* CWsClient::EventQueue()
1.389 + {return(iEventQueue);}
1.390 +
1.391 +inline const CEventQueue* CWsClient::EventQueue() const
1.392 + {return(iEventQueue);}
1.393 +
1.394 +inline CRedrawQueue* CWsClient::RedrawQueue()
1.395 + {return(iRedrawQueue);}
1.396 +
1.397 +inline const CRedrawQueue* CWsClient::RedrawQueue() const
1.398 + {return(iRedrawQueue);}
1.399 +
1.400 +inline CWsObjectIx* CWsClient::ObjectIndex()
1.401 + {return(iObjectIndex);}
1.402 +
1.403 +inline TInt CWsClient::ConnectionHandle() const
1.404 + {return(iConnectionHandle);}
1.405 +
1.406 +inline DWsScreenDevice* CWsClient::PrimaryScreenDevice()
1.407 + {return(iPrimaryScreenDevice);}
1.408 +
1.409 +inline const DWsScreenDevice* CWsClient::PrimaryScreenDevice() const
1.410 + {return(iPrimaryScreenDevice);}
1.411 +
1.412 +inline void CWsClient::NotifyScreenDeviceDeleted(DWsScreenDevice* aDeletedScreenDevice)
1.413 + {
1.414 + if (iPrimaryScreenDevice == aDeletedScreenDevice)
1.415 + iPrimaryScreenDevice = NULL;
1.416 + }
1.417 +
1.418 +inline CWsPointerCursor*& CWsClient::PointerCursor(TInt aIndex)
1.419 + {return (CWsPointerCursor*&)(*iSystemPointerCursors)[aIndex].iCursor;}
1.420 +
1.421 +inline CWsCustomTextCursor*& CWsClient::TextCursor(TInt aIndex)
1.422 + {return (CWsCustomTextCursor*&)(*iTextCursorArray)[aIndex].iCursor;}
1.423 +
1.424 +inline const RMessage2& CWsClient::ClientMessage() const
1.425 + {return iClientMessage;}
1.426 +
1.427 +inline CScreen* CWsClient::Screen()
1.428 + {return iScreen;}
1.429 +
1.430 +inline const CScreen* CWsClient::Screen() const
1.431 + {return iScreen;}
1.432 +
1.433 +inline TBool CWsClient::NotClosing() const
1.434 + {return !(iInternalFlags&EClientIsClosing);}
1.435 +
1.436 +inline CWsClient* CWsClient::CurrentClient()
1.437 + {return iCurrentClient;}
1.438 +
1.439 +inline TBool CWsClient::CheckBuffer(TInt aLength, TInt aMaxLength)
1.440 + {return TBool((aLength>=0) && (aLength<=aMaxLength));}
1.441 +
1.442 +inline TBool CWsClient::IsInitialised()
1.443 + {return iInternalFlags&EIsInitialised; }
1.444 +
1.445 +inline void CWsClient::WgMsgQueueOverflow()
1.446 + {iInternalFlags |= EWgMsgQueueOverflow;}
1.447 +
1.448 +#endif