vfs: check userland buffers before reading them.
[haiku.git] / src / tests / servers / app / no_pointer_history / NoPointerHistory.cpp
blob7c2dae40a0b3d5f71b14736ec603455c273f37d3
2 #include <Application.h>
3 #include <View.h>
4 #include <Window.h>
7 class MouseView : public BView {
8 public:
9 MouseView(BRect frame, bool noHistory);
10 ~MouseView();
12 virtual void AttachedToWindow();
13 virtual void MouseMoved(BPoint point, uint32 transit,
14 const BMessage *message);
15 virtual void MouseDown(BPoint point);
16 virtual void MouseUp(BPoint point);
18 private:
19 bool fNoHistory;
23 MouseView::MouseView(BRect frame, bool noHistory)
24 : BView(frame, "MouseView", B_FOLLOW_ALL, B_WILL_DRAW),
25 fNoHistory(noHistory)
27 SetViewColor(255, 255, 200);
28 if (noHistory)
29 SetHighColor(200, 0, 0);
30 else
31 SetHighColor(0, 200, 0);
35 MouseView::~MouseView()
40 void
41 MouseView::AttachedToWindow()
43 if (fNoHistory)
44 SetEventMask(0, B_NO_POINTER_HISTORY);
48 void
49 MouseView::MouseDown(BPoint point)
51 SetMouseEventMask(0, B_NO_POINTER_HISTORY);
52 SetHighColor(0, 0, 200);
56 void
57 MouseView::MouseUp(BPoint point)
59 if (fNoHistory)
60 SetHighColor(200, 0, 0);
61 else
62 SetHighColor(0, 200, 0);
66 void
67 MouseView::MouseMoved(BPoint point, uint32 transit, const BMessage *message)
69 FillRect(BRect(point - BPoint(1, 1), point + BPoint(1, 1)));
70 snooze(25000);
74 // #pragma mark -
77 int
78 main(int argc, char** argv)
80 BApplication app("application/x-vnd.Simon-NoPointerHistory");
82 BWindow* window = new BWindow(BRect(100, 100, 700, 400), "Window",
83 B_TITLED_WINDOW, B_QUIT_ON_WINDOW_CLOSE);
84 window->AddChild(new MouseView(BRect(10, 10, 295, 290), true));
85 window->AddChild(new MouseView(BRect(305, 10, 590, 290), false));
86 window->Show();
88 app.Run();
89 return 0;