#define BUTTONS 7
+class InputDevice *vncInputDevice;
+InputDevice InputDevice::singleton;
+
/* Event queue is shared between all devices. */
#if XORG == 15
static xEvent *eventq = NULL;
#endif /* XORG < 111 */
InputDevice::InputDevice()
- : initialized(false), oldButtonMask(0)
+ : oldButtonMask(0)
{
int i;
+ vncInputDevice = this;
+
#if XORG < 111
initEventq();
#endif
#include "xorg-version.h"
-/* Represents input device (keyboard + pointer) */
+/*
+ * Represents input device (keyboard + pointer)
+ *
+ * Is a singleton as input devices are global in the X server so
+ * we do not have one per desktop (i.e. per screen).
+ */
+extern class InputDevice *vncInputDevice;
+
class InputDevice {
public:
- /* Create new InputDevice instance */
- InputDevice();
-
/*
* Press or release buttons. Relationship between buttonMask and
* buttons is specified in RFB protocol.
void KeyboardRelease(rdr::U32 keysym) { keyEvent(keysym, false); }
/*
- * Init input device. This cannot be done in the constructor
- * because constructor is called during X server extensions
- * initialization. Devices must be initialized after core
- * pointer/keyboard initialization which is actually after extesions
- * initialization. Check InitExtensions(), InitCoreDevices() and
- * InitInput() calls in dix/main.c. Instead it is called from
- * XserverDesktop at an appropriate time.
+ * Init input device.
+ * This has to be called after core pointer/keyboard
+ * initialization which unfortunately is after extesions
+ * initialization (which means we cannot call it in
+ * vncExtensionInit(). Check InitExtensions(),
+ * InitCoreDevices() and InitInput() calls in dix/main.c.
+ * Instead we call it from XserverDesktop at an appropriate
+ * time.
*/
void InitInputDevice(void);
private:
+ InputDevice();
+
void keyEvent(rdr::U32 keysym, bool down);
/* Backend dependent functions below here */
rfb::Point cursorPos;
KeySym pressedKeys[256];
+
+private:
+ static InputDevice singleton;
};
#endif
if (httpListener)
httpServer = new FileHTTPServer(this);
-
- inputDevice = new InputDevice(server);
}
XserverDesktop::~XserverDesktop()
{
if (!directFbptr)
delete [] data;
- delete inputDevice;
delete httpServer;
delete server;
}
// so we abuse the fact that this routine will be called first thing
// once the dix is done initialising.
// [1] Technically Xvnc has InitInput(), but libvnc.so has nothing.
- inputDevice->InitInputDevice();
+ vncInputDevice->InitInputDevice();
try {
int nextTimeout;
}
// We are responsible for propagating mouse movement between clients
- if (!oldCursorPos.equals(inputDevice->getPointerPos())) {
- oldCursorPos = inputDevice->getPointerPos();
+ if (!oldCursorPos.equals(vncInputDevice->getPointerPos())) {
+ oldCursorPos = vncInputDevice->getPointerPos();
server->setCursorPos(oldCursorPos);
}
}
void XserverDesktop::pointerEvent(const Point& pos, int buttonMask)
{
- inputDevice->PointerMove(pos);
- inputDevice->PointerButtonAction(buttonMask);
+ vncInputDevice->PointerMove(pos);
+ vncInputDevice->PointerButtonAction(buttonMask);
}
void XserverDesktop::clientCutText(const char* str, int len)
void XserverDesktop::keyEvent(rdr::U32 keysym, bool down)
{
if (down)
- inputDevice->KeyboardPress(keysym);
+ vncInputDevice->KeyboardPress(keysym);
else
- inputDevice->KeyboardRelease(keysym);
+ vncInputDevice->KeyboardRelease(keysym);
}
#endif
ScreenPtr pScreen;
- InputDevice *inputDevice;
rfb::VNCServerST* server;
rfb::HTTPServer* httpServer;
network::TcpListener* listener;