[PATCH xf86-video-nested 3/5] Add preliminary support for screen options "Fullscreen" and "Output" in xorg.conf

Laércio de Sousa laerciosousa at sme-mogidascruzes.sp.gov.br
Fri Oct 31 06:12:09 PDT 2014


This patch introduces support for new screen options in xorg.conf, namely:
"Fullscreen" and "Output". They are expected to work exactly as command-line
options -fullscreen and -output for Xephyr, allowing to open nested Xorg
window in fullscreen mode (restricted to given host X server output
if option "Output" is set).

In order to achieve this, NestedClientCheckDisplay() needs to be extended
to allow collecting fullscreen geometry from host X server while
checking if it's ready for connections, which has to be implemented
on each backend client.

NestedClientCreateScreen() also was extended to include a boolean
argument that tells backend client if it needs to set appropriate fullscreen
hint for nested Xorg window.

Signed-off-by: Laércio de Sousa <laerciosousa at sme-mogidascruzes.sp.gov.br>
---
 src/client.h     | 12 +++++--
 src/driver.c     | 96 ++++++++++++++++++++++++++++++++++++++------------------
 src/xlibclient.c |  8 ++++-
 3 files changed, 82 insertions(+), 34 deletions(-)

diff --git a/src/client.h b/src/client.h
index 46f372b..be7d501 100644
--- a/src/client.h
+++ b/src/client.h
@@ -39,15 +39,21 @@
 struct NestedClientPrivate;
 typedef struct NestedClientPrivate *NestedClientPrivatePtr;
 
