os/graphics/windowing/windowserver/nonnga/SERVER/EVQUEUE.H
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
sl@0
     1
// Copyright (c) 1999-2009 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
// Definition of classes related event queues
sl@0
    15
// 
sl@0
    16
//
sl@0
    17
sl@0
    18
#if !defined(__EVQUEUE_H__)
sl@0
    19
#define __EVQUEUE_H__
sl@0
    20
sl@0
    21
#include <e32std.h>
sl@0
    22
#include <e32base.h>
sl@0
    23
#include <w32std.h>
sl@0
    24
#include <graphics/wsgraphicdrawerinterface.h>
sl@0
    25
sl@0
    26
class CWsClient;
sl@0
    27
class CWsWindowRedraw;
sl@0
    28
class CWsGraphicDrawer;
sl@0
    29
sl@0
    30
enum TEventQueueWalkRet
sl@0
    31
	{
sl@0
    32
	EEventQueueWalkOk,
sl@0
    33
	EEventQueueWalkDeleteEvent,
sl@0
    34
	EEventQueueWalkRestart,
sl@0
    35
	};
sl@0
    36
class TWsEvent;
sl@0
    37
sl@0
    38
typedef TEventQueueWalkRet (*EventQueueWalk)(TAny *aPtr, TWsEvent *aEvent);
sl@0
    39
sl@0
    40
enum TWservEventPriorities
sl@0
    41
	{
sl@0
    42
	EEventPriorityHigh,
sl@0
    43
	EEventPriorityLow,
sl@0
    44
	};
sl@0
    45
sl@0
    46
struct TRedraw
sl@0
    47
	{
sl@0
    48
	CWsWindowRedraw *iRedraw;
sl@0
    49
	TUint iPriority;
sl@0
    50
	};
sl@0
    51
sl@0
    52
class CEventBase : public CBase
sl@0
    53
	{
sl@0
    54
private:
sl@0
    55
	enum TEventSignalledState
sl@0
    56
		{
sl@0
    57
		EEventFlagSignalled=0x1,
sl@0
    58
		EEventFlagCancelled=0x2
sl@0
    59
		};
sl@0
    60
public:
sl@0
    61
	CEventBase(CWsClient *aOwner);
sl@0
    62
	~CEventBase();
sl@0
    63
	void CancelRead();
sl@0
    64
	void EventReadyCheck();
sl@0
    65
	virtual void EventReady(const RMessagePtr2& aEventMsg);
sl@0
    66
	void GetData(TAny *aData, TInt aLen);
sl@0
    67
protected:
sl@0
    68
	void SignalEvent(TInt aCode = KErrNone);
sl@0
    69
	inline TBool IsEventCancelled();
sl@0
    70
protected:
sl@0
    71
	TInt iEventSignalledState;
sl@0
    72
	CWsClient *iWsOwner;
sl@0
    73
	RMessagePtr2 iEventMsg;
sl@0
    74
	};
sl@0
    75
sl@0
    76
class CEventQueue : public CEventBase
sl@0
    77
	{
sl@0
    78
private:
sl@0
    79
	enum {EExtraQueueSize=16};
sl@0
    80
	enum {EMaxQueueSize=32};
sl@0
    81
	enum {EMinQueueSize=2};
sl@0
    82
	enum {EQueueGranularity=4};
sl@0
    83
	enum TCompressMode
sl@0
    84
		{
sl@0
    85
		ECompressNoPurge,	// Compress only free space
sl@0
    86
		ECompressPurge1,	// Purge from only non-foreground queues
sl@0
    87
		ECompressPurge2,	// Purge from all queues
sl@0
    88
		};
sl@0
    89
// Functions
sl@0
    90
public:
sl@0
    91
	CEventQueue(CWsClient *aOwner);
sl@0
    92
	~CEventQueue();
sl@0
    93
	void ConstructL();
sl@0
    94
	TBool QueueEvent(const TWsEvent &event);
sl@0
    95
	TBool QueueEvent(const TWsEvent &event, TWservEventPriorities aPriority);
sl@0
    96
	TBool QueueEvent(TUint32 aTarget, TInt aEvent);
sl@0
    97
	TBool CheckRoom();
sl@0
    98
	void GetData();
sl@0
    99
	void UpdateLastEvent(const TWsEvent &event);
sl@0
   100
	void RemoveEvent(TInt index);
sl@0
   101
	void PurgePointerEvents();
sl@0
   102
	const TWsEvent *PeekLastEvent();
sl@0
   103
	void WalkEventQueue(EventQueueWalk aFunc, TAny *aFuncParam);
sl@0
   104
	void MoveToFront();
sl@0
   105
	static void Wait();
sl@0
   106
	static void Signal();
sl@0
   107
	static void InitStaticsL();
sl@0
   108
	static void DeleteStaticsL();
sl@0
   109
	//void LogUpDownEvents(TChar aChar);
sl@0
   110
public:// from CEventBase
sl@0
   111
	void EventReady(const RMessagePtr2& aEventMsg);
sl@0
   112
private:
sl@0
   113
	static void EventCopy(TWsEvent *aStart, TWsEvent *aEnd, TInt aNumEvents);
sl@0
   114
	static TInt RequiredQueueSize(TInt aNumConnections);
sl@0
   115
	void AdjustQueueSizeL(TInt aNewSize);
sl@0
   116
	void IncreaseQueueSize(TInt aNumSpaces);
sl@0
   117
	TInt FollowingGap() const;
sl@0
   118
	void Purge();
sl@0
   119
	TInt PurgeInactiveEvents(const TInt& aSizeRequired);
sl@0
   120
	void Compress(TCompressMode aCompressMode);
sl@0
   121
	void AddQueueL();
sl@0
   122
	void RemoveQueue();
sl@0
   123
	TBool Expand(TWservEventPriorities aPriority);
sl@0
   124
	TBool doExpand(TCompressMode aCompressMode);
sl@0
   125
	TInt SqueezeUp();
sl@0
   126
	void SqueezeDown();
sl@0
   127
	void MoveUp(TInt aMove);
sl@0
   128
	void MoveDown(TInt aMove);
sl@0
   129
	TBool MoveDownAndExpand(TDblQueIter<CEventQueue> &aIter, TInt aExpand);
sl@0
   130
#if defined(_DEBUG)
sl@0
   131
	void CheckQueue();
sl@0
   132
	void ZapEvent(TWsEvent *aTarget);
sl@0
   133
	void ZapEvents(TWsEvent *aTarget, TInt aLen);
sl@0
   134
#endif
sl@0
   135
private:
sl@0
   136
	void QueueActive();
sl@0
   137
	TWsEvent *EventPtr(TInt index);
sl@0
   138
// Data
sl@0
   139
    TInt iHead;
sl@0
   140
    TInt iCount;
sl@0
   141
    TInt iQueueSize;
sl@0
   142
    TWsEvent *iEventPtr;
sl@0
   143
	TDblQueLink iLink;
sl@0
   144
	static RMutex iMutex;
sl@0
   145
	static TWsEvent iNullEvent;
sl@0
   146
	static TDblQue<CEventQueue> iQueueList;
sl@0
   147
	static TWsEvent *iGlobalEventQueue;
sl@0
   148
	static TInt iGlobalEventQueueSize;
sl@0
   149
	static TInt iNumConnections;
sl@0
   150
	};
