headers/bsd: Add sys/queue.h.
[haiku.git] / src / tests / servers / app / newerClipping / WindowLayer.h
blob0cd73d858d6c9b30927e9a89a1352ffc19c331cd
2 #ifndef WINDOW_LAYER_H
3 #define WINDOW_LAYER_H
5 #include <List.h>
6 #include <Looper.h>
7 #include <Region.h>
8 #include <String.h>
10 #include "ViewLayer.h"
12 class ClientLooper;
13 class Desktop;
14 class DrawingEngine;
16 enum {
17 MSG_REDRAW = 'rdrw',
19 // client messages
20 MSG_BEGIN_UPDATE = 'bgud',
21 MSG_END_UPDATE = 'edud',
22 MSG_DRAWING_COMMAND = 'draw',
24 MSG_SHOW = 'show',
26 MSG_INVALIDATE_VIEW = 'invl',
27 MSG_DRAW_POLYGON = 'drwp',
30 class UpdateSession {
31 public:
32 UpdateSession();
33 virtual ~UpdateSession();
35 void Include(BRegion* additionalDirty);
36 void Exclude(BRegion* dirtyInNextSession);
38 inline BRegion& DirtyRegion()
39 { return fDirtyRegion; }
41 void MoveBy(int32 x, int32 y);
43 void SetUsed(bool used);
44 inline bool IsUsed() const
45 { return fInUse; }
47 UpdateSession& operator=(const UpdateSession& other);
49 private:
50 BRegion fDirtyRegion;
51 bool fInUse;
54 class WindowLayer : public BLooper {
55 public:
56 WindowLayer(BRect frame, const char* name,
57 DrawingEngine* drawingEngine,
58 Desktop* desktop);
59 virtual ~WindowLayer();
61 virtual void MessageReceived(BMessage* message);
62 virtual bool QuitRequested();
64 inline BRect Frame() const
65 { return fFrame; }
66 // setting and getting the "hard" clipping
67 void SetClipping(BRegion* stillAvailableOnScreen);
68 inline BRegion& VisibleRegion()
69 { return fVisibleRegion; }
70 BRegion& VisibleContentRegion();
72 void GetFullRegion(BRegion* region) const;
73 void GetBorderRegion(BRegion* region);
74 void GetContentRegion(BRegion* region);
76 void SetFocus(bool focus);
78 void MoveBy(int32 x, int32 y);
79 void ResizeBy(int32 x, int32 y, BRegion* dirtyRegion);
81 void ScrollViewBy(ViewLayer* view, int32 dx, int32 dy);
83 void AddChild(ViewLayer* layer);
85 ViewLayer* ViewAt(const BPoint& where);
87 void SetHidden(bool hidden);
88 inline bool IsHidden() const
89 { return fHidden; }
91 void MarkDirty(BRegion* regionOnScreen);
92 void MarkContentDirty(BRegion* regionOnScreen);
93 void InvalidateView(int32 token);
95 void ProcessDirtyRegion(BRegion* region);
97 DrawingEngine* GetDrawingEngine() const
98 { return fDrawingEngine; }
100 void CopyContents(BRegion* region,
101 int32 xOffset, int32 yOffset);
103 private:
104 void _ShiftPartOfRegion(BRegion* region, BRegion* regionToShift,
105 int32 xOffset, int32 yOffset);
107 // different types of drawing
108 void _TriggerContentRedraw();
109 void _DrawClient(int32 token);
110 void _DrawClientPolygon(int32 token, BPoint polygon[4]);
111 void _DrawBorder();
113 // handling update sessions
114 void _MarkContentDirty(BRegion* contentDirtyRegion);
115 void _BeginUpdate();
116 void _EndUpdate();
118 void _UpdateContentRegion();
120 BRect fFrame;
122 // the visible region is only recalculated from the
123 // Desktop thread, when using it, Desktop::ReadLockClipping()
124 // has to be called
125 BRegion fVisibleRegion;
126 BRegion fVisibleContentRegion;
127 bool fVisibleContentRegionValid;
128 // our part of the "global" dirty region
129 // it is calculated from the desktop thread,
130 // but we can write to it when we read locked
131 // the clipping, since it is local and the desktop
132 // thread is blocked
133 BRegion fDirtyRegion;
135 // caching local regions
136 BRegion fBorderRegion;
137 bool fBorderRegionValid;
138 BRegion fContentRegion;
139 bool fContentRegionValid;
140 BRegion fEffectiveDrawingRegion;
141 bool fEffectiveDrawingRegionValid;
143 bool fFocus;
145 ViewLayer* fTopLayer;
147 bool fHidden;
149 DrawingEngine* fDrawingEngine;
150 Desktop* fDesktop;
152 // for mapping drawing requests from the client
153 // to the local view pointers
154 BList fTokenViewMap;
156 // the client looper, which will do asynchronous
157 // drawing (the window will clear the content
158 // and the client is supposed to draw onto
159 // the cleared regions)
160 ClientLooper* fClient;
161 // The synchronization, which client drawing commands
162 // belong to the redraw of which region is handled
163 // through an UpdateSession. When the client has
164 // been informed that it should redraw stuff, then
165 // this is the current update session. All new
166 // redraw requests from the root layer will go
167 // into the pending update session.
168 UpdateSession fCurrentUpdateSession;
169 UpdateSession fPendingUpdateSession;
170 // these two flags are supposed to ensure a sane
171 // and consistent update session
172 bool fUpdateRequested;
173 bool fInUpdate;
176 #endif // WINDOW_LAYER_H