diff options
author | Constantin Kaplinsky <const@tightvnc.com> | 2008-06-03 07:04:17 +0000 |
---|---|---|
committer | Constantin Kaplinsky <const@tightvnc.com> | 2008-06-03 07:04:17 +0000 |
commit | 54cfef3a6b09a663a0253991067622f614d35462 (patch) | |
tree | a56089d103ef07d53f48e4442e0c583e8ee0e07e /unix | |
parent | 429ea9689b1793cee77ea3e9fa23ed6a53d8c7e6 (diff) | |
download | tigervnc-54cfef3a6b09a663a0253991067622f614d35462.tar.gz tigervnc-54cfef3a6b09a663a0253991067622f614d35462.zip |
Code refactoring: passing VNCServer pointer to PollingManager methods
instead of maintaining it as a member variable.
git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@2569 3789f03b-4d11-0410-bbf8-ca57d06f2519
Diffstat (limited to 'unix')
-rw-r--r-- | unix/x0vncserver/PollingManager.cxx | 26 | ||||
-rw-r--r-- | unix/x0vncserver/PollingManager.h | 9 | ||||
-rw-r--r-- | unix/x0vncserver/x0vncserver.cxx | 4 |
3 files changed, 12 insertions, 27 deletions
diff --git a/unix/x0vncserver/PollingManager.cxx b/unix/x0vncserver/PollingManager.cxx index 9a9f28af..27f10285 100644 --- a/unix/x0vncserver/PollingManager.cxx +++ b/unix/x0vncserver/PollingManager.cxx @@ -51,7 +51,6 @@ PollingManager::PollingManager(Display *dpy, XPixelBuffer *buffer, ImageFactory *factory, int offsetLeft, int offsetTop) : m_dpy(dpy), - m_server(0), m_image(buffer->getImage()), m_bytesPerPixel(buffer->getPF().bpp / 8), m_offsetLeft(offsetLeft), @@ -91,15 +90,6 @@ PollingManager::~PollingManager() } // -// Register VNCServer object. -// - -void PollingManager::setVNCServer(VNCServer *s) -{ - m_server = s; -} - -// // DEBUG: Measuring time spent in the poll() function, // as well as time intervals between poll() calls. // @@ -127,15 +117,15 @@ void PollingManager::debugAfterPoll() // Search for changed rectangles on the screen. // -void PollingManager::poll() +void PollingManager::poll(VNCServer *server) { #ifdef DEBUG debugBeforePoll(); #endif // Perform polling and try update clients if changes were detected. - if (pollScreen()) - m_server->tryUpdate(); + if (pollScreen(server)) + server->tryUpdate(); #ifdef DEBUG debugAfterPoll(); @@ -148,9 +138,9 @@ void PollingManager::poll() #define DBG_REPORT_CHANGES(title) #endif -bool PollingManager::pollScreen() +bool PollingManager::pollScreen(VNCServer *server) { - if (!m_server) + if (!server) return false; // Clear the m_changeFlags[] array, indicating that no changes have @@ -175,7 +165,7 @@ bool PollingManager::pollScreen() checkNeighbors(); DBG_REPORT_CHANGES("After checking neighbors"); // Inform the server about the changes. - nTilesChanged = sendChanges(); + nTilesChanged = sendChanges(server); } #ifdef DEBUG_PRINT_NUM_CHANGED_TILES @@ -265,7 +255,7 @@ int PollingManager::checkColumn(int x, int y, int h, bool *pChangeFlags) return nTilesChanged; } -int PollingManager::sendChanges() +int PollingManager::sendChanges(VNCServer *server) { const bool *pChangeFlags = m_changeFlags; int nTilesChanged = 0; @@ -287,7 +277,7 @@ int PollingManager::sendChanges() if (rect.br.y > m_height) rect.br.y = m_height; // Add to the changed region maintained by the server. - m_server->add_changed(rect); + server->add_changed(rect); // Skip processed tiles. x += count; } diff --git a/unix/x0vncserver/PollingManager.h b/unix/x0vncserver/PollingManager.h index 97a158fa..587e347b 100644 --- a/unix/x0vncserver/PollingManager.h +++ b/unix/x0vncserver/PollingManager.h @@ -43,8 +43,6 @@ public: int offsetLeft = 0, int offsetTop = 0); virtual ~PollingManager(); - void setVNCServer(VNCServer *s); - // 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, @@ -54,15 +52,14 @@ public: void setPointerPos(const Point &pos) {} void unsetPointerPos() {} - void poll(); + void poll(VNCServer *server); protected: // Screen polling. Returns true if some changes were detected. - bool pollScreen(); + bool pollScreen(VNCServer *server); Display *m_dpy; - VNCServer *m_server; const Image *m_image; const int m_bytesPerPixel; @@ -98,7 +95,7 @@ private: int checkRow(int x, int y, int w); int checkColumn(int x, int y, int h, bool *pChangeFlags); - int sendChanges(); + int sendChanges(VNCServer *server); // Check neighboring tiles and update m_changeFlags[]. void checkNeighbors(); diff --git a/unix/x0vncserver/x0vncserver.cxx b/unix/x0vncserver/x0vncserver.cxx index 8489290a..edaf1a8c 100644 --- a/unix/x0vncserver/x0vncserver.cxx +++ b/unix/x0vncserver/x0vncserver.cxx @@ -202,8 +202,6 @@ public: pollmgr = new PollingManager(dpy, pb, &factory, geometry->offsetLeft(), geometry->offsetTop()); - pollmgr->setVNCServer(vs); - running = true; } @@ -225,7 +223,7 @@ public: inline void poll() { if (pollmgr) - pollmgr->poll(); + pollmgr->poll(server); } virtual void pointerEvent(const Point& pos, int buttonMask) { |