On 03/03/2011 09:34 PM, Sebastiaan Breedveld wrote:
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.

Ok, answers come after a good nights sleep. In stead of a quotated string, supply the resolutions in a comma separated list:
Xvnc -resolutions 1264x900,1400x1500

so the inetd issue is resolved (although I am still interested in the answer).

There also does not seem to be much limitations on the resolutions, but the server crashes for anything smaller than 4x4 pixels.

Using 'cvt 1 1' forces the resolution to 8x1, which seems to be ok. Nevertheless, I guess it is a good choice to set the minumum to 64x64.


One more thing: the action is now to add these resolutions to the default (hard coded) list. Would it maybe more interesting to replace the whole list?

Greetings,
Sebastiaan



--- ../../../../unix/xserver/hw/vnc/xvnc.cc 2011-02-21 16:05:15.000000000 +0100
+++ xvnc.cc    2011-03-04 10:00:16.798650722 +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,... additional screen resolutions for RandR\n");
     ErrorF("\nVNC parameters:\n");

     fprintf(stderr,"\n"
@@ -575,6 +580,54 @@
     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, "%19[^',']", 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 */
+            if (width>64 && height>64)
+            {
+                /* 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 +899,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 +911,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;
     }


------------------------------------------------------------------------------
What You Don't Know About Data Connectivity CAN Hurt You
This paper provides an overview of data connectivity, details
its effect on application quality, and explores various alternative
solutions. http://p.sf.net/sfu/progress-d2d
_______________________________________________
Tigervnc-devel mailing list
Tigervnc-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/tigervnc-devel

Reply via email to