Hi,
Here is another patch. It adds a -resolutions argument with a list of
resolutions to add to the default list:
Xvnc -resolutions "1264x900 1400x1500"
Of course this is a more flexible approach than specifying only 1 with
the -geometry. Also, window managers tend to resize to the users'
specified resolution (at least xfce does). It also allows adding odd
screen resolutions (maybe someone frequently uses vnc viewer on his cell
phone?).
My main purpose for this is that I want to add a list of pseudo
resolutions, which gives the user a screen-filling window approach which
does not hide the task bar: e.g. 1264x900 fits on a 1280x1024 display.
Of course this can be done by using cvt and xrandr a couple of times,
but that is quite a hassle.
I have 2 questions about this:
1) are there any restrictions on the resolutions? (e.g. divisable by 2
or so?)
2) How can one use quotation marks in inetd? When called from inetd, the
quotation marks are ignored.
Greetings,
Sebastiaan
--- ../../../../unix/xserver/hw/vnc/xvnc.cc 2011-02-21
16:05:15.000000000 +0100
+++ xvnc.cc 2011-03-03 21:23:51.128076509 +0100
@@ -78,6 +78,11 @@
#include "inputstr.h"
#ifdef RANDR
#include "randrstr.h"
+/* Set default resolutions */
+#define RANDRMAXDISPLAYS 100
+static int RandRwidths[RANDRMAXDISPLAYS] = { 1920, 1920, 1600, 1680,
1400, 1360, 1280, 1280, 1280, 1280, 1024, 800, 640};
+static int RandRheights[RANDRMAXDISPLAYS] = { 1200, 1080, 1200, 1050,
1050, 768, 1024, 960, 800, 720, 768, 600, 480};
+static int RandRNumDisplays = 13;
#endif /* RANDR */
#include <X11/keysym.h>
extern char buildtime[];
@@ -170,7 +175,6 @@
char *listenaddr = NULL;
-
static void
vfbInitializePixmapDepths(void)
{
@@ -292,6 +296,7 @@
ErrorF("-inetd has been launched from inetd\n");
ErrorF("-interface IP_address listen on specified interface\n");
ErrorF("-noclipboard disable clipboard settings
modification via vncconfig utility\n");
+ ErrorF("-resolutions \"X1xY1 X2xY2 ...\" screen resolutions for
RandR\n");
ErrorF("\nVNC parameters:\n");
fprintf(stderr,"\n"
@@ -575,6 +580,55 @@
noclipboard = true;
return 1;
}
+
+ if (strcmp(argv[i], "-resolutions") == 0) {
+ if (++i >= argc) {
+ UseMsg();
+ return 2;
+ }
+#ifdef RANDR
+ /* Read the resolution string in pieces */
+ int width, height, offset = 0;
+ char ResString[20];
+
+ while (offset<strlen(argv[i]) && sscanf(argv[i]+offset, "%19s",
ResString) == 1)
+ {
+ /* Read width and height */
+ if (sscanf(ResString, "%dx%d", &width, &height)==2 )
+ {
+ /* Offset + 1 to skip the space */
+ offset = offset + strlen(ResString) + 1;
+
+ /* Check if resolutions are sane */
+ /* Do we need to check for multiples of 2/4/8? */
+ if (width>0 && height>0)
+ {
+ /* Add resolution to list */
+ if ( (RandRNumDisplays+1)<RANDRMAXDISPLAYS )
+ {
+ RandRwidths[RandRNumDisplays] = width;
+ RandRheights[RandRNumDisplays] = height;
+ RandRNumDisplays++;
+ } else
+ {
+ ErrorF("Too many resolutions specified!\n");
+ }
+ } else
+ {
+ ErrorF("Insane resolution of %d x %d specified!\n",
width, height);
+ return 2;
+ }
+ } else
+ {
+ ErrorF("Malformed resolution string at: %s ", argv[i]+offset);
+ ErrorF("Ignoring remainder!");
+ return 2;
+ }
+ }
+#endif
+ return 2;
+ }
+
if (rfb::Configuration::setParam(argv[i]))
return 1;
@@ -846,13 +900,10 @@
Bool ret, gotCurrent = FALSE;
int i;
- const int widths[] = { 1920, 1920, 1600, 1680, 1400, 1360, 1280,
1280, 1280, 1280, 1024, 800, 640 };
- const int heights[] = { 1200, 1080, 1200, 1050, 1050, 768, 1024,
960, 800, 720, 768, 600, 480 };
-
- for (i = 0;i < sizeof(widths)/sizeof(*widths);i++) {
+ for (i = 0;i < RandRNumDisplays; i++) {
RRScreenSizePtr pSize;
- pSize = RRRegisterSize(pScreen, widths[i], heights[i],
+ pSize = RRRegisterSize(pScreen, RandRwidths[i], RandRheights[i],
pScreen->mmWidth, pScreen->mmHeight);
if (!pSize)
return FALSE;
@@ -861,7 +912,7 @@
if (!ret)
return FALSE;
- if ((widths[i] == pScreen->width) && (heights[i] == pScreen->height)) {
+ if ((RandRwidths[i] == pScreen->width) && (RandRheights[i] ==
pScreen->height)) {
RRSetCurrentConfig(pScreen, RR_Rotate_0, 60, pSize);
gotCurrent = TRUE;
}
------------------------------------------------------------------------------
Free Software Download: Index, Search & Analyze Logs and other IT data in
Real-Time with Splunk. Collect, index and harness all the fast moving IT data
generated by your applications, servers and devices whether physical, virtual
or in the cloud. Deliver compliance at lower cost and gain new business
insights. http://p.sf.net/sfu/splunk-dev2dev
_______________________________________________
Tigervnc-devel mailing list
Tigervnc-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/tigervnc-devel