sl@0
   151
sl@0
   152
class TWsRedrawEvent;
sl@0
   153
sl@0
   154
class CRedrawQueue : public CEventBase
sl@0
   155
	{
sl@0
   156
// Functions
sl@0
   157
public:
sl@0
   158
	CRedrawQueue(CWsClient *aOwner);
sl@0
   159
	~CRedrawQueue();
sl@0
   160
	void ConstructL();
sl@0
   161
	TBool TriggerRedraw();
sl@0
   162
	void ReCalcOrder();
sl@0
   163
	void AddInvalid(CWsWindowRedraw *redrawWin);
sl@0
   164
	void RemoveInvalid(CWsWindowRedraw *redrawWin);
sl@0
   165
	void GetData();
sl@0
   166
	TUint RedrawPriority(CWsWindowRedraw *aRedrawWin);
sl@0
   167
public:// from CEventBase
sl@0
   168
	void EventReady(const RMessagePtr2& aEventMsg);
sl@0
   169
private:
sl@0
   170
	void DeleteFromQueue(TInt aIndex);
sl@0
   171
	void QueueActive();
sl@0
   172
	TBool FindOutstandingRedrawEvent(CWsWindowRedraw& aRedraw, TWsRedrawEvent& aEvent);
sl@0
   173
	TBool FindWindowNeedingRedrawEvent(TWsRedrawEvent& aEvent);
sl@0
   174
private:
sl@0
   175
// Data
sl@0
   176
	CArrayFixSeg<TRedraw> *iRedraws;	// List of windows and their areas that require redraws
sl@0
   177
	TBool iAllocError;
sl@0
   178
	TBool iRedrawTrigger;
sl@0
   179
	TKeyArrayFix *iKeyPriority;
sl@0
   180
	TKeyArrayFix *iKeyWindow;
sl@0
   181
	static TWsRedrawEvent iNullRedrawEvent;
sl@0
   182
	};
sl@0
   183
sl@0
   184
class CWsGraphicMessageQueue: public CEventBase
sl@0
   185
	{
sl@0
   186
public:
sl@0
   187
	class CMessage: public CWsMessageData
sl@0
   188
		{
sl@0
   189
	public:
sl@0
   190
		static CMessage* New(const TDesC8& aData);
sl@0
   191
		~CMessage();
sl@0
   192
	public: // From CWsMessageData
sl@0
   193
		TPtrC8 Data() const;
sl@0
   194
		void Release();
sl@0
   195
	private:
sl@0
   196
		CMessage(const TDesC8& aData);
sl@0
   197
	private:
sl@0
   198
		TPtr8 iData;
sl@0
   199
		};
sl@0
   200
public:
sl@0
   201
	CWsGraphicMessageQueue(CWsClient *aOwner);
sl@0
   202
	~CWsGraphicMessageQueue();
sl@0
   203
	void GetGraphicMessage();
sl@0
   204
	void AbortMessage(TInt aError);
sl@0
   205
	void EventReady(const RMessagePtr2& aEventMsg);
sl@0
   206
	void Queue(CWsMessageData* aMessage);
sl@0
   207
	TInt TopClientHandle() const;
sl@0
   208
private:
sl@0
   209
	CWsMessageData* iHead;
sl@0
   210
	CWsMessageData* iTail;
sl@0
   211
	CWsMessageData* Pop();
sl@0
   212
	void GetDataWithHeader(TUint aHeader, const TDesC8& aData, TInt aDataLen);
sl@0
   213
	};
sl@0
   214
sl@0
   215
#endif