blob: c983ecee3c8a07b29a3b37906916a85cf9f240a2 [file] [log] [blame]
Constantin Kaplinsky47ed8d32004-10-08 09:43:57 +00001/* Copyright (C) 2002-2004 RealVNC Ltd. All Rights Reserved.
2 *
3 * This is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation; either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This software is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this software; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
16 * USA.
17 */
18//
19// XserverDesktop.h
20//
21
22#ifndef __XSERVERDESKTOP_H__
23#define __XSERVERDESKTOP_H__
24
25#include <rfb/SDesktop.h>
26#include <rfb/PixelBuffer.h>
27#include <rfb/Configuration.h>
28#include <rdr/SubstitutingInStream.h>
29
30extern "C" {
31#define class c_class;
32#include <scrnintstr.h>
33#include <os.h>
34#undef class
35}
36
37namespace rfb {
38 class VNCServerST;
39}
40
41namespace network { class TcpListener; class Socket; }
42class MyHTTPServer;
43
44class XserverDesktop : public rfb::SDesktop, public rfb::FullFramePixelBuffer,
45 public rfb::ColourMap, public rdr::Substitutor {
46public:
47
48 XserverDesktop(ScreenPtr pScreen, network::TcpListener* listener,
49 network::TcpListener* httpListener_,
50 const char* name, void* fbptr);
51 virtual ~XserverDesktop();
52
53 // methods called from X server code
54 void serverReset(ScreenPtr pScreen);
55 void setColormap(ColormapPtr cmap);
56 void setColourMapEntries(ColormapPtr pColormap, int ndef, xColorItem* pdef);
57 void bell();
58 void serverCutText(const char* str, int len);
59 void setCursor(CursorPtr cursor);
60 void add_changed(RegionPtr reg);
61 void add_copied(RegionPtr dst, int dx, int dy);
62 void positionCursor();
63 void ignoreHooks(bool b) { ignoreHooks_ = b; }
64 void blockHandler(fd_set* fds);
65 void wakeupHandler(fd_set* fds, int nfds);
66 void addClient(network::Socket* sock, bool reverse);
67 void disconnectClients();
68
69 // rfb::SDesktop callbacks
70 virtual void pointerEvent(const rfb::Point& pos, rdr::U8 buttonMask);
71 virtual void keyEvent(rdr::U32 key, bool down);
72 virtual void clientCutText(const char* str, int len);
73 virtual rfb::Point getFbSize() { return rfb::Point(width(), height()); }
74
75 // rfb::PixelBuffer callbacks
76 virtual void grabRegion(const rfb::Region& r);
77
78 // rfb::ColourMap callbacks
79 virtual void lookup(int index, int* r, int* g, int* b);
80
81 // rdr::Substitutor callback
82 virtual char* substitute(const char* varName);
83
84private:
85 void setColourMapEntries(int firstColour, int nColours);
86 static CARD32 deferredUpdateTimerCallback(OsTimerPtr timer, CARD32 now,
87 pointer arg);
88 ScreenPtr pScreen;
89 OsTimerPtr deferredUpdateTimer, dummyTimer;
90 rfb::VNCServerST* server;
91 MyHTTPServer* httpServer;
92 network::TcpListener* listener;
93 network::TcpListener* httpListener;
94 ColormapPtr cmap;
95 bool deferredUpdateTimerSet;
96 bool grabbing;
97 bool ignoreHooks_;
98 bool directFbptr;
99 int oldButtonMask;
100 int cursorX, cursorY, oldCursorX, oldCursorY;
101};
102#endif