1 /* 2 * Copyright 2009, Haiku, Inc. 3 * Distributed under the terms of the MIT License. 4 * 5 * Authors: 6 * Michael Lotz <mmlr@mlotz.ch> 7 */ 8 #ifndef REMOTE_VIEW_H 9 #define REMOTE_VIEW_H 10 11 #include <Cursor.h> 12 #include <NetEndpoint.h> 13 #include <ObjectList.h> 14 #include <View.h> 15 16 class BBitmap; 17 class NetReceiver; 18 class NetSender; 19 class StreamingRingBuffer; 20 21 struct engine_state; 22 23 class RemoteView : public BView { 24 public: 25 RemoteView(BRect frame, uint16 listenPort); 26 virtual ~RemoteView(); 27 28 status_t InitCheck(); 29 30 virtual void AttachedToWindow(); 31 32 virtual void Draw(BRect updateRect); 33 34 virtual void MouseMoved(BPoint where, uint32 code, 35 const BMessage *dragMessage); 36 virtual void MouseDown(BPoint where); 37 virtual void MouseUp(BPoint where); 38 39 virtual void KeyDown(const char *bytes, int32 numBytes); 40 virtual void KeyUp(const char *bytes, int32 numBytes); 41 42 virtual void MessageReceived(BMessage *message); 43 44 private: 45 void _SendMouseMessage(uint16 code, 46 BPoint where); 47 void _SendKeyMessage(uint16 code, 48 const char *bytes, int32 numBytes); 49 50 static int _StateCompareByKey(const uint32 *key, 51 const engine_state *state); 52 void _CreateState(uint32 token); 53 void _DeleteState(uint32 token); 54 engine_state * _FindState(uint32 token); 55 56 static int32 _DrawEntry(void *data); 57 void _DrawThread(); 58 59 BRect _BuildInvalidateRect(BPoint *points, 60 int32 pointCount); 61 62 status_t fInitStatus; 63 bool fIsConnected; 64 65 StreamingRingBuffer * fReceiveBuffer; 66 StreamingRingBuffer * fSendBuffer; 67 BNetEndpoint * fReceiveEndpoint; 68 BNetEndpoint * fSendEndpoint; 69 NetReceiver * fReceiver; 70 NetSender * fSender; 71 72 bool fStopThread; 73 thread_id fDrawThread; 74 75 BBitmap * fOffscreenBitmap; 76 BView * fOffscreen; 77 78 BCursor fViewCursor; 79 BBitmap * fCursorBitmap; 80 BRect fCursorFrame; 81 bool fCursorVisible; 82 83 BObjectList<engine_state> fStates; 84 }; 85 86 #endif // REMOTE_VIEW_H 87