1 /* 2 * Copyright 2005, Haiku, Inc. All Rights Reserved. 3 * Distributed under the terms of the MIT License. 4 * 5 * Authors: 6 * Axel Dörfler, axeld@pinc-software.de 7 */ 8 #ifndef EVENT_STREAM_H 9 #define EVENT_STREAM_H 10 11 12 #include <LinkReceiver.h> 13 #include <MessageQueue.h> 14 #include <Messenger.h> 15 16 17 struct shared_cursor; 18 19 20 class EventStream { 21 public: 22 EventStream(); 23 virtual ~EventStream(); 24 25 virtual bool IsValid() = 0; 26 virtual void SendQuit() = 0; 27 28 virtual bool SupportsCursorThread() const; 29 30 virtual void UpdateScreenBounds(BRect bounds) = 0; 31 32 virtual bool GetNextEvent(BMessage** _event) = 0; 33 virtual bool GetNextCursorPosition(BPoint& where); 34 35 virtual BMessage* PeekLatestMouseMoved() = 0; 36 }; 37 38 39 class InputServerStream : public EventStream { 40 public: 41 InputServerStream(BMessenger& inputServerMessenger); 42 #if TEST_MODE 43 InputServerStream(); 44 #endif 45 46 virtual ~InputServerStream(); 47 48 virtual bool IsValid(); 49 virtual void SendQuit(); 50 51 virtual bool SupportsCursorThread() const { return fCursorSemaphore >= B_OK; } 52 53 virtual void UpdateScreenBounds(BRect bounds); 54 55 virtual bool GetNextEvent(BMessage** _event); 56 virtual bool GetNextCursorPosition(BPoint& where); 57 58 virtual BMessage* PeekLatestMouseMoved(); 59 60 private: 61 status_t _MessageFromPort(BMessage** _message, 62 bigtime_t timeout = B_INFINITE_TIMEOUT); 63 64 BMessenger fInputServer; 65 BMessageQueue fEvents; 66 port_id fPort; 67 bool fQuitting; 68 sem_id fCursorSemaphore; 69 area_id fCursorArea; 70 shared_cursor* fCursorBuffer; 71 BMessage* fLatestMouseMoved; 72 }; 73 74 #endif /* EVENT_STREAM_H */ 75