-Bool NestedClientCheckDisplay(int   scrnIndex,
-                              char *displayName,
-                              char *xauthFile);
+Bool NestedClientCheckDisplay(int           scrnIndex,
+                              char         *displayName,
+                              char         *xauthFile,
+                              char         *output,
+                              unsigned int *width,
+                              unsigned int *height,
+                              int          *x,
+                              int          *y);
 
 Bool NestedClientValidDepth(int depth);
 
 NestedClientPrivatePtr NestedClientCreateScreen(int    scrnIndex,
                                                 char  *displayName,
                                                 char  *xauthFile,
+                                                Bool   wantFullscreenHint,
                                                 int    width,
                                                 int    height,
                                                 int    originX,
diff --git a/src/driver.c b/src/driver.c
index a91954f..3ac2cc4 100644
--- a/src/driver.c
+++ b/src/driver.c
@@ -101,7 +101,9 @@ void NestedPrintMode(ScrnInfoPtr p, DisplayModePtr m);
 typedef enum {
     OPTION_DISPLAY,
     OPTION_XAUTHORITY,
-    OPTION_ORIGIN
+    OPTION_ORIGIN,
+    OPTION_FULLSCREEN,
+    OPTION_OUTPUT
 } NestedOpts;
 
 typedef enum {
@@ -117,10 +119,12 @@ static SymTabRec NestedChipsets[] = {
  * port NestedClient to something that's not Xlib/Xcb we might need to add some
  * custom options */
 static OptionInfoRec NestedOptions[] = {
-    { OPTION_DISPLAY,    "Display",    OPTV_STRING, {0}, FALSE },
-    { OPTION_XAUTHORITY, "Xauthority", OPTV_STRING, {0}, FALSE },
-    { OPTION_ORIGIN,     "Origin",     OPTV_STRING, {0}, FALSE },
-    { -1,                NULL,         OPTV_NONE,   {0}, FALSE }
+    { OPTION_DISPLAY,    "Display",    OPTV_STRING,  {0}, FALSE },
+    { OPTION_XAUTHORITY, "Xauthority", OPTV_STRING,  {0}, FALSE },
+    { OPTION_ORIGIN,     "Origin",     OPTV_STRING,  {0}, FALSE },
+    { OPTION_FULLSCREEN, "Fullscreen", OPTV_BOOLEAN, {0}, FALSE },
+    { OPTION_OUTPUT,     "Output",     OPTV_STRING,  {0}, FALSE },
+    { -1,                NULL,         OPTV_NONE,    {0}, FALSE }
 };
 
 _X_EXPORT DriverRec NESTED = {
@@ -175,6 +179,10 @@ typedef struct NestedPrivate {
     char                        *xauthFile;
     int                          originX;
     int                          originY;
+    unsigned int                 fullWidth;
+    unsigned int                 fullHeight;
+    Bool                         fullscreen;
+    char                        *output;
     NestedClientPrivatePtr       clientData;
     CreateScreenResourcesProcPtr CreateScreenResources;
     CloseScreenProcPtr           CloseScreen;
@@ -332,6 +340,10 @@ static Bool NestedPreInit(ScrnInfoPtr pScrn, int flags) {
     pNested->xauthFile = NULL;
     pNested->originX = 0;
     pNested->originY = 0;
+    pNested->fullWidth = 0;
+    pNested->fullHeight = 0;
+    pNested->fullscreen = FALSE;
+    pNested->output = NULL;
 
     if (!xf86SetDepthBpp(pScrn, 0, 0, 0, Support24bppFb | Support32bppFb))
         return FALSE;
@@ -379,11 +391,27 @@ static Bool NestedPreInit(ScrnInfoPtr pScrn, int flags) {
                    pNested->originX, pNested->originY);
     }
 
+    if (xf86GetOptValBool(NestedOptions, OPTION_FULLSCREEN, &pNested->fullscreen))
+        xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Fullscreen mode %s\n",
+                   pNested->fullscreen ? "enabled" : "disabled");
+
+    if (xf86IsOptionSet(NestedOptions, OPTION_OUTPUT)) {
+        pNested->output = xf86GetOptValString(NestedOptions,
+                                              OPTION_OUTPUT);
+        xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Targeting host X server output \"%s\"\n",
+                   pNested->output);
+    }
+
     xf86ShowUnusedOptions(pScrn->scrnIndex, pScrn->options);
 
     if (!NestedClientCheckDisplay(pScrn->scrnIndex,
                                   pNested->displayName,
-                                  pNested->xauthFile)) {
+                                  pNested->xauthFile,
+                                  pNested->output,
+                                  &pNested->fullWidth,
+                                  &pNested->fullHeight,
+                                  &pNested->originX,
+                                  &pNested->originY)) {
         xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "Can't open display: %s\n",
                    pNested->displayName ? pNested->displayName : getenv("DISPLAY"));
         return FALSE;
@@ -433,35 +461,42 @@ NestedValidateModes(ScrnInfoPtr pScrn) {
     DisplayModePtr mode;
     int i, width, height, ret = 0;
     int maxX = 0, maxY = 0;
+    NestedPrivatePtr pNested = PNESTED(pScrn);
 
-    /* Print useless stuff */
-    xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Monitor wants these modes:\n");
-    for(mode = pScrn->monitor->Modes; mode != NULL; mode = mode->next) {
-        xf86DrvMsg(pScrn->scrnIndex, X_INFO, "  %s (%dx%d)\n", mode->name,
-                   mode->HDisplay, mode->VDisplay);
-    }
-    xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Too bad for it...\n");
-
-    /* If user requested modes, add them. If not, use 640x480 */
-    if (pScrn->display->modes != NULL) {
-        xf86DrvMsg(pScrn->scrnIndex, X_INFO, "User wants these modes:\n");
-        for(i = 0; pScrn->display->modes[i] != NULL; i++) {
-            xf86DrvMsg(pScrn->scrnIndex, X_INFO, "  %s\n",
-                       pScrn->display->modes[i]);
-            if (sscanf(pScrn->display->modes[i], "%dx%d", &width,
-                       &height) != 2) {
-                xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
-                           "This is not the mode name I was expecting...\n");
-                return 0;
+    if (pNested->output != NULL || pNested->fullscreen) {
+        if (!NestedAddMode(pScrn, pNested->fullWidth, pNested->fullHeight)) {
+            return 0;
+        }
+    } else {
+        /* Print useless stuff */
+        xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Monitor wants these modes:\n");
+        for(mode = pScrn->monitor->Modes; mode != NULL; mode = mode->next) {
+            xf86DrvMsg(pScrn->scrnIndex, X_INFO, "  %s (%dx%d)\n", mode->name,
+                       mode->HDisplay, mode->VDisplay);
+        }
+        xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Too bad for it...\n");
+
+        /* If user requested modes, add them. If not, use 640x480 */
+        if (pScrn->display->modes != NULL) {
+            xf86DrvMsg(pScrn->scrnIndex, X_INFO, "User wants these modes:\n");
+            for(i = 0; pScrn->display->modes[i] != NULL; i++) {
+                xf86DrvMsg(pScrn->scrnIndex, X_INFO, "  %s\n",
+                           pScrn->display->modes[i]);
+                if (sscanf(pScrn->display->modes[i], "%dx%d", &width,
+                           &height) != 2) {
+                    xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
+                               "This is not the mode name I was expecting...\n");
+                    return 0;
+                }
+                if (!NestedAddMode(pScrn, width, height)) {
+                    return 0;
+                }
             }
-            if (!NestedAddMode(pScrn, width, height)) {
+        } else {
+            if (!NestedAddMode(pScrn, 640, 480)) {
                 return 0;
             }
         }
-    } else {
-        if (!NestedAddMode(pScrn, 640, 480)) {
-            return 0;
-        }
     }
 
     pScrn->modePool = NULL;
@@ -585,6 +620,7 @@ static Bool NestedScreenInit(SCREEN_INIT_ARGS_DECL)
     pNested->clientData = NestedClientCreateScreen(pScrn->scrnIndex,
                                                    pNested->displayName,
                                                    pNested->xauthFile,
+                                                   pNested->output != NULL || pNested->fullscreen,
                                                    pScrn->virtualX,
                                                    pScrn->virtualY,
                                                    pNested->originX,
diff --git a/src/xlibclient.c b/src/xlibclient.c
index 3a87c96..7ad6a9a 100644
--- a/src/xlibclient.c
+++ b/src/xlibclient.c
@@ -87,7 +87,12 @@ struct NestedClientPrivate {
 Bool
 NestedClientCheckDisplay(int scrnIndex,
                          char *displayName,
-                         char *xauthFile) {
+                         char *xauthFile,
+                         char *output,
+                         unsigned int *width,
+                         unsigned int *height,
+                         int *x,
+                         int *y) {
     Display *d;
 
     /* Needed until we can pass authorization file
@@ -175,6 +180,7 @@ NestedClientPrivatePtr
 NestedClientCreateScreen(int scrnIndex,
                          char *displayName,
                          char *xauthFile,
+                         Bool wantFullscreenHint,
                          int width,
                          int height,
                          int originX,
-- 
1.8.4.5



More information about the xorg-devel mailing list