Code refactoring -- moving a code chunk from poll_New() to a separate sendChanges() method.


git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@2344 3789f03b-4d11-0410-bbf8-ca57d06f2519
diff --git a/unix/x0vncserver/PollingManager.cxx b/unix/x0vncserver/PollingManager.cxx
index d10dde7..4ceb03d 100644
--- a/unix/x0vncserver/PollingManager.cxx
+++ b/unix/x0vncserver/PollingManager.cxx
@@ -260,32 +260,8 @@
   }
 
   // Inform the server about the changes.
-  if (nTilesChanged) {
-    bool *pmxChanged = mxChanged;
-    Rect rect;
-    for (int y = 0; y < m_heightTiles; y++) {
-      for (int x = 0; x < m_widthTiles; x++) {
-        if (*pmxChanged++) {
-          // Count successive tiles marked as changed.
-          int count = 1;
-          while (x + count < m_widthTiles && *pmxChanged++) {
-            count++;
-          }
-          // Compute the coordinates and the size of this band.
-          rect.setXYWH(x * 32, y * 32, count * 32, 32);
-          if (rect.br.x > m_width)
-            rect.br.x = m_width;
-          if (rect.br.y > m_height)
-            rect.br.y = m_height;
-          // Add to the changed region maintained by the server.
-          getScreenRect(rect);
-          m_server->add_changed(rect);
-          // Skip processed tiles.
-          x += count;
-        }
-      }
-    }
-  }
+  if (nTilesChanged)
+    sendChanges(mxChanged);
 
   // Cleanup.
   delete[] mxChanged;
@@ -319,6 +295,33 @@
   return nTilesChanged;
 }
 
+void PollingManager::sendChanges(bool *pmxChanged)
+{
+  Rect rect;
+  for (int y = 0; y < m_heightTiles; y++) {
+    for (int x = 0; x < m_widthTiles; x++) {
+      if (*pmxChanged++) {
+        // Count successive tiles marked as changed.
+        int count = 1;
+        while (x + count < m_widthTiles && *pmxChanged++) {
+          count++;
+        }
+        // Compute the coordinates and the size of this band.
+        rect.setXYWH(x * 32, y * 32, count * 32, 32);
+        if (rect.br.x > m_width)
+          rect.br.x = m_width;
+        if (rect.br.y > m_height)
+          rect.br.y = m_height;
+        // Add to the changed region maintained by the server.
+        getScreenRect(rect);
+        m_server->add_changed(rect);
+        // Skip processed tiles.
+        x += count;
+      }
+    }
+  }
+}
+
 bool PollingManager::poll_DetectVideo()
 {
   if (!m_server)
diff --git a/unix/x0vncserver/PollingManager.h b/unix/x0vncserver/PollingManager.h
index 0d9e90e..3b922d8 100644
--- a/unix/x0vncserver/PollingManager.h
+++ b/unix/x0vncserver/PollingManager.h
@@ -136,6 +136,7 @@
   }
 
   int checkRow(int x, int y, int w, bool *pmxChanged);
+  void sendChanges(bool *pmxChanged);
 
   void adjustVideoArea();