//
PollingManager::PollingManager(Display *dpy, const Image *image,
- ImageFactory *factory,
+ ImageFactory &factory,
int offsetLeft, int offsetTop)
: m_dpy(dpy),
m_image(image),
// Create additional images used in polling algorithm, warn if
// underlying class names are different from the class name of the
// primary image.
- m_rowImage = factory->newImage(m_dpy, m_width, 1);
- m_columnImage = factory->newImage(m_dpy, 1, m_height);
+ m_rowImage = factory.newImage(m_dpy, m_width, 1);
+ m_columnImage = factory.newImage(m_dpy, 1, m_height);
const char *primaryImgClass = m_image->className();
const char *rowImgClass = m_rowImage->className();
const char *columnImgClass = m_columnImage->className();
public:
- PollingManager(Display *dpy, const Image *image, ImageFactory *factory,
+ PollingManager(Display *dpy, const Image *image, ImageFactory &factory,
int offsetLeft = 0, int offsetTop = 0);
virtual ~PollingManager();
- // Currently, these functions do nothing. In past versions, we used
- // to poll area around the pointer if its position has been changed
- // recently. But that rather decreased overal polling performance,
- // so we don't do that any more. However, pointer position may be a
- // useful hint and might be used in future code, so we do not remove
- // these functions, just in case.
- void setPointerPos(const Point &pos) {}
- void unsetPointerPos() {}
-
void poll(VNCServer *server);
protected:
XPixelBuffer::XPixelBuffer(Display *dpy, ImageFactory &factory,
const Rect &rect, ColourMap* cm)
: FullFramePixelBuffer(),
+ m_poller(0),
m_dpy(dpy),
m_image(factory.newImage(dpy, rect.width(), rect.height())),
m_offsetLeft(rect.tl.x),
// Get initial screen image from the X display.
m_image->get(DefaultRootWindow(m_dpy), m_offsetLeft, m_offsetTop);
+
+ // PollingManager will detect changed pixels.
+ m_poller = new PollingManager(dpy, getImage(), factory,
+ m_offsetLeft, m_offsetTop);
}
XPixelBuffer::~XPixelBuffer()
{
+ delete m_poller;
delete m_image;
}
#define __XPIXELBUFFER_H__
#include <rfb/PixelBuffer.h>
+#include <rfb/VNCServer.h>
#include <x0vncserver/Image.h>
+#include <x0vncserver/PollingManager.h>
using namespace rfb;
virtual ~XPixelBuffer();
// Provide access to the underlying Image object.
- virtual const Image *getImage() const { return m_image; }
+ const Image *getImage() const { return m_image; }
+
+ // Detect changed pixels, notify the server.
+ inline void poll(VNCServer *server) { m_poller->poll(server); }
// Override PixelBuffer::getStride().
virtual int getStride() const { return m_stride; }
virtual void grabRegion(const rfb::Region& region);
protected:
+ PollingManager *m_poller;
+
Display *m_dpy;
Image* m_image;
int m_offsetLeft;
#include <x0vncserver/Geometry.h>
#include <x0vncserver/Image.h>
#include <x0vncserver/XPixelBuffer.h>
-#include <x0vncserver/PollingManager.h>
#include <x0vncserver/PollingScheduler.h>
// XXX Lynx/OS 2.3: protos for select(), bzero()
{
public:
XDesktop(Display* dpy_, Geometry *geometry_)
- : dpy(dpy_), geometry(geometry_), pb(0), server(0), pollmgr(0),
+ : dpy(dpy_), geometry(geometry_), pb(0), server(0),
oldButtonMask(0), haveXtest(false), maxButtons(0), running(false)
{
#ifdef HAVE_XTEST
server = vs;
server->setPixelBuffer(pb);
- // Create polling manager object for detection of pixel changes.
- pollmgr = new PollingManager(dpy, pb->getImage(), &factory,
- geometry->offsetLeft(),
- geometry->offsetTop());
running = true;
}
running = false;
delete pb;
- delete pollmgr;
-
pb = 0;
- pollmgr = 0;
}
inline bool isRunning() {
}
inline void poll() {
- if (pollmgr)
- pollmgr->poll(server);
+ if (pb)
+ pb->poll(server);
}
virtual void pointerEvent(const Point& pos, int buttonMask) {
- pollmgr->setPointerPos(pos);
#ifdef HAVE_XTEST
if (!haveXtest) return;
XTestFakeMotionEvent(dpy, DefaultScreen(dpy),
Geometry* geometry;
XPixelBuffer* pb;
VNCServer* server;
- PollingManager* pollmgr;
int oldButtonMask;
bool haveXtest;
int maxButtons;