[PATCH xf86-video-nested v4 02/11] Add support for option "Xauthority" in xorg.conf
Laércio de Sousa
laerciosousa at sme-mogidascruzes.sp.gov.br
Fri Nov 13 10:28:02 PST 2015
With this patch, one can set explicitly an authorization file for
"nested" video driver in xorg.conf section "Device". It also removes
member displayName from NestedPrivate struct, replacing it
with DISPLAY environment variable wherever it's needed.
Example:
Section "Device"
Identifier "Nested virtual video device"
Driver "nested"
Option "Display" ":0"
Option "Xauthority" "/var/run/Xauthority/:0"
EndSection
If no such an option is defined in xorg.conf, the value defined
in environment variable XAUTHORITY will be used, as before.
Signed-off-by: Laércio de Sousa <laerciosousa at sme-mogidascruzes.sp.gov.br>
---
src/client.h | 3 +--
src/driver.c | 39 +++++++++++++++++++++++----------------
src/xlibclient.c | 7 +++----
3 files changed, 27 insertions(+), 22 deletions(-)
diff --git a/src/client.h b/src/client.h
index a066ea8..7f46844 100644
--- a/src/client.h
+++ b/src/client.h
@@ -39,12 +39,11 @@
struct NestedClientPrivate;
typedef struct NestedClientPrivate *NestedClientPrivatePtr;
-Bool NestedClientCheckDisplay(const char *displayName);
+Bool NestedClientCheckDisplay();
Bool NestedClientValidDepth(int depth);
NestedClientPrivatePtr NestedClientCreateScreen(int scrnIndex,
- const char *displayName,
int width,
int height,
int originX,
diff --git a/src/driver.c b/src/driver.c
index 2cedee0..0c2f26a 100644
--- a/src/driver.c
+++ b/src/driver.c
@@ -96,6 +96,7 @@ void NestedPrintMode(ScrnInfoPtr p, DisplayModePtr m);
typedef enum {
OPTION_DISPLAY,
+ OPTION_XAUTHORITY,
OPTION_ORIGIN
} NestedOpts;
@@ -112,9 +113,10 @@ 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_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 },
+ { -1, NULL, OPTV_NONE, {0}, FALSE }
};
_X_EXPORT DriverRec NESTED = {
@@ -163,7 +165,6 @@ _X_EXPORT XF86ModuleData nestedModuleData = {
/* These stuff should be valid to all server generations */
typedef struct NestedPrivate {
- const char *displayName;
int originX;
int originY;
NestedClientPrivatePtr clientData;
@@ -304,6 +305,7 @@ static void NestedFreePrivate(ScrnInfoPtr pScrn) {
/* Data from here is valid to all server generations */
static Bool NestedPreInit(ScrnInfoPtr pScrn, int flags) {
NestedPrivatePtr pNested;
+ const char *displayName = getenv("DISPLAY");
const char *originString = NULL;
xf86DrvMsg(pScrn->scrnIndex, X_INFO, "NestedPreInit\n");
@@ -317,6 +319,8 @@ static Bool NestedPreInit(ScrnInfoPtr pScrn, int flags) {
}
pNested = PNESTED(pScrn);
+ pNested->originX = 0;
+ pNested->originY = 0;
if (!xf86SetDepthBpp(pScrn, 0, 0, 0, Support24bppFb | Support32bppFb))
return FALSE;
@@ -339,34 +343,38 @@ static Bool NestedPreInit(ScrnInfoPtr pScrn, int flags) {
xf86ProcessOptions(pScrn->scrnIndex, pScrn->options, NestedOptions);
if (xf86IsOptionSet(NestedOptions, OPTION_DISPLAY)) {
- pNested->displayName = xf86GetOptValString(NestedOptions,
- OPTION_DISPLAY);
+ displayName = xf86GetOptValString(NestedOptions,
+ OPTION_DISPLAY);
xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Using display \"%s\"\n",
- pNested->displayName);
- } else {
- pNested->displayName = NULL;
+ displayName);
+ setenv("DISPLAY", displayName, 1);
+ }
+
+ if (xf86IsOptionSet(NestedOptions, OPTION_XAUTHORITY)) {
+ setenv("XAUTHORITY",
+ xf86GetOptValString(NestedOptions,
+ OPTION_XAUTHORITY), 1);
}
if (xf86IsOptionSet(NestedOptions, OPTION_ORIGIN)) {
originString = xf86GetOptValString(NestedOptions, OPTION_ORIGIN);
+
if (sscanf(originString, "%d %d", &pNested->originX,
- &pNested->originY) != 2) {
+ &pNested->originY) != 2) {
xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
"Invalid value for option \"Origin\"\n");
return FALSE;
}
+
xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Using origin x:%d y:%d\n",
pNested->originX, pNested->originY);
- } else {
- pNested->originX = 0;
- pNested->originY = 0;
}
xf86ShowUnusedOptions(pScrn->scrnIndex, pScrn->options);
- if (!NestedClientCheckDisplay(pNested->displayName)) {
+ if (!NestedClientCheckDisplay()) {
xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "Can't open display: %s\n",
- pNested->displayName);
+ displayName);
return FALSE;
}
@@ -562,7 +570,6 @@ static Bool NestedScreenInit(SCREEN_INIT_ARGS_DECL)
//Load_Nested_Mouse();
pNested->clientData = NestedClientCreateScreen(pScrn->scrnIndex,
- pNested->displayName,
pScrn->virtualX,
pScrn->virtualY,
pNested->originX,
diff --git a/src/xlibclient.c b/src/xlibclient.c
index a1fa39a..c5aaf96 100644
--- a/src/xlibclient.c
+++ b/src/xlibclient.c
@@ -79,10 +79,10 @@ struct NestedClientPrivate {
/* Checks if a display is open */
Bool
-NestedClientCheckDisplay(const char *displayName) {
+NestedClientCheckDisplay() {
Display *d;
- d = XOpenDisplay(displayName);
+ d = XOpenDisplay(NULL);
if (!d) {
return FALSE;
} else {
@@ -160,7 +160,6 @@ NestedClientTryXShm(NestedClientPrivatePtr pPriv, int scrnIndex, int width, int
NestedClientPrivatePtr
NestedClientCreateScreen(int scrnIndex,
- const char *displayName,
int width,
int height,
int originX,
@@ -178,7 +177,7 @@ NestedClientCreateScreen(int scrnIndex,
pPriv = malloc(sizeof(struct NestedClientPrivate));
pPriv->scrnIndex = scrnIndex;
- pPriv->display = XOpenDisplay(displayName);
+ pPriv->display = XOpenDisplay(NULL);
if (!pPriv->display)
return NULL;
--
2.1.4
More information about the xorg-devel
mailing list