]> source.dussan.org Git - tigervnc.git/commitdiff
Support for ExtendedDesktopSize and -DesktopSize in the Windows client.
authorPierre Ossman <ossman@cendio.se>
Tue, 24 Mar 2009 12:29:50 +0000 (12:29 +0000)
committerPierre Ossman <ossman@cendio.se>
Tue, 24 Mar 2009 12:29:50 +0000 (12:29 +0000)
git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@3716 3789f03b-4d11-0410-bbf8-ca57d06f2519

win/vncviewer/CConn.cxx
win/vncviewer/CConn.h
win/vncviewer/CConnOptions.cxx
win/vncviewer/CConnOptions.h

index 41b3aa3d6b1a3646ea9d4875a3da67941fcf0578..aa4ba75d5024f27fc777116f8b85f9b795cd2c3b 100644 (file)
@@ -75,7 +75,8 @@ RegKey            CConn::userConfigKey;
 CConn::CConn() 
   : window(0), sameMachine(false), encodingChange(false), formatChange(false), 
     lastUsedEncoding_(encodingRaw), sock(0), sockEvent(CreateEvent(0, TRUE, FALSE, 0)), 
-    reverseConnection(false), requestUpdate(false), isClosed_(false) {
+    reverseConnection(false), requestUpdate(false), firstUpdate(true),
+    isClosed_(false) {
 }
 
 CConn::~CConn() {
@@ -134,6 +135,7 @@ CConn::applyOptions(CConnOptions& opt) {
   // - Set optional features in ConnParams
   cp.supportsLocalCursor = options.useLocalCursor;
   cp.supportsDesktopResize = options.useDesktopResize;
+  cp.supportsExtendedDesktopSize = options.useDesktopResize;
   cp.supportsDesktopRename = true;
   cp.customCompressLevel = options.customCompressLevel;
   cp.compressLevel = options.compressLevel;
@@ -447,6 +449,24 @@ CConn::setDesktopSize(int w, int h) {
   CConnection::setDesktopSize(w, h);
 }
 
+
+void
+CConn::setExtendedDesktopSize(int reason, int result, int w, int h,
+                              const rfb::ScreenSet& layout) {
+  if ((reason == reasonClient) && (result != resultSuccess)) {
+    vlog.error("SetDesktopSize failed: %d", result);
+    return;
+  }
+
+  // Resize the window's buffer
+  if (window)
+    window->setSize(w, h);
+
+  // Tell the underlying CConnection
+  CConnection::setExtendedDesktopSize(reason, result, w, h, layout);
+}
+
+
 void
 CConn::setCursor(int w, int h, const Point& hotspot, void* data, void* mask) {
   if (!options.useLocalCursor) return;
@@ -491,6 +511,43 @@ CConn::framebufferUpdateEnd() {
     }
     debugRects.clear();
   }
+
+  if (firstUpdate) {
+    int width, height;
+
+    if (cp.supportsSetDesktopSize &&
+        sscanf(options.desktopSize.buf, "%dx%d", &width, &height) == 2) {
+      ScreenSet layout;
+
+      layout = cp.screenLayout;
+
+      if (layout.num_screens() == 0)
+        layout.add_screen(rfb::Screen());
+      else if (layout.num_screens() != 1) {
+        ScreenSet::iterator iter;
+
+        while (true) {
+          iter = layout.begin();
+          ++iter;
+
+          if (iter == layout.end())
+            break;
+
+          layout.remove_screen(iter->id);
+        }
+      }
+
+      layout.begin()->dimensions.tl.x = 0;
+      layout.begin()->dimensions.tl.y = 0;
+      layout.begin()->dimensions.br.x = width;
+      layout.begin()->dimensions.br.y = height;
+
+      writer()->writeSetDesktopSize(width, height, layout);
+    }
+
+    firstUpdate = false;
+  }
+
   if (options.autoSelect)
     autoSelectFormatAndEncoding();
 
index 5dacb1ee507e7d47bff5fac1d0f234d14a2140f1..726a6e862ab130c35876fdd022787be321cd3611 100644 (file)
@@ -99,6 +99,8 @@ namespace rfb {
       void bell();
       void framebufferUpdateEnd();
       void setDesktopSize(int w, int h);
+      void setExtendedDesktopSize(int reason, int result, int w, int h,
+                                  const rfb::ScreenSet& layout);
       void setCursor(int w, int h, const Point& hotspot, void* data, void* mask);
       void setName(const char* name);
       void serverInit();
@@ -144,6 +146,7 @@ namespace rfb {
       Handle sockEvent;
       bool reverseConnection;
       bool requestUpdate;
+      bool firstUpdate;
 
       // Debugging/logging
       std::list<Rect> debugRects;
index cb561930dd7bbcea3b727ff3eeef177a6fbfb0ad..2f889dd0b1405cea9a8dad816a61fa9d020791b3 100644 (file)
@@ -65,6 +65,10 @@ static BoolParameter sharedConnection("Shared",
                          "(Default is to disconnect all other clients)",
                          false);
 
+StringParameter desktopSize("DesktopSize",
+                            "Reconfigure desktop size on the server on "
+                            "connect (if possible)", "");
+
 static BoolParameter sendPtrEvents("SendPointerEvents",
                          "Send pointer (mouse) events to the server.", true);
 static BoolParameter sendKeyEvents("SendKeyEvents",
@@ -133,6 +137,7 @@ lowColourLevel(::lowColourLevel),
 preferredEncoding(encodingTight), 
 autoSelect(::autoSelect), 
 shared(::sharedConnection), 
+desktopSize(::desktopSize.getData()), 
 sendPtrEvents(::sendPtrEvents), 
 sendKeyEvents(::sendKeyEvents),
 showToolbar(::showToolbar), 
index 51ab78af5a1c972e692d4b2b7b59024819b63463..d010d172b61d0e3903010539885bcc361a9e5e9c 100644 (file)
@@ -56,6 +56,7 @@ namespace rfb {
       int preferredEncoding;
       bool autoSelect;
       bool shared;
+      CharArray desktopSize;
       bool sendPtrEvents;
       bool sendKeyEvents;
       bool showToolbar;