From 66539cc05d0b017b9feb4a038499907810140623 Mon Sep 17 00:00:00 2001 From: Alan Coopersmith Date: Thu, 26 Mar 2009 22:22:32 -0700 Subject: [PATCH 01/67] Don't leak default font path when appending built-ins Signed-off-by: Alan Coopersmith --- hw/xfree86/common/xf86Config.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/hw/xfree86/common/xf86Config.c b/hw/xfree86/common/xf86Config.c index 9a25c7bca..7da85ea2f 100644 --- a/hw/xfree86/common/xf86Config.c +++ b/hw/xfree86/common/xf86Config.c @@ -597,7 +597,9 @@ configFiles(XF86ConfFilesPtr fileconf) defaultFontPath = Xprintf("%s%s%s", fileconf->file_fontpath, *temp_path ? "," : "", temp_path); - must_copy = FALSE; + if (defaultFontPath != NULL) { + must_copy = FALSE; + } } else defaultFontPath = fileconf->file_fontpath; @@ -613,7 +615,14 @@ configFiles(XF86ConfFilesPtr fileconf) !((start == temp_path || start[-1] == ',') && (!*end || *end == ','))) { defaultFontPath = Xprintf("%s%sbuilt-ins", temp_path, *temp_path ? "," : ""); - must_copy = FALSE; + if (must_copy == TRUE) { + if (defaultFontPath != NULL) { + must_copy = FALSE; + } + } else { + /* already made a copy of the font path */ + xfree(temp_path); + } } /* xf86ValidateFontPath modifies its argument, but returns a copy of it. */ temp_path = must_copy ? xnfstrdup(defaultFontPath) : defaultFontPath; From 30d81ad72e870cc37754bd8c8aadf605450ec16e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristian=20H=C3=B8gsberg?= Date: Thu, 2 Apr 2009 17:24:12 -0400 Subject: [PATCH 02/67] Make GLX context lookup use dixLookupResourceByType() --- glx/glxcmds.c | 98 ++++++++++++++++++++++----------------------------- 1 file changed, 43 insertions(+), 55 deletions(-) diff --git a/glx/glxcmds.c b/glx/glxcmds.c index 80f3a6936..7197204ef 100644 --- a/glx/glxcmds.c +++ b/glx/glxcmds.c @@ -138,6 +138,22 @@ validGlxFBConfigForWindow(ClientPtr client, __GLXconfig *config, return TRUE; } +static int +validGlxContext(ClientPtr client, XID id, int access_mode, + __GLXcontext **context, int *err) +{ + *err = dixLookupResourceByType((pointer *) context, id, + __glXContextRes, client, access_mode); + if (err != Success) { + client->errorValue = id; + if (*err == BadValue) + *err = __glXError(GLXBadContext); + return FALSE; + } + + return TRUE; +} + void __glXContextDestroy(__GLXcontext *context) { @@ -189,7 +205,8 @@ DoCreateContext(__GLXclientState *cl, GLXContextID gcId, { ClientPtr client = cl->client; __GLXcontext *glxc, *shareglxc; - + int err; + LEGAL_NEW_RESOURCE(gcId, client); /* @@ -204,11 +221,10 @@ DoCreateContext(__GLXclientState *cl, GLXContextID gcId, if (shareList == None) { shareglxc = 0; } else { - shareglxc = (__GLXcontext *) LookupIDByType(shareList, __glXContextRes); - if (!shareglxc) { - client->errorValue = shareList; - return __glXError(GLXBadContext); - } + if (!validGlxContext(client, shareList, DixReadAccess, + &shareglxc, &err)) + return err; + if (shareglxc->isDirect) { /* ** NOTE: no support for sharing display lists between direct @@ -321,25 +337,16 @@ int __glXDisp_CreateContextWithConfigSGIX(__GLXclientState *cl, GLbyte *pc) } int __glXDisp_DestroyContext(__GLXclientState *cl, GLbyte *pc) { - ClientPtr client = cl->client; xGLXDestroyContextReq *req = (xGLXDestroyContextReq *) pc; - GLXContextID gcId = req->context; __GLXcontext *glxc; - - glxc = (__GLXcontext *) LookupIDByType(gcId, __glXContextRes); - if (glxc) { - /* - ** Just free the resource; don't actually destroy the context, - ** because it might be in use. The - ** destroy method will be called by the resource destruction routine - ** if necessary. - */ - FreeResourceByType(gcId, __glXContextRes, FALSE); - return Success; - } else { - client->errorValue = gcId; - return __glXError(GLXBadContext); - } + int err; + + if (!validGlxContext(cl->client, req->context, DixDestroyAccess, + &glxc, &err)) + return err; + + FreeResourceByType(req->context, __glXContextRes, FALSE); + return Success; } /*****************************************************************************/ @@ -528,7 +535,7 @@ DoMakeCurrent(__GLXclientState *cl, __GLXcontext *glxc, *prevglxc; __GLXdrawable *drawPriv = NULL; __GLXdrawable *readPriv = NULL; - GLint error; + int error; GLuint mask; /* @@ -569,11 +576,8 @@ DoMakeCurrent(__GLXclientState *cl, if (contextId != None) { int status; - glxc = (__GLXcontext *) LookupIDByType(contextId, __glXContextRes); - if (!glxc) { - client->errorValue = contextId; - return __glXError(GLXBadContext); - } + if (!validGlxContext(client, contextId, DixUseAccess, &glxc, &error)) + return error; if ((glxc != prevglxc) && glxc->isCurrent) { /* Context is current to somebody else */ return BadAccess; @@ -702,15 +706,10 @@ int __glXDisp_IsDirect(__GLXclientState *cl, GLbyte *pc) xGLXIsDirectReq *req = (xGLXIsDirectReq *) pc; xGLXIsDirectReply reply; __GLXcontext *glxc; + int err; - /* - ** Find the GL context. - */ - glxc = (__GLXcontext *) LookupIDByType(req->context, __glXContextRes); - if (!glxc) { - client->errorValue = req->context; - return __glXError(GLXBadContext); - } + if (!validGlxContext(cl->client, req->context, DixReadAccess, &glxc, &err)) + return err; reply.isDirect = glxc->isDirect; reply.length = 0; @@ -814,19 +813,10 @@ int __glXDisp_CopyContext(__GLXclientState *cl, GLbyte *pc) __GLXcontext *src, *dst; int error; - /* - ** Check that each context exists. - */ - src = (__GLXcontext *) LookupIDByType(source, __glXContextRes); - if (!src) { - client->errorValue = source; - return __glXError(GLXBadContext); - } - dst = (__GLXcontext *) LookupIDByType(dest, __glXContextRes); - if (!dst) { - client->errorValue = dest; - return __glXError(GLXBadContext); - } + if (!validGlxContext(cl->client, source, DixReadAccess, &src, &error)) + return error; + if (!validGlxContext(cl->client, dest, DixWriteAccess, &dst, &error)) + return error; /* ** They must be in the same address space, and same screen. @@ -1475,12 +1465,10 @@ DoQueryContext(__GLXclientState *cl, GLXContextID gcId) int nProps; int *sendBuf, *pSendBuf; int nReplyBytes; + int err; - ctx = (__GLXcontext *) LookupIDByType(gcId, __glXContextRes); - if (!ctx) { - client->errorValue = gcId; - return __glXError(GLXBadContext); - } + if (!validGlxContext(cl->client, gcId, DixReadAccess, &ctx, &err)) + return err; nProps = 3; reply.length = nProps << 1; From f70cfc8f90091ef0f5ed0a5b2e023e7fd6369b36 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristian=20H=C3=B8gsberg?= Date: Thu, 2 Apr 2009 17:30:19 -0400 Subject: [PATCH 03/67] Don't stomp on dixLookupDrawable() return value in DoCreateGLXPixmap(). --- glx/glxcmds.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/glx/glxcmds.c b/glx/glxcmds.c index 7197204ef..ec122407b 100644 --- a/glx/glxcmds.c +++ b/glx/glxcmds.c @@ -1106,7 +1106,11 @@ DoCreateGLXPixmap(ClientPtr client, __GLXscreen *pGlxScreen, __GLXconfig *config int err; err = dixLookupDrawable(&pDraw, drawableId, client, 0, DixAddAccess); - if (err != Success || pDraw->type != DRAWABLE_PIXMAP) { + if (err != Success) { + client->errorValue = drawableId; + return err; + } + if (pDraw->type != DRAWABLE_PIXMAP) { client->errorValue = drawableId; return BadPixmap; } From 92562747a0fdbef1dbedf734cb55dd6a9e1d2994 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristian=20H=C3=B8gsberg?= Date: Tue, 7 Apr 2009 13:58:53 -0400 Subject: [PATCH 04/67] Add validGlxDrawable() and use dixLookupResourceByType(). Fixes deprecation warnings, and fixes a couple of GLX error codes for failing drawable lookups. --- glx/glxcmds.c | 143 ++++++++++++++++++++++++---------------------- glx/glxdrawable.h | 3 +- 2 files changed, 76 insertions(+), 70 deletions(-) diff --git a/glx/glxcmds.c b/glx/glxcmds.c index ec122407b..d2e739325 100644 --- a/glx/glxcmds.c +++ b/glx/glxcmds.c @@ -154,6 +154,42 @@ validGlxContext(ClientPtr client, XID id, int access_mode, return TRUE; } +static int +validGlxDrawable(ClientPtr client, XID id, int type, int access_mode, + __GLXdrawable **drawable, int *err) +{ + int rc; + + rc = dixLookupResourceByType((pointer *) drawable, id, + __glXDrawableRes, client, access_mode); + if (rc != Success && rc != BadValue) { + *err = rc; + client->errorValue = id; + return FALSE; + } + + if (rc == BadValue || + (type != GLX_DRAWABLE_ANY && type != (*drawable)->type)) { + client->errorValue = id; + switch (type) { + case GLX_DRAWABLE_WINDOW: + *err = __glXError(GLXBadWindow); + return FALSE; + case GLX_DRAWABLE_PIXMAP: + *err = __glXError(GLXBadPixmap); + return FALSE; + case GLX_DRAWABLE_PBUFFER: + *err = __glXError(GLXBadPbuffer); + return FALSE; + case GLX_DRAWABLE_ANY: + *err = __glXError(GLXBadDrawable); + return FALSE; + } + } + + return TRUE; +} + void __glXContextDestroy(__GLXcontext *context) { @@ -441,20 +477,10 @@ static void StartUsingContext(__GLXclientState *cl, __GLXcontext *glxc) } /** - * Given a drawable ID, get the associated drawable and / or pixmap. - * - * If the specified drawable ID is not a pixmap, \c ppPixmap will be set - * to \c NULL on return. In either case, \c ppDraw will be set to a drawable. - * In the case where the drawable ID is a pixmap, \c ppDraw will be set to - * the drawable associated with that pixmap. - * - * \param glxc Associated GLX context. - * \param drawId ID of the drawable. - * \param client Pointer to the client state. - * \return the __GLXdrawable is returned on success. Otherwise NULL. - * - * \notes This function will need some modification when support pbuffers - * is added. + * This is a helper function to handle the legacy (pre GLX 1.3) cases + * where passing an X window to glXMakeCurrent is valid. Given a + * resource ID, look up the GLX drawable if available, otherwise, make + * sure it's an X window and create a GLX drawable one the fly. */ static __GLXdrawable * __glXGetDrawable(__GLXcontext *glxc, GLXDrawable drawId, ClientPtr client, @@ -464,10 +490,8 @@ __glXGetDrawable(__GLXcontext *glxc, GLXDrawable drawId, ClientPtr client, __GLXdrawable *pGlxDraw; int rc; - /* This is the GLX 1.3 case - the client passes in a GLXWindow or - * GLXPixmap and we just return the __GLXdrawable. */ - pGlxDraw = (__GLXdrawable *) LookupIDByType(drawId, __glXDrawableRes); - if (pGlxDraw != NULL) { + if (validGlxDrawable(client, drawId, GLX_DRAWABLE_ANY, + DixWriteAccess, &pGlxDraw, &rc)) { if (glxc != NULL && pGlxDraw->config != glxc->config) { client->errorValue = drawId; *error = BadMatch; @@ -477,13 +501,10 @@ __glXGetDrawable(__GLXcontext *glxc, GLXDrawable drawId, ClientPtr client, return pGlxDraw; } - /* The drawId wasn't a GLX drawable, so presumably it's a regular - * X window. In that case, we create a shadow GLXWindow for it on - * demand here for pre GLX 1.3 compatibility and use the X Window - * XID as its GLXWindow XID. The client can't explicitly create a - * GLXWindow with the same XID as an X Window, so we wont get any - * resource ID clashes. Effectively, the X Window is now also a - * GLXWindow. */ + /* The drawId wasn't a GLX drawable. Make sure it's a window and + * create a GLXWindow for it. Check that the drawable screen + * matches the context screen and that the context fbconfig is + * compatible with the window visual. */ rc = dixLookupDrawable(&pDraw, drawId, client, 0, DixGetAttrAccess); if (rc != Success || pDraw->type != DRAWABLE_WINDOW) { @@ -492,18 +513,13 @@ __glXGetDrawable(__GLXcontext *glxc, GLXDrawable drawId, ClientPtr client, return NULL; } - /* If we're not given a context, don't create the __GLXdrawable */ - if (glxc == NULL) { - *error = __glXError(GLXBadDrawable); + if (pDraw->pScreen != glxc->pGlxScreen->pScreen) { + client->errorValue = pDraw->pScreen->myNum; + *error = BadMatch; return NULL; } - /* We're binding an X Window for the first time and need to create - * a GLX drawable for it. Check that the drawable screen matches - * the context screen and that the context fbconfig is compatible - * with the window visual. */ - if (pDraw->pScreen != glxc->pGlxScreen->pScreen || - !validGlxFBConfigForWindow(client, glxc->config, pDraw, error)) + if (!validGlxFBConfigForWindow(client, glxc->config, pDraw, error)) return NULL; pGlxDraw = glxc->pGlxScreen->createDrawable(glxc->pGlxScreen, @@ -1125,14 +1141,18 @@ DoCreateGLXPixmap(ClientPtr client, __GLXscreen *pGlxScreen, __GLXconfig *config } static void -determineTextureTarget(XID glxDrawableID, CARD32 *attribs, CARD32 numAttribs) +determineTextureTarget(ClientPtr client, XID glxDrawableID, + CARD32 *attribs, CARD32 numAttribs) { GLenum target = 0; GLenum format = 0; - int i; + int i, err; __GLXdrawable *pGlxDraw; - pGlxDraw = LookupIDByType(glxDrawableID, __glXDrawableRes); + if (!validGlxDrawable(client, glxDrawableID, GLX_DRAWABLE_PIXMAP, + DixWriteAccess, &pGlxDraw, &err)) + /* We just added it in CreatePixmap, so we should never get here. */ + return; for (i = 0; i < numAttribs; i++) { if (attribs[2 * i] == GLX_TEXTURE_TARGET_EXT) { @@ -1196,7 +1216,7 @@ int __glXDisp_CreatePixmap(__GLXclientState *cl, GLbyte *pc) if (err != Success) return err; - determineTextureTarget(req->glxpixmap, + determineTextureTarget(cl->client, req->glxpixmap, (CARD32*) (req + 1), req->numAttribs); return Success; @@ -1222,24 +1242,12 @@ int __glXDisp_CreateGLXPixmapWithConfigSGIX(__GLXclientState *cl, GLbyte *pc) static int DoDestroyDrawable(__GLXclientState *cl, XID glxdrawable, int type) { - ClientPtr client = cl->client; __GLXdrawable *pGlxDraw; + int err; - /* - ** Check it's the right type of drawable. - */ - pGlxDraw = LookupIDByType(glxdrawable, __glXDrawableRes); - if (pGlxDraw == NULL || pGlxDraw->type != type) { - client->errorValue = glxdrawable; - switch (type) { - case GLX_DRAWABLE_WINDOW: - return __glXError(GLXBadWindow); - case GLX_DRAWABLE_PIXMAP: - return __glXError(GLXBadDrawable); - case GLX_DRAWABLE_PBUFFER: - return __glXError(GLXBadPbuffer); - } - } + if (!validGlxDrawable(cl->client, glxdrawable, type, + DixDestroyAccess, &pGlxDraw, &err)) + return err; FreeResource(glxdrawable, FALSE); @@ -1339,9 +1347,12 @@ DoChangeDrawableAttributes(ClientPtr client, XID glxdrawable, int numAttribs, CARD32 *attribs) { __GLXdrawable *pGlxDraw; - int i; + int i, err; + + if (!validGlxDrawable(client, glxdrawable, GLX_DRAWABLE_ANY, + DixSetAttrAccess, &pGlxDraw, &err)) + return err; - pGlxDraw = LookupIDByType(glxdrawable, __glXDrawableRes); for (i = 0; i < numAttribs; i++) { switch(attribs[i * 2]) { case GLX_EVENT_MASK: @@ -1540,11 +1551,9 @@ int __glXDisp_BindTexImageEXT(__GLXclientState *cl, GLbyte *pc) if (!context) return error; - pGlxDraw = __glXGetDrawable(NULL, drawId, client, &error); - if (!pGlxDraw || pGlxDraw->type != GLX_DRAWABLE_PIXMAP) { - client->errorValue = drawId; - return __glXError(GLXBadPixmap); - } + if (!validGlxDrawable(client, drawId, GLX_DRAWABLE_PIXMAP, + DixReadAccess, &pGlxDraw, &error)) + return error; if (!context->textureFromPixmap) return __glXError(GLXUnsupportedPrivateRequest); @@ -1573,11 +1582,9 @@ int __glXDisp_ReleaseTexImageEXT(__GLXclientState *cl, GLbyte *pc) if (!context) return error; - pGlxDraw = __glXGetDrawable(NULL, drawId, client, &error); - if (!pGlxDraw || pGlxDraw->type != GLX_DRAWABLE_PIXMAP) { - client->errorValue = drawId; + if (!validGlxDrawable(client, drawId, GLX_DRAWABLE_PIXMAP, + DixReadAccess, &pGlxDraw, &error)) return error; - } if (!context->textureFromPixmap) return __glXError(GLXUnsupportedPrivateRequest); @@ -1657,11 +1664,9 @@ DoGetDrawableAttributes(__GLXclientState *cl, XID drawId) CARD32 attributes[6]; int numAttribs, error; - pGlxDraw = __glXGetDrawable(NULL, drawId, client, &error); - if (!pGlxDraw) { - client->errorValue = drawId; + if (!validGlxDrawable(client, drawId, GLX_DRAWABLE_ANY, + DixGetAttrAccess, &pGlxDraw, &error)) return error; - } numAttribs = 3; reply.length = numAttribs << 1; diff --git a/glx/glxdrawable.h b/glx/glxdrawable.h index 2d787ae78..b64ff35c9 100644 --- a/glx/glxdrawable.h +++ b/glx/glxdrawable.h @@ -41,7 +41,8 @@ enum { GLX_DRAWABLE_WINDOW, GLX_DRAWABLE_PIXMAP, - GLX_DRAWABLE_PBUFFER + GLX_DRAWABLE_PBUFFER, + GLX_DRAWABLE_ANY }; struct __GLXdrawable { From df27b870a8db7a5153b18a556fe77efa590f9eee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristian=20H=C3=B8gsberg?= Date: Tue, 7 Apr 2009 16:28:08 -0400 Subject: [PATCH 05/67] Convert remaining GLX LookupIDByType() calls --- glx/glxscreens.c | 7 +++++-- glx/xfont.c | 15 ++++++++++----- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/glx/glxscreens.c b/glx/glxscreens.c index 6f68b066a..2b12049fb 100644 --- a/glx/glxscreens.c +++ b/glx/glxscreens.c @@ -254,6 +254,7 @@ AddScreenVisuals(ScreenPtr pScreen, int count, int d) VisualPtr visuals; ColormapPtr installedCmap; DepthPtr depth; + int rc; depth = NULL; for (i = 0; i < pScreen->numDepths; i++) { @@ -294,8 +295,10 @@ AddScreenVisuals(ScreenPtr pScreen, int count, int d) * for all colormaps. */ for (i = 0; i < numInstalledCmaps; i++) { - installedCmap = LookupIDByType (installedCmaps[i], RT_COLORMAP); - if (!installedCmap) + rc = dixLookupResourceByType((pointer *)&installedCmap, + installedCmaps[i], RT_COLORMAP, + serverClient, DixReadAccess); + if (rc != Success) continue; j = installedCmap->pVisual - pScreen->visuals; installedCmap->pVisual = &visuals[j]; diff --git a/glx/xfont.c b/glx/xfont.c index 1f4ecbd4d..b8b466d87 100644 --- a/glx/xfont.c +++ b/glx/xfont.c @@ -180,12 +180,17 @@ int __glXDisp_UseXFont(__GLXclientState *cl, GLbyte *pc) ** Font can actually be either the ID of a font or the ID of a GC ** containing a font. */ - pFont = (FontPtr)LookupIDByType(req->font, RT_FONT); - if (!pFont) { - pGC = (GC *)LookupIDByType(req->font, RT_GC); - if (!pGC) { + + error = dixLookupResourceByType((pointer *)&pFont, + req->font, RT_FONT, + client, DixReadAccess); + if (error != Success) { + error = dixLookupResourceByType((pointer *)&pGC, + req->font, RT_GC, + client, DixReadAccess); + if (error != Success) { client->errorValue = req->font; - return BadFont; + return error == BadGC ? BadFont : error; } pFont = pGC->font; } From e8b324102f6e21ae2b8292a6f50d016dd6254dd6 Mon Sep 17 00:00:00 2001 From: Eamon Walsh Date: Wed, 8 Apr 2009 15:10:16 -0400 Subject: [PATCH 06/67] xselinux: Don't require incoming context strings to be null-terminated. --- Xext/xselinux.c | 66 +++++++++++++++++++++++++++++++++---------------- 1 file changed, 45 insertions(+), 21 deletions(-) diff --git a/Xext/xselinux.c b/Xext/xselinux.c index 4a1fe004b..399e28ad4 100644 --- a/Xext/xselinux.c +++ b/Xext/xselinux.c @@ -1258,6 +1258,17 @@ typedef struct { CARD32 id; } SELinuxListItemRec; +static security_context_t +SELinuxCopyContext(char *ptr, unsigned len) +{ + security_context_t copy = xalloc(len + 1); + if (!copy) + return NULL; + strncpy(copy, ptr, len); + copy[len] = '\0'; + return copy; +} + static int ProcSELinuxQueryVersion(ClientPtr client) { @@ -1315,29 +1326,34 @@ ProcSELinuxSetCreateContext(ClientPtr client, unsigned offset) { PrivateRec **privPtr = &client->devPrivates; security_id_t *pSid; - security_context_t ctx; + security_context_t ctx = NULL; char *ptr; + int rc; REQUEST(SELinuxSetCreateContextReq); REQUEST_FIXED_SIZE(SELinuxSetCreateContextReq, stuff->context_len); - ctx = (char *)(stuff + 1); - if (stuff->context_len > 0 && ctx[stuff->context_len - 1]) - return BadLength; + if (stuff->context_len > 0) { + ctx = SELinuxCopyContext((char *)(stuff + 1), stuff->context_len); + if (!ctx) + return BadAlloc; + } if (offset == CTX_DEV) { /* Device create context currently requires manage permission */ - int rc = XaceHook(XACE_SERVER_ACCESS, client, DixManageAccess); + rc = XaceHook(XACE_SERVER_ACCESS, client, DixManageAccess); if (rc != Success) - return rc; + goto out; privPtr = &serverClient->devPrivates; } else if (offset == USE_SEL) { /* Selection use context currently requires no selections owned */ Selection *pSel; for (pSel = CurrentSelections; pSel; pSel = pSel->next) - if (pSel->client == client) - return BadMatch; + if (pSel->client == client) { + rc = BadMatch; + goto out; + } } ptr = dixLookupPrivate(privPtr, subjectKey); @@ -1345,13 +1361,15 @@ ProcSELinuxSetCreateContext(ClientPtr client, unsigned offset) sidput(*pSid); *pSid = NULL; + rc = Success; if (stuff->context_len > 0) { - if (security_check_context_raw(ctx) < 0) - return BadValue; - if (avc_context_to_sid_raw(ctx, pSid) < 0) - return BadValue; + if (security_check_context_raw(ctx) < 0 || + avc_context_to_sid_raw(ctx, pSid) < 0) + rc = BadValue; } - return Success; +out: + xfree(ctx); + return rc; } static int @@ -1384,18 +1402,21 @@ ProcSELinuxSetDeviceContext(ClientPtr client) REQUEST(SELinuxSetContextReq); REQUEST_FIXED_SIZE(SELinuxSetContextReq, stuff->context_len); - ctx = (char *)(stuff + 1); - if (stuff->context_len < 1 || ctx[stuff->context_len - 1]) + if (stuff->context_len < 1) return BadLength; + ctx = SELinuxCopyContext((char *)(stuff + 1), stuff->context_len); + if (!ctx) + return BadAlloc; rc = dixLookupDevice(&dev, stuff->id, client, DixManageAccess); if (rc != Success) - return rc; + goto out; - if (security_check_context_raw(ctx) < 0) - return BadValue; - if (avc_context_to_sid_raw(ctx, &sid) < 0) - return BadValue; + if (security_check_context_raw(ctx) < 0 || + avc_context_to_sid_raw(ctx, &sid) < 0) { + rc = BadValue; + goto out; + } subj = dixLookupPrivate(&dev->devPrivates, subjectKey); sidput(subj->sid); @@ -1404,7 +1425,10 @@ ProcSELinuxSetDeviceContext(ClientPtr client) sidput(obj->sid); sidget(obj->sid = sid); - return Success; + rc = Success; +out: + xfree(ctx); + return rc; } static int From 0d9f3ca7eabd4c514808114d30627f682c8bd030 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Wed, 8 Apr 2009 14:53:46 -0700 Subject: [PATCH 07/67] Allow GLX sources to build against Mesa 7.4 sources Signed-off-by: Ian Romanick --- glx/glxdri2.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/glx/glxdri2.c b/glx/glxdri2.c index 4df406b5a..77b530721 100644 --- a/glx/glxdri2.c +++ b/glx/glxdri2.c @@ -251,12 +251,15 @@ __glXDRIbindTexImage(__GLXcontext *baseContext, if (texBuffer == NULL) return Success; +#if __DRI_TEX_BUFFER_VERSION >= 2 if (texBuffer->base.version >= 2 && texBuffer->setTexBuffer2 != NULL) { (*texBuffer->setTexBuffer2)(context->driContext, glxPixmap->target, glxPixmap->format, drawable->driDrawable); - } else { + } else +#endif + { texBuffer->setTexBuffer(context->driContext, glxPixmap->target, drawable->driDrawable); From 03aebed519986c4dd03e02b3b3d4af1f64595ca7 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Wed, 8 Apr 2009 14:54:30 -0700 Subject: [PATCH 08/67] Use a #define instead of a magic number The number of buffers is likely to change in the future, so having this as a define is the right way to go. Signed-off-by: Ian Romanick --- glx/glxdri2.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/glx/glxdri2.c b/glx/glxdri2.c index 77b530721..c896536c8 100644 --- a/glx/glxdri2.c +++ b/glx/glxdri2.c @@ -82,6 +82,8 @@ struct __GLXDRIcontext { __DRIcontext *driContext; }; +#define MAX_DRAWABLE_BUFFERS 5 + struct __GLXDRIdrawable { __GLXdrawable base; __DRIdrawable *driDrawable; @@ -90,7 +92,7 @@ struct __GLXDRIdrawable { /* Dimensions as last reported by DRI2GetBuffers. */ int width; int height; - __DRIbuffer buffers[5]; + __DRIbuffer buffers[MAX_DRAWABLE_BUFFERS]; int count; }; @@ -407,7 +409,7 @@ dri2GetBuffers(__DRIdrawable *driDrawable, buffers = DRI2GetBuffers(private->base.pDraw, width, height, attachments, count, out_count); - if (*out_count > 5) { + if (*out_count > MAX_DRAWABLE_BUFFERS) { *out_count = 0; return NULL; } From 7b3982eb6518da33ab01c2fbf7ceb45b89f841df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michel=20D=C3=A4nzer?= Date: Thu, 9 Apr 2009 08:21:09 +0200 Subject: [PATCH 09/67] glx: Test the error value, not its address... --- glx/glxcmds.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/glx/glxcmds.c b/glx/glxcmds.c index d2e739325..e21f0f098 100644 --- a/glx/glxcmds.c +++ b/glx/glxcmds.c @@ -144,7 +144,7 @@ validGlxContext(ClientPtr client, XID id, int access_mode, { *err = dixLookupResourceByType((pointer *) context, id, __glXContextRes, client, access_mode); - if (err != Success) { + if (*err != Success) { client->errorValue = id; if (*err == BadValue) *err = __glXError(GLXBadContext); From 3a0ee199dcec39596756a995996eac388acf6315 Mon Sep 17 00:00:00 2001 From: Eamon Walsh Date: Thu, 9 Apr 2009 02:26:24 -0400 Subject: [PATCH 10/67] config: fix crash caused by strdup(NULL) --- hw/xfree86/parser/Flags.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/hw/xfree86/parser/Flags.c b/hw/xfree86/parser/Flags.c index b4e8d2583..6865d3592 100644 --- a/hw/xfree86/parser/Flags.c +++ b/hw/xfree86/parser/Flags.c @@ -235,11 +235,12 @@ XF86OptionPtr xf86optionListDup (XF86OptionPtr opt) { XF86OptionPtr newopt = NULL; + char *val; while (opt) { - newopt = xf86addNewOption(newopt, strdup(opt->opt_name), - strdup(opt->opt_val)); + val = opt->opt_val ? strdup(opt->opt_val) : NULL; + newopt = xf86addNewOption(newopt, strdup(opt->opt_name), val); newopt->opt_used = opt->opt_used; if (opt->opt_comment) newopt->opt_comment = strdup(opt->opt_comment); From 682d7b55699cacbb2dbcd84a5e816bf6e2d2f02a Mon Sep 17 00:00:00 2001 From: Eamon Walsh Date: Thu, 9 Apr 2009 02:48:04 -0400 Subject: [PATCH 11/67] xselinux: Don't BadAlloc in List* requests if there are no items to list. --- Xext/xselinux.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Xext/xselinux.c b/Xext/xselinux.c index 399e28ad4..2c7262140 100644 --- a/Xext/xselinux.c +++ b/Xext/xselinux.c @@ -1567,7 +1567,7 @@ SELinuxSendItemsToClient(ClientPtr client, SELinuxListItemRec *items, CARD32 *buf; buf = xcalloc(size, sizeof(CARD32)); - if (!buf) { + if (size && !buf) { rc = BadAlloc; goto out; } @@ -1639,7 +1639,7 @@ ProcSELinuxListProperties(ClientPtr client) for (pProp = wUserProps(pWin); pProp; pProp = pProp->next) count++; items = xcalloc(count, sizeof(SELinuxListItemRec)); - if (!items) + if (count && !items) return BadAlloc; /* Fill in the items and calculate size */ @@ -1673,7 +1673,7 @@ ProcSELinuxListSelections(ClientPtr client) for (pSel = CurrentSelections; pSel; pSel = pSel->next) count++; items = xcalloc(count, sizeof(SELinuxListItemRec)); - if (!items) + if (count && !items) return BadAlloc; /* Fill in the items and calculate size */ From 346e71525fc545c6ca4ad79425722282d1544459 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michel=20D=C3=A4nzer?= Date: Thu, 9 Apr 2009 09:36:41 +0200 Subject: [PATCH 12/67] EXA: If the driver can't composite to an a8 mask, try an argb mask for glyphs. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Michel Dänzer --- exa/exa_glyphs.c | 33 +++++++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/exa/exa_glyphs.c b/exa/exa_glyphs.c index 596b60c6e..d2a0168b4 100644 --- a/exa/exa_glyphs.c +++ b/exa/exa_glyphs.c @@ -713,6 +713,7 @@ exaGlyphs (CARD8 op, if (maskFormat) { + ExaScreenPriv(pScreen); GCPtr pGC; xRectangle rect; @@ -739,10 +740,38 @@ exaGlyphs (CARD8 op, pMask = CreatePicture (0, &pMaskPixmap->drawable, maskFormat, CPComponentAlpha, &component_alpha, serverClient, &error); - if (!pMask) + if (!pMask || + (!component_alpha && pExaScr->info->CheckComposite && + !(*pExaScr->info->CheckComposite) (PictOpAdd, pSrc, NULL, pMask))) { + PictFormatPtr argbFormat; + (*pScreen->DestroyPixmap) (pMaskPixmap); - return; + + if (!pMask) + return; + + /* The driver can't seem to composite to a8, let's try argb (but + * without component-alpha) */ + FreePicture ((pointer) pMask, (XID) 0); + + argbFormat = PictureMatchFormat (pScreen, 32, PICT_a8r8g8b8); + + if (argbFormat) + maskFormat = argbFormat; + + pMaskPixmap = (*pScreen->CreatePixmap) (pScreen, width, height, + maskFormat->depth, + CREATE_PIXMAP_USAGE_SCRATCH); + if (!pMaskPixmap) + return; + + pMask = CreatePicture (0, &pMaskPixmap->drawable, maskFormat, 0, 0, + serverClient, &error); + if (!pMask) { + (*pScreen->DestroyPixmap) (pMaskPixmap); + return; + } } pGC = GetScratchGC (pMaskPixmap->drawable.depth, pScreen); ValidateGC (&pMaskPixmap->drawable, pGC); From e3bb7dea06b9ab0e30d801bf6c3a59f94290aaed Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Thu, 9 Apr 2009 19:07:36 +1000 Subject: [PATCH 13/67] mi: add prototype for CopyGetMasterEvent. Signed-off-by: Peter Hutterer --- mi/mi.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/mi/mi.h b/mi/mi.h index 076cea704..182cea593 100644 --- a/mi/mi.h +++ b/mi/mi.h @@ -221,6 +221,13 @@ extern _X_EXPORT void mieqProcessInputEvents( void ); +extern void CopyGetMasterEvent( + DeviceIntPtr /* mdev */, + DeviceIntPtr /* sdev */, + InternalEvent* /* original */, + EventListPtr /* master */ +); + /** * Custom input event handler. If you need to process input events in some * other way than the default path, register an input event handler for the From 630a6e9d14ffbf036fa72f580c72c0172d7c20bd Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Thu, 9 Apr 2009 08:40:20 +1000 Subject: [PATCH 14/67] mi: fix compiler warning - explicitly typecast to InternalEvent. Signed-off-by: Peter Hutterer --- mi/mipointer.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mi/mipointer.c b/mi/mipointer.c index e3a465615..3d34481ef 100644 --- a/mi/mipointer.c +++ b/mi/mipointer.c @@ -590,7 +590,7 @@ miPointerMove (DeviceIntPtr pDev, ScreenPtr pScreen, int x, int y) darwinEvents_lock(); #endif for (i = 0; i < nevents; i++) - mieqEnqueue(pDev, events[i].event); + mieqEnqueue(pDev, (InternalEvent*)events[i].event); #ifdef XQUARTZ darwinEvents_unlock(); #endif From 011cee3103c146c8096b7098a27993f99e07a824 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Thu, 9 Apr 2009 08:14:39 +1000 Subject: [PATCH 15/67] dix: fix dev/keybd variable mixup. Reported-by: Eric Anhold Signed-off-by: Peter Hutterer --- dix/devices.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/dix/devices.c b/dix/devices.c index 4a36669ac..b9d1c85a5 100644 --- a/dix/devices.c +++ b/dix/devices.c @@ -1925,14 +1925,14 @@ ProcBell(ClientPtr client) else newpercent = base - newpercent + stuff->percent; - for (keybd = inputInfo.devices; keybd; keybd = keybd->next) { + for (dev = inputInfo.devices; dev; dev = dev->next) { if ((dev == keybd || (!dev->isMaster && dev->u.master == keybd)) && - keybd->kbdfeed && keybd->kbdfeed->BellProc) { + dev->kbdfeed && dev->kbdfeed->BellProc) { rc = XaceHook(XACE_DEVICE_ACCESS, client, dev, DixBellAccess); if (rc != Success) return rc; - XkbHandleBell(FALSE, FALSE, keybd, newpercent, + XkbHandleBell(FALSE, FALSE, dev, newpercent, &dev->kbdfeed->ctrl, 0, None, NULL, client); } } From 8a2a184da78a3e9cbeae8290431f40d5ec7f3636 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Thu, 9 Apr 2009 08:06:32 +1000 Subject: [PATCH 16/67] xfree86: fix use of uninitialized variable in DGAProcessPointerEvent. Reported-by: Eric Anholt Signed-off-by: Peter Hutterer --- hw/xfree86/common/xf86DGA.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/hw/xfree86/common/xf86DGA.c b/hw/xfree86/common/xf86DGA.c index 4cc530a40..f83bcd5e3 100644 --- a/hw/xfree86/common/xf86DGA.c +++ b/hw/xfree86/common/xf86DGA.c @@ -1088,7 +1088,6 @@ static void DGAProcessPointerEvent (ScreenPtr pScreen, DGAEvent *event, DeviceIntPtr mouse) { ButtonClassPtr butc = mouse->button; - int coreEquiv; DGAScreenPtr pScreenPriv = DGA_GET_SCREEN_PRIV(pScreen); DeviceEvent ev; @@ -1107,7 +1106,11 @@ DGAProcessPointerEvent (ScreenPtr pScreen, DGAEvent *event, DeviceIntPtr mouse) if (pScreenPriv->client) { dgaEvent de; - de.u.u.type = *XDGAEventBase + GetCoreType((InternalEvent*)&ev); + int coreEquiv; + + coreEquiv = GetCoreType((InternalEvent*)&ev); + + de.u.u.type = *XDGAEventBase + coreEquiv; de.u.u.detail = event->detail; de.u.event.time = event->time; de.u.event.dx = 0; From 6b467bf879eeb77d167ef321e6dda97ca9d7010a Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Thu, 9 Apr 2009 08:42:06 +1000 Subject: [PATCH 17/67] xfree86: shut up compiler warnings - typecast to InternalEvent Reported-by: Eric Anholt Signed-off-by: Peter Hutterer --- hw/xfree86/common/xf86Events.c | 2 +- hw/xfree86/common/xf86Xinput.c | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/hw/xfree86/common/xf86Events.c b/hw/xfree86/common/xf86Events.c index 4f84a4c55..19120cede 100644 --- a/hw/xfree86/common/xf86Events.c +++ b/hw/xfree86/common/xf86Events.c @@ -428,7 +428,7 @@ xf86ReleaseKeys(DeviceIntPtr pDev) sigstate = xf86BlockSIGIO (); nevents = GetKeyboardEvents(xf86Events, pDev, KeyRelease, i); for (j = 0; j < nevents; j++) - mieqEnqueue(pDev, (xf86Events + j)->event); + mieqEnqueue(pDev, (InternalEvent*)(xf86Events + j)->event); xf86UnblockSIGIO(sigstate); } } diff --git a/hw/xfree86/common/xf86Xinput.c b/hw/xfree86/common/xf86Xinput.c index 3a56b49b2..96aff1538 100644 --- a/hw/xfree86/common/xf86Xinput.c +++ b/hw/xfree86/common/xf86Xinput.c @@ -792,7 +792,7 @@ xf86PostMotionEventP(DeviceIntPtr device, /* Don't post core motion events for devices not registered to send * drag events. */ if (xE->u.u.type != MotionNotify || drag) { - mieqEnqueue(device, (xf86Events + i)->event); + mieqEnqueue(device, (InternalEvent*)((xf86Events + i)->event)); } } } @@ -825,7 +825,7 @@ xf86PostProximityEvent(DeviceIntPtr device, is_in ? ProximityIn : ProximityOut, first_valuator, num_valuators, valuators); for (i = 0; i < nevents; i++) - mieqEnqueue(device, (xf86Events + i)->event); + mieqEnqueue(device, (InternalEvent*)((xf86Events + i)->event)); } @@ -868,7 +868,7 @@ xf86PostButtonEvent(DeviceIntPtr device, first_valuator, num_valuators, valuators); for (i = 0; i < nevents; i++) - mieqEnqueue(device, (xf86Events + i)->event); + mieqEnqueue(device, (InternalEvent*)((xf86Events + i)->event)); } @@ -915,7 +915,7 @@ xf86PostKeyEvent(DeviceIntPtr device, } for (i = 0; i < nevents; i++) - mieqEnqueue(device, (xf86Events + i)->event); + mieqEnqueue(device, (InternalEvent*)((xf86Events + i)->event)); } void @@ -944,7 +944,7 @@ xf86PostKeyboardEvent(DeviceIntPtr device, is_down ? KeyPress : KeyRelease, key_code); for (i = 0; i < nevents; i++) - mieqEnqueue(device, (xf86Events + i)->event); + mieqEnqueue(device, (InternalEvent*)((xf86Events + i)->event)); } LocalDevicePtr From 4fee979d0632751d3d54d2115e84e9654edf0622 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Thu, 9 Apr 2009 19:11:27 +1000 Subject: [PATCH 18/67] Xi: silence compiler warnings about "wrong" event types. Signed-off-by: Peter Hutterer --- Xi/exevents.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/Xi/exevents.c b/Xi/exevents.c index 29dceca0e..478866553 100644 --- a/Xi/exevents.c +++ b/Xi/exevents.c @@ -1002,12 +1002,13 @@ ProcessOtherEvent(InternalEvent *ev, DeviceIntPtr device) if (grab) - DeliverGrabbedEvent(event, device, deactivateDeviceGrab); + DeliverGrabbedEvent((InternalEvent*)event, device, deactivateDeviceGrab); else if (device->focus && !IsPointerEvent((InternalEvent*)ev)) - DeliverFocusedEvent(device, event, GetSpriteWindow(device)); + DeliverFocusedEvent(device, (InternalEvent*)event, + GetSpriteWindow(device)); else - DeliverDeviceEvents(GetSpriteWindow(device), event, NullGrab, - NullWindow, device); + DeliverDeviceEvents(GetSpriteWindow(device), (InternalEvent*)event, + NullGrab, NullWindow, device); if (deactivateDeviceGrab == TRUE) (*device->deviceGrab.DeactivateGrab) (device); From fcc19e673e3ef33d64916dd933853f8aa667c4d7 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Thu, 9 Apr 2009 20:27:00 +1000 Subject: [PATCH 19/67] mi: fix wrong (*EnqueueEvent) declaration in miPointerScreenFuncRec. Signed-off-by: Peter Hutterer --- mi/mipointer.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mi/mipointer.h b/mi/mipointer.h index 83277e46c..8b13f0848 100644 --- a/mi/mipointer.h +++ b/mi/mipointer.h @@ -82,7 +82,7 @@ typedef struct _miPointerScreenFuncRec { ); void (*EnqueueEvent)( DeviceIntPtr /* pDev */, - xEventPtr /* event */ + InternalEvent* /* event */ ); void (*NewEventScreen)( DeviceIntPtr /* pDev */, From a0b6a363dca8ce0dc6f4eb79333e48496153cd67 Mon Sep 17 00:00:00 2001 From: Alan Coopersmith Date: Mon, 9 Mar 2009 13:22:57 -0700 Subject: [PATCH 20/67] Lift fatal signal handlers from DDX'es up to a common DIX implementation Signed-off-by: Alan Coopersmith --- hw/kdrive/src/kdrive.c | 34 ++------------ hw/xfree86/common/xf86Events.c | 28 +++--------- hw/xfree86/common/xf86Init.c | 18 ++++---- hw/xfree86/common/xf86Priv.h | 2 +- include/os.h | 2 + os/log.c | 7 +++ os/osinit.c | 83 ++++++++++++++++++++++++++++++++++ 7 files changed, 113 insertions(+), 61 deletions(-) diff --git a/hw/kdrive/src/kdrive.c b/hw/kdrive/src/kdrive.c index 76355e8a1..ccef2a0c8 100644 --- a/hw/kdrive/src/kdrive.c +++ b/hw/kdrive/src/kdrive.c @@ -1279,38 +1279,12 @@ KdDepthToFb (ScreenPtr pScreen, int depth) #endif -#ifdef HAVE_BACKTRACE -/* shamelessly ripped from xf86Events.c */ -void -KdBacktrace (int signum) -{ - void *array[32]; /* more than 32 and you have bigger problems */ - size_t size, i; - char **strings; - - signal(signum, SIG_IGN); - - size = backtrace (array, 32); - fprintf (stderr, "\nBacktrace (%d deep):\n", size); - strings = backtrace_symbols (array, size); - for (i = 0; i < size; i++) - fprintf (stderr, "%d: %s\n", i, strings[i]); - free (strings); - - kdCaughtSignal = TRUE; - if (signum == SIGSEGV) - FatalError("Segmentation fault caught\n"); - else if (signum > 0) - FatalError("Signal %d caught\n", signum); -} -#else -void -KdBacktrace (int signum) +static int +KdSignalWrapper (int signum) { kdCaughtSignal = TRUE; - FatalError("Segmentation fault caught\n"); + return 1; /* use generic OS layer cleanup & abort */ } -#endif void KdInitOutput (ScreenInfo *pScreenInfo, @@ -1357,7 +1331,7 @@ KdInitOutput (ScreenInfo *pScreenInfo, for (screen = card->screenList; screen; screen = screen->next) KdAddScreen (pScreenInfo, screen, argc, argv); - signal(SIGSEGV, KdBacktrace); + OsRegisterSigWrapper(KdSignalWrapper); } void diff --git a/hw/xfree86/common/xf86Events.c b/hw/xfree86/common/xf86Events.c index 19120cede..aa818c358 100644 --- a/hw/xfree86/common/xf86Events.c +++ b/hw/xfree86/common/xf86Events.c @@ -79,11 +79,6 @@ #include "xkbsrv.h" #include "xkbstr.h" -#ifdef XF86BIGFONT -#define _XF86BIGFONT_SERVER_ -#include -#endif - #ifdef DPMSExtension #define DPMS_SERVER #include @@ -356,35 +351,24 @@ xf86InterceptSigIll(void (*sigillhandler)(void)) } /* - * xf86SigHandler -- + * xf86SigWrapper -- * Catch unexpected signals and exit or continue cleanly. */ -void -xf86SigHandler(int signo) +int +xf86SigWrapper(int signo) { if ((signo == SIGILL) && xf86SigIllHandler) { (*xf86SigIllHandler)(); - /* Re-arm handler just in case we unexpectedly return here */ - (void) signal(signo, xf86SigHandler); - return; + return 0; /* continue */ } if (xf86SignalIntercept && (*xf86SignalIntercept < 0)) { *xf86SignalIntercept = signo; - /* Re-arm handler just in case */ - (void) signal(signo, xf86SigHandler); - return; + return 0; /* continue */ } - signal(signo,SIG_IGN); xf86Info.caughtSignal = TRUE; -#ifdef XF86BIGFONT - XF86BigfontCleanup(); -#endif - - xorg_backtrace(); - - FatalError("Caught signal %d. Server aborting\n", signo); + return 1; /* abort */ } /* diff --git a/hw/xfree86/common/xf86Init.c b/hw/xfree86/common/xf86Init.c index acb775bbe..cf28ae73e 100644 --- a/hw/xfree86/common/xf86Init.c +++ b/hw/xfree86/common/xf86Init.c @@ -380,23 +380,25 @@ InstallSignalHandlers(void) */ xf86Info.caughtSignal=FALSE; if (!xf86Info.notrapSignals) { - signal(SIGSEGV,xf86SigHandler); - signal(SIGILL,xf86SigHandler); + OsRegisterSigWrapper(xf86SigWrapper); + } else { + signal(SIGSEGV, SIG_DFL); + signal(SIGILL, SIG_DFL); #ifdef SIGEMT - signal(SIGEMT,xf86SigHandler); + signal(SIGEMT, SIG_DFL); #endif - signal(SIGFPE,xf86SigHandler); + signal(SIGFPE, SIG_DFL); #ifdef SIGBUS - signal(SIGBUS,xf86SigHandler); + signal(SIGBUS, SIG_DFL); #endif #ifdef SIGSYS - signal(SIGSYS,xf86SigHandler); + signal(SIGSYS, SIG_DFL); #endif #ifdef SIGXCPU - signal(SIGXCPU,xf86SigHandler); + signal(SIGXCPU, SIG_DFL); #endif #ifdef SIGXFSZ - signal(SIGXFSZ,xf86SigHandler); + signal(SIGXFSZ, SIG_DFL); #endif } } diff --git a/hw/xfree86/common/xf86Priv.h b/hw/xfree86/common/xf86Priv.h index bc984f2f7..f4ed8c085 100644 --- a/hw/xfree86/common/xf86Priv.h +++ b/hw/xfree86/common/xf86Priv.h @@ -147,7 +147,7 @@ extern _X_EXPORT void DoShowOptions(void); /* xf86Events.c */ extern _X_EXPORT void xf86Wakeup(pointer blockData, int err, pointer pReadmask); -extern _X_EXPORT void xf86SigHandler(int signo); +extern _X_HIDDEN int xf86SigWrapper(int signo); extern _X_EXPORT void xf86HandlePMEvents(int fd, pointer data); extern _X_EXPORT int (*xf86PMGetEventFromOs)(int fd,pmEvent *events,int num); extern _X_EXPORT pmWait (*xf86PMConfirmEventToOs)(int fd,pmEvent event); diff --git a/include/os.h b/include/os.h index bda7125a0..2f6b0c06f 100644 --- a/include/os.h +++ b/include/os.h @@ -228,8 +228,10 @@ extern _X_EXPORT char *XNFprintf(const char *fmt, ...); extern _X_EXPORT char *XNFvprintf(const char *fmt, va_list va); typedef void (*OsSigHandlerPtr)(int /* sig */); +typedef int (*OsSigWrapperPtr)(int /* sig */); extern _X_EXPORT OsSigHandlerPtr OsSignal(int /* sig */, OsSigHandlerPtr /* handler */); +extern _X_EXPORT OsSigWrapperPtr OsRegisterSigWrapper(OsSigWrapperPtr newWrap); extern _X_EXPORT int auditTrailLevel; diff --git a/os/log.c b/os/log.c index b01965a17..3961b0b9f 100644 --- a/os/log.c +++ b/os/log.c @@ -98,6 +98,10 @@ OR PERFORMANCE OF THIS SOFTWARE. #define getpid(x) _getpid(x) #endif +#ifdef XF86BIGFONT +#define _XF86BIGFONT_SERVER_ +#include +#endif #ifdef DDXOSVERRORF void (*OsVendorVErrorFProc)(const char *, va_list args) = NULL; @@ -401,6 +405,9 @@ void AbortServer(void) __attribute__((noreturn)); void AbortServer(void) { +#ifdef XF86BIGFONT + XF86BigfontCleanup(); +#endif CloseWellKnownConnections(); OsCleanup(TRUE); CloseDownDevices(); diff --git a/os/osinit.c b/os/osinit.c index f9ee73ec1..34d8378a6 100644 --- a/os/osinit.c +++ b/os/osinit.c @@ -54,6 +54,8 @@ SOFTWARE. #include "os.h" #include "osdep.h" #include +#include +#include #include "dixstruct.h" @@ -88,6 +90,58 @@ int limitStackSpace = -1; int limitNoFile = -1; #endif +static OsSigWrapperPtr OsSigWrapper = NULL; + +OsSigWrapperPtr +OsRegisterSigWrapper(OsSigWrapperPtr newSigWrapper) +{ + OsSigWrapperPtr oldSigWrapper = OsSigWrapper; + + OsSigWrapper = newSigWrapper; + + return oldSigWrapper; +} + +/* + * OsSigHandler -- + * Catch unexpected signals and exit or continue cleanly. + */ +static void +#ifdef SA_SIGINFO +OsSigHandler(int signo, siginfo_t *sip, void *unused) +#else +OsSigHandler(int signo) +#endif +{ + if (OsSigWrapper != NULL) { + if (OsSigWrapper(signo) == 0) { + /* ddx handled signal and wants us to continue */ + return; + } + } + + /* log, cleanup, and abort */ + xorg_backtrace(); + +#ifdef SA_SIGINFO + if (sip->si_code == SI_USER) { + ErrorF("Recieved signal %d sent by process %ld, uid %ld\n", + (long) sip->si_pid, (long) sip->si_uid); + } else { + switch (signo) { + case SIGSEGV: + case SIGBUS: + case SIGILL: + case SIGFPE: + ErrorF("%s at address %p\n", strsignal(signo), sip->si_addr); + } + } +#endif + + FatalError("Caught signal %d (%s). Server aborting\n", + signo, strsignal(signo)); +} + void OsInit(void) { @@ -97,6 +151,35 @@ OsInit(void) char fname[PATH_MAX]; if (!been_here) { + struct sigaction act, oact; + int i; + int siglist[] = { SIGSEGV, SIGQUIT, SIGILL, SIGFPE, SIGBUS, +#ifdef SIGSYS + SIGSYS, +#endif +#ifdef SIGXCPU + SIGXCPU, +#endif +#ifdef SIGXFSZ + SIGXFSZ, +#endif +#ifdef SIGEMT + SIGEMT, +#endif + 0 /* must be last */ }; + sigemptyset(&act.sa_mask); + act.sa_handler = OsSigHandler; + act.sa_flags = 0; +#ifdef SA_SIGINFO + act.sa_flags |= SA_SIGINFO; +#endif + for (i = 0; siglist[i] != 0; i++) { + if (sigaction(siglist[i], &act, &oact)) { + ErrorF("failed to install signal handler for signal %d: %s\n", + siglist[i], strerror(errno)); + } + } + #if !defined(__SCO__) && !defined(__CYGWIN__) && !defined(__UNIXWARE__) fclose(stdin); fclose(stdout); From 98f4179156391752e6688339487458ad7828abf4 Mon Sep 17 00:00:00 2001 From: Alan Coopersmith Date: Thu, 26 Mar 2009 23:04:24 -0700 Subject: [PATCH 21/67] Use RTLD_DI_SETSIGNAL to catch runtime dynamic loader errors and clean up Based on fix for Sun bug 6813925: Xorg needs to catch ld.so.1 failure so it can close down devices cleanly Signed-off-by: Alan Coopersmith --- configure.ac | 2 +- os/osinit.c | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index f4e1dbb04..93ef0bd23 100644 --- a/configure.ac +++ b/configure.ac @@ -105,7 +105,7 @@ AM_CONDITIONAL(XSERVER_DTRACE, [test "x$WDTRACE" != "xno"]) AC_HEADER_DIRENT AC_HEADER_STDC -AC_CHECK_HEADERS([fcntl.h stdlib.h string.h unistd.h]) +AC_CHECK_HEADERS([fcntl.h stdlib.h string.h unistd.h dlfcn.h]) dnl Checks for typedefs, structures, and compiler characteristics. AC_C_CONST diff --git a/os/osinit.c b/os/osinit.c index 34d8378a6..b7bd0763b 100644 --- a/os/osinit.c +++ b/os/osinit.c @@ -56,6 +56,9 @@ SOFTWARE. #include #include #include +#ifdef HAVE_DLFCN_H +# include +#endif #include "dixstruct.h" @@ -113,6 +116,14 @@ OsSigHandler(int signo, siginfo_t *sip, void *unused) OsSigHandler(int signo) #endif { +#ifdef RTLD_DI_SETSIGNAL + const char *dlerr = dlerror(); + + if (dlerr) { + LogMessage(X_ERROR, "Dynamic loader error: %s\n", dlerr); + } +#endif /* RTLD_DI_SETSIGNAL */ + if (OsSigWrapper != NULL) { if (OsSigWrapper(signo) == 0) { /* ddx handled signal and wants us to continue */ @@ -180,6 +191,15 @@ OsInit(void) } } +#ifdef RTLD_DI_SETSIGNAL + /* Tell runtime linker to send a signal we can catch instead of SIGKILL + * for failures to load libraries/modules at runtime so we can clean up + * after ourselves. + */ + int failure_signal = SIGQUIT; + dlinfo(RTLD_SELF, RTLD_DI_SETSIGNAL, &failure_signal); +#endif + #if !defined(__SCO__) && !defined(__CYGWIN__) && !defined(__UNIXWARE__) fclose(stdin); fclose(stdout); From 06aebecb19dd9d90d73b742a09b6068b862f1d05 Mon Sep 17 00:00:00 2001 From: Simon Thum Date: Wed, 8 Apr 2009 14:35:01 +0200 Subject: [PATCH 22/67] dix: fix pointer accelerations remainder handling This didn't really work as intended, but did amazingly well thanks to roundf() hiding the defect. Cheers! Signed-off-by: Peter Hutterer --- dix/ptrveloc.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/dix/ptrveloc.c b/dix/ptrveloc.c index a3a04512f..fc1d1210b 100644 --- a/dix/ptrveloc.c +++ b/dix/ptrveloc.c @@ -950,7 +950,7 @@ acceleratePointerPredictable( int *px = NULL, *py = NULL; DeviceVelocityPtr velocitydata = (DeviceVelocityPtr) pDev->valuator->accelScheme.accelData; - float fdx, fdy; /* no need to init */ + float fdx, fdy, tmp; /* no need to init */ Bool soften = TRUE; if (!num_valuators || !valuators || !velocitydata) @@ -991,14 +991,14 @@ acceleratePointerPredictable( (mult > 1.0) && soften); if (dx) { - pDev->last.remainder[0] = roundf(mult * fdx + pDev->last.remainder[0]); - *px = (int)pDev->last.remainder[0]; - pDev->last.remainder[0] = pDev->last.remainder[0] - (float)*px; + tmp = mult * fdx + pDev->last.remainder[0]; + *px = (int)roundf(tmp); + pDev->last.remainder[0] = tmp - (float)*px; } if (dy) { - pDev->last.remainder[1] = roundf(mult * fdy + pDev->last.remainder[1]); - *py = (int)pDev->last.remainder[1]; - pDev->last.remainder[1] = pDev->last.remainder[1] - (float)*py; + tmp = mult * fdy + pDev->last.remainder[1]; + *py = (int)roundf(tmp); + pDev->last.remainder[1] = tmp - (float)*py; } } } From ff7f019bbcbc52618cc478db7baed57aa5b7c3d3 Mon Sep 17 00:00:00 2001 From: Simon Thum Date: Wed, 1 Apr 2009 10:53:10 +0200 Subject: [PATCH 23/67] dix: correctly utilize tracker buffer and protect from timer overruns two small related fixes hard to split up Signed-off-by: Peter Hutterer --- dix/ptrveloc.c | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/dix/ptrveloc.c b/dix/ptrveloc.c index fc1d1210b..99efc794c 100644 --- a/dix/ptrveloc.c +++ b/dix/ptrveloc.c @@ -98,7 +98,7 @@ InitVelocityData(DeviceVelocityPtr s) s->min_acceleration = 1.0; /* don't decelerate */ s->max_rel_diff = 0.2; s->max_diff = 1.0; - s->initial_range = 1; + s->initial_range = 2; s->average_accel = TRUE; SetAccelerationProfile(s, AccelProfileClassic); InitTrackers(s, 16); @@ -445,8 +445,8 @@ FeedTrackers(DeviceVelocityPtr s, int dx, int dy, int cur_t) s->tracker[n].dy += dy; } n = (s->cur_tracker + 1) % s->num_tracker; - s->tracker[n].dx = dx; - s->tracker[n].dy = dy; + s->tracker[n].dx = 0; + s->tracker[n].dy = 0; s->tracker[n].time = cur_t; s->tracker[n].dir = GetDirection(dx, dy); DebugAccelF("(dix prtacc) motion [dx: %i dy: %i dir:%i diff: %i]\n", @@ -465,7 +465,7 @@ CalcTracker(DeviceVelocityPtr s, int offset, int cur_t){ int index = TRACKER_INDEX(s, offset); float dist = sqrt( s->tracker[index].dx * s->tracker[index].dx + s->tracker[index].dy * s->tracker[index].dy); - int dtime = cur_t - s->tracker[TRACKER_INDEX(s, offset+1)].time; + int dtime = cur_t - s->tracker[index].time; if(dtime > 0) return (dist / dtime); else @@ -476,20 +476,22 @@ CalcTracker(DeviceVelocityPtr s, int offset, int cur_t){ * (in time) tracker which isn't too old, beyond a linear partition, * or simply too much off initial velocity. * - * min_t should be (now - ~100-600 ms). May return 0. + * May return 0. */ static float -QueryTrackers(DeviceVelocityPtr s, int min_t, int cur_t){ - int n, offset, dir = 255, i = -1; +QueryTrackers(DeviceVelocityPtr s, int cur_t){ + int n, offset, dir = 255, i = -1, age_ms; /* initial velocity: a low-offset, valid velocity */ float iveloc = 0, res = 0, tmp, vdiff; float vfac = s->corr_mul * s->const_acceleration; /* premultiply */ /* loop from current to older data */ - for(offset = 0; offset < s->num_tracker-1; offset++){ + for(offset = 1; offset < s->num_tracker; offset++){ n = TRACKER_INDEX(s, offset); - /* bail out if data is too old */ - if(s->tracker[TRACKER_INDEX(s, offset+1)].time < min_t){ + age_ms = cur_t - s->tracker[n].time; + + /* bail out if data is too old and protect from overrun */ + if (age_ms >= s->reset_time || age_ms < 0) { DebugAccelF("(dix prtacc) query: tracker too old\n"); break; } @@ -566,7 +568,7 @@ ProcessVelocityData2D( FeedTrackers(s, dx, dy, time); - velocity = QueryTrackers(s, time - s->reset_time, time); + velocity = QueryTrackers(s, time); s->velocity = velocity; return velocity == 0; From 5ccfad8df099e8ebc4bf2dd53c3db1460903b135 Mon Sep 17 00:00:00 2001 From: Jeremy Huddleston Date: Mon, 6 Apr 2009 19:21:46 -0700 Subject: [PATCH 24/67] XQuartz: Revert most of the previous override redirect patch The changes actually caused all windows to move to the current space. Instead, we're going with a fix entirely within Xplugin that depends on quartz-wm being the window-manager for now. (cherry picked from commit 997b6f3142c622541bb5bac98652abae75d1101d) --- hw/xquartz/xpr/xprFrame.c | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/hw/xquartz/xpr/xprFrame.c b/hw/xquartz/xpr/xprFrame.c index a7fc3a9e7..a45290e20 100644 --- a/hw/xquartz/xpr/xprFrame.c +++ b/hw/xquartz/xpr/xprFrame.c @@ -257,22 +257,12 @@ xprRestackFrame(RootlessFrameID wid, RootlessFrameID nextWid) if (nextWid == NULL) { -#if defined(XPLUGIN_VERSION) && XPLUGIN_VERSION >= 3 - WindowPtr pWin = xprGetXWindow((xp_window_id)wid); - wc.stack_mode = (pWin && pWin->overrideRedirect) ? XP_MAPPED_ABOVE_CURRENT_SPACE : XP_MAPPED_ABOVE; -#else wc.stack_mode = XP_MAPPED_ABOVE; -#endif wc.sibling = 0; } else { -#if defined(XPLUGIN_VERSION) && XPLUGIN_VERSION >= 3 - WindowPtr pWin = xprGetXWindow((xp_window_id)wid); - wc.stack_mode = (pWin && pWin->overrideRedirect) ? XP_MAPPED_BELOW_CURRENT_SPACE : XP_MAPPED_BELOW; -#else wc.stack_mode = XP_MAPPED_BELOW; -#endif wc.sibling = x_cvt_vptr_to_uint(nextWid); } From e86f4e93020d56385418850a9eebae8076dcb9ac Mon Sep 17 00:00:00 2001 From: Jeremy Huddleston Date: Mon, 6 Apr 2009 21:34:14 -0700 Subject: [PATCH 25/67] XQuartz: Send MotionNotify before button presses when X11 is in the background (cherry picked from commit c80d0ec18ef5b842447d31360406d0b5b9424222) --- hw/xquartz/X11Application.m | 49 +++++++++++++++++++++++-------------- 1 file changed, 30 insertions(+), 19 deletions(-) diff --git a/hw/xquartz/X11Application.m b/hw/xquartz/X11Application.m index 937517c6e..441748101 100644 --- a/hw/xquartz/X11Application.m +++ b/hw/xquartz/X11Application.m @@ -1054,8 +1054,7 @@ static inline int ensure_flag(int flags, int device_independent, int device_depe * NSTabletProximityEventSubtype will come from NSTabletPoint * rather than NSMouseMoved. pressure = [e pressure]; - tilt_x = [e tilt].x; - tilt_y = [e tilt].y; + tilt = [e tilt]; pDev = darwinTabletCurrent; */ @@ -1071,6 +1070,7 @@ static inline int ensure_flag(int flags, int device_independent, int device_depe } if(!quartzServerVisible && noTestExtensions) { + if(ev_button == 0) { #if 0 /* Seems this has somehow triggered 100% CPU usage while X11.app is in the * background on some obscure HW configurations. @@ -1078,28 +1078,29 @@ static inline int ensure_flag(int flags, int device_independent, int device_depe */ //#if defined(XPLUGIN_VERSION) && XPLUGIN_VERSION > 0 /* Older libXplugin (Tiger/"Stock" Leopard) aren't thread safe, so we can't call xp_find_window from the Appkit thread */ - xp_window_id wid; - xp_error e; + xp_window_id wid = 0; + xp_error e; - /* Sigh. Need to check that we're really over one of - * our windows. (We need to receive pointer events while - * not in the foreground, but we don't want to receive them - * when another window is over us or we might show a tooltip) - */ + /* Sigh. Need to check that we're really over one of + * our windows. (We need to receive pointer events while + * not in the foreground, but we don't want to receive them + * when another window is over us or we might show a tooltip) + */ - wid = 0; - e = xp_find_window(location.x, location.y, 0, &wid); + e = xp_find_window(location.x, location.y, 0, &wid); - if (e == XP_Success && wid == 0) { - bgMouseLocation = location; - return; - } -#else - bgMouseLocation = location; - return; + if (e == XP_Success && wid == 0) #endif + { + bgMouseLocation = location; + return; + } + } else { + DarwinSendPointerEvents(pDev, MotionNotify, 0, location.x, + location.y, pressure, tilt.x, tilt.y); + } } - + DarwinSendPointerEvents(pDev, ev_type, ev_button, location.x, location.y, pressure, tilt.x, tilt.y); @@ -1125,6 +1126,16 @@ static inline int ensure_flag(int flags, int device_independent, int device_depe break; case NSScrollWheel: +//#if !defined(XPLUGIN_VERSION) || XPLUGIN_VERSION == 0 +#if 1 /* Strange 100% CPU issue, so always enabling. see above */ + /* If we're in the background, we need to send a MotionNotify event + * first, since we aren't getting them on background mouse motion + */ + if(!quartzServerVisible && noTestExtensions) { + DarwinSendPointerEvents(darwinPointer, MotionNotify, 0, location.x, + location.y, pressure, tilt.x, tilt.y); + } +#endif DarwinSendScrollEvents([e deltaX], [e deltaY], location.x, location.y, pressure, tilt.x, tilt.y); break; From 82d7cf5cdcbc5e451a87f8c2f64cd5d2e3627d54 Mon Sep 17 00:00:00 2001 From: Jeremy Huddleston Date: Thu, 9 Apr 2009 03:55:13 -0700 Subject: [PATCH 26/67] XQuartz: In rooted mode, make sure we start in the hidden state. (cherry picked from commit 5ecc497f71c2133f773f6c56ad76cb778862ddd6) --- hw/xquartz/xpr/xprScreen.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/hw/xquartz/xpr/xprScreen.c b/hw/xquartz/xpr/xprScreen.c index da262f654..1fac9ec60 100644 --- a/hw/xquartz/xpr/xprScreen.c +++ b/hw/xquartz/xpr/xprScreen.c @@ -256,6 +256,9 @@ xprDisplayInit(void) AppleDRIExtensionInit(); xprAppleWMInit(); + + if (!quartzEnableRootless) + RootlessHideAllWindows(); } /* From 8d5dcfe2154f217bd8fde5509d78f3383add8725 Mon Sep 17 00:00:00 2001 From: Jeremy Huddleston Date: Thu, 9 Apr 2009 04:36:26 -0700 Subject: [PATCH 27/67] XQuartz: Properly set the menu bar and hotkey state when changing rootless mode. Currently no code path exhibits the broken behavior since we only toggle into rootless if we don't have the root. (cherry picked from commit 970f100ca3c5fc0662ae7658d49d118fbd9de943) --- hw/xquartz/quartz.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/hw/xquartz/quartz.c b/hw/xquartz/quartz.c index 0de63b642..344edec54 100644 --- a/hw/xquartz/quartz.c +++ b/hw/xquartz/quartz.c @@ -352,13 +352,20 @@ void QuartzSetRootless(Bool state) { /* When in rootless, the menubar is not part of the screen, so we need to update our screens on toggle */ QuartzUpdateScreens(); - if (!quartzEnableRootless && !quartzHasRoot) { - RootlessHideAllWindows(); - } else if (quartzEnableRootless && !quartzHasRoot) { - RootlessShowAllWindows(); + if(!quartzHasRoot) { + if(!quartzEnableRootless) { + RootlessHideAllWindows(); + } else { + RootlessShowAllWindows(); + } } + X11ApplicationShowHideMenubar(!quartzHasRoot); + xp_reenable_update(); + + if (!quartzEnableRootless && quartzFullscreenDisableHotkeys) + xp_disable_hot_keys(quartzHasRoot); } /* From 15146b863759640e7a73fab2301fb28ef4dead84 Mon Sep 17 00:00:00 2001 From: Jeremy Huddleston Date: Thu, 9 Apr 2009 17:47:41 -0700 Subject: [PATCH 28/67] XQuartz: Properly set the window level for the root window (cherry picked from commit bdf9286d1cbfeaaf8eaf03d28091e91ee587ee25) --- hw/xquartz/xpr/xpr.h | 13 +++++++++++++ hw/xquartz/xpr/xprAppleWM.c | 13 +------------ hw/xquartz/xpr/xprFrame.c | 7 +++++++ miext/rootless/rootlessWindow.c | 8 -------- 4 files changed, 21 insertions(+), 20 deletions(-) diff --git a/hw/xquartz/xpr/xpr.h b/hw/xquartz/xpr/xpr.h index ab79a42cd..a93b83753 100644 --- a/hw/xquartz/xpr/xpr.h +++ b/hw/xquartz/xpr/xpr.h @@ -47,4 +47,17 @@ Bool QuartzInitCursor(ScreenPtr pScreen); void QuartzSuspendXCursor(ScreenPtr pScreen); void QuartzResumeXCursor(ScreenPtr pScreen, int x, int y); +/* This lookup table came straight from the Tiger X11 source. I tried to figure + * it out based on CGWindowLevel.h, but I dunno... -JH + */ + +#define _APPLEWM_SERVER_ +#include +static const int normal_window_levels[AppleWMNumWindowLevels+1] = { +0, 3, 4, 5, INT_MIN + 30, INT_MIN + 29, +}; +static const int rooted_window_levels[AppleWMNumWindowLevels+1] = { +202, 203, 204, 205, 201, 200 +}; + #endif /* XPR_H */ diff --git a/hw/xquartz/xpr/xprAppleWM.c b/hw/xquartz/xpr/xprAppleWM.c index fb506986c..b13db0637 100644 --- a/hw/xquartz/xpr/xprAppleWM.c +++ b/hw/xquartz/xpr/xprAppleWM.c @@ -43,16 +43,6 @@ #include "quartz.h" #include "x-hash.h" -/* This lookup table came straight from the Tiger X11 source. I tried to figure - * it out based on CGWindowLevel.h, but I dunno... -JH - */ -static const int normal_window_levels[AppleWMNumWindowLevels+1] = { -0, 3, 4, 5, INT_MIN + 30, INT_MIN + 29, -}; -static const int rooted_window_levels[AppleWMNumWindowLevels+1] = { -202, 203, 204, 205, 201, 200 -}; - static int xprSetWindowLevel( WindowPtr pWin, int level) @@ -66,8 +56,7 @@ static int xprSetWindowLevel( RootlessStopDrawing (pWin, FALSE); - //if (WINREC(WindowTable[pWin->drawable.pScreen->myNum]) == NULL) - if (quartzHasRoot) + if(quartzEnableRootless) wc.window_level = normal_window_levels[level]; else wc.window_level = rooted_window_levels[level]; diff --git a/hw/xquartz/xpr/xprFrame.c b/hw/xquartz/xpr/xprFrame.c index a45290e20..ba697ac62 100644 --- a/hw/xquartz/xpr/xprFrame.c +++ b/hw/xquartz/xpr/xprFrame.c @@ -42,6 +42,7 @@ #include "dix.h" #include #include "windowstr.h" +#include "quartz.h" #include "threadSafety.h" @@ -161,6 +162,12 @@ xprCreateFrame(RootlessWindowPtr pFrame, ScreenPtr pScreen, mask |= XP_SHAPE; } + if(quartzEnableRootless) + wc.window_level = normal_window_levels[!IsRoot (pWin) ? AppleWMWindowLevelNormal : AppleWMNumWindowLevels]; + else + wc.window_level = rooted_window_levels[!IsRoot (pWin) ? AppleWMWindowLevelNormal : AppleWMNumWindowLevels]; + mask |= XP_WINDOW_LEVEL; + err = xp_create_window(mask, &wc, (xp_window_id *) &pFrame->wid); if (err != Success) diff --git a/miext/rootless/rootlessWindow.c b/miext/rootless/rootlessWindow.c index 5ce26bd2f..7bd7f18bb 100644 --- a/miext/rootless/rootlessWindow.c +++ b/miext/rootless/rootlessWindow.c @@ -48,8 +48,6 @@ extern int darwinMainScreenX, darwinMainScreenY; #endif #include "fb.h" -#define AppleWMNumWindowLevels 5 - #include "rootlessCommon.h" #include "rootlessWindow.h" @@ -105,12 +103,6 @@ current_time_in_seconds (void) return t; } */ -static inline Bool -rootlessHasRoot (ScreenPtr pScreen) -{ - return WINREC (WindowTable[pScreen->myNum]) != NULL; -} - void RootlessNativeWindowStateChanged (WindowPtr pWin, unsigned int state) { From d5ef88d7543ed787093099ab18db766c446b47d1 Mon Sep 17 00:00:00 2001 From: Jeremy Huddleston Date: Thu, 9 Apr 2009 18:27:22 -0700 Subject: [PATCH 29/67] XQuartz: Fix window levels for rooted mode to allow showing the menu bar. (cherry picked from commit 80759a4186bf0335edc85aecea2faf11fe09f491) --- hw/xquartz/xpr/xpr.h | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/hw/xquartz/xpr/xpr.h b/hw/xquartz/xpr/xpr.h index a93b83753..b329ca118 100644 --- a/hw/xquartz/xpr/xpr.h +++ b/hw/xquartz/xpr/xpr.h @@ -47,8 +47,10 @@ Bool QuartzInitCursor(ScreenPtr pScreen); void QuartzSuspendXCursor(ScreenPtr pScreen); void QuartzResumeXCursor(ScreenPtr pScreen, int x, int y); -/* This lookup table came straight from the Tiger X11 source. I tried to figure - * it out based on CGWindowLevel.h, but I dunno... -JH +/* If we are rooted, we need the root window and desktop levels to be below + * the menubar (24) but above native windows. Normal window level is 0. + * Floating window level is 3. The rest are filled in as appropriate. + * See CGWindowLevel.h */ #define _APPLEWM_SERVER_ @@ -57,7 +59,7 @@ static const int normal_window_levels[AppleWMNumWindowLevels+1] = { 0, 3, 4, 5, INT_MIN + 30, INT_MIN + 29, }; static const int rooted_window_levels[AppleWMNumWindowLevels+1] = { -202, 203, 204, 205, 201, 200 +20, 21, 22, 23, 19, 18, }; #endif /* XPR_H */ From dfb0d7aefbbdfc0db966e3a84d52f638135d9138 Mon Sep 17 00:00:00 2001 From: Jeremy Huddleston Date: Thu, 9 Apr 2009 18:51:22 -0700 Subject: [PATCH 30/67] XQuartz: Update window levels when changing rootless state (cherry picked from commit 1359ded5bfc14a80fb998b01a54ecacb96c4ff88) --- hw/xquartz/xpr/xprFrame.c | 34 +++++++++++++++++++++------------ miext/rootless/rootless.h | 1 + miext/rootless/rootlessWindow.c | 1 + 3 files changed, 24 insertions(+), 12 deletions(-) diff --git a/hw/xquartz/xpr/xprFrame.c b/hw/xquartz/xpr/xprFrame.c index ba697ac62..6635f08d8 100644 --- a/hw/xquartz/xpr/xprFrame.c +++ b/hw/xquartz/xpr/xprFrame.c @@ -162,10 +162,12 @@ xprCreateFrame(RootlessWindowPtr pFrame, ScreenPtr pScreen, mask |= XP_SHAPE; } + pFrame->level = !IsRoot (pWin) ? AppleWMWindowLevelNormal : AppleWMNumWindowLevels; + if(quartzEnableRootless) - wc.window_level = normal_window_levels[!IsRoot (pWin) ? AppleWMWindowLevelNormal : AppleWMNumWindowLevels]; + wc.window_level = normal_window_levels[pFrame->level]; else - wc.window_level = rooted_window_levels[!IsRoot (pWin) ? AppleWMWindowLevelNormal : AppleWMNumWindowLevels]; + wc.window_level = rooted_window_levels[pFrame->level]; mask |= XP_WINDOW_LEVEL; err = xp_create_window(mask, &wc, (xp_window_id *) &pFrame->wid); @@ -252,28 +254,36 @@ xprResizeFrame(RootlessFrameID wid, ScreenPtr pScreen, /* * Change frame stacking. */ -static void -xprRestackFrame(RootlessFrameID wid, RootlessFrameID nextWid) -{ +static void xprRestackFrame(RootlessFrameID wid, RootlessFrameID nextWid) { xp_window_changes wc; + unsigned int mask = XP_STACKING; TA_SERVER(); - /* Stack frame below nextWid it if it exists, or raise + /* Stack frame below nextWid it if it exists, or raise frame above everything otherwise. */ - if (nextWid == NULL) - { + if(nextWid == NULL) { wc.stack_mode = XP_MAPPED_ABOVE; wc.sibling = 0; - } - else - { + } else { wc.stack_mode = XP_MAPPED_BELOW; wc.sibling = x_cvt_vptr_to_uint(nextWid); } - xprConfigureWindow(x_cvt_vptr_to_uint(wid), XP_STACKING, &wc); + if(window_hash) { + RootlessWindowRec *winRec = x_hash_table_lookup(window_hash, x_cvt_uint_to_vptr((xp_window_id)wid), NULL); + + if(winRec) { + if(quartzEnableRootless) + wc.window_level = normal_window_levels[winRec->level]; + else + wc.window_level = rooted_window_levels[winRec->level]; + mask |= XP_WINDOW_LEVEL; + } + } + + xprConfigureWindow(x_cvt_vptr_to_uint(wid), mask, &wc); } diff --git a/miext/rootless/rootless.h b/miext/rootless/rootless.h index 5224dca2b..bde4cff52 100644 --- a/miext/rootless/rootless.h +++ b/miext/rootless/rootless.h @@ -57,6 +57,7 @@ typedef struct _RootlessWindowRec { int x, y; unsigned int width, height; unsigned int borderWidth; + int level; RootlessFrameID wid; // implementation specific frame id WindowPtr win; // underlying X window diff --git a/miext/rootless/rootlessWindow.c b/miext/rootless/rootlessWindow.c index 7bd7f18bb..b173cef70 100644 --- a/miext/rootless/rootlessWindow.c +++ b/miext/rootless/rootlessWindow.c @@ -478,6 +478,7 @@ RootlessEnsureFrame(WindowPtr pWin) winRec->is_reorder_pending = FALSE; winRec->pixmap = NULL; winRec->wid = NULL; + winRec->level = 0; SETWINREC(pWin, winRec); From 808fd2c67f303cb721769375b11ce8b90ffc1909 Mon Sep 17 00:00:00 2001 From: Jeremy Huddleston Date: Thu, 9 Apr 2009 20:00:37 -0700 Subject: [PATCH 31/67] XQuartz: xprSetWindowLevel updated to store the level requested by the WM (cherry picked from commit c28c2ddc3a8f3c5b9beec396953bb3ac9ee4714b) --- hw/xquartz/xpr/xprAppleWM.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/hw/xquartz/xpr/xprAppleWM.c b/hw/xquartz/xpr/xprAppleWM.c index b13db0637..9c44e20a2 100644 --- a/hw/xquartz/xpr/xprAppleWM.c +++ b/hw/xquartz/xpr/xprAppleWM.c @@ -38,6 +38,7 @@ #include "applewmExt.h" #include "rootless.h" +#include "rootlessCommon.h" #include #include #include "quartz.h" @@ -49,13 +50,24 @@ static int xprSetWindowLevel( { xp_window_id wid; xp_window_changes wc; + RootlessWindowRec *winRec; + // AppleWMNumWindowLevels is allowed, but is only set by the server + // for the root window. + if (level < 0 || level >= AppleWMNumWindowLevels) { + return BadValue; + } + wid = x_cvt_vptr_to_uint(RootlessFrameForWindow (pWin, TRUE)); if (wid == 0) return BadWindow; RootlessStopDrawing (pWin, FALSE); - + winRec = WINREC(pWin); + + if(!winRec) + return BadWindow; + if(quartzEnableRootless) wc.window_level = normal_window_levels[level]; else @@ -65,6 +77,8 @@ static int xprSetWindowLevel( return BadValue; } + winRec->level = level; + return Success; } From aa2928325fe51d94a636dde9c090e8f54a311a12 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Wed, 8 Apr 2009 15:44:34 -0700 Subject: [PATCH 32/67] DRI2: Add fake front-buffer to request list for windows If a front-buffer is requested for a window, add the fake front-buffer to the list of requested buffers. Signed-off-by: Ian Romanick --- hw/xfree86/dri2/dri2.c | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/hw/xfree86/dri2/dri2.c b/hw/xfree86/dri2/dri2.c index 0f2e24b3f..351d02b7b 100644 --- a/hw/xfree86/dri2/dri2.c +++ b/hw/xfree86/dri2/dri2.c @@ -139,6 +139,42 @@ DRI2GetBuffers(DrawablePtr pDraw, int *width, int *height, DRI2ScreenPtr ds = DRI2GetScreen(pDraw->pScreen); DRI2DrawablePtr pPriv = DRI2GetDrawable(pDraw); DRI2BufferPtr buffers; + unsigned int temp_buf[32]; + unsigned int *temp = temp_buf; + + + /* If the drawable is a window and the front-buffer is requested, silently + * add the fake front-buffer to the list of requested attachments. The + * counting logic in the loop accounts for the case where the client + * requests both the fake and real front-buffer. + */ + if (pDraw->type == DRAWABLE_WINDOW) { + int need_fake_front = 0; + int i; + + if ((count + 1) > 32) { + temp = xalloc((count + 1) * sizeof(temp[0])); + } + + for (i = 0; i < count; i++) { + if (attachments[i] == DRI2BufferFrontLeft) { + need_fake_front++; + } + + if (attachments[i] == DRI2BufferFakeFrontLeft) { + need_fake_front--; + } + + temp[i] = attachments[i]; + } + + if (need_fake_front > 0) { + temp[i] = DRI2BufferFakeFrontLeft; + count++; + attachments = temp; + } + } + if (pPriv->buffers == NULL || pDraw->width != pPriv->width || pDraw->height != pPriv->height) @@ -151,6 +187,10 @@ DRI2GetBuffers(DrawablePtr pDraw, int *width, int *height, pPriv->height = pDraw->height; } + if (temp != temp_buf) { + xfree(temp); + } + *width = pPriv->width; *height = pPriv->height; *out_count = pPriv->bufferCount; From f1a995d1496d73741731e32f475097c44a8da972 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Thu, 9 Apr 2009 14:31:01 -0700 Subject: [PATCH 33/67] DRI2: Do not send the real front buffer of a window to the client Signed-off-by: Ian Romanick --- glx/glxdri2.c | 10 ++++++++++ hw/xfree86/dri2/dri2ext.c | 24 ++++++++++++++++++++++-- 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/glx/glxdri2.c b/glx/glxdri2.c index c896536c8..ea5b5ef72 100644 --- a/glx/glxdri2.c +++ b/glx/glxdri2.c @@ -406,6 +406,7 @@ dri2GetBuffers(__DRIdrawable *driDrawable, __GLXDRIdrawable *private = loaderPrivate; DRI2BufferPtr buffers; int i; + int skip = 0; buffers = DRI2GetBuffers(private->base.pDraw, width, height, attachments, count, out_count); @@ -420,6 +421,14 @@ dri2GetBuffers(__DRIdrawable *driDrawable, /* This assumes the DRI2 buffer attachment tokens matches the * __DRIbuffer tokens. */ for (i = 0; i < *out_count; i++) { + /* Do not send the real front buffer of a window to the client. + */ + if ((private->base.pDraw->type == DRAWABLE_WINDOW) + && (buffers[i].attachment == DRI2BufferFrontLeft)) { + skip++; + continue; + } + private->buffers[i].attachment = buffers[i].attachment; private->buffers[i].name = buffers[i].name; private->buffers[i].pitch = buffers[i].pitch; @@ -427,6 +436,7 @@ dri2GetBuffers(__DRIdrawable *driDrawable, private->buffers[i].flags = buffers[i].flags; } + *out_count -= skip; return private->buffers; } diff --git a/hw/xfree86/dri2/dri2ext.c b/hw/xfree86/dri2/dri2ext.c index d6e1c9689..503f82716 100644 --- a/hw/xfree86/dri2/dri2ext.c +++ b/hw/xfree86/dri2/dri2ext.c @@ -202,6 +202,7 @@ ProcDRI2GetBuffers(ClientPtr client) int i, status, width, height, count; unsigned int *attachments; xDRI2Buffer buffer; + int skip; REQUEST_FIXED_SIZE(xDRI2GetBuffersReq, stuff->count * 4); if (!validDrawable(client, stuff->drawable, &pDrawable, &status)) @@ -211,15 +212,34 @@ ProcDRI2GetBuffers(ClientPtr client) buffers = DRI2GetBuffers(pDrawable, &width, &height, attachments, stuff->count, &count); + skip = 0; + if (pDrawable->type == DRAWABLE_WINDOW) { + for (i = 0; i < count; i++) { + /* Do not send the real front buffer of a window to the client. + */ + if (buffers[i].attachment == DRI2BufferFrontLeft) { + skip++; + continue; + } + } + } + rep.type = X_Reply; - rep.length = count * sizeof(xDRI2Buffer) / 4; + rep.length = (count - skip) * sizeof(xDRI2Buffer) / 4; rep.sequenceNumber = client->sequence; rep.width = width; rep.height = height; - rep.count = count; + rep.count = count - skip; WriteToClient(client, sizeof(xDRI2GetBuffersReply), &rep); for (i = 0; i < count; i++) { + /* Do not send the real front buffer of a window to the client. + */ + if ((pDrawable->type == DRAWABLE_WINDOW) + && (buffers[i].attachment == DRI2BufferFrontLeft)) { + continue; + } + buffer.attachment = buffers[i].attachment; buffer.name = buffers[i].name; buffer.pitch = buffers[i].pitch; From 567cf67959b30432ae30f4851ec17b3a375ab838 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Thu, 9 Apr 2009 14:38:24 -0700 Subject: [PATCH 34/67] DRI2: Synchronize the contents of the real and fake front-buffers Signed-off-by: Ian Romanick --- hw/xfree86/dri2/dri2.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/hw/xfree86/dri2/dri2.c b/hw/xfree86/dri2/dri2.c index 351d02b7b..0b52a0f8c 100644 --- a/hw/xfree86/dri2/dri2.c +++ b/hw/xfree86/dri2/dri2.c @@ -141,6 +141,7 @@ DRI2GetBuffers(DrawablePtr pDraw, int *width, int *height, DRI2BufferPtr buffers; unsigned int temp_buf[32]; unsigned int *temp = temp_buf; + int have_fake_front = 0; /* If the drawable is a window and the front-buffer is requested, silently @@ -163,6 +164,7 @@ DRI2GetBuffers(DrawablePtr pDraw, int *width, int *height, if (attachments[i] == DRI2BufferFakeFrontLeft) { need_fake_front--; + have_fake_front = 1; } temp[i] = attachments[i]; @@ -171,6 +173,7 @@ DRI2GetBuffers(DrawablePtr pDraw, int *width, int *height, if (need_fake_front > 0) { temp[i] = DRI2BufferFakeFrontLeft; count++; + have_fake_front = 1; attachments = temp; } } @@ -195,6 +198,25 @@ DRI2GetBuffers(DrawablePtr pDraw, int *width, int *height, *height = pPriv->height; *out_count = pPriv->bufferCount; + + /* If the client is getting a fake front-buffer, pre-fill it with the + * contents of the real front-buffer. This ensures correct operation of + * applications that call glXWaitX before calling glDrawBuffer. + */ + if (have_fake_front) { + BoxRec box; + RegionRec region; + + box.x1 = 0; + box.y1 = 0; + box.x2 = pPriv->width; + box.y2 = pPriv->height; + REGION_INIT(pDraw->pScreen, ®ion, &box, 0); + + DRI2CopyRegion(pDraw, ®ion, DRI2BufferFakeFrontLeft, + DRI2BufferFrontLeft); + } + return pPriv->buffers; } From 1b5758bef0840c6614244e321790231b3c9477c9 Mon Sep 17 00:00:00 2001 From: Maarten Maathuis Date: Thu, 9 Apr 2009 15:45:57 +0200 Subject: [PATCH 35/67] exa: implement UTS based upload through CopyArea - Some image viewers (eog, gqview) trigger the CopyArea path of Xext/shm.c - I'm not aware of any code path that wouldn't like UTS and trigger this code. - miDoCopy should handle src coordinate clipping. - Overlapping blits are obviously not an issue (both would have to be offscreen or not). --- exa/exa_accel.c | 72 +++++++++++++++++++++++++++++++++++-------------- 1 file changed, 52 insertions(+), 20 deletions(-) diff --git a/exa/exa_accel.c b/exa/exa_accel.c index b1ab2d1d9..d284ff560 100644 --- a/exa/exa_accel.c +++ b/exa/exa_accel.c @@ -466,27 +466,59 @@ exaHWCopyNtoN (DrawablePtr pSrcDrawable, goto fallback; } - if (!exaPixmapIsOffscreen(pSrcPixmap) || - !exaPixmapIsOffscreen(pDstPixmap) || - !(*pExaScr->info->PrepareCopy) (pSrcPixmap, pDstPixmap, reverse ? -1 : 1, - upsidedown ? -1 : 1, - pGC ? pGC->alu : GXcopy, - pGC ? pGC->planemask : FB_ALLONES)) { + if (exaPixmapIsOffscreen(pDstPixmap)) { + /* Normal blitting. */ + if (exaPixmapIsOffscreen(pSrcPixmap)) { + if (!(*pExaScr->info->PrepareCopy) (pSrcPixmap, pDstPixmap, reverse ? -1 : 1, + upsidedown ? -1 : 1, + pGC ? pGC->alu : GXcopy, + pGC ? pGC->planemask : FB_ALLONES)) { + goto fallback; + } + + while (nbox--) + { + (*pExaScr->info->Copy) (pDstPixmap, + pbox->x1 + dx + src_off_x, + pbox->y1 + dy + src_off_y, + pbox->x1 + dst_off_x, pbox->y1 + dst_off_y, + pbox->x2 - pbox->x1, pbox->y2 - pbox->y1); + pbox++; + } + + (*pExaScr->info->DoneCopy) (pDstPixmap); + exaMarkSync (pDstDrawable->pScreen); + /* UTS: mainly for SHM PutImage's secondary path. */ + } else { + int bpp = pSrcDrawable->bitsPerPixel; + int src_stride = exaGetPixmapPitch(pSrcPixmap); + CARD8 *src = NULL; + + if (!pExaScr->info->UploadToScreen) + goto fallback; + + if (pSrcDrawable->bitsPerPixel != pDstDrawable->bitsPerPixel) + goto fallback; + + if (pSrcDrawable->bitsPerPixel < 8) + goto fallback; + + if (pGC && !(pGC->alu == GXcopy && EXA_PM_IS_SOLID(pSrcDrawable, pGC->planemask))) + goto fallback; + + while (nbox--) + { + src = pSrcExaPixmap->sys_ptr + (pbox->y1 + dy + src_off_y) * src_stride + (pbox->x1 + dx + src_off_x) * (bpp / 8); + if (!pExaScr->info->UploadToScreen(pDstPixmap, pbox->x1 + dst_off_x, + pbox->y1 + dst_off_y, pbox->x2 - pbox->x1, pbox->y2 - pbox->y1, + (char *) src, src_stride)) + goto fallback; + + pbox++; + } + } + } else goto fallback; - } - - while (nbox--) - { - (*pExaScr->info->Copy) (pDstPixmap, - pbox->x1 + dx + src_off_x, - pbox->y1 + dy + src_off_y, - pbox->x1 + dst_off_x, pbox->y1 + dst_off_y, - pbox->x2 - pbox->x1, pbox->y2 - pbox->y1); - pbox++; - } - - (*pExaScr->info->DoneCopy) (pDstPixmap); - exaMarkSync (pDstDrawable->pScreen); goto out; From bd1d9179094657865b0606ed0ac835a8b8df3be1 Mon Sep 17 00:00:00 2001 From: Jeremy Huddleston Date: Sat, 11 Apr 2009 13:53:38 -0700 Subject: [PATCH 36/67] XQuartz: Re-enable Fn as an option for 3button mouse simulation. Patch from Martin Otte (cherry picked from commit b5ec3be6b5449b5d575bc1472fdd1c9cb15cb8be) --- hw/xquartz/darwinEvents.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/hw/xquartz/darwinEvents.c b/hw/xquartz/darwinEvents.c index 7f0ff7e88..b69ed6a7e 100644 --- a/hw/xquartz/darwinEvents.c +++ b/hw/xquartz/darwinEvents.c @@ -154,7 +154,7 @@ int darwin_modifier_mask_list[] = { #else NX_CONTROLMASK, NX_SHIFTMASK, NX_COMMANDMASK, NX_ALTERNATEMASK, #endif - NX_ALPHASHIFTMASK, + NX_ALPHASHIFTMASK, NX_SECONDARYFNMASK 0 }; @@ -174,7 +174,10 @@ static void DarwinUpdateModifiers( } for(f=darwin_modifier_mask_list; *f; f++) - if(*f & flags && *f != NX_ALPHASHIFTMASK) { + /* NX_ALPHASHIFTMASK is handled above and NX_SECONDARYFNMASK is not + * mapped to a key (it is just useful for 3button mouse simulation + */ + if(*f & flags && *f != NX_ALPHASHIFTMASK && *f != NX_SECONDARYFNMASK) { key = DarwinModifierNXMaskToNXKey(*f); if(key == -1) ErrorF("DarwinUpdateModifiers: Unsupported NXMask: 0x%x\n", *f); From 5e55becddccc376ab7338789562ad6d6cd750de9 Mon Sep 17 00:00:00 2001 From: Jeremy Huddleston Date: Sat, 11 Apr 2009 14:23:41 -0700 Subject: [PATCH 37/67] XQuartz: Make sure the Fn doesn't trigger unneccessary calls to DarwinUpdateModKeys() (cherry picked from commit 70a18558c6b0a02b633fd8974f002cdf3cdc713e) --- hw/xquartz/X11Application.m | 12 +++------- hw/xquartz/darwinEvents.c | 45 +++++++++++++++++++++++-------------- hw/xquartz/darwinEvents.h | 12 ++++++++-- 3 files changed, 41 insertions(+), 28 deletions(-) diff --git a/hw/xquartz/X11Application.m b/hw/xquartz/X11Application.m index 441748101..f27894fdf 100644 --- a/hw/xquartz/X11Application.m +++ b/hw/xquartz/X11Application.m @@ -65,7 +65,6 @@ extern BOOL xpbproxy_init (void); /* Stuck modifier / button state... force release when we context switch */ static NSEventType keyState[NUM_KEYCODES]; -static int modifierFlagsMask; int X11EnableKeyEquivalents = TRUE, quartzFullscreenMenu = FALSE; int quartzHasRoot = FALSE, quartzEnableRootless = TRUE; @@ -207,7 +206,7 @@ static void message_kit_thread (SEL selector, NSObject *arg) { } } else { - if(darwin_modifier_flags) + if(darwin_all_modifier_flags) DarwinUpdateModKeys(0); for(i=0; i < NUM_KEYCODES; i++) { if(keyState[i] == NSKeyDown) { @@ -880,7 +879,6 @@ environment the next time you start X11?", @"Startup xinitrc dialog"); void X11ApplicationMain (int argc, char **argv, char **envp) { NSAutoreleasePool *pool; - int *p; #ifdef DEBUG while (access ("/tmp/x11-block", F_OK) == 0) sleep (1); @@ -925,10 +923,6 @@ void X11ApplicationMain (int argc, char **argv, char **envp) { fprintf(stderr, "X11ApplicationMain: Could not build a valid keymap.\n"); } - for(p=darwin_modifier_mask_list, modifierFlagsMask=0; *p; p++) { - modifierFlagsMask |= *p; - } - /* Tell the server thread that it can proceed */ QuartzInitServer(argc, argv, envp); @@ -1005,14 +999,14 @@ static inline int ensure_flag(int flags, int device_independent, int device_depe modifierFlags = ensure_flag(modifierFlags, NX_ALTERNATEMASK, NX_DEVICELALTKEYMASK | NX_DEVICERALTKEYMASK, NX_DEVICELALTKEYMASK); #endif - modifierFlags &= modifierFlagsMask; + modifierFlags &= darwin_all_modifier_mask; /* We don't receive modifier key events while out of focus, and 3button * emulation mucks this up, so we need to check our modifier flag state * on every event... ugg */ - if(darwin_modifier_flags != modifierFlags) + if(darwin_all_modifier_flags != modifierFlags) DarwinUpdateModKeys(modifierFlags); switch ([e type]) { diff --git a/hw/xquartz/darwinEvents.c b/hw/xquartz/darwinEvents.c index b69ed6a7e..e8ed56c88 100644 --- a/hw/xquartz/darwinEvents.c +++ b/hw/xquartz/darwinEvents.c @@ -74,7 +74,9 @@ in this Software without prior written authorization from The Open Group. /* FIXME: Abstract this better */ void QuartzModeEQInit(void); -int darwin_modifier_flags = 0; // last known modifier state +int darwin_all_modifier_flags = 0; // last known modifier state +int darwin_all_modifier_mask = 0; +int darwin_x11_modifier_mask = 0; #define FD_ADD_MAX 128 static int fd_add[FD_ADD_MAX]; @@ -145,7 +147,7 @@ static void DarwinPressModifierKey(int pressed, int key) { * Send events to update the modifier state. */ -int darwin_modifier_mask_list[] = { +static int darwin_x11_modifier_mask_list[] = { #ifdef NX_DEVICELCMDKEYMASK NX_DEVICELCTLKEYMASK, NX_DEVICERCTLKEYMASK, NX_DEVICELSHIFTKEYMASK, NX_DEVICERSHIFTKEYMASK, @@ -154,10 +156,12 @@ int darwin_modifier_mask_list[] = { #else NX_CONTROLMASK, NX_SHIFTMASK, NX_COMMANDMASK, NX_ALTERNATEMASK, #endif - NX_ALPHASHIFTMASK, NX_SECONDARYFNMASK + NX_ALPHASHIFTMASK, 0 }; +static int darwin_all_modifier_mask_additions[] = { NX_SECONDARYFNMASK, }; + static void DarwinUpdateModifiers( int pressed, // KeyPress or KeyRelease int flags ) // modifier flags that have changed @@ -173,11 +177,8 @@ static void DarwinUpdateModifiers( DarwinPressModifierKey(KeyRelease, NX_MODIFIERKEY_ALPHALOCK); } - for(f=darwin_modifier_mask_list; *f; f++) - /* NX_ALPHASHIFTMASK is handled above and NX_SECONDARYFNMASK is not - * mapped to a key (it is just useful for 3button mouse simulation - */ - if(*f & flags && *f != NX_ALPHASHIFTMASK && *f != NX_SECONDARYFNMASK) { + for(f=darwin_x11_modifier_mask_list; *f; f++) + if(*f & flags && *f != NX_ALPHASHIFTMASK) { key = DarwinModifierNXMaskToNXKey(*f); if(key == -1) ErrorF("DarwinUpdateModifiers: Unsupported NXMask: 0x%x\n", *f); @@ -309,6 +310,16 @@ static void kXquartzListenOnOpenFDHandler(int screenNum, xEventPtr xe, DeviceInt } Bool DarwinEQInit(void) { + int *p; + + for(p=darwin_x11_modifier_mask_list, darwin_all_modifier_mask=0; *p; p++) { + darwin_x11_modifier_mask |= *p; + } + + for(p=darwin_all_modifier_mask_additions, darwin_all_modifier_mask= darwin_x11_modifier_mask; *p; p++) { + darwin_all_modifier_mask |= *p; + } + mieqInit(); mieqSetHandler(kXquartzReloadKeymap, DarwinKeyboardReloadHandler); mieqSetHandler(kXquartzActivate, DarwinEventHandler); @@ -437,14 +448,14 @@ void DarwinSendPointerEvents(DeviceIntPtr pDev, int ev_type, int ev_button, floa DarwinSendPointerEvents(pDev, ButtonRelease, darwinFakeMouseButtonDown, pointer_x, pointer_y, pressure, tilt_x, tilt_y); darwinFakeMouseButtonDown=0; } - if (darwin_modifier_flags & darwinFakeMouse2Mask) { + if (darwin_all_modifier_flags & darwinFakeMouse2Mask) { ev_button = 2; darwinFakeMouseButtonDown = 2; - DarwinUpdateModKeys(darwin_modifier_flags & ~darwinFakeMouse2Mask); - } else if (darwin_modifier_flags & darwinFakeMouse3Mask) { + DarwinUpdateModKeys(darwin_all_modifier_flags & ~darwinFakeMouse2Mask); + } else if (darwin_all_modifier_flags & darwinFakeMouse3Mask) { ev_button = 3; darwinFakeMouseButtonDown = 3; - DarwinUpdateModKeys(darwin_modifier_flags & ~darwinFakeMouse3Mask); + DarwinUpdateModKeys(darwin_all_modifier_flags & ~darwinFakeMouse3Mask); } } @@ -454,9 +465,9 @@ void DarwinSendPointerEvents(DeviceIntPtr pDev, int ev_type, int ev_button, floa } if(darwinFakeMouseButtonDown == 2) { - DarwinUpdateModKeys(darwin_modifier_flags & ~darwinFakeMouse2Mask); + DarwinUpdateModKeys(darwin_all_modifier_flags & ~darwinFakeMouse2Mask); } else if(darwinFakeMouseButtonDown == 3) { - DarwinUpdateModKeys(darwin_modifier_flags & ~darwinFakeMouse3Mask); + DarwinUpdateModKeys(darwin_all_modifier_flags & ~darwinFakeMouse3Mask); } darwinFakeMouseButtonDown = 0; @@ -546,9 +557,9 @@ void DarwinSendScrollEvents(float count_x, float count_y, /* Send the appropriate KeyPress/KeyRelease events to GetKeyboardEvents to reflect changing modifier flags (alt, control, meta, etc) */ void DarwinUpdateModKeys(int flags) { - DarwinUpdateModifiers(KeyRelease, darwin_modifier_flags & ~flags); - DarwinUpdateModifiers(KeyPress, ~darwin_modifier_flags & flags); - darwin_modifier_flags = flags; + DarwinUpdateModifiers(KeyRelease, darwin_all_modifier_flags & ~flags & darwin_x11_modifier_mask); + DarwinUpdateModifiers(KeyPress, ~darwin_all_modifier_flags & flags & darwin_x11_modifier_mask); + darwin_all_modifier_flags = flags; } /* diff --git a/hw/xquartz/darwinEvents.h b/hw/xquartz/darwinEvents.h index 9ec3bda2f..126851422 100644 --- a/hw/xquartz/darwinEvents.h +++ b/hw/xquartz/darwinEvents.h @@ -78,7 +78,15 @@ enum { /* Send one of the above events to the server thread. */ void DarwinSendDDXEvent(int type, int argc, ...); -extern int darwin_modifier_mask_list[]; -extern int darwin_modifier_flags; +/* A mask of the modifiers that are in our X11 keyboard layout: + * (Fn for example is just useful for 3button mouse emulation) */ +extern int darwin_all_modifier_mask; + +/* A mask of the modifiers that are in our X11 keyboard layout: + * (Fn for example is just useful for 3button mouse emulation) */ +extern int darwin_x11_modifier_mask; + +/* The current state of the above listed modifiers */ +extern int darwin_all_modifier_flags; #endif /* _DARWIN_EVENTS_H */ From 8522a759c9e78478bb399b91d3a0af2d23ea6766 Mon Sep 17 00:00:00 2001 From: Jeremy Huddleston Date: Sat, 11 Apr 2009 16:12:23 -0700 Subject: [PATCH 38/67] XQuartz: Only set MotionNotify on activation if it is updated. (cherry picked from commit ae8077a251ef27381a755d57ff974767bda16148) --- hw/xquartz/X11Application.m | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/hw/xquartz/X11Application.m b/hw/xquartz/X11Application.m index f27894fdf..0a36b1d4e 100644 --- a/hw/xquartz/X11Application.m +++ b/hw/xquartz/X11Application.m @@ -83,6 +83,7 @@ extern int darwinFakeButtons; * location when we become the foreground application */ static NSPoint bgMouseLocation; +static BOOL bgMouseLocationUpdated = FALSE; X11Application *X11App; @@ -192,7 +193,8 @@ static void message_kit_thread (SEL selector, NSObject *arg) { size_t i; DEBUG_LOG("state=%d, _x_active=%d, \n", state, _x_active) if (state) { - DarwinSendPointerEvents(darwinPointer, MotionNotify, 0, bgMouseLocation.x, bgMouseLocation.y, 0.0, 0.0, 0.0); + if(bgMouseLocationUpdated) + DarwinSendPointerEvents(darwinPointer, MotionNotify, 0, bgMouseLocation.x, bgMouseLocation.y, 0.0, 0.0, 0.0); DarwinSendDDXEvent(kXquartzActivate, 0); if (!_x_active) { @@ -1087,9 +1089,11 @@ static inline int ensure_flag(int flags, int device_independent, int device_depe #endif { bgMouseLocation = location; + bgMouseLocationUpdated = TRUE; return; } } else { + bgMouseLocationUpdated = FALSE; DarwinSendPointerEvents(pDev, MotionNotify, 0, location.x, location.y, pressure, tilt.x, tilt.y); } From 6f8f7c78f1b722bc70a0ea8f6340116a1e09e858 Mon Sep 17 00:00:00 2001 From: Jeremy Huddleston Date: Sat, 11 Apr 2009 16:13:42 -0700 Subject: [PATCH 39/67] XQuartz: Re-enable background window checking since that code was not the culprit for the wacom tablet, background 100% CPU bug (cherry picked from commit fc1dc5d71b2a488a8a94d953dd8e67353161a590) --- hw/xquartz/X11Application.m | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/hw/xquartz/X11Application.m b/hw/xquartz/X11Application.m index 0a36b1d4e..7bac8db20 100644 --- a/hw/xquartz/X11Application.m +++ b/hw/xquartz/X11Application.m @@ -1067,12 +1067,7 @@ static inline int ensure_flag(int flags, int device_independent, int device_depe if(!quartzServerVisible && noTestExtensions) { if(ev_button == 0) { -#if 0 -/* Seems this has somehow triggered 100% CPU usage while X11.app is in the - * background on some obscure HW configurations. - * http://xquartz.macosforge.org/trac/ticket/241 - */ -//#if defined(XPLUGIN_VERSION) && XPLUGIN_VERSION > 0 +#if defined(XPLUGIN_VERSION) && XPLUGIN_VERSION > 0 /* Older libXplugin (Tiger/"Stock" Leopard) aren't thread safe, so we can't call xp_find_window from the Appkit thread */ xp_window_id wid = 0; xp_error e; @@ -1124,8 +1119,7 @@ static inline int ensure_flag(int flags, int device_independent, int device_depe break; case NSScrollWheel: -//#if !defined(XPLUGIN_VERSION) || XPLUGIN_VERSION == 0 -#if 1 /* Strange 100% CPU issue, so always enabling. see above */ +#if !defined(XPLUGIN_VERSION) || XPLUGIN_VERSION == 0 /* If we're in the background, we need to send a MotionNotify event * first, since we aren't getting them on background mouse motion */ From 80a7bb2605f9b439d6221c0495a629a39177a018 Mon Sep 17 00:00:00 2001 From: Jeremy Huddleston Date: Sat, 11 Apr 2009 17:26:07 -0700 Subject: [PATCH 40/67] XQuartz: Solve the tablet 100% CPU bug This happened because we put a byte in the fd to wake up dispatch, but we never actually enqueued anything in mieq because the num_events was 0. (cherry picked from commit c21ca7558d2faf93c61f5feaafd7c878e9e21942) --- hw/xquartz/darwinEvents.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/hw/xquartz/darwinEvents.c b/hw/xquartz/darwinEvents.c index e8ed56c88..54d05fb63 100644 --- a/hw/xquartz/darwinEvents.c +++ b/hw/xquartz/darwinEvents.c @@ -478,7 +478,7 @@ void DarwinSendPointerEvents(DeviceIntPtr pDev, int ev_type, int ev_button, floa num_events = GetPointerEvents(darwinEvents, pDev, ev_type, ev_button, POINTER_ABSOLUTE, 0, pDev==darwinTabletCurrent?5:2, valuators); for(i=0; i 0) DarwinPokeEQ(); } darwinEvents_unlock(); } @@ -493,7 +493,7 @@ void DarwinSendKeyboardEvents(int ev_type, int keycode) { darwinEvents_lock(); { num_events = GetKeyboardEvents(darwinEvents, darwinKeyboard, ev_type, keycode + MIN_KEYCODE); for(i=0; i 0) DarwinPokeEQ(); } darwinEvents_unlock(); } @@ -521,7 +521,7 @@ void DarwinSendProximityEvents(int ev_type, float pointer_x, float pointer_y) { num_events = GetProximityEvents(darwinEvents, pDev, ev_type, 0, 5, valuators); for(i=0; i 0) DarwinPokeEQ(); } darwinEvents_unlock(); } From 140463a197fb93d0a4bfad924efc35b860e8cc54 Mon Sep 17 00:00:00 2001 From: Jeremy Huddleston Date: Sat, 11 Apr 2009 16:53:59 -0700 Subject: [PATCH 41/67] XQuartz: Use correct values for ProximityIn and ProximityOut This was the other underlying cause of teh 100% CPU tablet issue. (cherry picked from commit a9cecf34c23fbcd59b56b380c51d31a9fabc3eb7) --- hw/xquartz/X11Application.m | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/hw/xquartz/X11Application.m b/hw/xquartz/X11Application.m index 7bac8db20..0445b8e29 100644 --- a/hw/xquartz/X11Application.m +++ b/hw/xquartz/X11Application.m @@ -44,6 +44,7 @@ #define _APPLEWM_SERVER_ #include "X11/extensions/applewm.h" #include "micmap.h" +#include "exglobals.h" #include #include @@ -60,9 +61,6 @@ extern BOOL xpbproxy_init (void); #define XSERVER_VERSION "?" #endif -#define ProximityIn 0 -#define ProximityOut 1 - /* Stuck modifier / button state... force release when we context switch */ static NSEventType keyState[NUM_KEYCODES]; From 7b6400a1b8d2f228fcbedf17c30a7e3924e4dd2a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristian=20H=C3=B8gsberg?= Date: Thu, 9 Apr 2009 13:16:37 -0400 Subject: [PATCH 42/67] glx: Fix drawable private leak on destroy When a drawable goes away, we don't destroy the GLX drawable in full, since it may be current for a context. This means that when the drawable is destroyed in full later, the backend doesn't get a chance to destroy resources associated with the drawable (the DRI2Drawable). With this patch, we destroy the GLX drawable in full when it goes away and then track down all contexts that reference it and NULL their pointers. --- glx/Makefile.am | 1 - glx/glxcmds.c | 44 +++++++++++++++++---------- glx/glxdrawable.h | 5 ---- glx/glxdri.c | 2 ++ glx/glxdri2.c | 2 ++ glx/glxdriswrast.c | 2 ++ glx/glxext.c | 42 ++++++++++++++++++-------- glx/glxext.h | 1 + glx/glxutil.c | 74 ---------------------------------------------- glx/glxutil.h | 9 +----- 10 files changed, 67 insertions(+), 115 deletions(-) delete mode 100644 glx/glxutil.c diff --git a/glx/Makefile.am b/glx/Makefile.am index 2537db865..a23ae0a47 100644 --- a/glx/Makefile.am +++ b/glx/Makefile.am @@ -80,7 +80,6 @@ libglx_la_SOURCES = \ glxscreens.c \ glxscreens.h \ glxserver.h \ - glxutil.c \ glxutil.h \ render2.c \ render2swap.c \ diff --git a/glx/glxcmds.c b/glx/glxcmds.c index e21f0f098..86e8dd8a5 100644 --- a/glx/glxcmds.c +++ b/glx/glxcmds.c @@ -193,18 +193,9 @@ validGlxDrawable(ClientPtr client, XID id, int type, int access_mode, void __glXContextDestroy(__GLXcontext *context) { - if (!context->isDirect) { - if (context->drawPriv) - __glXUnrefDrawable(context->drawPriv); - if (context->readPriv) - __glXUnrefDrawable(context->readPriv); - context->drawPriv = NULL; - context->readPriv = NULL; - } __glXFlushContextCache(); } - static void __glXdirectContextDestroy(__GLXcontext *context) { __glXContextDestroy(context); @@ -320,6 +311,8 @@ DoCreateContext(__GLXclientState *cl, GLXContextID gcId, glxc->isDirect = isDirect; glxc->renderMode = GL_RENDER; + __glXAddToContextList(glxc); + return Success; } @@ -639,10 +632,6 @@ DoMakeCurrent(__GLXclientState *cl, } __glXFlushContextCache(); if (!prevglxc->isDirect) { - if (prevglxc->drawPriv) - __glXUnrefDrawable(prevglxc->drawPriv); - if (prevglxc->readPriv) - __glXUnrefDrawable(prevglxc->readPriv); prevglxc->drawPriv = NULL; prevglxc->readPriv = NULL; } @@ -662,8 +651,6 @@ DoMakeCurrent(__GLXclientState *cl, } glxc->isCurrent = GL_TRUE; - __glXRefDrawable(glxc->drawPriv); - __glXRefDrawable(glxc->readPriv); } if (prevglxc) { @@ -1090,6 +1077,33 @@ int __glXDisp_GetFBConfigsSGIX(__GLXclientState *cl, GLbyte *pc) return DoGetFBConfigs(cl, req->screen); } +GLboolean +__glXDrawableInit(__GLXdrawable *drawable, + __GLXscreen *screen, DrawablePtr pDraw, int type, + XID drawId, __GLXconfig *config) +{ + drawable->pDraw = pDraw; + drawable->type = type; + drawable->drawId = drawId; + drawable->config = config; + drawable->eventMask = 0; + + return GL_TRUE; +} + +void +__glXDrawableRelease(__GLXdrawable *drawable) +{ + ScreenPtr pScreen = drawable->pDraw->pScreen; + + switch (drawable->type) { + case GLX_DRAWABLE_PIXMAP: + case GLX_DRAWABLE_PBUFFER: + (*pScreen->DestroyPixmap)((PixmapPtr) drawable->pDraw); + break; + } +} + static int DoCreateGLXDrawable(ClientPtr client, __GLXscreen *pGlxScreen, __GLXconfig *config, DrawablePtr pDraw, XID glxDrawableId, int type) diff --git a/glx/glxdrawable.h b/glx/glxdrawable.h index b64ff35c9..0215b3b20 100644 --- a/glx/glxdrawable.h +++ b/glx/glxdrawable.h @@ -67,11 +67,6 @@ struct __GLXdrawable { */ __GLXconfig *config; - /* - ** reference count - */ - int refCount; - GLenum target; GLenum format; diff --git a/glx/glxdri.c b/glx/glxdri.c index cc6d93976..eeac7fcb2 100644 --- a/glx/glxdri.c +++ b/glx/glxdri.c @@ -238,6 +238,8 @@ __glXDRIdrawableDestroy(__GLXdrawable *drawable) __glXleaveServer(GL_FALSE); } + __glXDrawableRelease(drawable); + xfree(private); } diff --git a/glx/glxdri2.c b/glx/glxdri2.c index ea5b5ef72..9dac8a6a3 100644 --- a/glx/glxdri2.c +++ b/glx/glxdri2.c @@ -109,6 +109,8 @@ __glXDRIdrawableDestroy(__GLXdrawable *drawable) if (drawable->pDraw != NULL) DRI2DestroyDrawable(drawable->pDraw); + __glXDrawableRelease(drawable); + xfree(private); } diff --git a/glx/glxdriswrast.c b/glx/glxdriswrast.c index de89d381e..328aa7e56 100644 --- a/glx/glxdriswrast.c +++ b/glx/glxdriswrast.c @@ -102,6 +102,8 @@ __glXDRIdrawableDestroy(__GLXdrawable *drawable) FreeScratchGC(private->gc); FreeScratchGC(private->swapgc); + __glXDrawableRelease(drawable); + xfree(private); } diff --git a/glx/glxext.c b/glx/glxext.c index 025e6198f..93391e9fd 100644 --- a/glx/glxext.c +++ b/glx/glxext.c @@ -50,6 +50,7 @@ ** from the server's perspective. */ __GLXcontext *__glXLastContext; +__GLXcontext *__glXContextList; /* ** X resources. @@ -111,31 +112,46 @@ static int ContextGone(__GLXcontext* cx, XID id) return True; } +static __GLXcontext *glxPendingDestroyContexts; +static __GLXcontext *glxAllContexts; +static int glxServerLeaveCount; +static int glxBlockClients; + /* ** Destroy routine that gets called when a drawable is freed. A drawable ** contains the ancillary buffers needed for rendering. */ static Bool DrawableGone(__GLXdrawable *glxPriv, XID xid) { - ScreenPtr pScreen = glxPriv->pDraw->pScreen; + __GLXcontext *c; - switch (glxPriv->type) { - case GLX_DRAWABLE_PIXMAP: - case GLX_DRAWABLE_PBUFFER: - (*pScreen->DestroyPixmap)((PixmapPtr) glxPriv->pDraw); - break; + for (c = glxAllContexts; c; c = c->next) { + if (c->drawPriv == glxPriv) + c->drawPriv = NULL; + if (c->readPriv == glxPriv) + c->readPriv = NULL; } - glxPriv->pDraw = NULL; - glxPriv->drawId = 0; - __glXUnrefDrawable(glxPriv); + glxPriv->destroy(glxPriv); return True; } -static __GLXcontext *glxPendingDestroyContexts; -static int glxServerLeaveCount; -static int glxBlockClients; +void __glXAddToContextList(__GLXcontext *cx) +{ + cx->next = glxAllContexts; + glxAllContexts = cx; +} + +void __glXRemoveFromContextList(__GLXcontext *cx) +{ + __GLXcontext *c, **prev; + + prev = &glxAllContexts; + for (c = glxAllContexts; c; c = c->next) + if (c == cx) + *prev = c->next; +} /* ** Free a context. @@ -150,6 +166,8 @@ GLboolean __glXFreeContext(__GLXcontext *cx) __glXFlushContextCache(); } + __glXRemoveFromContextList(cx); + /* We can get here through both regular dispatching from * __glXDispatch() or as a callback from the resource manager. In * the latter case we need to lift the DRI lock manually. */ diff --git a/glx/glxext.h b/glx/glxext.h index 72092f34a..7008c4763 100644 --- a/glx/glxext.h +++ b/glx/glxext.h @@ -38,6 +38,7 @@ extern GLboolean __glXFreeContext(__GLXcontext *glxc); extern void __glXFlushContextCache(void); +extern void __glXAddToContextList(__GLXcontext *cx); extern void __glXErrorCallBack(GLenum code); extern void __glXClearErrorOccured(void); extern GLboolean __glXErrorOccured(void); diff --git a/glx/glxutil.c b/glx/glxutil.c deleted file mode 100644 index 52a10e4e5..000000000 --- a/glx/glxutil.c +++ /dev/null @@ -1,74 +0,0 @@ -/* - * SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008) - * Copyright (C) 1991-2000 Silicon Graphics, Inc. All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice including the dates of first publication and - * either this permission notice or a reference to - * http://oss.sgi.com/projects/FreeB/ - * shall be included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * SILICON GRAPHICS, INC. BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, - * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF - * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - * - * Except as contained in this notice, the name of Silicon Graphics, Inc. - * shall not be used in advertising or otherwise to promote the sale, use or - * other dealings in this Software without prior written authorization from - * Silicon Graphics, Inc. - */ - -#define FONT_PCF -#ifdef HAVE_DIX_CONFIG_H -#include -#endif - -#include - -#include "glxserver.h" -#include "glxutil.h" - -/*****************************************************************************/ -/* Drawable private stuff */ - -void -__glXRefDrawable(__GLXdrawable *glxPriv) -{ - glxPriv->refCount++; -} - -void -__glXUnrefDrawable(__GLXdrawable *glxPriv) -{ - glxPriv->refCount--; - if (glxPriv->refCount == 0) { - /* remove the drawable from the drawable list */ - FreeResourceByType(glxPriv->drawId, __glXDrawableRes, FALSE); - glxPriv->destroy(glxPriv); - } -} - -GLboolean -__glXDrawableInit(__GLXdrawable *drawable, - __GLXscreen *screen, DrawablePtr pDraw, int type, - XID drawId, __GLXconfig *config) -{ - drawable->pDraw = pDraw; - drawable->type = type; - drawable->drawId = drawId; - drawable->refCount = 1; - drawable->config = config; - drawable->eventMask = 0; - - return GL_TRUE; -} diff --git a/glx/glxutil.h b/glx/glxutil.h index baa490500..d1a715b4b 100644 --- a/glx/glxutil.h +++ b/glx/glxutil.h @@ -35,18 +35,11 @@ * Silicon Graphics, Inc. */ -/* relate contexts with drawables */ -extern void __glXAssociateContext(__GLXcontext *glxc); -extern void __glXDeassociateContext(__GLXcontext *glxc); - -/* drawable management */ -extern void __glXRefDrawable(__GLXdrawable *glxPriv); -extern void __glXUnrefDrawable(__GLXdrawable *glxPriv); - extern GLboolean __glXDrawableInit(__GLXdrawable *drawable, __GLXscreen *screen, DrawablePtr pDraw, int type, XID drawID, __GLXconfig *config); +extern void __glXDrawableRelease(__GLXdrawable *drawable); /* context helper routines */ extern __GLXcontext *__glXLookupContextByTag(__GLXclientState*, GLXContextTag); From bef1cfb2395df47458159a0b7ae27b9db15025ef Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Tue, 14 Apr 2009 16:54:42 +1000 Subject: [PATCH 43/67] xnest: remove unused variable 'names'. Signed-off-by: Peter Hutterer --- hw/xnest/Keyboard.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/hw/xnest/Keyboard.c b/hw/xnest/Keyboard.c index c9b4a1748..8404c8bfa 100644 --- a/hw/xnest/Keyboard.c +++ b/hw/xnest/Keyboard.c @@ -120,7 +120,6 @@ xnestKeyboardProc(DeviceIntPtr pDev, int onoff) KeySymsRec keySyms; int i; XKeyboardState values; - XkbComponentNamesRec names; XkbDescPtr xkb; XkbRMLVOSet rmlvo; int op, event, error, major, minor; @@ -166,7 +165,6 @@ xnestKeyboardProc(DeviceIntPtr pDev, int onoff) } XkbGetControls(xnestDisplay, XkbAllControlsMask, xkb); - memset(&names, 0, sizeof(XkbComponentNamesRec)); rmlvo.rules = XKB_DFLT_RULES; rmlvo.model = XKB_DFLT_MODEL; rmlvo.layout = XKB_DFLT_LAYOUT; From e72c85547b405fbd0117dc1236e5ca5a2126063c Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Wed, 8 Apr 2009 14:17:38 -0700 Subject: [PATCH 44/67] Move contributed m4 to a subdir so we can more easily update contributions. --- Makefile.am | 1 + m4/ac_define_dir.m4 | 49 ++++++++++++++++++++++++++++++++++++ acinclude.m4 => m4/dolt.m4 | 51 +------------------------------------- 3 files changed, 51 insertions(+), 50 deletions(-) create mode 100644 m4/ac_define_dir.m4 rename acinclude.m4 => m4/dolt.m4 (76%) diff --git a/Makefile.am b/Makefile.am index f5ab8a5ab..dea6fa47c 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,4 +1,5 @@ AUTOMAKE_OPTIONS=dist-bzip2 foreign nostdinc +ACLOCAL_AMFLAGS = -I m4 if COMPOSITE COMPOSITE_DIR=composite diff --git a/m4/ac_define_dir.m4 b/m4/ac_define_dir.m4 new file mode 100644 index 000000000..db42d3eb0 --- /dev/null +++ b/m4/ac_define_dir.m4 @@ -0,0 +1,49 @@ +# =========================================================================== +# http://autoconf-archive.cryp.to/ac_define_dir.html +# =========================================================================== +# +# SYNOPSIS +# +# AC_DEFINE_DIR(VARNAME, DIR [, DESCRIPTION]) +# +# DESCRIPTION +# +# This macro sets VARNAME to the expansion of the DIR variable, taking +# care of fixing up ${prefix} and such. +# +# VARNAME is then offered as both an output variable and a C preprocessor +# symbol. +# +# Example: +# +# AC_DEFINE_DIR([DATADIR], [datadir], [Where data are placed to.]) +# +# LAST MODIFICATION +# +# 2008-04-12 +# +# COPYLEFT +# +# Copyright (c) 2008 Stepan Kasal +# Copyright (c) 2008 Andreas Schwab +# Copyright (c) 2008 Guido U. Draheim +# Copyright (c) 2008 Alexandre Oliva +# +# Copying and distribution of this file, with or without modification, are +# permitted in any medium without royalty provided the copyright notice +# and this notice are preserved. + +AC_DEFUN([AC_DEFINE_DIR], [ + prefix_NONE= + exec_prefix_NONE= + test "x$prefix" = xNONE && prefix_NONE=yes && prefix=$ac_default_prefix + test "x$exec_prefix" = xNONE && exec_prefix_NONE=yes && exec_prefix=$prefix +dnl In Autoconf 2.60, ${datadir} refers to ${datarootdir}, which in turn +dnl refers to ${prefix}. Thus we have to use `eval' twice. + eval ac_define_dir="\"[$]$2\"" + eval ac_define_dir="\"$ac_define_dir\"" + AC_SUBST($1, "$ac_define_dir") + AC_DEFINE_UNQUOTED($1, "$ac_define_dir", [$3]) + test "$prefix_NONE" && prefix=NONE + test "$exec_prefix_NONE" && exec_prefix=NONE +]) diff --git a/acinclude.m4 b/m4/dolt.m4 similarity index 76% rename from acinclude.m4 rename to m4/dolt.m4 index c3e36f8b1..1109bdb0c 100644 --- a/acinclude.m4 +++ b/m4/dolt.m4 @@ -155,6 +155,7 @@ modeok=false tagok=false for arg in "$[]@"; do case "$arg" in + --silent) ;; --mode=compile) modeok=true ;; --tag=CC|--tag=CXX) tagok=true ;; *) args@<:@${#args[@]}@:>@="$arg" ;; @@ -175,53 +176,3 @@ AC_SUBST(LTCOMPILE) AC_SUBST(LTCXXCOMPILE) # end dolt ]) - -# =========================================================================== -# http://autoconf-archive.cryp.to/ac_define_dir.html -# =========================================================================== -# -# SYNOPSIS -# -# AC_DEFINE_DIR(VARNAME, DIR [, DESCRIPTION]) -# -# DESCRIPTION -# -# This macro sets VARNAME to the expansion of the DIR variable, taking -# care of fixing up ${prefix} and such. -# -# VARNAME is then offered as both an output variable and a C preprocessor -# symbol. -# -# Example: -# -# AC_DEFINE_DIR([DATADIR], [datadir], [Where data are placed to.]) -# -# LAST MODIFICATION -# -# 2008-04-12 -# -# COPYLEFT -# -# Copyright (c) 2008 Stepan Kasal -# Copyright (c) 2008 Andreas Schwab -# Copyright (c) 2008 Guido U. Draheim -# Copyright (c) 2008 Alexandre Oliva -# -# Copying and distribution of this file, with or without modification, are -# permitted in any medium without royalty provided the copyright notice -# and this notice are preserved. - -AC_DEFUN([AC_DEFINE_DIR], [ - prefix_NONE= - exec_prefix_NONE= - test "x$prefix" = xNONE && prefix_NONE=yes && prefix=$ac_default_prefix - test "x$exec_prefix" = xNONE && exec_prefix_NONE=yes && exec_prefix=$prefix -dnl In Autoconf 2.60, ${datadir} refers to ${datarootdir}, which in turn -dnl refers to ${prefix}. Thus we have to use `eval' twice. - eval ac_define_dir="\"[$]$2\"" - eval ac_define_dir="\"$ac_define_dir\"" - AC_SUBST($1, "$ac_define_dir") - AC_DEFINE_UNQUOTED($1, "$ac_define_dir", [$3]) - test "$prefix_NONE" && prefix=NONE - test "$exec_prefix_NONE" && exec_prefix=NONE -]) From 4474c200a102feda72f9572a96cb588009aa0147 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Wed, 8 Apr 2009 14:17:39 -0700 Subject: [PATCH 45/67] Move VENDOR_* defines from AC_SUBST to a header to avoid angering shave. This is more sane anyway, as it ensures a rebuild when changing them. --- .gitignore | 1 + configure.ac | 10 +++++++--- dix/Makefile.am | 4 +--- dix/main.c | 1 + include/version-config.h.in | 16 ++++++++++++++++ 5 files changed, 26 insertions(+), 6 deletions(-) create mode 100644 include/version-config.h.in diff --git a/.gitignore b/.gitignore index 4d277d98e..df9006a1b 100644 --- a/.gitignore +++ b/.gitignore @@ -146,6 +146,7 @@ hw/xwin/winprefsyacc.c hw/xwin/winprefsyacc.h include/dix-config.h include/kdrive-config.h +include/version-config.h include/xkb-config.h include/xorg-config.h include/xorg-server.h diff --git a/configure.ac b/configure.ac index 93ef0bd23..c5084f056 100644 --- a/configure.ac +++ b/configure.ac @@ -54,6 +54,9 @@ dnl xwin-config.h covers the XWin DDX. AC_CONFIG_HEADERS(include/xwin-config.h) dnl kdrive-config.h covers the kdrive DDX AC_CONFIG_HEADERS(include/kdrive-config.h) +dnl version-config.h covers the version numbers so they can be bumped without +dnl forcing an entire recompile.x +AC_CONFIG_HEADERS(include/version-config.h) AC_PROG_CC AM_PROG_AS @@ -1120,10 +1123,11 @@ AC_DEFINE_UNQUOTED(OSNAME, ["$OSNAME"], [Operating System Name]) AC_DEFINE_UNQUOTED(OSVENDOR, ["$OSVENDOR"], [Operating System Vendor]) AC_DEFINE_UNQUOTED(BUILDERSTRING, ["$BUILDERSTRING"], [Builder string]) -AC_SUBST([VENDOR_NAME]) AC_SUBST([VENDOR_NAME_SHORT]) -AC_SUBST([VENDOR_RELEASE]) -AC_SUBST([VENDOR_MAN_VERSION]) +AC_DEFINE_UNQUOTED(VENDOR_NAME, ["$VENDOR_NAME"], [Vendor name]) +AC_DEFINE_UNQUOTED(VENDOR_NAME_SHORT, ["$VENDOR_NAME_SHORT"], [Vendor name]) +AC_DEFINE_UNQUOTED(VENDOR_RELEASE, [$VENDOR_RELEASE], [Vendor release]) +AC_DEFINE_UNQUOTED(VENDOR_MAN_VERSION, ["$VENDOR_MAN_VERSION"], [Vendor man version]) AC_DEFINE(NO_LIBCWRAPPER, 1, [Define to 1 if modules should avoid the libcwrapper]) diff --git a/dix/Makefile.am b/dix/Makefile.am index 8c5f3c00e..83b8c62c2 100644 --- a/dix/Makefile.am +++ b/dix/Makefile.am @@ -1,8 +1,6 @@ noinst_LTLIBRARIES = libdix.la -AM_CFLAGS = $(DIX_CFLAGS) \ - -DVENDOR_NAME=\""@VENDOR_NAME@"\" \ - -DVENDOR_RELEASE="@VENDOR_RELEASE@" +AM_CFLAGS = $(DIX_CFLAGS) libdix_la_SOURCES = \ atom.c \ diff --git a/dix/main.c b/dix/main.c index e10f7e1a4..9d5d83944 100644 --- a/dix/main.c +++ b/dix/main.c @@ -76,6 +76,7 @@ Equipment Corporation. #ifdef HAVE_DIX_CONFIG_H #include +#include #endif #include diff --git a/include/version-config.h.in b/include/version-config.h.in new file mode 100644 index 000000000..8180dff8e --- /dev/null +++ b/include/version-config.h.in @@ -0,0 +1,16 @@ +/* version-config.h.in: not generated */ + +#ifndef VERSION_CONFIG_H +#define VERSION_CONFIG_H + +/* Vendor man version */ +#undef VENDOR_MAN_VERSION + +/* Vendor name */ +#undef VENDOR_NAME + +/* Vendor release */ +#undef VENDOR_RELEASE + +#endif /* VERSION_CONFIG_H */ + From 181cc08c8908a119fc403f970dea8cc98d3e0b9b Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Wed, 8 Apr 2009 14:17:40 -0700 Subject: [PATCH 46/67] Add shave so that we can see the steaming piles of warnings generated. The old style output can be reenabled for build system debugging using "make V=1", or --disable-shave at configure time. --- .gitignore | 2 ++ configure.ac | 7 +++++ m4/shave.m4 | 73 ++++++++++++++++++++++++++++++++++++++++++++++ shave-libtool.in | 69 +++++++++++++++++++++++++++++++++++++++++++ shave.in | 76 ++++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 227 insertions(+) create mode 100644 m4/shave.m4 create mode 100644 shave-libtool.in create mode 100644 shave.in diff --git a/.gitignore b/.gitignore index df9006a1b..3fb73f061 100644 --- a/.gitignore +++ b/.gitignore @@ -35,6 +35,8 @@ install-sh libtool ltmain.sh missing +shave +shave-libtool TAGS tags cscope* diff --git a/configure.ac b/configure.ac index c5084f056..033173032 100644 --- a/configure.ac +++ b/configure.ac @@ -32,6 +32,11 @@ AC_CONFIG_SRCDIR([Makefile.am]) AM_INIT_AUTOMAKE([dist-bzip2 foreign]) AM_MAINTAINER_MODE +AC_CONFIG_FILES([ + shave + shave-libtool +]) + # Require xorg-macros version 1.2.0 or newer for XORG_CHANGELOG and # XORG_CWARNFLAGS m4_ifndef([XORG_MACROS_VERSION], [AC_FATAL([must install xorg-macros 1.2 or later before running autoconf/autogen])]) @@ -1878,6 +1883,8 @@ AC_SUBST([prefix]) XORG_MANPAGE_SECTIONS XORG_CHANGELOG +SHAVE_INIT([.], [enable]) + AC_OUTPUT([ Makefile glx/Makefile diff --git a/m4/shave.m4 b/m4/shave.m4 new file mode 100644 index 000000000..0c2c9f5a0 --- /dev/null +++ b/m4/shave.m4 @@ -0,0 +1,73 @@ +dnl Make automake/libtool output more friendly to humans +dnl +dnl SHAVE_INIT([shavedir],[default_mode]) +dnl +dnl shavedir: the directory where the shave scripts are, it defaults to +dnl $(top_builddir) +dnl default_mode: (enable|disable) default shave mode. This parameter +dnl controls shave's behaviour when no option has been +dnl given to configure. It defaults to disable. +dnl +dnl * SHAVE_INIT should be called late in your configure.(ac|in) file (just +dnl before AC_CONFIG_FILE/AC_OUTPUT is perfect. This macro rewrites CC and +dnl LIBTOOL, you don't want the configure tests to have these variables +dnl re-defined. +dnl * This macro requires GNU make's -s option. + +AC_DEFUN([_SHAVE_ARG_ENABLE], +[ + AC_ARG_ENABLE([shave], + AS_HELP_STRING( + [--enable-shave], + [use shave to make the build pretty [[default=$1]]]),, + [enable_shave=$1] + ) +]) + +AC_DEFUN([SHAVE_INIT], +[ + dnl you can tweak the default value of enable_shave + m4_if([$2], [enable], [_SHAVE_ARG_ENABLE(yes)], [_SHAVE_ARG_ENABLE(no)]) + + if test x"$enable_shave" = xyes; then + dnl where can we find the shave scripts? + m4_if([$1],, + [shavedir="$ac_pwd"], + [shavedir="$ac_pwd/$1"]) + AC_SUBST(shavedir) + + dnl make is now quiet + AC_SUBST([MAKEFLAGS], [-s]) + AC_SUBST([AM_MAKEFLAGS], ['`test -z $V && echo -s`']) + + dnl we need sed + AC_CHECK_PROG(SED,sed,sed,false) + + dnl substitute libtool + SHAVE_SAVED_LIBTOOL=$LIBTOOL + LIBTOOL="${SHELL} ${shavedir}/shave-libtool '${SHAVE_SAVED_LIBTOOL}'" + AC_SUBST(LIBTOOL) + + dnl substitute cc/cxx + SHAVE_SAVED_CC=$CC + SHAVE_SAVED_CXX=$CXX + SHAVE_SAVED_FC=$FC + SHAVE_SAVED_F77=$F77 + CC="${SHELL} ${shavedir}/shave cc ${SHAVE_SAVED_CC}" + CXX="${SHELL} ${shavedir}/shave cxx ${SHAVE_SAVED_CXX}" + FC="${SHELL} ${shavedir}/shave fc ${SHAVE_SAVED_FC}" + F77="${SHELL} ${shavedir}/shave f77 ${SHAVE_SAVED_F77}" + AC_SUBST(CC) + AC_SUBST(CXX) + AC_SUBST(FC) + AC_SUBST(F77) + + V=@ + else + V=1 + fi + Q='$(V:1=)' + AC_SUBST(V) + AC_SUBST(Q) +]) + diff --git a/shave-libtool.in b/shave-libtool.in new file mode 100644 index 000000000..1f3a720c1 --- /dev/null +++ b/shave-libtool.in @@ -0,0 +1,69 @@ +#!/bin/sh + +# we need sed +SED=@SED@ +if test -z "$SED" ; then +SED=sed +fi + +lt_unmangle () +{ + last_result=`echo $1 | $SED -e 's#.libs/##' -e 's#[0-9a-zA-Z_\-\.]*_la-##'` +} + +# the real libtool to use +LIBTOOL="$1" +shift + +# if 1, don't print anything, the underlaying wrapper will do it +pass_though=0 + +# scan the arguments, keep the right ones for libtool, and discover the mode +preserved_args= +while test "$#" -gt 0; do + opt="$1" + shift + + case $opt in + --mode=*) + mode=`echo $opt | $SED -e 's/[-_a-zA-Z0-9]*=//'` + preserved_args="$preserved_args $opt" + ;; + -o) + lt_output="$1" + preserved_args="$preserved_args $opt" + ;; + *) + preserved_args="$preserved_args $opt" + ;; + esac +done + +case "$mode" in +compile) + # shave will be called and print the actual CC/CXX/LINK line + preserved_args="$preserved_args --shave-mode=$mode" + pass_though=1 + ;; +link) + preserved_args="$preserved_args --shave-mode=$mode" + Q=" LINK " + ;; +*) + # let's u + # echo "*** libtool: Unimplemented mode: $mode, fill a bug report" + ;; +esac + +lt_unmangle "$lt_output" +output=$last_result + +if test -z $V; then + if test $pass_though -eq 0; then + echo "$Q$output" + fi + $LIBTOOL --silent $preserved_args +else + echo $LIBTOOL $preserved_args + $LIBTOOL $preserved_args +fi diff --git a/shave.in b/shave.in new file mode 100644 index 000000000..174641e9b --- /dev/null +++ b/shave.in @@ -0,0 +1,76 @@ +#!/bin/sh + +# we need sed +SED=@SED@ +if test -z "$SED" ; then +SED=sed +fi + +lt_unmangle () +{ + last_result=`echo $1 | $SED -e 's#.libs/##' -e 's#[0-9a-zA-Z_\-\.]*_la-##'` +} + +# the tool to wrap (cc, cxx, ar, ranlib, ..) +tool="$1" +shift + +# the reel tool (to call) +REEL_TOOL="$1" +shift + +pass_through=0 +preserved_args= +while test "$#" -gt 0; do + opt="$1" + shift + + case $opt in + --shave-mode=*) + mode=`echo $opt | $SED -e 's/[-_a-zA-Z0-9]*=//'` + ;; + -o) + lt_output="$1" + preserved_args="$preserved_args $opt" + ;; + *) + preserved_args="$preserved_args $opt" + ;; + esac +done + +# mode=link is handled in the libtool wrapper +case "$mode,$tool" in +link,*) + pass_through=1 + ;; +*,cxx) + Q=" CXX " + ;; +*,cc) + Q=" CC " + ;; +*,fc) + Q=" FC " + ;; +*,f77) + Q=" F77 " + ;; +*,*) + # should not happen + Q=" CC " + ;; +esac + +lt_unmangle "$lt_output" +output=$last_result + +if test -z $V; then + if test $pass_through -eq 0; then + echo "$Q$output" + fi + $REEL_TOOL $preserved_args +else + echo $REEL_TOOL $preserved_args + $REEL_TOOL $preserved_args +fi From f0543ae4ec0fcb5d696e7b2983653bd779f1eddc Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Wed, 8 Apr 2009 14:17:41 -0700 Subject: [PATCH 47/67] Fix unused var warning from pci cleanups. --- hw/xfree86/os-support/bus/linuxPci.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/hw/xfree86/os-support/bus/linuxPci.c b/hw/xfree86/os-support/bus/linuxPci.c index a60df2538..e210fa1ab 100644 --- a/hw/xfree86/os-support/bus/linuxPci.c +++ b/hw/xfree86/os-support/bus/linuxPci.c @@ -69,8 +69,6 @@ static pointer DomainMmappedIO[MAX_DOMAINS]; void linuxPciInit(void) { - struct stat st; - memset(DomainMmappedIO, 0, sizeof(DomainMmappedIO)); } From 0eb19f9437b7d8c19592e49eedb028771d300d80 Mon Sep 17 00:00:00 2001 From: Adam Jackson Date: Tue, 14 Apr 2009 10:54:25 -0400 Subject: [PATCH 48/67] xdmcp: Don't crash on X -query with more than 255 IP addresses. (#20675) You could be more clever than this, but the wire protocol says this really is an array of not more than 255 ARRAY8, so it's not just a matter of changing the types. --- os/xdmcp.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/os/xdmcp.c b/os/xdmcp.c index cf9558679..c1d650d46 100644 --- a/os/xdmcp.c +++ b/os/xdmcp.c @@ -490,6 +490,8 @@ XdmcpRegisterConnection ( return; } } + if (ConnectionAddresses.length + 1 == 256) + return; newAddress = xalloc (addrlen * sizeof (CARD8)); if (!newAddress) return; From e7785e8af3e34f9d1089d8499d16802984ab9823 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristian=20H=C3=B8gsberg?= Date: Tue, 14 Apr 2009 14:24:31 -0400 Subject: [PATCH 49/67] xfixes: Fix a couple of resource lookups --- xfixes/cursor.c | 21 +++++++++++++-------- xfixes/xfixes.h | 20 +++++++++++++------- 2 files changed, 26 insertions(+), 15 deletions(-) diff --git a/xfixes/cursor.c b/xfixes/cursor.c index 99403e5ce..33ab4265c 100644 --- a/xfixes/cursor.c +++ b/xfixes/cursor.c @@ -64,14 +64,19 @@ static DevPrivateKey CursorScreenPrivateKey = &CursorScreenPrivateKeyIndex; static void deleteCursorHideCountsForScreen (ScreenPtr pScreen); -#define VERIFY_CURSOR(pCursor, cursor, client, access) { \ - pCursor = (CursorPtr)SecurityLookupIDByType((client), (cursor), \ - RT_CURSOR, (access)); \ - if (!pCursor) { \ - (client)->errorValue = (cursor); \ - return BadCursor; \ - } \ -} +#define VERIFY_CURSOR(pCursor, cursor, client, access) \ + do { \ + int err; \ + err = dixLookupResourceByType((pointer *) &pCursor, cursor, \ + RT_CURSOR, client, access); \ + if (err == BadValue) { \ + client->errorValue = cursor; \ + return BadCursor; \ + } else if (err != Success) { \ + client->errorValue = cursor; \ + return err; \ + } \ + } while (0) /* * There is a global list of windows selecting for cursor events diff --git a/xfixes/xfixes.h b/xfixes/xfixes.h index ade2f8236..69d162ffe 100644 --- a/xfixes/xfixes.h +++ b/xfixes/xfixes.h @@ -32,13 +32,19 @@ extern _X_EXPORT RESTYPE RegionResType; extern _X_EXPORT int XFixesErrorBase; -#define VERIFY_REGION(pRegion, rid, client, mode) { \ - pRegion = SecurityLookupIDByType (client, rid, RegionResType, mode); \ - if (!pRegion) { \ - client->errorValue = rid; \ - return XFixesErrorBase + BadRegion; \ - } \ -} +#define VERIFY_REGION(pRegion, rid, client, mode) \ + do { \ + int err; \ + err = dixLookupResourceByType((pointer *) &pRegion, rid, \ + RegionResType, client, mode); \ + if (err == BadValue) { \ + client->errorValue = rid; \ + return XFixesErrorBase + BadRegion; \ + } else if (err != Success) { \ + client->errorValue = rid; \ + return err; \ + } \ + } while (0) #define VERIFY_REGION_OR_NONE(pRegion, rid, client, mode) { \ pRegion = 0; \ From 4a27618565f3151ab17f0ca9ecbde12fa7ba13c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristian=20H=C3=B8gsberg?= Date: Tue, 14 Apr 2009 16:21:04 -0400 Subject: [PATCH 50/67] composite: Fix resource lookups --- composite/compext.c | 87 +++++++++++++++----------------------------- composite/compinit.c | 8 ++-- 2 files changed, 35 insertions(+), 60 deletions(-) diff --git a/composite/compext.c b/composite/compext.c index 4fff20efa..829c90fbf 100644 --- a/composite/compext.c +++ b/composite/compext.c @@ -136,21 +136,30 @@ ProcCompositeQueryVersion (ClientPtr client) return(client->noClientException); } +#define VERIFY_WINDOW(pWindow, wid, client, mode) \ + do { \ + int err; \ + err = dixLookupResourceByType((pointer *) &pWindow, wid, \ + RT_WINDOW, client, mode); \ + if (err == BadValue) { \ + client->errorValue = wid; \ + return BadWindow; \ + } else if (err != Success) { \ + client->errorValue = wid; \ + return err; \ + } \ + } while (0) + static int ProcCompositeRedirectWindow (ClientPtr client) { WindowPtr pWin; - int rc; REQUEST(xCompositeRedirectWindowReq); REQUEST_SIZE_MATCH(xCompositeRedirectWindowReq); - rc = dixLookupResourceByType((pointer *)&pWin, stuff->window, RT_WINDOW, client, - DixSetAttrAccess|DixManageAccess|DixBlendAccess); - if (rc != Success) - { - client->errorValue = stuff->window; - return (rc == BadValue) ? BadWindow : rc; - } + VERIFY_WINDOW(pWin, stuff->window, client, + DixSetAttrAccess|DixManageAccess|DixBlendAccess); + return compRedirectWindow (client, pWin, stuff->update); } @@ -158,17 +167,12 @@ static int ProcCompositeRedirectSubwindows (ClientPtr client) { WindowPtr pWin; - int rc; REQUEST(xCompositeRedirectSubwindowsReq); REQUEST_SIZE_MATCH(xCompositeRedirectSubwindowsReq); - rc = dixLookupResourceByType((pointer *)&pWin, stuff->window, RT_WINDOW, client, - DixSetAttrAccess|DixManageAccess|DixBlendAccess); - if (rc != Success) - { - client->errorValue = stuff->window; - return (rc == BadValue) ? BadWindow : rc; - } + VERIFY_WINDOW(pWin, stuff->window, client, + DixSetAttrAccess|DixManageAccess|DixBlendAccess); + return compRedirectSubwindows (client, pWin, stuff->update); } @@ -179,12 +183,9 @@ ProcCompositeUnredirectWindow (ClientPtr client) REQUEST(xCompositeUnredirectWindowReq); REQUEST_SIZE_MATCH(xCompositeUnredirectWindowReq); - pWin = (WindowPtr) LookupIDByType (stuff->window, RT_WINDOW); - if (!pWin) - { - client->errorValue = stuff->window; - return BadWindow; - } + VERIFY_WINDOW(pWin, stuff->window, client, + DixSetAttrAccess|DixManageAccess|DixBlendAccess); + return compUnredirectWindow (client, pWin, stuff->update); } @@ -195,12 +196,9 @@ ProcCompositeUnredirectSubwindows (ClientPtr client) REQUEST(xCompositeUnredirectSubwindowsReq); REQUEST_SIZE_MATCH(xCompositeUnredirectSubwindowsReq); - pWin = (WindowPtr) LookupIDByType (stuff->window, RT_WINDOW); - if (!pWin) - { - client->errorValue = stuff->window; - return BadWindow; - } + VERIFY_WINDOW(pWin, stuff->window, client, + DixSetAttrAccess|DixManageAccess|DixBlendAccess); + return compUnredirectSubwindows (client, pWin, stuff->update); } @@ -210,18 +208,10 @@ ProcCompositeCreateRegionFromBorderClip (ClientPtr client) WindowPtr pWin; CompWindowPtr cw; RegionPtr pBorderClip, pRegion; - int rc; REQUEST(xCompositeCreateRegionFromBorderClipReq); REQUEST_SIZE_MATCH(xCompositeCreateRegionFromBorderClipReq); - rc = dixLookupResourceByType((pointer *)&pWin, stuff->window, RT_WINDOW, client, - DixGetAttrAccess); - if (rc != Success) - { - client->errorValue = stuff->window; - return (rc == BadValue) ? BadWindow : rc; - } - + VERIFY_WINDOW(pWin, stuff->window, client, DixGetAttrAccess); LEGAL_NEW_RESOURCE (stuff->region, client); cw = GetCompWindow (pWin); @@ -250,13 +240,7 @@ ProcCompositeNameWindowPixmap (ClientPtr client) REQUEST(xCompositeNameWindowPixmapReq); REQUEST_SIZE_MATCH(xCompositeNameWindowPixmapReq); - rc = dixLookupResourceByType((pointer *)&pWin, stuff->window, RT_WINDOW, client, - DixGetAttrAccess); - if (rc != Success) - { - client->errorValue = stuff->window; - return (rc == BadValue) ? BadWindow : rc; - } + VERIFY_WINDOW(pWin, stuff->window, client, DixGetAttrAccess); if (!pWin->viewable) return BadMatch; @@ -298,13 +282,7 @@ ProcCompositeGetOverlayWindow (ClientPtr client) int rc; REQUEST_SIZE_MATCH(xCompositeGetOverlayWindowReq); - rc = dixLookupResourceByType((pointer *)&pWin, stuff->window, RT_WINDOW, client, - DixGetAttrAccess); - if (rc != Success) - { - client->errorValue = stuff->window; - return (rc == BadValue) ? BadWindow : rc; - } + VERIFY_WINDOW(pWin, stuff->window, client, DixGetAttrAccess); pScreen = pWin->drawable.pScreen; /* @@ -360,12 +338,7 @@ ProcCompositeReleaseOverlayWindow (ClientPtr client) CompOverlayClientPtr pOc; REQUEST_SIZE_MATCH(xCompositeReleaseOverlayWindowReq); - pWin = (WindowPtr) LookupIDByType (stuff->window, RT_WINDOW); - if (!pWin) - { - client->errorValue = stuff->window; - return BadWindow; - } + VERIFY_WINDOW(pWin, stuff->window, client, DixGetAttrAccess); pScreen = pWin->drawable.pScreen; /* diff --git a/composite/compinit.c b/composite/compinit.c index 5b2fba1a4..a844017c1 100644 --- a/composite/compinit.c +++ b/composite/compinit.c @@ -296,10 +296,12 @@ compAddAlternateVisual(ScreenPtr pScreen, CompScreenPtr cs, * for all colormaps. */ for (i = 0; i < numInstalledCmaps; i++) { - int j; + int j, rc; - installedCmap = LookupIDByType (installedCmaps[i], RT_COLORMAP); - if (!installedCmap) + rc = dixLookupResourceByType((pointer *)&installedCmap, + installedCmaps[i], RT_COLORMAP, + serverClient, DixReadAccess); + if (rc != Success) continue; j = installedCmap->pVisual - pScreen->visuals; installedCmap->pVisual = &visuals[j]; From d79bad0aa70403ead8ec87bac8463a6e2005802c Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Mon, 13 Apr 2009 17:49:00 +1000 Subject: [PATCH 51/67] xfree86: don't synthesise a mouse section if synaptics devices are found. Signed-off-by: Peter Hutterer --- hw/xfree86/common/xf86Config.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/hw/xfree86/common/xf86Config.c b/hw/xfree86/common/xf86Config.c index 7da85ea2f..7ea6197de 100644 --- a/hw/xfree86/common/xf86Config.c +++ b/hw/xfree86/common/xf86Config.c @@ -1282,7 +1282,8 @@ checkCoreInputDevices(serverLayoutPtr servlayoutp, Bool implicitLayout) */ for (devs = servlayoutp->inputs; devs && *devs; devs++) { if (!strcmp((*devs)->driver, "void") || !strcmp((*devs)->driver, "mouse") || - !strcmp((*devs)->driver, "vmmouse") || !strcmp((*devs)->driver, "evdev")) { + !strcmp((*devs)->driver, "vmmouse") || !strcmp((*devs)->driver, "evdev") || + !strcmp((*devs)->driver, "synaptics")) { found = 1; break; } } From efa31092d6703397121a0ada4f7205a8ecad3d3d Mon Sep 17 00:00:00 2001 From: Ander Conselvan de Oliveira Date: Mon, 6 Apr 2009 16:01:20 -0300 Subject: [PATCH 52/67] xfree86: Remove device from inputInfo.devices if ActivateDevice failed. After the call to xf86ActivateDevice, the new device will be added to inputInfo.devices. However, if the subsequent call to ActivateDevice fails, the correponding InputInfoRec for the device is deleted but an entry still remains in inputInfo.devices. This might lead to a server crash later on (on InitAndStartDevices for instance) when the device control proc would be called for an invalid device. Signed-off-by: Peter Hutterer --- hw/xfree86/common/xf86Xinput.c | 1 + 1 file changed, 1 insertion(+) diff --git a/hw/xfree86/common/xf86Xinput.c b/hw/xfree86/common/xf86Xinput.c index 96aff1538..a035fca7f 100644 --- a/hw/xfree86/common/xf86Xinput.c +++ b/hw/xfree86/common/xf86Xinput.c @@ -548,6 +548,7 @@ xf86NewInputDevice(IDevPtr idev, DeviceIntPtr *pdev, BOOL enable) if (rval != Success) { xf86Msg(X_ERROR, "Couldn't init device \"%s\"\n", idev->identifier); + RemoveDevice(dev); goto unwind; } From faf7dfa099f5b42a703313fbd1bf8afdad07a179 Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Wed, 15 Apr 2009 18:26:06 +1000 Subject: [PATCH 53/67] randr12: looking up these bits if randr isn't initialised is bad. When xinerama is enabled we don't get randr protocol, but the driver might still want randr internals --- hw/xfree86/modes/xf86RandR12.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/hw/xfree86/modes/xf86RandR12.c b/hw/xfree86/modes/xf86RandR12.c index dacb5d27d..ac066a85f 100644 --- a/hw/xfree86/modes/xf86RandR12.c +++ b/hw/xfree86/modes/xf86RandR12.c @@ -754,8 +754,8 @@ Bool xf86RandR12CreateScreenResources (ScreenPtr pScreen) { ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; - xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(pScrn); - XF86RandRInfoPtr randrp = XF86RANDRINFO(pScreen); + xf86CrtcConfigPtr config; + XF86RandRInfoPtr randrp; int c; int width, height; int mmWidth, mmHeight; @@ -765,6 +765,8 @@ xf86RandR12CreateScreenResources (ScreenPtr pScreen) return TRUE; #endif + config = XF86_CRTC_CONFIG_PTR(pScrn); + randrp = XF86RANDRINFO(pScreen); /* * Compute size of screen */ From 74d27c8b5bac7c8d2ed02ba86e09bf09924ce05c Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Wed, 15 Apr 2009 15:44:17 +0200 Subject: [PATCH 54/67] Fix build on hurd-i386 http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=523970 --- configure.ac | 3 +++ hw/xfree86/os-support/bus/Pci.h | 2 +- hw/xfree86/os-support/hurd/Makefile.am | 1 + hw/xfree86/os-support/hurd/hurd_video.c | 28 +++++++--------------- hw/xfree86/os-support/shared/stdResource.c | 2 +- 5 files changed, 15 insertions(+), 21 deletions(-) diff --git a/configure.ac b/configure.ac index 033173032..9263fc0c1 100644 --- a/configure.ac +++ b/configure.ac @@ -1455,6 +1455,9 @@ if test "x$XORG" = xyes; then gnu*) XORG_OS="gnu" XORG_OS_SUBDIR="hurd" + # Use the same stubs as BSD for old functions, since we now + # use libpciaccess for PCI + xorg_bus_bsdpci="yes" ;; *) XORG_OS="unknown" diff --git a/hw/xfree86/os-support/bus/Pci.h b/hw/xfree86/os-support/bus/Pci.h index 3a3f3d7f8..7623e9738 100644 --- a/hw/xfree86/os-support/bus/Pci.h +++ b/hw/xfree86/os-support/bus/Pci.h @@ -169,7 +169,7 @@ #endif /* !defined(DEBUGPCI) */ #if defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__) || \ - defined(__DragonFly__) || defined(__sun) + defined(__DragonFly__) || defined(__sun) || defined(__GNU__) #define ARCH_PCI_INIT bsdPciInit #endif diff --git a/hw/xfree86/os-support/hurd/Makefile.am b/hw/xfree86/os-support/hurd/Makefile.am index b405b1f2a..9bbe2afaf 100644 --- a/hw/xfree86/os-support/hurd/Makefile.am +++ b/hw/xfree86/os-support/hurd/Makefile.am @@ -5,6 +5,7 @@ libhurd_la_SOURCES = hurd_bell.c hurd_init.c hurd_mmap.c \ $(srcdir)/../shared/VTsw_noop.c \ $(srcdir)/../shared/posix_tty.c \ $(srcdir)/../shared/stdResource.c \ + $(srcdir)/../shared/vidmem.c \ $(srcdir)/../shared/sigiostubs.c \ $(srcdir)/../shared/pm_noop.c \ $(srcdir)/../shared/kmod_noop.c \ diff --git a/hw/xfree86/os-support/hurd/hurd_video.c b/hw/xfree86/os-support/hurd/hurd_video.c index 9f2e2bd01..b8b00c892 100644 --- a/hw/xfree86/os-support/hurd/hurd_video.c +++ b/hw/xfree86/os-support/hurd/hurd_video.c @@ -41,8 +41,8 @@ /************************************************************************** * Video Memory Mapping section ***************************************************************************/ -pointer -xf86MapVidMem(int ScreenNum,int Flags, unsigned long Base, unsigned long Size) +static pointer +mapVidMem(int ScreenNum,int Flags, unsigned long Base, unsigned long Size) { mach_port_t device,iopl_dev; memory_object_t iopl_mem; @@ -95,8 +95,8 @@ xf86MapVidMem(int ScreenNum,int Flags, unsigned long Base, unsigned long Size) return (pointer)addr; } -void -xf86UnMapVidMem(int ScreenNum,pointer Base,unsigned long Size) +static void +unmapVidMem(int ScreenNum,pointer Base,unsigned long Size) { kern_return_t err = vm_deallocate(mach_task_self(), (int)Base, Size); if( err ) @@ -107,12 +107,6 @@ xf86UnMapVidMem(int ScreenNum,pointer Base,unsigned long Size) return; } -Bool -xf86LinearVidMem() -{ - return(TRUE); -} - /************************************************************************** * I/O Permissions section ***************************************************************************/ @@ -143,14 +137,10 @@ xf86DisableIO() } void -xf86MapReadSideEffects(int ScreenNum, int Flags, pointer Base, - unsigned long Size) +xf86OSInitVidMem(VidMemInfoPtr pVidMem) { + pVidMem->linearSupported = TRUE; + pVidMem->mapMem = mapVidMem; + pVidMem->unmapMem = unmapVidMem; + pVidMem->initialised = TRUE; } - -Bool -xf86CheckMTRR(int s) -{ - return FALSE; -} - diff --git a/hw/xfree86/os-support/shared/stdResource.c b/hw/xfree86/os-support/shared/stdResource.c index 8cb101488..a4c162d97 100644 --- a/hw/xfree86/os-support/shared/stdResource.c +++ b/hw/xfree86/os-support/shared/stdResource.c @@ -44,7 +44,7 @@ #include "bus/Pci.h" #if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || \ - defined(__DragonFly__) || defined(__sun) + defined(__DragonFly__) || defined(__sun) || defined(__GNU__) #define xf86StdAccResFromOS xf86AccResFromOS #endif From b3e3154cce47add97f5561088036ce3b9e7dc937 Mon Sep 17 00:00:00 2001 From: Robert Noland Date: Wed, 15 Apr 2009 12:06:19 -0500 Subject: [PATCH 55/67] One = is more than adequate here. Make is sh safe. --- configure.ac | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/configure.ac b/configure.ac index 9263fc0c1..ef5062705 100644 --- a/configure.ac +++ b/configure.ac @@ -897,7 +897,7 @@ case "$DRI2,$HAVE_DRI2PROTO" in DRI2=yes ;; esac -AM_CONDITIONAL(DRI2, test "x$DRI2" == xyes) +AM_CONDITIONAL(DRI2, test "x$DRI2" = xyes) if test "x$DRI" = xyes || test "x$DRI2" = xyes; then PKG_CHECK_MODULES([LIBDRM], [libdrm >= 2.3.0]) @@ -924,7 +924,7 @@ if test "x$DRI2" = xyes; then DRI2_AIGLX=no fi fi -AM_CONDITIONAL(DRI2_AIGLX, test "x$DRI2_AIGLX" == xyes) +AM_CONDITIONAL(DRI2_AIGLX, test "x$DRI2_AIGLX" = xyes) AM_CONDITIONAL(XINERAMA, [test "x$XINERAMA" = xyes]) From de1e43181bd670877b994db221ad8a04b5d63324 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Wed, 15 Apr 2009 11:13:48 -0700 Subject: [PATCH 56/67] DRI2: Don't leave empty entries in private->buffers This should fix bug #21130. Signed-off-by: Ian Romanick --- glx/glxdri2.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/glx/glxdri2.c b/glx/glxdri2.c index 9dac8a6a3..9e452c4fd 100644 --- a/glx/glxdri2.c +++ b/glx/glxdri2.c @@ -408,7 +408,7 @@ dri2GetBuffers(__DRIdrawable *driDrawable, __GLXDRIdrawable *private = loaderPrivate; DRI2BufferPtr buffers; int i; - int skip = 0; + int j; buffers = DRI2GetBuffers(private->base.pDraw, width, height, attachments, count, out_count); @@ -422,23 +422,24 @@ dri2GetBuffers(__DRIdrawable *driDrawable, /* This assumes the DRI2 buffer attachment tokens matches the * __DRIbuffer tokens. */ + j = 0; for (i = 0; i < *out_count; i++) { /* Do not send the real front buffer of a window to the client. */ if ((private->base.pDraw->type == DRAWABLE_WINDOW) && (buffers[i].attachment == DRI2BufferFrontLeft)) { - skip++; continue; } - private->buffers[i].attachment = buffers[i].attachment; - private->buffers[i].name = buffers[i].name; - private->buffers[i].pitch = buffers[i].pitch; - private->buffers[i].cpp = buffers[i].cpp; - private->buffers[i].flags = buffers[i].flags; + private->buffers[j].attachment = buffers[i].attachment; + private->buffers[j].name = buffers[i].name; + private->buffers[j].pitch = buffers[i].pitch; + private->buffers[j].cpp = buffers[i].cpp; + private->buffers[j].flags = buffers[i].flags; + j++; } - *out_count -= skip; + *out_count = j; return private->buffers; } From dd6e8a14ec1c8f4ed9c51ca2764261e6e48d13b3 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Sat, 11 Apr 2009 11:19:29 +1000 Subject: [PATCH 57/67] Xi: fix a typo in a #ifdef Signed-off-by: Peter Hutterer --- Xi/xiproperty.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Xi/xiproperty.h b/Xi/xiproperty.h index bf562b1aa..e66b447ea 100644 --- a/Xi/xiproperty.h +++ b/Xi/xiproperty.h @@ -23,8 +23,8 @@ * Author: Peter Hutterer */ -#ifndef XIPROPERTY_C -#define XIPROPERTY_C +#ifndef XIPROPERTY_H +#define XIPROPERTY_H int ProcXListDeviceProperties (ClientPtr client); int ProcXChangeDeviceProperty (ClientPtr client); @@ -43,4 +43,4 @@ void SRepXListDeviceProperties(ClientPtr client, int size, void SRepXGetDeviceProperty(ClientPtr client, int size, xGetDevicePropertyReply *rep); -#endif /* XIPROPERTY_C */ +#endif /* XIPROPERTY_H */ From 4e4e263bc073bf452f19c932b937c4881ae71f64 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Wed, 15 Apr 2009 22:16:49 +1000 Subject: [PATCH 58/67] dix: remove un-used parameter "core" from AllowSome Signed-off-by: Peter Hutterer --- Xi/allowev.c | 12 ++++++------ dix/events.c | 19 +++++++++---------- include/dix.h | 3 +-- 3 files changed, 16 insertions(+), 18 deletions(-) diff --git a/Xi/allowev.c b/Xi/allowev.c index 5f0753d42..96f3b543c 100644 --- a/Xi/allowev.c +++ b/Xi/allowev.c @@ -104,22 +104,22 @@ ProcXAllowDeviceEvents(ClientPtr client) switch (stuff->mode) { case ReplayThisDevice: - AllowSome(client, time, thisdev, NOT_GRABBED, FALSE); + AllowSome(client, time, thisdev, NOT_GRABBED); break; case SyncThisDevice: - AllowSome(client, time, thisdev, FREEZE_NEXT_EVENT, FALSE); + AllowSome(client, time, thisdev, FREEZE_NEXT_EVENT); break; case AsyncThisDevice: - AllowSome(client, time, thisdev, THAWED, FALSE); + AllowSome(client, time, thisdev, THAWED); break; case AsyncOtherDevices: - AllowSome(client, time, thisdev, THAW_OTHERS, FALSE); + AllowSome(client, time, thisdev, THAW_OTHERS); break; case SyncAll: - AllowSome(client, time, thisdev, FREEZE_BOTH_NEXT_EVENT, FALSE); + AllowSome(client, time, thisdev, FREEZE_BOTH_NEXT_EVENT); break; case AsyncAll: - AllowSome(client, time, thisdev, THAWED_BOTH, FALSE); + AllowSome(client, time, thisdev, THAWED_BOTH); break; default: client->errorValue = stuff->mode; diff --git a/dix/events.c b/dix/events.c index e73044e83..faa84259c 100644 --- a/dix/events.c +++ b/dix/events.c @@ -1573,8 +1573,7 @@ void AllowSome(ClientPtr client, TimeStamp time, DeviceIntPtr thisDev, - int newState, - Bool core) + int newState) { Bool thisGrabbed, otherGrabbed, othersFrozen, thisSynced; TimeStamp grabTime; @@ -1716,28 +1715,28 @@ ProcAllowEvents(ClientPtr client) switch (stuff->mode) { case ReplayPointer: - AllowSome(client, time, mouse, NOT_GRABBED, True); + AllowSome(client, time, mouse, NOT_GRABBED); break; case SyncPointer: - AllowSome(client, time, mouse, FREEZE_NEXT_EVENT, True); + AllowSome(client, time, mouse, FREEZE_NEXT_EVENT); break; case AsyncPointer: - AllowSome(client, time, mouse, THAWED, True); + AllowSome(client, time, mouse, THAWED); break; case ReplayKeyboard: - AllowSome(client, time, keybd, NOT_GRABBED, True); + AllowSome(client, time, keybd, NOT_GRABBED); break; case SyncKeyboard: - AllowSome(client, time, keybd, FREEZE_NEXT_EVENT, True); + AllowSome(client, time, keybd, FREEZE_NEXT_EVENT); break; case AsyncKeyboard: - AllowSome(client, time, keybd, THAWED, True); + AllowSome(client, time, keybd, THAWED); break; case SyncBoth: - AllowSome(client, time, keybd, FREEZE_BOTH_NEXT_EVENT, True); + AllowSome(client, time, keybd, FREEZE_BOTH_NEXT_EVENT); break; case AsyncBoth: - AllowSome(client, time, keybd, THAWED_BOTH, True); + AllowSome(client, time, keybd, THAWED_BOTH); break; default: client->errorValue = stuff->mode; diff --git a/include/dix.h b/include/dix.h index 552a2d008..b1333dc5c 100644 --- a/include/dix.h +++ b/include/dix.h @@ -353,8 +353,7 @@ extern _X_EXPORT void AllowSome( ClientPtr /* client */, TimeStamp /* time */, DeviceIntPtr /* thisDev */, - int /* newState */, - Bool /* core */); + int /* newState */); extern _X_EXPORT void ReleaseActiveGrabs( ClientPtr client); From b406886bbffadaa52864a99f2a0520999eadc15d Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Tue, 14 Apr 2009 16:57:29 +1000 Subject: [PATCH 59/67] input: allow NULL as XkbRMVLOSet in InitKeyboardDeviceStruct. Virtually all callers use XkbGetRulesDefault(&rmlvo); InitKeyboardDeviceStruct(..., rmlvo); Let's save them the trouble and accept NULL as a hint to take the default RMLVO. Signed-off-by: Peter Hutterer Acked-by: Benjamin Close Signed-off-by: Daniel Stone --- Xi/exevents.c | 13 +++---------- dix/devices.c | 4 +--- hw/vfb/InitInput.c | 4 +--- hw/xnest/Keyboard.c | 9 +-------- hw/xquartz/quartzKeyboard.c | 4 +--- xkb/xkbInit.c | 10 +++++++++- 6 files changed, 16 insertions(+), 28 deletions(-) diff --git a/Xi/exevents.c b/Xi/exevents.c index 478866553..cfae57de1 100644 --- a/Xi/exevents.c +++ b/Xi/exevents.c @@ -226,11 +226,7 @@ DeepCopyFeedbackClasses(DeviceIntPtr from, DeviceIntPtr to) to->kbdfeed = classes->kbdfeed; if (!to->kbdfeed) - { - XkbRMLVOSet rmlvo; - XkbGetRulesDflts(&rmlvo); - InitKeyboardDeviceStruct(to, &rmlvo, NULL, NULL); - } + InitKeyboardDeviceStruct(to, NULL, NULL, NULL); } k = &to->kbdfeed; @@ -473,11 +469,8 @@ DeepCopyDeviceClasses(DeviceIntPtr from, DeviceIntPtr to) UnusedClassesPrivateKey); to->key = classes->key; if (!to->key) - { - XkbRMLVOSet rmlvo; - XkbGetRulesDflts(&rmlvo); - InitKeyboardDeviceStruct(to, &rmlvo, NULL, NULL); - } else + InitKeyboardDeviceStruct(to, NULL, NULL, NULL); + else classes->key = NULL; } diff --git a/dix/devices.c b/dix/devices.c index b9d1c85a5..d14eddd72 100644 --- a/dix/devices.c +++ b/dix/devices.c @@ -471,12 +471,10 @@ CoreKeyboardCtl(DeviceIntPtr pDev, KeybdCtrl *ctrl) static int CoreKeyboardProc(DeviceIntPtr pDev, int what) { - XkbRMLVOSet rmlvo; switch (what) { case DEVICE_INIT: - XkbGetRulesDflts(&rmlvo); - if (!InitKeyboardDeviceStruct(pDev, &rmlvo, CoreKeyboardBell, + if (!InitKeyboardDeviceStruct(pDev, NULL, CoreKeyboardBell, CoreKeyboardCtl)) { ErrorF("Keyboard initialization failed. This could be a missing " diff --git a/hw/vfb/InitInput.c b/hw/vfb/InitInput.c index aa902522a..4c8c99653 100644 --- a/hw/vfb/InitInput.c +++ b/hw/vfb/InitInput.c @@ -66,13 +66,11 @@ static int vfbKeybdProc(DeviceIntPtr pDevice, int onoff) { DevicePtr pDev = (DevicePtr)pDevice; - XkbRMLVOSet rmlvo; switch (onoff) { case DEVICE_INIT: - XkbGetRulesDflts(&rmlvo); - InitKeyboardDeviceStruct(pDevice, &rmlvo, NULL, NULL); + InitKeyboardDeviceStruct(pDevice, NULL, NULL, NULL); break; case DEVICE_ON: pDev->on = TRUE; diff --git a/hw/xnest/Keyboard.c b/hw/xnest/Keyboard.c index 8404c8bfa..f94e26079 100644 --- a/hw/xnest/Keyboard.c +++ b/hw/xnest/Keyboard.c @@ -121,7 +121,6 @@ xnestKeyboardProc(DeviceIntPtr pDev, int onoff) int i; XKeyboardState values; XkbDescPtr xkb; - XkbRMLVOSet rmlvo; int op, event, error, major, minor; switch (onoff) @@ -165,13 +164,7 @@ xnestKeyboardProc(DeviceIntPtr pDev, int onoff) } XkbGetControls(xnestDisplay, XkbAllControlsMask, xkb); - rmlvo.rules = XKB_DFLT_RULES; - rmlvo.model = XKB_DFLT_MODEL; - rmlvo.layout = XKB_DFLT_LAYOUT; - rmlvo.variant = XKB_DFLT_VARIANT; - rmlvo.options = XKB_DFLT_OPTIONS; - - InitKeyboardDeviceStruct(pDev, &rmlvo, + InitKeyboardDeviceStruct(pDev, NULL, xnestBell, xnestChangeKeyboardControl); XkbDDXChangeControls(pDev, xkb->ctrls, xkb->ctrls); XkbFreeKeyboard(xkb, 0, False); diff --git a/hw/xquartz/quartzKeyboard.c b/hw/xquartz/quartzKeyboard.c index 823c2e67c..2b8cb13f8 100644 --- a/hw/xquartz/quartzKeyboard.c +++ b/hw/xquartz/quartzKeyboard.c @@ -317,7 +317,6 @@ void DarwinKeyboardInit(DeviceIntPtr pDev) { XkbComponentNamesRec names; CFIndex value; BOOL ok; - XkbRMLVOSet rmlvo; // Open a shared connection to the HID System. // Note that the Event Status Driver is really just a wrapper @@ -328,8 +327,7 @@ void DarwinKeyboardInit(DeviceIntPtr pDev) { bzero(&names, sizeof(names)); - XkbGetRulesDflts(&rmlvo); - InitKeyboardDeviceStruct(pDev, &rmlvo, QuartzBell, + InitKeyboardDeviceStruct(pDev, NULL, QuartzBell, DarwinChangeKeyboardControl); /* Get our key repeat settings from GlobalPreferences */ diff --git a/xkb/xkbInit.c b/xkb/xkbInit.c index 1f5f8dc49..2e7561294 100644 --- a/xkb/xkbInit.c +++ b/xkb/xkbInit.c @@ -474,10 +474,18 @@ InitKeyboardDeviceStruct(DeviceIntPtr dev, XkbRMLVOSet *rmlvo, XkbSrvLedInfoPtr sli; XkbChangesRec changes; XkbEventCauseRec cause; + XkbRMLVOSet rmlvo_dflts = { NULL }; - if (dev->key || dev->kbdfeed || !rmlvo) + if (dev->key || dev->kbdfeed) return False; + if (!rmlvo) + { + rmlvo = &rmlvo_dflts; + XkbGetRulesDflts(rmlvo); + } + + memset(&changes, 0, sizeof(changes)); XkbSetCauseUnknown(&cause); From 56a5955c8cd87137248edb2cbc65d384376d72ad Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Tue, 14 Apr 2009 17:05:04 +1000 Subject: [PATCH 60/67] xkb: strdup the values returned by XkbGetRulesDflts XkbGetRulesDftls may get a copy of what will later be freed when passed into XkbSetRulesDftls. On the second run of XkbGet/SetRulesDflts: XkbGetRulesDflts(rmlvo) rmlvo->rules = current-rules XkbSetRulesDflts(rmlvo) free(current-rules) current-rules = strdup(rmlvo->rules) Leaving us with garbage in current-rules. This patch requires callers of XkbGetRulesDflts to free the associated memory. See also http://lists.freedesktop.org/archives/xorg-devel/2009-February/000305.html Reported-by: Benjamin Close Signed-off-by: Peter Hutterer Acked-by: Benjamin Close Signed-off-by: Daniel Stone --- xkb/xkbInit.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/xkb/xkbInit.c b/xkb/xkbInit.c index 2e7561294..9d4d9a212 100644 --- a/xkb/xkbInit.c +++ b/xkb/xkbInit.c @@ -111,6 +111,10 @@ static Bool XkbWantRulesProp= XKB_DFLT_RULES_PROP; /***====================================================================***/ +/** + * Get the current default XKB rules. + * Caller must free the data in rmlvo. + */ void XkbGetRulesDflts(XkbRMLVOSet *rmlvo) { @@ -124,6 +128,12 @@ XkbGetRulesDflts(XkbRMLVOSet *rmlvo) else rmlvo->variant= XKB_DFLT_VARIANT; if (XkbOptionsDflt) rmlvo->options= XkbOptionsDflt; else rmlvo->options= XKB_DFLT_OPTIONS; + + rmlvo->rules = strdup(rmlvo->rules); + rmlvo->model = strdup(rmlvo->model); + rmlvo->layout = strdup(rmlvo->layout); + rmlvo->variant = strdup(rmlvo->variant); + rmlvo->options = strdup(rmlvo->options); } static Bool @@ -586,6 +596,17 @@ InitKeyboardDeviceStruct(DeviceIntPtr dev, XkbRMLVOSet *rmlvo, XkbSetRulesDflts(rmlvo); XkbSetRulesUsed(rmlvo); + if (rmlvo_dflts.rules) + xfree(rmlvo_dflts.rules); + if (rmlvo_dflts.model) + xfree(rmlvo_dflts.model); + if (rmlvo_dflts.layout) + xfree(rmlvo_dflts.layout); + if (rmlvo_dflts.variant) + xfree(rmlvo_dflts.variant); + if (rmlvo_dflts.options) + xfree(rmlvo_dflts.options); + return TRUE; unwind_desc: From 6045506be0cebca4ebbe943ae77f020aafa703d4 Mon Sep 17 00:00:00 2001 From: Eamon Walsh Date: Thu, 16 Apr 2009 22:33:12 -0400 Subject: [PATCH 61/67] security: Revert behavior of extension access for compatibility. Previously, three extensions were defined as "trusted" by the extension: BIG-REQUESTS, XC-MISC, and XPrint. No other extensions were permitted to be used by untrusted clients. In commit 8b5d21cc1d1f4e9d20e5d5eca44cb1e60a419763 this was changed for some reason. Return to the old, compatible behavior. --- Xext/security.c | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/Xext/security.c b/Xext/security.c index c9077c87e..0cbb7e37e 100644 --- a/Xext/security.c +++ b/Xext/security.c @@ -61,10 +61,10 @@ typedef struct { } SecurityStateRec; /* Extensions that untrusted clients shouldn't have access to */ -static char *SecurityUntrustedExtensions[] = { - "RandR", - "SECURITY", - "XFree86-DGA", +static char *SecurityTrustedExtensions[] = { + "XC-MISC", + "BIG-REQUESTS", + "XpExtension", NULL }; @@ -852,16 +852,18 @@ SecurityExtension(CallbackListPtr *pcbl, pointer unused, pointer calldata) subj = dixLookupPrivate(&rec->client->devPrivates, stateKey); - if (subj->haveState && subj->trustLevel != XSecurityClientTrusted) - while (SecurityUntrustedExtensions[i]) - if (!strcmp(SecurityUntrustedExtensions[i++], rec->ext->name)) { - SecurityAudit("Security: denied client %d access to extension " - "%s on request %s\n", - rec->client->index, rec->ext->name, - SecurityLookupRequestName(rec->client)); - rec->status = BadAccess; - return; - } + if (subj->haveState && subj->trustLevel == XSecurityClientTrusted) + return; + + while (SecurityTrustedExtensions[i]) + if (!strcmp(SecurityTrustedExtensions[i++], rec->ext->name)) + return; + + SecurityAudit("Security: denied client %d access to extension " + "%s on request %s\n", + rec->client->index, rec->ext->name, + SecurityLookupRequestName(rec->client)); + rec->status = BadAccess; } static void From 3481b32ab971c41cb972f6819ae049f3e9f7033b Mon Sep 17 00:00:00 2001 From: Eamon Walsh Date: Thu, 16 Apr 2009 22:39:54 -0400 Subject: [PATCH 62/67] security: Fix a crash caused by wrong ordering of format arguments. --- Xext/security.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Xext/security.c b/Xext/security.c index 0cbb7e37e..f1e0bb16f 100644 --- a/Xext/security.c +++ b/Xext/security.c @@ -948,9 +948,10 @@ SecuritySend(CallbackListPtr *pcbl, pointer unused, pointer calldata) SecurityAudit("Security: denied client %d from sending event " "of type %s to window 0x%x of client %d\n", - rec->client->index, rec->pWin->drawable.id, - wClient(rec->pWin)->index, - LookupEventName(rec->events[i].u.u.type)); + rec->client->index, + LookupEventName(rec->events[i].u.u.type), + rec->pWin->drawable.id, + wClient(rec->pWin)->index); rec->status = BadAccess; return; } From 4559d2ace6ac55fe361f572ded0769cdd1f3b545 Mon Sep 17 00:00:00 2001 From: Eamon Walsh Date: Thu, 16 Apr 2009 22:48:11 -0400 Subject: [PATCH 63/67] security: Grant untrusted windows remove access on all windows. This allows untrusted clients to destroy their own windows when they have been reparented by a trusted window manager. --- Xext/security.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Xext/security.c b/Xext/security.c index f1e0bb16f..7962fdb37 100644 --- a/Xext/security.c +++ b/Xext/security.c @@ -74,6 +74,7 @@ static char *SecurityTrustedExtensions[] = { static const Mask SecurityResourceMask = DixGetAttrAccess | DixReceiveAccess | DixListPropAccess | DixGetPropAccess | DixListAccess; +static const Mask SecurityWindowExtraMask = DixRemoveAccess; static const Mask SecurityRootWindowExtraMask = DixReceiveAccess | DixSendAccess | DixAddAccess | DixRemoveAccess; static const Mask SecurityDeviceMask = @@ -817,6 +818,10 @@ SecurityResource(CallbackListPtr *pcbl, pointer unused, pointer calldata) if (subj->haveState && subj->trustLevel != XSecurityClientTrusted) ((WindowPtr)rec->res)->forcedBG = TRUE; + /* additional permissions for specific resource types */ + if (rec->rtype == RT_WINDOW) + allowed |= SecurityWindowExtraMask; + /* special checks for server-owned resources */ if (cid == 0) { if (rec->rtype & RC_DRAWABLE) From d9bf52b4abd29a3c206cd1e765b680659ddac1c6 Mon Sep 17 00:00:00 2001 From: David Jander Date: Fri, 17 Apr 2009 01:34:18 -0400 Subject: [PATCH 64/67] [kdrive] Fix rotation of pointer Rotation matrix for pointer coordinates was incomplete and pointers with absolute coordinates did not work correctly in xserver (kdrive) when the sceen was rotated other than by 0 degrees. Signed-off-by: David Jander Signed-off-by: James Cloos --- hw/kdrive/src/kinput.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hw/kdrive/src/kinput.c b/hw/kdrive/src/kinput.c index 4b2d709d6..7ed36017f 100644 --- a/hw/kdrive/src/kinput.c +++ b/hw/kdrive/src/kinput.c @@ -1918,8 +1918,8 @@ KdEnqueuePointerEvent(KdPointerInfo *pi, unsigned long flags, int rx, int ry, } else { if (pi->transformCoordinates) { - x = matrix[0][0] * rx + matrix[0][1] * ry; - y = matrix[1][0] * rx + matrix[1][1] * ry; + x = matrix[0][0] * rx + matrix[0][1] * ry + matrix[0][2]; + y = matrix[1][0] * rx + matrix[1][1] * ry + matrix[1][2]; } else { x = rx; From ad76656f8869e2065f0c4e66cfbeef0b42c61769 Mon Sep 17 00:00:00 2001 From: Adam Jackson Date: Fri, 17 Apr 2009 17:46:58 -0400 Subject: [PATCH 65/67] randr: Accept gamma set requests from XF86VidMode clients too --- hw/xfree86/common/xf86RandR.c | 1 + hw/xfree86/common/xf86cmap.c | 13 ++++++-- hw/xfree86/modes/xf86RandR12.c | 55 ++++++++++++++++++++++++++++++++++ 3 files changed, 67 insertions(+), 2 deletions(-) diff --git a/hw/xfree86/common/xf86RandR.c b/hw/xfree86/common/xf86RandR.c index 0e06de661..02dcc34b4 100644 --- a/hw/xfree86/common/xf86RandR.c +++ b/hw/xfree86/common/xf86RandR.c @@ -30,6 +30,7 @@ #include "mibank.h" #include "globals.h" #include "xf86.h" +#include "xf86str.h" #include "xf86Priv.h" #include "xf86DDC.h" #include "mipointer.h" diff --git a/hw/xfree86/common/xf86cmap.c b/hw/xfree86/common/xf86cmap.c index 316470df4..a627b5315 100644 --- a/hw/xfree86/common/xf86cmap.c +++ b/hw/xfree86/common/xf86cmap.c @@ -85,6 +85,7 @@ typedef struct { Bool (*EnterVT)(int, int); Bool (*SwitchMode)(int, DisplayModePtr, int); int (*SetDGAMode)(int, int, DGADevicePtr); + xf86ChangeGammaProc *ChangeGamma; int maxColors; int sigRGBbits; int gammaElements; @@ -195,6 +196,7 @@ Bool xf86HandleColormaps( pScreenPriv->EnterVT = pScrn->EnterVT; pScreenPriv->SwitchMode = pScrn->SwitchMode; pScreenPriv->SetDGAMode = pScrn->SetDGAMode; + pScreenPriv->ChangeGamma = pScrn->ChangeGamma; if (!(flags & CMAP_LOAD_EVEN_IF_OFFSCREEN)) { pScrn->EnterVT = CMapEnterVT; @@ -824,6 +826,7 @@ CMapUnwrapScreen(ScreenPtr pScreen) pScrn->EnterVT = pScreenPriv->EnterVT; pScrn->SwitchMode = pScreenPriv->SwitchMode; pScrn->SetDGAMode = pScreenPriv->SetDGAMode; + pScrn->ChangeGamma = pScreenPriv->ChangeGamma; xfree(pScreenPriv->gamma); xfree(pScreenPriv->PreAllocIndices); @@ -889,6 +892,7 @@ CMapChangeGamma( int index, Gamma gamma ){ + int ret = Success; ScrnInfoPtr pScrn = xf86Screens[index]; ScreenPtr pScreen = pScrn->pScreen; CMapColormapPtr pColPriv; @@ -954,7 +958,12 @@ CMapChangeGamma( CMapReinstallMap(pMap); } - return Success; + pScrn->ChangeGamma = pScreenPriv->ChangeGamma; + if (pScrn->ChangeGamma) + ret = pScrn->ChangeGamma(index, gamma); + pScrn->ChangeGamma = CMapChangeGamma; + + return ret; } @@ -1113,5 +1122,5 @@ xf86ChangeGamma( if(pScrn->ChangeGamma) return (*pScrn->ChangeGamma)(pScreen->myNum, gamma); - return Success; /* Success? */ + return BadImplementation; } diff --git a/hw/xfree86/modes/xf86RandR12.c b/hw/xfree86/modes/xf86RandR12.c index ac066a85f..f941a3b4a 100644 --- a/hw/xfree86/modes/xf86RandR12.c +++ b/hw/xfree86/modes/xf86RandR12.c @@ -1689,6 +1689,60 @@ xf86RandR13SetPanning (ScreenPtr pScreen, } } +/* + * Compatibility with XF86VidMode's gamma changer. This necessarily clobbers + * any per-crtc setup. You asked for it... + */ + +static void +gamma_to_ramp(float gamma, CARD16 *ramp, int size) +{ + int i; + + for (i = 0; i < size; i++) { + if (gamma == 1.0) + ramp[i] = i << 8; + else + ramp[i] = (CARD16)(pow((double)i / (double)(size - 1), gamma) + * (double)(size - 1) * 256); + } +} + +static int +xf86RandR12ChangeGamma(int scrnIndex, Gamma gamma) +{ + int i, size = 0; + CARD16 *points, *red, *green, *blue; + ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; + rrScrPrivPtr rp = rrGetScrPriv(pScrn->pScreen); + + for (i = 0; i < rp->numCrtcs; i++) + size = max(size, rp->crtcs[i]->gammaSize); + + if (!size) + return Success; + + points = xcalloc(size, 3 * sizeof(CARD16)); + if (!points) + return BadAlloc; + + red = points; + green = points + size; + blue = points + 2 * size; + + for (i = 0; i < rp->numCrtcs; i++) { + gamma_to_ramp(gamma.red, red, rp->crtcs[i]->gammaSize); + gamma_to_ramp(gamma.green, green, rp->crtcs[i]->gammaSize); + gamma_to_ramp(gamma.blue, blue, rp->crtcs[i]->gammaSize); + RRCrtcGammaSet(rp->crtcs[i], red, green, blue); + memset(points, 0, 3 * size * sizeof(CARD16)); + } + + xfree(points); + + return Success; +} + static Bool xf86RandR12Init12 (ScreenPtr pScreen) { @@ -1710,6 +1764,7 @@ xf86RandR12Init12 (ScreenPtr pScreen) rp->rrModeDestroy = xf86RandR12ModeDestroy; rp->rrSetConfig = NULL; pScrn->PointerMoved = xf86RandR12PointerMoved; + pScrn->ChangeGamma = xf86RandR12ChangeGamma; if (!xf86RandR12CreateObjects12 (pScreen)) return FALSE; From 62d2fb68638e9f2aa3c1d72027619c4d38f5b812 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Thu, 16 Apr 2009 17:06:33 +1000 Subject: [PATCH 66/67] xkb: Add XkbFreeRMLVOSet helper function. Signed-off-by: Peter Hutterer Acked-by: Dan Nicholson --- include/xkbsrv.h | 5 +++++ xkb/xkbInit.c | 30 +++++++++++++++++++----------- 2 files changed, 24 insertions(+), 11 deletions(-) diff --git a/include/xkbsrv.h b/include/xkbsrv.h index 8a81431ea..df3308534 100644 --- a/include/xkbsrv.h +++ b/include/xkbsrv.h @@ -858,6 +858,11 @@ extern _X_EXPORT void XkbGetRulesDflts( XkbRMLVOSet * /* rmlvo */ ); +extern _X_EXPORT void XkbFreeRMLVOSet( + XkbRMLVOSet * /* rmlvo */, + Bool /* freeRMLVO */ +); + extern _X_EXPORT void XkbSetRulesDflts( XkbRMLVOSet * /* rmlvo */ ); diff --git a/xkb/xkbInit.c b/xkb/xkbInit.c index 9d4d9a212..5ac06feae 100644 --- a/xkb/xkbInit.c +++ b/xkb/xkbInit.c @@ -136,6 +136,24 @@ XkbGetRulesDflts(XkbRMLVOSet *rmlvo) rmlvo->options = strdup(rmlvo->options); } +void +XkbFreeRMLVOSet(XkbRMLVOSet *rmlvo, Bool freeRMLVO) +{ + if (!rmlvo) + return; + + xfree(rmlvo->rules); + xfree(rmlvo->model); + xfree(rmlvo->layout); + xfree(rmlvo->variant); + xfree(rmlvo->options); + + if (freeRMLVO) + xfree(rmlvo); + else + memset(rmlvo, 0, sizeof(XkbRMLVOSet)); +} + static Bool XkbWriteRulesProp(ClientPtr client, pointer closure) { @@ -595,17 +613,7 @@ InitKeyboardDeviceStruct(DeviceIntPtr dev, XkbRMLVOSet *rmlvo, XkbSetRulesDflts(rmlvo); XkbSetRulesUsed(rmlvo); - - if (rmlvo_dflts.rules) - xfree(rmlvo_dflts.rules); - if (rmlvo_dflts.model) - xfree(rmlvo_dflts.model); - if (rmlvo_dflts.layout) - xfree(rmlvo_dflts.layout); - if (rmlvo_dflts.variant) - xfree(rmlvo_dflts.variant); - if (rmlvo_dflts.options) - xfree(rmlvo_dflts.options); + XkbFreeRMLVOSet(&rmlvo_dflts, FALSE); return TRUE; From 0e0642ee9466d3268476d0084a83a9d93a4aa555 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Thu, 16 Apr 2009 16:17:07 +1000 Subject: [PATCH 67/67] os: don't malloc memory in LogVMessageVerb. LogVWrite is limited to a buffer size of 1024, so we don't loose anything here by truncating. This way we can use LogVMessageVerb (and xf86Msg and friends) during signal handlers with the normal message types. Signed-off-by: Peter Hutterer Acked-by: Alan Coopersmith --- os/log.c | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) diff --git a/os/log.c b/os/log.c index 3961b0b9f..8108890b6 100644 --- a/os/log.c +++ b/os/log.c @@ -316,7 +316,7 @@ void LogVMessageVerb(MessageType type, int verb, const char *format, va_list args) { const char *s = X_UNKNOWN_STRING; - char *tmpBuf = NULL; + char tmpBuf[1024]; /* Ignore verbosity for X_ERROR */ if (logVerbosity >= verb || logFileVerbosity >= verb || type == X_ERROR) { @@ -358,21 +358,11 @@ LogVMessageVerb(MessageType type, int verb, const char *format, va_list args) break; } - /* - * Prefix the format string with the message type. We do it this way - * so that LogVWrite() is only called once per message. - */ - if (s) { - tmpBuf = malloc(strlen(format) + strlen(s) + 1 + 1); - /* Silently return if malloc fails here. */ - if (!tmpBuf) - return; - sprintf(tmpBuf, "%s ", s); - strcat(tmpBuf, format); - LogVWrite(verb, tmpBuf, args); - free(tmpBuf); - } else - LogVWrite(verb, format, args); + /* if s is not NULL we need a space before format */ + snprintf(tmpBuf, sizeof(tmpBuf), "%s%s%s", s ? s : "", + s ? " " : "", + format); + LogVWrite(verb, tmpBuf, args); } }