]> source.dussan.org Git - tigervnc.git/commitdiff
Add parameter to make client attempt to resize server desktop on connect.
authorPierre Ossman <ossman@cendio.se>
Mon, 23 Mar 2009 16:49:47 +0000 (16:49 +0000)
committerPierre Ossman <ossman@cendio.se>
Mon, 23 Mar 2009 16:49:47 +0000 (16:49 +0000)
git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@3712 3789f03b-4d11-0410-bbf8-ca57d06f2519

unix/vncviewer/CConn.cxx
unix/vncviewer/CConn.h
unix/vncviewer/parameters.h
unix/vncviewer/vncviewer.cxx

index 47ccbb27afa991f72567dee9036543687eb70fd5..135794aec558c3d256002ae4de1e31454f3570e8 100644 (file)
@@ -62,7 +62,7 @@ CConn::CConn(Display* dpy_, int argc_, char** argv_, network::Socket* sock_,
     encodingChange(false), sameMachine(false), fullScreen(::fullScreen),
     ctrlDown(false), altDown(false),
     menuKeysym(0), menu(dpy, this), options(dpy, this), about(dpy), info(dpy),
-    reverseConnection(reverse)
+    reverseConnection(reverse), firstUpdate(true)
 {
   CharArray menuKeyStr(menuKey.getData());
   menuKeysym = XStringToKeysym(menuKeyStr.buf);
@@ -277,8 +277,10 @@ void CConn::setExtendedDesktopSize(int reason, int result, int w, int h,
                                    const rfb::ScreenSet& layout) {
   CConnection::setExtendedDesktopSize(reason, result, w, h, layout);
 
-  if ((reason == reasonClient) && (result != resultSuccess))
+  if ((reason == reasonClient) && (result != resultSuccess)) {
+    vlog.error("SetDesktopSize failed: %d", result);
     return;
+  }
 
   resizeFramebuffer();
 }
@@ -316,6 +318,43 @@ void CConn::framebufferUpdateEnd() {
     debugRects.clear();
   }
   desktop->framebufferUpdateEnd();
+
+  if (firstUpdate) {
+    int width, height;
+
+    if (cp.supportsSetDesktopSize &&
+        sscanf(desktopSize.getValueStr(), "%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 (autoSelect)
     autoSelectFormatAndEncoding();
   requestNewUpdate();
index 10a12e495ee45d434e711576c47e0e559e2dcb1c..96a76fe42aedb60f5076270f69156232591680b5 100644 (file)
@@ -130,6 +130,7 @@ private:
   AboutDialog about;
   InfoDialog info;
   bool reverseConnection;
+  bool firstUpdate;
 };
 
 #endif
index 6505aa8afefa14c51ab3692fefd409f6e30f84aa..7e4960af9c3defcbd89ebc3a0971062856f24090 100644 (file)
@@ -35,6 +35,7 @@ extern rfb::BoolParameter shared;
 extern rfb::BoolParameter acceptClipboard;
 extern rfb::BoolParameter sendClipboard;
 extern rfb::BoolParameter sendPrimary;
+extern rfb::StringParameter desktopSize;
 extern rfb::BoolParameter fullScreen;
 extern rfb::StringParameter geometry;
 extern rfb::BoolParameter customCompressLevel;
index dc494309a79a1cb257a1a00ba5663719414e4c3c..4a47788ea5b0ca063dbba66ec4f09564081d47e3 100644 (file)
@@ -98,6 +98,10 @@ BoolParameter sendPrimary("SendPrimary",
                           "server as well as the clipboard selection",
                           true);
 
+StringParameter desktopSize("DesktopSize",
+                            "Reconfigure desktop size on the server on "
+                            "connect (if possible)", "");
+
 BoolParameter listenMode("listen", "Listen for connections from VNC servers",
                          false);
 StringParameter geometry("geometry", "X geometry specification", "");