Handling VideoRectangleSelection protocol message (TightVNC extension).


git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@2585 3789f03b-4d11-0410-bbf8-ca57d06f2519
diff --git a/common/rfb/SMsgHandler.cxx b/common/rfb/SMsgHandler.cxx
index ccc97ad..64f0534 100644
--- a/common/rfb/SMsgHandler.cxx
+++ b/common/rfb/SMsgHandler.cxx
@@ -50,3 +50,12 @@
 void SMsgHandler::supportsLocalCursor()
 {
 }
+
+void SMsgHandler::setVideoRectangle(const Rect& r)
+{
+}
+
+void SMsgHandler::unsetVideoRectangle()
+{
+}
+
diff --git a/common/rfb/SMsgHandler.h b/common/rfb/SMsgHandler.h
index cf3377d..f6d714c 100644
--- a/common/rfb/SMsgHandler.h
+++ b/common/rfb/SMsgHandler.h
@@ -47,6 +47,9 @@
     virtual void setEncodings(int nEncodings, rdr::U32* encodings);
     virtual void framebufferUpdateRequest(const Rect& r, bool incremental);
 
+    virtual void setVideoRectangle(const Rect& r);
+    virtual void unsetVideoRectangle();
+
     // InputHandler interface
     // The InputHandler methods will be called for the corresponding messages.
 
diff --git a/common/rfb/SMsgReader.cxx b/common/rfb/SMsgReader.cxx
index cdca1b9..c55e8f1 100644
--- a/common/rfb/SMsgReader.cxx
+++ b/common/rfb/SMsgReader.cxx
@@ -111,10 +111,10 @@
   if (enable) {
     vlog.debug("Video area selected by client: %dx%d at (%d,%d)",
                w, h, x, y);
+    handler->setVideoRectangle(Rect(x, y, x+w, y+h));
   } else {
     vlog.debug("Video area discarded by client");
+    handler->unsetVideoRectangle();
   }
-
-  // FIXME: Implement VideoRectangleSelection message handling.
 }
 
diff --git a/common/rfb/VNCSConnectionST.cxx b/common/rfb/VNCSConnectionST.cxx
index a9c59f3..024be01 100644
--- a/common/rfb/VNCSConnectionST.cxx
+++ b/common/rfb/VNCSConnectionST.cxx
@@ -481,6 +481,16 @@
   writeFramebufferUpdate();
 }
 
+void VNCSConnectionST::setVideoRectangle(const Rect& r)
+{
+  server->setVideoRectangle(r);
+}
+
+void VNCSConnectionST::unsetVideoRectangle()
+{
+  server->unsetVideoRectangle();
+}
+
 void VNCSConnectionST::setInitialColourMap()
 {
   setColourMapEntries(0, 0);
diff --git a/common/rfb/VNCSConnectionST.h b/common/rfb/VNCSConnectionST.h
index cde2b31..1df718a 100644
--- a/common/rfb/VNCSConnectionST.h
+++ b/common/rfb/VNCSConnectionST.h
@@ -130,6 +130,9 @@
     virtual void setInitialColourMap();
     virtual void supportsLocalCursor();
 
+    virtual void setVideoRectangle(const Rect& r);
+    virtual void unsetVideoRectangle();
+
     // setAccessRights() allows a security package to limit the access rights
     // of a VNCSConnectioST to the server.  These access rights are applied
     // such that the actual rights granted are the minimum of the server's
diff --git a/common/rfb/VNCServerST.cxx b/common/rfb/VNCServerST.cxx
index dc6c709..066feb9 100644
--- a/common/rfb/VNCServerST.cxx
+++ b/common/rfb/VNCServerST.cxx
@@ -555,3 +555,22 @@
     }
   }
 }
+
+void VNCServerST::setVideoRectangle(const Rect& r)
+{
+  if (isVideoSelectionEnabled()) {
+    // FIXME: Duplication between m_videoRect and comparer->video_area.
+    m_videoRect = r;
+    set_video_area(m_videoRect);
+  }
+}
+
+void VNCServerST::unsetVideoRectangle()
+{
+  if (isVideoSelectionEnabled()) {
+    // FIXME: Duplication between m_videoRect and comparer->video_area.
+    m_videoRect.clear();
+    set_video_area(m_videoRect);
+  }
+}
+
diff --git a/common/rfb/VNCServerST.h b/common/rfb/VNCServerST.h
index 213f6b1..5277f55 100644
--- a/common/rfb/VNCServerST.h
+++ b/common/rfb/VNCServerST.h
@@ -202,6 +202,9 @@
     void enableVideoSelection(bool enable) { m_videoSelectionEnabled = enable; }
     bool isVideoSelectionEnabled() { return m_videoSelectionEnabled; }
 
+    void setVideoRectangle(const Rect& r);
+    void unsetVideoRectangle();
+
   protected:
 
     friend class VNCSConnectionST;
@@ -252,6 +255,7 @@
     bool disableclients;
 
     bool m_videoSelectionEnabled;
+    Rect m_videoRect;
   };
 
 };