xref: /haiku/src/apps/remotedesktop/RemoteView.h (revision ed24eb5ff12640d052171c6a7feba37fab8a75d1)
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,
26 										const char *remoteHost,
27 										uint16 remotePort);
28 virtual								~RemoteView();
29 
30 		status_t					InitCheck();
31 
32 virtual	void						AttachedToWindow();
33 
34 virtual	void						Draw(BRect updateRect);
35 
36 virtual	void						MouseMoved(BPoint where, uint32 code,
37 										const BMessage *dragMessage);
38 virtual	void						MouseDown(BPoint where);
39 virtual	void						MouseUp(BPoint where);
40 
41 virtual	void						KeyDown(const char *bytes, int32 numBytes);
42 virtual	void						KeyUp(const char *bytes, int32 numBytes);
43 
44 virtual	void						MessageReceived(BMessage *message);
45 
46 private:
47 		void						_SendMouseMessage(uint16 code,
48 										BPoint where);
49 		void						_SendKeyMessage(uint16 code,
50 										const char *bytes, int32 numBytes);
51 
52 static	int							_StateCompareByKey(const uint32 *key,
53 										const engine_state *state);
54 		engine_state *				_CreateState(uint32 token);
55 		void						_DeleteState(uint32 token);
56 		engine_state *				_FindState(uint32 token);
57 
58 static	int32						_DrawEntry(void *data);
59 		void						_DrawThread();
60 
61 		BRect						_BuildInvalidateRect(BPoint *points,
62 										int32 pointCount);
63 
64 		status_t					fInitStatus;
65 		bool						fIsConnected;
66 
67 		StreamingRingBuffer *		fReceiveBuffer;
68 		StreamingRingBuffer *		fSendBuffer;
69 		BNetEndpoint *				fEndpoint;
70 		NetReceiver *				fReceiver;
71 		NetSender *					fSender;
72 
73 		bool						fStopThread;
74 		thread_id					fDrawThread;
75 
76 		BBitmap *					fOffscreenBitmap;
77 		BView *						fOffscreen;
78 
79 		BCursor						fViewCursor;
80 		BBitmap *					fCursorBitmap;
81 		BRect						fCursorFrame;
82 		bool						fCursorVisible;
83 
84 		BObjectList<engine_state>	fStates;
85 };
86 
87 #endif // REMOTE_VIEW_H
88