windowing/windowserver/nonnga/SERVER/server.h
changeset 0 5d03bc08d59c
child 26 15986eb6c500
equal deleted inserted replaced
-1:000000000000 0:5d03bc08d59c
       
     1 // Copyright (c) 1999-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 // Window server C++ Class definitions
       
    15 // 
       
    16 //
       
    17 
       
    18 #ifndef __SERVER_H__
       
    19 #define __SERVER_H__
       
    20 
       
    21 #include <e32std.h>
       
    22 #include <w32std.h>
       
    23 #include "w32cmd.h"
       
    24 #include <bitstd.h>
       
    25 #include <bitdev.h>
       
    26 #include <e32svr.h>
       
    27 #include "OBJECT.H"
       
    28 #include "CLIENT.H"
       
    29 #include "ScrDev.H"
       
    30 #include <Graphics/WSGRAPHICDRAWERINTERFACE.H>
       
    31 #include "WSGRAPHICDRAWERARRAY.H"
       
    32 #include "panics.h"
       
    33 
       
    34 class CWsGc;
       
    35 class CWsDirectScreenAccess;
       
    36 class CWsAnim;
       
    37 class CWsPluginManager;
       
    38 
       
    39 const TUid KDllUid={0x10000079};
       
    40 
       
    41 const TUint KMaxNumberOfMsgsInQueue=20;
       
    42 const TUint KMaxNumberOfMsgsInInactiveQueue=2;
       
    43 
       
    44 enum TWservActiveObjectPriorities
       
    45 	{
       
    46 	EWsGraphicAnimateAwaitIdlePriority=0, // lowest of all, when the system is really idle
       
    47 	EWsGraphicAnimatePriority=50,		// used by the default animation scheduler; custom schedulers might use other priorities as they see fit
       
    48 	EMainServerPriority=100,
       
    49 	ESpriteAnimatePriority=900,			// Below normal heartbeat
       
    50 	EPointerCursorPriority=950,
       
    51 	EHeartBeatPriority=1000,
       
    52 	EKeyRepeatPriority=1990,	// Just below normal events
       
    53 	EPointerRepeatPriority=1990,// Same as for key repeats
       
    54 	EEventPriority=2000,
       
    55 	EWsShellLogonPriority=3000,	// Log on to the shell dying
       
    56 	EDirectTimeOut=4000,
       
    57 	EDirectAbort=4010,
       
    58 	};
       
    59 
       
    60 enum {ETidyCountSetting=8};
       
    61 
       
    62 class CWsClient;
       
    63 class DWsScreenDevice;
       
    64 
       
    65 GLREF_C RWsRegion *GetRegionFromClientL(CWsClient *aClient, TInt aCount);
       
    66 
       
    67 //---------------------------
       
    68 // The event queue
       
    69 //---------------------------
       
    70 
       
    71 #define WS_EVENT_QUEUE_SIZE 50
       
    72 
       
    73 // Forward references
       
    74 
       
    75 class CWsRedrawMsgWindow;
       
    76 class CWsWindowRedraw;
       
    77 class CWsWindow;
       
    78 class CWsWindowBase;
       
    79 class CWsWindowGroup;
       
    80 class CWsClientWindow;
       
    81 class CWsClient;
       
    82 class CWsBackedUpWindow;
       
    83 class CWsPointerCursor;
       
    84 class TWindowServerEvent;
       
    85 class CWsRootWindow;
       
    86 
       
    87 enum TFlashState {EFlashOn,EFlashOff};
       
    88 
       
    89 struct TPointerKeyList
       
    90 	{
       
    91 	TRect iRect;
       
    92 	TInt iScanCode;
       
    93 	TBool iActivatedByPointerSwitchOn;
       
    94 	TDblQueLink iQue;
       
    95 	};
       
    96 
       
    97 struct TWsMessage
       
    98 	{
       
    99 	TUid iUid;
       
   100 	TUint8 iTheRest[4];	// Dummy elemnt where a variable length component will be
       
   101 	};
       
   102 
       
   103 class WsKeyboardEmulator
       
   104 	{
       
   105 public:
       
   106 	static TBool PointerEvent(TPointerEvent::TType type,const TPoint &aPoint, TDblQue<TPointerKeyList> *iPointerKeyList);
       
   107 private:
       
   108 	static void RawKeyEvent(TRawEvent::TType aType);
       
   109 private: // Private data
       
   110 	static TBool iKeyIsDown;
       
   111 	static TInt iCurrentKeyDown;
       
   112 	};
       
   113 
       
   114 struct TPointerEventInternal
       
   115 	{
       
   116 	TPointerEvent::TType iType;		// Type of pointer event
       
   117 	TUint iModifiers;	// State of pointing device and associated buttons
       
   118 	TPoint iPosition; 	// Screen co-ordinates of mouse event
       
   119 	};
       
   120 
       
   121 //------------------------------
       
   122 // Client object
       
   123 //------------------------------
       
   124 
       
   125 class CWsCliObj : public CWsObject
       
   126 	{
       
   127 public:
       
   128 	static CWsCliObj* NewL(CWsClient *aOwner);
       
   129 private:
       
   130 	CWsCliObj(CWsClient *aOwner);
       
   131 	void ConstructL();
       
   132 public: //from CWsObject
       
   133 	void CommandL(TInt aOpcode, const TAny *aCmdData);
       
   134 	};
       
   135 
       
   136 
       
   137 //---------------------------
       
   138 // Capture Key
       
   139 //---------------------------
       
   140 class CWsCaptureKey : public CWsObject
       
   141 	{
       
   142 public:
       
   143 	CWsCaptureKey(CWsWindowGroup *owner);
       
   144 	~CWsCaptureKey();
       
   145 	void ConstructL(const TWsWinCmdCaptureKey &aCaptureKey);
       
   146 	void SetL(const TWsWinCmdCaptureKey &aCaptureKey);
       
   147 	void CommandL(TInt aOpcode, const TAny *aCmdData);
       
   148 	inline CWsWindowGroup *WindowGroup();
       
   149 	inline const CWsWindowGroup *WindowGroup() const;
       
   150 private:
       
   151 	void CmdToParams(const TWsWinCmdCaptureKey &aCaptureKey, TCaptureKey &aParams);
       
   152 private:
       
   153 	CWsWindowGroup *iWindowGroup;
       
   154 	};
       
   155 
       
   156 class CWsHotKey : public CBase
       
   157 	{
       
   158 public:
       
   159 	CWsHotKey(TInt aHotKey, TBool aIsDefault);
       
   160 	~CWsHotKey();
       
   161 	void ConstructLD(const TWsWinCmdCaptureKey &aCaptureKey);
       
   162 	inline TInt HotKeyType() const;
       
   163 	inline TInt KeyHandle() const;
       
   164 	inline TBool IsDefault() const;
       
   165 	inline void SetLink(CWsHotKey *aLink);
       
   166 	void SetL(const TWsWinCmdCaptureKey &aCaptureKey);
       
   167 public:
       
   168 	CWsHotKey *iNext;
       
   169 private:
       
   170 	TInt iHotKeyType;
       
   171 	TBool iIsDefault;
       
   172 	CWsCaptureKey *iCaptureKey;
       
   173 	};
       
   174 
       
   175 class CWsCaptureKeyUpsAndDowns : public CWsObject
       
   176 	{
       
   177 public:
       
   178 	CWsCaptureKeyUpsAndDowns(CWsWindowGroup *owner);
       
   179 	~CWsCaptureKeyUpsAndDowns();
       
   180 	void ConstructL(const TWsWinCmdCaptureKey &aCaptureKey);
       
   181 	void CommandL(TInt aOpcode, const TAny *aCmdData);
       
   182 	static CWsWindowGroup *CheckForCapture(TUint aScanCode, TUint aModifiers);
       
   183 	inline CWsWindowGroup *WindowGroup();
       
   184 	inline const CWsWindowGroup *WindowGroup() const;
       
   185 private:
       
   186 	TUint iModifierValue;
       
   187 	TUint iModifierMask;
       
   188 	TUint iScanCode;
       
   189 	static TPriQue<CWsCaptureKeyUpsAndDowns> iCaptureKeysUpsAndDowns;
       
   190 	TPriQueLink iLink;
       
   191 	CWsWindowGroup *iWindowGroup;
       
   192 	};
       
   193 
       
   194 class CWsCaptureLongKey : public CWsObject
       
   195 	{
       
   196 	friend class CKeyboardRepeat;
       
   197 public:
       
   198 	CWsCaptureLongKey(CWsWindowGroup *owner);
       
   199 	~CWsCaptureLongKey();
       
   200 	void ConstructL(const TWsWinCmdCaptureLongKey &aCaptureKey);
       
   201 	void CommandL(TInt aOpcode, const TAny *aCmdData);
       
   202 	inline CWsWindowGroup *WindowGroup();
       
   203 	inline const CWsWindowGroup *WindowGroup() const;
       
   204 	static CWsCaptureLongKey* CheckForCapture(TUint aKeyCode, TInt aModifiers);
       
   205 public:
       
   206 	static TPriQue<CWsCaptureLongKey> iCaptureLongKeys;
       
   207 private:
       
   208 	TPriQueLink iLink;
       
   209 	CWsWindowGroup *iWindowGroup;
       
   210 	TWsWinCmdCaptureLongKey iData;
       
   211 	};
       
   212 
       
   213 //--------------------------------
       
   214 // Owner of CWsGraphicDrawer
       
   215 //--------------------------------
       
   216 
       
   217 class CWsGraphicDrawerObject: public CWsObject
       
   218 	{
       
   219 public:
       
   220 	static CWsGraphicDrawerObject* NewL(CWsClient* aClient,const TWsClCmdUnion &aParams);
       
   221 	~CWsGraphicDrawerObject();
       
   222 	// from CWsObject
       
   223 	void CommandL(TInt aOpcode, const TAny *aCmdData);
       
   224 	// access
       
   225 	CWsGraphicDrawer* Drawer();
       
   226 	const CWsGraphicDrawer* Drawer() const;
       
   227 	inline TInt ClientHandle() const;
       
   228 private:
       
   229 	CWsGraphicDrawerObject(CWsClient* aOwner);
       
   230 	void ConstructL(TUid aType,MWsGraphicDrawerEnvironment& aEnv,const TGraphicDrawerId& aId,const TDesC8& aData,TInt aClientHandle);
       
   231 private:
       
   232 	static TInt TransientSequence;
       
   233 	static TBool RollOver;
       
   234 	CWsGraphicDrawer* iDrawer;
       
   235 	TInt iClientHandle;
       
   236 	};
       
   237 
       
   238 //----------------------------
       
   239 // Window's
       
   240 //----------------------------
       
   241 
       
   242 enum TWalkMode
       
   243 	{
       
   244 	EWalkBehind,
       
   245 	EWalkChildren,
       
   246 	EWalkChildrenAndBehind
       
   247 	};
       
   248 enum TWindowFlags
       
   249 	{
       
   250 	EFlagHidden=0x1,			// True if the window is invisble for any reason
       
   251 	EFlagPointerCaptured=0x2,
       
   252 	EFlagPointerGrab=0x4,
       
   253 	EFlagInvisible=0x8,			// True if the client has requested the window to be invisible
       
   254 	EFlagActive=0x10,			// True if the window has been activated
       
   255 	//0x20
       
   256 	//0x40
       
   257 	EFlagDrawnToScreen=0x80,    // True if the window has been drawn to the screen since it became visible
       
   258 	//0x100
       
   259 	EFlagPointerCaptureDragDrop=0x200,	// True if pointure capture in Drag/Drop mode
       
   260 	EFlagPointerCaptureAllGroups=0x400,	// True if pointer capture affects all groups
       
   261 	EFlagUsingPointerBuffer=0x800,		// True if using a pointer event buffer
       
   262 	EFlagHasPointerBuffer=0x1000,		// True if has pointer event buffer allocated
       
   263 	//0x2000
       
   264 	EFlagFadeBehind=0x4000,             // True if fade behind requested for this window
       
   265 	//0x8000
       
   266 	EFlagNonFadingWindow=0x00010000,		//True if the window should never be faded
       
   267 	EFlagScreenDeviceInvalid=0x00020000,
       
   268 	EFlagShutDownInProgress=0x00040000,		// True if the window is currently being shut down
       
   269 	//0x00080000,
       
   270 	//0x00100000,
       
   271 	//0x00200000,
       
   272 	//0x00400000,
       
   273 	//0x00800000,
       
   274 	EFlagGeneratesVisibilityEvents=0x02000000,	// True if visibility events are enabled for this window
       
   275 	EFlagCanBeSeen=0x04000000,					// True if the last visibility event indicated that part of the window was visible
       
   276 //	EFlagTransparencyAlphaChannel=0x08000000, // True if the window is transparent with an alpha channel (and no transparency mask)
       
   277 	EFlagNotCantBeSeen=0x10000000,					// True if the last visibility event did not indicate that part of the window was not visible
       
   278 //	EFlagTransparencyPolicyFreezeUnder=0x20000000,	// True if the transparent window enables freezing under policy
       
   279 //	EFlagChildClippedRegionValid=0x40000000,  // True if the ChildClippedRegion is valid
       
   280 	EFlagHasAlpha=            0x80000000,  // Equivalent to EFlagTransperencyAlphaChannel - new name to prevent confusion
       
   281 	};
       
   282 
       
   283 //
       
   284 // Sprites
       
   285 //
       
   286 
       
   287 class TWsDeltaTimerEntry
       
   288 	{
       
   289 	friend class CWsDeltaTimer;
       
   290 public:
       
   291 	inline TWsDeltaTimerEntry(TCallBack& aCallback);
       
   292 	inline TWsDeltaTimerEntry();
       
   293 	inline void Set(TCallBack& aCallback);
       
   294 	inline TBool IsPending();
       
   295 private:
       
   296 	TCallBack iCallBack; 
       
   297 	TDeltaQueLink iLink;
       
   298 	};
       
   299 class CWsDeltaTimer : public CActive
       
   300 	{
       
   301 	enum {CWsDeltaTimerGranularity=100000};
       
   302 public:
       
   303 	static CWsDeltaTimer* NewL(TInt aPriority);
       
   304 	void Queue(TTimeIntervalMicroSeconds32 aTimeInMicroSeconds,TWsDeltaTimerEntry& aHandle);
       
   305 	void Remove(TWsDeltaTimerEntry& anEntry);
       
   306 	void Activate();
       
   307 	~CWsDeltaTimer();
       
   308 private:
       
   309 	CWsDeltaTimer(TInt aPriority);
       
   310 	void DoCancel();
       
   311 	void RunL();
       
   312 protected:
       
   313 	RTimer iTimer;
       
   314 	TDeltaQue<TWsDeltaTimerEntry> iQueue;
       
   315 	};
       
   316 
       
   317 //---------------------------
       
   318 // Top level command class
       
   319 //---------------------------
       
   320 
       
   321 /** The main server class.
       
   322 
       
   323 @internalComponent
       
   324 @released
       
   325 */
       
   326 class CWindowServer : public CPolicyServer, public MWsGraphicDrawerEnvironment, public MWsMemoryRelease, public MWsRawEventServer
       
   327 	{
       
   328 public:
       
   329 	static CWindowServer *NewL();
       
   330 	~CWindowServer();
       
   331 	TInt SessionCount();
       
   332 	MWsAnimationScheduler* AnimationScheduler();
       
   333 	CWsPluginManager * PluginManager();
       
   334 	TBool ReleaseMemory();
       
   335 public:	// from MWsGraphicDrawerEnvironment
       
   336 	const CWsGraphicDrawer* ResolveGraphic(const TGraphicDrawerId& aId) const;
       
   337 	void Invalidate(const TGraphicDrawerId& aId);
       
   338 	TInt ScreenCount() const;
       
   339 	MWsScreen* Screen(TInt aIndex);
       
   340 	const MWsScreen* Screen(TInt aIndex) const;
       
   341 	TBool SetCustomAnimationScheduler(MWsAnimationScheduler* aScheduler);
       
   342 	TBool HasCustomAnimationScheduler() const;
       
   343 	TBool ClearCustomAnimationScheduler(MWsAnimationScheduler* aCurrentScheduler);
       
   344 	TInt RegisterEventHandler(CWsGraphicDrawer* aDrawer, MWsEventHandler* aHandler, TUint32 aEventMask);
       
   345 	TInt UnregisterEventHandler(CWsGraphicDrawer* aDrawer);
       
   346 	TInt RegisterWsEventHandler(MWsEventHandler* aHandler, TUint32 aEventMask);
       
   347 	TInt UnregisterWsEventHandler(MWsEventHandler* aHandler);
       
   348 	void Log(TInt aPriority,const TDesC &aFmt,TInt aParam=0);
       
   349 	TInt RegisterMemoryRelease(MWsMemoryRelease * aMemoryRelease);
       
   350 	void UnregisterMemoryRelease(MWsMemoryRelease * aMemoryRelease);
       
   351 
       
   352 public: // from MWsRawEventServer
       
   353 	TInt RegisterRawEventHandler(MEventHandler * aHandler);
       
   354 	void UnregisterRawEventHandler(MEventHandler * aHandler);
       
   355 	void PostRawEvent(const TRawEvent & aEvent);
       
   356 	void PostKeyEvent(const TKeyEvent & aEvent);
       
   357 
       
   358 public:
       
   359 	// CWsGraphicDrawer master index
       
   360 	TInt AddGraphicDrawer(CWsGraphicDrawer* aDrawer);
       
   361 	TInt SwapGraphicDrawer(CWsGraphicDrawer* aDrawer);
       
   362 	TInt RemoveGraphicDrawer(const TGraphicDrawerId& aId);
       
   363 	TInt RemoveAllGraphicDrawers(const MWsClient& aOwner);
       
   364 public: // from MWsMemoryRelease
       
   365 	TBool ReleaseMemory(TMemoryReleaseLevel aLevel);
       
   366 private:
       
   367 	CWindowServer();
       
   368 	void ConstructL();
       
   369 	TAny* ResolveObjectInterface(TUint aTypeId);
       
   370 private:	// from CServer2
       
   371 	CSession2* NewSessionL(const TVersion& aVersion,const RMessage2& aMessage) const;
       
   372 private:
       
   373 	class CDefaultAnimationScheduler;
       
   374 	CDefaultAnimationScheduler* iDefaultAnimationScheduler;
       
   375 	MWsAnimationScheduler* iCustomAnimationScheduler;
       
   376 	CWsPluginManager* iPluginManager;
       
   377 	RPointerArray<MWsMemoryRelease> iMemoryReleases;
       
   378 	/** An index to all the CWsGraphicDrawer objects.
       
   379 	
       
   380 	All the CWsGraphicDrawer objects are created and owned by the CWsClient objects but they are
       
   381 	indexed centrally because some operations require access to the full list.
       
   382 	*/
       
   383 	CWsGraphicDrawerArray iDrawerMasterIndex;
       
   384 	};
       
   385 
       
   386 //
       
   387 inline CWsWindowGroup *CWsCaptureKey::WindowGroup()
       
   388 	{return(iWindowGroup);}
       
   389 inline const CWsWindowGroup *CWsCaptureKey::WindowGroup() const
       
   390 	{return(iWindowGroup);}
       
   391 //
       
   392 inline CWsWindowGroup *CWsCaptureKeyUpsAndDowns::WindowGroup()
       
   393 	{return(iWindowGroup);}
       
   394 inline const CWsWindowGroup *CWsCaptureKeyUpsAndDowns::WindowGroup() const
       
   395 	{return(iWindowGroup);}
       
   396 //
       
   397 inline CWsWindowGroup *CWsCaptureLongKey::WindowGroup()
       
   398 	{return(iWindowGroup);}
       
   399 inline const CWsWindowGroup *CWsCaptureLongKey::WindowGroup() const
       
   400 	{return(iWindowGroup);}
       
   401 //
       
   402 inline CWsPointerCursor *CWsClient::DefaultSystemPointerCursor()
       
   403 	{return(iDefaultSystemPointerCursor);}
       
   404 //
       
   405 inline TInt CWsHotKey::HotKeyType() const
       
   406 	{return(iHotKeyType);}
       
   407 inline TInt CWsHotKey::KeyHandle() const
       
   408 	{return((TInt)iCaptureKey);}
       
   409 inline TBool CWsHotKey::IsDefault() const
       
   410 	{return(iIsDefault);}
       
   411 inline void CWsHotKey::SetLink(CWsHotKey *aLink)
       
   412 	{iNext=aLink;}
       
   413 //
       
   414 inline TWsDeltaTimerEntry::TWsDeltaTimerEntry(TCallBack& aCallback)
       
   415 	{iCallBack=aCallback;}
       
   416 inline TWsDeltaTimerEntry::TWsDeltaTimerEntry()
       
   417 	{}
       
   418 inline void TWsDeltaTimerEntry::Set(TCallBack& aCallback)
       
   419 	{iCallBack=aCallback;}
       
   420 inline TBool TWsDeltaTimerEntry::IsPending()
       
   421 	{return(iLink.iNext!=NULL);}
       
   422 //
       
   423 inline TInt CWsGraphicDrawerObject::ClientHandle() const
       
   424 	{return iClientHandle;}
       
   425 
       
   426 #endif