dri2: Pass a ScreenPtr through to the driver's AuthMagic function. (v3)

xwayland drivers need access to their screen private data to authenticate.
Now that drivers no longer have direct access to the global screen arrays,
this needs to be passed in as function context.

v2: Don't break ABI
v3: Paint the bikeshed blue; drop fd from AuthMagic2ProcPtr prototype

Signed-off-by: Christopher James Halse Rogers <christopher.halse.rogers@canonical.com>
Reviewed-by: Kristian Høgsberg <krh@bitplanet.net>
Signed-off-by: Keith Packard <keithp@keithp.com>
This commit is contained in:
Christopher James Halse Rogers 2012-06-20 13:53:53 +10:00 committed by Keith Packard
parent dae317e726
commit 3f97284b10
2 changed files with 36 additions and 8 deletions

View File

@ -104,7 +104,8 @@ typedef struct _DRI2Screen {
DRI2ScheduleSwapProcPtr ScheduleSwap; DRI2ScheduleSwapProcPtr ScheduleSwap;
DRI2GetMSCProcPtr GetMSC; DRI2GetMSCProcPtr GetMSC;
DRI2ScheduleWaitMSCProcPtr ScheduleWaitMSC; DRI2ScheduleWaitMSCProcPtr ScheduleWaitMSC;
DRI2AuthMagicProcPtr AuthMagic; DRI2AuthMagic2ProcPtr AuthMagic;
DRI2AuthMagicProcPtr LegacyAuthMagic;
DRI2ReuseBufferNotifyProcPtr ReuseBufferNotify; DRI2ReuseBufferNotifyProcPtr ReuseBufferNotify;
DRI2SwapLimitValidateProcPtr SwapLimitValidate; DRI2SwapLimitValidateProcPtr SwapLimitValidate;
DRI2GetParamProcPtr GetParam; DRI2GetParamProcPtr GetParam;
@ -1110,12 +1111,22 @@ DRI2Connect(ScreenPtr pScreen, unsigned int driverType, int *fd,
return TRUE; return TRUE;
} }
static Bool
DRI2AuthMagic (ScreenPtr pScreen, uint32_t magic)
{
DRI2ScreenPtr ds = DRI2GetScreen(pScreen);
if (ds == NULL || (*ds->LegacyAuthMagic) (ds->fd, magic))
return FALSE;
return TRUE;
}
Bool Bool
DRI2Authenticate(ScreenPtr pScreen, uint32_t magic) DRI2Authenticate(ScreenPtr pScreen, uint32_t magic)
{ {
DRI2ScreenPtr ds = DRI2GetScreen(pScreen); DRI2ScreenPtr ds = DRI2GetScreen(pScreen);
if (ds == NULL || (*ds->AuthMagic) (ds->fd, magic)) if (ds == NULL || (*ds->AuthMagic) (pScreen, magic))
return FALSE; return FALSE;
return TRUE; return TRUE;
@ -1202,8 +1213,11 @@ DRI2ScreenInit(ScreenPtr pScreen, DRI2InfoPtr info)
cur_minor = 1; cur_minor = 1;
} }
if (info->version >= 8) {
ds->AuthMagic = info->AuthMagic2;
}
if (info->version >= 5) { if (info->version >= 5) {
ds->AuthMagic = info->AuthMagic; ds->LegacyAuthMagic = info->AuthMagic;
} }
if (info->version >= 6) { if (info->version >= 6) {
@ -1218,14 +1232,21 @@ DRI2ScreenInit(ScreenPtr pScreen, DRI2InfoPtr info)
/* /*
* if the driver doesn't provide an AuthMagic function or the info struct * if the driver doesn't provide an AuthMagic function or the info struct
* version is too low, it relies on the old method (using libdrm) or fail * version is too low, call through LegacyAuthMagic
*/ */
if (!ds->AuthMagic) if (!ds->AuthMagic) {
ds->AuthMagic = DRI2AuthMagic;
/*
* If the driver doesn't provide an AuthMagic function
* it relies on the old method (using libdrm) or fails
*/
if (!ds->LegacyAuthMagic)
#ifdef WITH_LIBDRM #ifdef WITH_LIBDRM
ds->AuthMagic = drmAuthMagic; ds->LegacyAuthMagic = drmAuthMagic;
#else #else
goto err_out; goto err_out;
#endif #endif
}
/* Initialize minor if needed and set to minimum provied by DDX */ /* Initialize minor if needed and set to minimum provied by DDX */
if (!dri2_minor || dri2_minor > cur_minor) if (!dri2_minor || dri2_minor > cur_minor)

View File

@ -64,6 +64,7 @@ typedef void (*DRI2CopyRegionProcPtr) (DrawablePtr pDraw,
DRI2BufferPtr pSrcBuffer); DRI2BufferPtr pSrcBuffer);
typedef void (*DRI2WaitProcPtr) (WindowPtr pWin, unsigned int sequence); typedef void (*DRI2WaitProcPtr) (WindowPtr pWin, unsigned int sequence);
typedef int (*DRI2AuthMagicProcPtr) (int fd, uint32_t magic); typedef int (*DRI2AuthMagicProcPtr) (int fd, uint32_t magic);
typedef int (*DRI2AuthMagic2ProcPtr) (ScreenPtr pScreen, uint32_t magic);
/** /**
* Schedule a buffer swap * Schedule a buffer swap
@ -192,7 +193,7 @@ typedef int (*DRI2GetParamProcPtr) (ClientPtr client,
/** /**
* Version of the DRI2InfoRec structure defined in this header * Version of the DRI2InfoRec structure defined in this header
*/ */
#define DRI2INFOREC_VERSION 7 #define DRI2INFOREC_VERSION 8
typedef struct { typedef struct {
unsigned int version; /**< Version of this struct */ unsigned int version; /**< Version of this struct */
@ -229,6 +230,12 @@ typedef struct {
/* added in version 7 */ /* added in version 7 */
DRI2GetParamProcPtr GetParam; DRI2GetParamProcPtr GetParam;
/* added in version 8 */
/* AuthMagic callback which passes extra context */
/* If this is NULL the AuthMagic callback is used */
/* If this is non-NULL the AuthMagic callback is ignored */
DRI2AuthMagic2ProcPtr AuthMagic2;
} DRI2InfoRec, *DRI2InfoPtr; } DRI2InfoRec, *DRI2InfoPtr;
extern _X_EXPORT int DRI2EventBase; extern _X_EXPORT int DRI2EventBase;