From ffdeb47b94a654c4ebe719dac5b60897ab15a842 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Mon, 20 Aug 2007 22:46:34 +0000 Subject: [PATCH] Imported B_NO_POINTER_HISTORY test app from bug #1415, applied our coding style, cleaned it up, and made it a bit more evident. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22020 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/tests/servers/app/Jamfile | 3 +- .../servers/app/no_pointer_history/Jamfile | 18 +++++ .../no_pointer_history/NoPointerHistory.cpp | 71 +++++++++++++++++++ 3 files changed, 91 insertions(+), 1 deletion(-) create mode 100644 src/tests/servers/app/no_pointer_history/Jamfile create mode 100644 src/tests/servers/app/no_pointer_history/NoPointerHistory.cpp diff --git a/src/tests/servers/app/Jamfile b/src/tests/servers/app/Jamfile index c3cab9c4fc..7c924594cb 100644 --- a/src/tests/servers/app/Jamfile +++ b/src/tests/servers/app/Jamfile @@ -167,11 +167,12 @@ SubInclude HAIKU_TOP src tests servers app desktop_window ; SubInclude HAIKU_TOP src tests servers app event_mask ; SubInclude HAIKU_TOP src tests servers app following ; SubInclude HAIKU_TOP src tests servers app look_and_feel ; +SubInclude HAIKU_TOP src tests servers app no_pointer_history ; SubInclude HAIKU_TOP src tests servers app painter ; SubInclude HAIKU_TOP src tests servers app playground ; +SubInclude HAIKU_TOP src tests servers app regularapps ; SubInclude HAIKU_TOP src tests servers app resize_limits ; SubInclude HAIKU_TOP src tests servers app scrolling ; SubInclude HAIKU_TOP src tests servers app stress_test ; SubInclude HAIKU_TOP src tests servers app textview ; -SubInclude HAIKU_TOP src tests servers app regularapps ; SubInclude HAIKU_TOP src tests servers app view_state ; diff --git a/src/tests/servers/app/no_pointer_history/Jamfile b/src/tests/servers/app/no_pointer_history/Jamfile new file mode 100644 index 0000000000..eca15ced71 --- /dev/null +++ b/src/tests/servers/app/no_pointer_history/Jamfile @@ -0,0 +1,18 @@ +SubDir HAIKU_TOP src tests servers app no_pointer_history ; + +SetSubDirSupportedPlatformsBeOSCompatible ; +AddSubDirSupportedPlatforms libbe_test ; + +UseHeaders [ FDirName os app ] ; +UseHeaders [ FDirName os interface ] ; + +Application NoPointerHistory : + NoPointerHistory.cpp + : be $(TARGET_LIBSTDC++) +; + +if $(TARGET_PLATFORM) = libbe_test { + HaikuInstall install-test-apps : $(HAIKU_APP_TEST_DIR) : NoPointerHistory + : tests!apps ; +} + diff --git a/src/tests/servers/app/no_pointer_history/NoPointerHistory.cpp b/src/tests/servers/app/no_pointer_history/NoPointerHistory.cpp new file mode 100644 index 0000000000..01763ad837 --- /dev/null +++ b/src/tests/servers/app/no_pointer_history/NoPointerHistory.cpp @@ -0,0 +1,71 @@ + +#include +#include +#include + + +class MouseView : public BView { +public: + MouseView(BRect frame, bool noHistory); + ~MouseView(); + + virtual void AttachedToWindow(); + virtual void MouseMoved(BPoint point, uint32 transit, + const BMessage *message); + +private: + bool fNoHistory; +}; + + +MouseView::MouseView(BRect frame, bool noHistory) + : BView(frame, "MouseView", B_FOLLOW_ALL, B_WILL_DRAW), + fNoHistory(noHistory) +{ + SetViewColor(255, 255, 200); + if (noHistory) + SetHighColor(200, 0, 0); + else + SetHighColor(0, 200, 0); +} + + +MouseView::~MouseView() +{ +} + + +void +MouseView::AttachedToWindow() +{ + if (fNoHistory) + SetEventMask(0, B_NO_POINTER_HISTORY); +} + + +void +MouseView::MouseMoved(BPoint point, uint32 transit, const BMessage *message) +{ + FillRect(BRect(point - BPoint(1, 1), point + BPoint(1, 1))); + snooze(25000); +} + + +// #pragma mark - + + +int +main(int argc, char** argv) +{ + BApplication app("application/x-vnd.Simon-NoPointerHistory"); + + BWindow* window = new BWindow(BRect(100, 100, 700, 400), "Window", + B_TITLED_WINDOW, B_QUIT_ON_WINDOW_CLOSE); + window->AddChild(new MouseView(BRect(10, 10, 295, 290), true)); + window->AddChild(new MouseView(BRect(305, 10, 590, 290), false)); + window->Show(); + + app.Run(); + return 0; +} +