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 status_t InsertEvent(BMessage* event) = 0; 36 37 virtual BMessage* PeekLatestMouseMoved() = 0; 38 }; 39 40 41 class InputServerStream : public EventStream { 42 public: 43 InputServerStream(BMessenger& inputServerMessenger); 44 #if TEST_MODE 45 InputServerStream(); 46 #endif 47 48 virtual ~InputServerStream(); 49 50 virtual bool IsValid(); 51 virtual void SendQuit(); 52 53 virtual bool SupportsCursorThread() const { return fCursorSemaphore >= B_OK; } 54 55 virtual void UpdateScreenBounds(BRect bounds); 56 57 virtual bool GetNextEvent(BMessage** _event); 58 virtual bool GetNextCursorPosition(BPoint& where); 59 60 virtual status_t InsertEvent(BMessage* event); 61 62 virtual BMessage* PeekLatestMouseMoved(); 63 64 private: 65 status_t _MessageFromPort(BMessage** _message, 66 bigtime_t timeout = B_INFINITE_TIMEOUT); 67 68 BMessenger fInputServer; 69 BMessageQueue fEvents; 70 port_id fPort; 71 bool fQuitting; 72 sem_id fCursorSemaphore; 73 area_id fCursorArea; 74 shared_cursor* fCursorBuffer; 75 BMessage* fLatestMouseMoved; 76 }; 77 78 #endif /* EVENT_STREAM_H */ 79