From: Pierre Ossman Date: Mon, 23 Mar 2009 16:49:47 +0000 (+0000) Subject: Add parameter to make client attempt to resize server desktop on connect. X-Git-Tag: v0.0.90~77 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=eb3cecb856ac878c4d3f37902a2b5453b1ee16a5;p=tigervnc.git Add parameter to make client attempt to resize server desktop on connect. git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@3712 3789f03b-4d11-0410-bbf8-ca57d06f2519 --- diff --git a/unix/vncviewer/CConn.cxx b/unix/vncviewer/CConn.cxx index 47ccbb27..135794ae 100644 --- a/unix/vncviewer/CConn.cxx +++ b/unix/vncviewer/CConn.cxx @@ -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(); diff --git a/unix/vncviewer/CConn.h b/unix/vncviewer/CConn.h index 10a12e49..96a76fe4 100644 --- a/unix/vncviewer/CConn.h +++ b/unix/vncviewer/CConn.h @@ -130,6 +130,7 @@ private: AboutDialog about; InfoDialog info; bool reverseConnection; + bool firstUpdate; }; #endif diff --git a/unix/vncviewer/parameters.h b/unix/vncviewer/parameters.h index 6505aa8a..7e4960af 100644 --- a/unix/vncviewer/parameters.h +++ b/unix/vncviewer/parameters.h @@ -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; diff --git a/unix/vncviewer/vncviewer.cxx b/unix/vncviewer/vncviewer.cxx index dc494309..4a47788e 100644 --- a/unix/vncviewer/vncviewer.cxx +++ b/unix/vncviewer/vncviewer.cxx @@ -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", "");