[PATCH xserver 3/3] Xvfb: rework RandR init

Paolo Borelli paolo.borelli at gmail.com
Sun Sep 18 16:02:27 UTC 2016


Set gamma to 256 and max size to 8192x8192: these are
arbitrary values and are taken from Xwayland which I
figured is the most modern case to look at. Gamma is
needed because otherwise xrandr -q complains.
To make code cleaner, the patch also factors out a
small utility function to get the mode.

Signed-off-by: Paolo Borelli <pborelli at gnome.org>
---
 hw/vfb/InitOutput.c | 43 +++++++++++++++++++++++++++----------------
 1 file changed, 27 insertions(+), 16 deletions(-)

diff --git a/hw/vfb/InitOutput.c b/hw/vfb/InitOutput.c
index e4b226d..a71258f 100644
--- a/hw/vfb/InitOutput.c
+++ b/hw/vfb/InitOutput.c
@@ -800,20 +800,37 @@ vfbRRGetInfo(ScreenPtr pScreen, Rotation *rotations)
     return TRUE;
 }
 
+static RRModePtr
+vfbRandRModeGet(int width, int height)
+{
+    xRRModeInfo modeInfo;
+    char name[64];
+
+    sprintf (name, "%dx%d", width, height);
+    memset (&modeInfo, 0, sizeof (modeInfo));
+    modeInfo.width = width;
+    modeInfo.height = height;
+    modeInfo.hTotal = width;
+    modeInfo.vTotal = height;
+    modeInfo.dotClock = ((CARD32)width * (CARD32)height * 60);
+    modeInfo.nameLength = strlen (name);
+
+    return RRModeGet (&modeInfo, name);
+}
+
 static Bool
 vfbRandRInit(ScreenPtr pScreen)
 {
     rrScrPrivPtr pScrPriv;
 #if RANDR_12_INTERFACE
-    RRModePtr  mode;
-    RRCrtcPtr  crtc;
-    RROutputPtr        output;
-    xRRModeInfo modeInfo;
-    char       name[64];
+    RRModePtr mode;
+    RRCrtcPtr crtc;
+    RROutputPtr output;
 #endif
 
     if (!RRScreenInit (pScreen))
        return FALSE;
+
     pScrPriv = rrGetScrPriv(pScreen);
     pScrPriv->rrGetInfo = vfbRRGetInfo;
 #if RANDR_12_INTERFACE
@@ -826,24 +843,18 @@ vfbRandRInit(ScreenPtr pScreen)
     pScrPriv->rrOutputValidateMode = vfbRROutputValidateMode;
     pScrPriv->rrModeDestroy = NULL;
 
-    RRScreenSetSizeRange (pScreen,
-                         1, 1,
-                         pScreen->width, pScreen->height);
+    RRScreenSetSizeRange (pScreen, 320, 200, 8192, 8192);
 
-    sprintf (name, "%dx%d", pScreen->width, pScreen->height);
-    memset (&modeInfo, '\0', sizeof (modeInfo));
-    modeInfo.width = pScreen->width;
-    modeInfo.height = pScreen->height;
-    modeInfo.nameLength = strlen (name);
-
-    mode = RRModeGet (&modeInfo, name);
-    if (!mode)
+    mode = vfbRandRModeGet(pScreen->width, pScreen->height);
+    if (mode == NULL)
        return FALSE;
 
     crtc = RRCrtcCreate (pScreen, NULL);
     if (!crtc)
        return FALSE;
 
+    RRCrtcGammaSetSize (crtc, 256);
+
     output = RROutputCreate (pScreen, "screen", strlen("screen"), NULL);
     if (!output)
        return FALSE;
-- 
2.7.4



More information about the xorg-devel mailing list