vfs: check userland buffers before reading them.
[haiku.git] / src / tests / servers / app / newerClipping / Desktop.h
blob67a83475571676c57d8797c3c19cc115b39e638a
2 #ifndef DESKTOP_H
3 #define DESKTOP_H
5 #include <List.h>
6 #include <Region.h>
7 #include <View.h>
8 #include <Window.h>
10 #define SHOW_GLOBAL_DIRTY_REGION 0
11 #define SHOW_WINDOW_CONTENT_DIRTY_REGION 0
13 #define MULTI_LOCKER 1
15 #if MULTI_LOCKER
16 # include "MultiLocker.h"
17 #else
18 # include <Locker.h>
19 #endif
21 class DrawingEngine;
22 class DrawView;
23 class WindowLayer;
24 class ViewLayer;
26 enum {
27 MSG_ADD_WINDOW = 'addw',
28 MSG_DRAW = 'draw',
30 MSG_MARK_CLEAN = 'mcln',
32 MSG_QUIT = 'quit',
35 class Desktop : public BLooper {
36 public:
37 Desktop(DrawView* drawView,
38 DrawingEngine* engine);
39 virtual ~Desktop();
41 // functions for the DrawView
42 void MouseDown(BPoint where, uint32 buttons,
43 int32 clicks);
44 void MouseUp(BPoint where);
45 void MouseMoved(BPoint where, uint32 code,
46 const BMessage* dragMessage);
48 virtual void MessageReceived(BMessage* message);
50 void SetMasterClipping(BRegion* clipping);
51 void SetOffset(int32 x, int32 y);
53 bool AddWindow(WindowLayer* window);
54 bool RemoveWindow(WindowLayer* window);
55 int32 IndexOf(WindowLayer* window) const;
56 int32 CountWindows() const;
57 bool HasWindow(WindowLayer* window) const;
59 WindowLayer* WindowAt(int32 index) const;
60 WindowLayer* WindowAtFast(int32 index) const;
61 WindowLayer* WindowAt(const BPoint& where) const;
62 WindowLayer* TopWindow() const;
63 WindowLayer* BottomWindow() const;
65 // doing something with the windows
66 void MoveWindowBy(WindowLayer* window, int32 x, int32 y);
67 void ResizeWindowBy(WindowLayer* window, int32 x, int32 y);
69 void ShowWindow(WindowLayer* window);
70 void HideWindow(WindowLayer* window);
71 void SetWindowHidden(WindowLayer* window, bool hidden);
73 void BringToFront(WindowLayer* window);
74 void SendToBack(WindowLayer* window);
76 void SetFocusWindow(WindowLayer* window);
78 #if MULTI_LOCKER
79 bool ReadLockClipping() { return fClippingLock.ReadLock(); }
80 void ReadUnlockClipping() { fClippingLock.ReadUnlock(); }
82 bool LockClipping() { return fClippingLock.WriteLock(); }
83 void UnlockClipping() { fClippingLock.WriteUnlock(); }
84 #else // BLocker
85 bool ReadLockClipping() { return fClippingLock.Lock(); }
86 void ReadUnlockClipping() { fClippingLock.Unlock(); }
88 bool LockClipping() { return fClippingLock.Lock(); }
89 void UnlockClipping() { fClippingLock.Unlock(); }
90 #endif
92 void MarkDirty(BRegion* region);
94 DrawingEngine* GetDrawingEngine() const
95 { return fDrawingEngine; }
97 BRegion& BackgroundRegion()
98 { return fBackgroundRegion; }
100 void WindowDied(WindowLayer* window);
102 private:
103 void _RebuildClippingForAllWindows(BRegion* stillAvailableOnScreen);
104 void _TriggerWindowRedrawing(BRegion* newDirtyRegion);
105 void _SetBackground(BRegion* background);
107 bool fTracking;
108 BPoint fLastMousePos;
109 WindowLayer* fClickedWindow;
110 ViewLayer* fScrollingView;
111 bool fResizing;
112 bigtime_t fClickTime;
113 bool fIs2ndButton;
115 #if MULTI_LOCKER
116 MultiLocker fClippingLock;
117 #else
118 BLocker fClippingLock;
119 #endif
120 BRegion fBackgroundRegion;
122 BRegion fMasterClipping;
123 int32 fXOffset;
124 int32 fYOffset;
126 DrawView* fDrawView;
127 DrawingEngine* fDrawingEngine;
129 BList fWindows;
131 bool fFocusFollowsMouse;
132 WindowLayer* fFocusWindow;
135 #endif // DESKTOP_H