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