diff options
author | Jon TURNEY <jon.turney@dronecode.org.uk> | 2011-06-24 14:11:39 +0100 |
---|---|---|
committer | Jon TURNEY <jon.turney@dronecode.org.uk> | 2011-06-27 13:27:17 +0100 |
commit | fb649060ae10c48d7bee2343119d495de1474ad4 (patch) | |
tree | c6c9ce38afd4aa4c80557896d7896f5d6bf8b39e | |
parent | 601504cb32855c90b531265b9da27522a85c978e (diff) | |
parent | d784fd09dc277610d5f4e98d577c4fdcd9215f9c (diff) |
Merge commit 'xorg-server-1.10.2' into cygwin-release-1.10xserver-cygwin-1.10.2-1
Conflicts:
configure.ac
glx/Makefile.am
glx/glapi.c
glx/glxext.c
38 files changed, 408 insertions, 381 deletions
diff --git a/Xi/exevents.c b/Xi/exevents.c index 35f96e6cd..9bd9d6078 100644 --- a/Xi/exevents.c +++ b/Xi/exevents.c @@ -535,6 +535,7 @@ DeepCopyPointerClasses(DeviceIntPtr from, DeviceIntPtr to) if (from->valuator) { ValuatorClassPtr v; + if (!to->valuator) { classes = to->unused_classes; @@ -543,18 +544,14 @@ DeepCopyPointerClasses(DeviceIntPtr from, DeviceIntPtr to) classes->valuator = NULL; } - to->valuator = realloc(to->valuator, sizeof(ValuatorClassRec) + - from->valuator->numAxes * sizeof(AxisInfo) + - from->valuator->numAxes * sizeof(double)); - v = to->valuator; + v = AllocValuatorClass(to->valuator, from->valuator->numAxes); + if (!v) FatalError("[Xi] no memory for class shift.\n"); - v->numAxes = from->valuator->numAxes; - v->axes = (AxisInfoPtr)&v[1]; + to->valuator = v; memcpy(v->axes, from->valuator->axes, v->numAxes * sizeof(AxisInfo)); - v->axisVal = (double*)(v->axes + from->valuator->numAxes); v->sourceid = from->id; } else if (to->valuator && !from->valuator) { diff --git a/Xi/extinit.c b/Xi/extinit.c index ec815c913..7f09dfea6 100644 --- a/Xi/extinit.c +++ b/Xi/extinit.c @@ -511,7 +511,7 @@ SReplyIDispatch(ClientPtr client, int len, xGrabDeviceReply * rep) SRepXIQueryDevice(client, len, (xXIQueryDeviceReply*)rep); else if (rep->RepType == X_XIGrabDevice) SRepXIGrabDevice(client, len, (xXIGrabDeviceReply *) rep); - else if (rep->RepType == X_XIGrabDevice) + else if (rep->RepType == X_XIPassiveGrabDevice) SRepXIPassiveGrabDevice(client, len, (xXIPassiveGrabDeviceReply *) rep); else if (rep->RepType == X_XIListProperties) SRepXIListProperties(client, len, (xXIListPropertiesReply *) rep); diff --git a/Xi/xipassivegrab.c b/Xi/xipassivegrab.c index 4b71c688a..776d33459 100644 --- a/Xi/xipassivegrab.c +++ b/Xi/xipassivegrab.c @@ -43,6 +43,7 @@ #include "exevents.h" #include "xipassivegrab.h" #include "dixgrabs.h" +#include "misc.h" int SProcXIPassiveGrabDevice(ClientPtr client) @@ -87,6 +88,7 @@ ProcXIPassiveGrabDevice(ClientPtr client) GrabParameters param; void *tmp; int mask_len; + int n; REQUEST(xXIPassiveGrabDeviceReq); REQUEST_AT_LEAST_SIZE(xXIPassiveGrabDeviceReq); @@ -99,7 +101,10 @@ ProcXIPassiveGrabDevice(ClientPtr client) { ret = dixLookupDevice(&dev, stuff->deviceid, client, DixGrabAccess); if (ret != Success) + { + client->errorValue = stuff->deviceid; return ret; + } } if (stuff->grab_type != XIGrabtypeButton && @@ -156,6 +161,8 @@ ProcXIPassiveGrabDevice(ClientPtr client) return status; status = CheckGrabValues(client, ¶m); + if (status != Success) + return status; modifiers = (uint32_t*)&stuff[1] + stuff->mask_len; modifiers_failed = calloc(stuff->num_modifiers, sizeof(xXIGrabModifierInfo)); @@ -193,6 +200,9 @@ ProcXIPassiveGrabDevice(ClientPtr client) info->status = status; info->modifiers = *modifiers; + if (client->swapped) + swapl(&info->modifiers, n); + rep.num_modifiers++; rep.length += bytes_to_int32(sizeof(xXIGrabModifierInfo)); } @@ -200,10 +210,8 @@ ProcXIPassiveGrabDevice(ClientPtr client) WriteReplyToClient(client, sizeof(rep), &rep); if (rep.num_modifiers) - { - client->pSwapReplyFunc = (ReplySwapPtr) Swap32Write; - WriteSwappedDataToClient(client, rep.length * 4, (char*)modifiers_failed); - } + WriteToClient(client, rep.length * 4, (char*)modifiers_failed); + free(modifiers_failed); return ret; } diff --git a/configure.ac b/configure.ac index 711637bfe..03e04751b 100644 --- a/configure.ac +++ b/configure.ac @@ -26,8 +26,8 @@ dnl dnl Process this file with autoconf to create configure. AC_PREREQ(2.57) -AC_INIT([xorg-server], 1.10.1, [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg], xorg-server) -RELEASE_DATE="2011-04-15" +AC_INIT([xorg-server], 1.10.2, [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg], xorg-server) +RELEASE_DATE="2011-05-28" AC_CONFIG_SRCDIR([Makefile.am]) AM_INIT_AUTOMAKE([foreign dist-bzip2]) AM_MAINTAINER_MODE @@ -1013,7 +1013,8 @@ if test "x$GLX" = xno; then AIGLX=no fi -if test "x$AIGLX" = xyes -a "x$DRI" = xyes; then + +if test "x$AIGLX" = xyes -a "x$GLX" = xyes -a \( "x$DRI" = xyes -o "x$DRI2" = xyes \); then AC_DEFINE(AIGLX, 1, [Build AIGLX loader]) fi AM_CONDITIONAL(AIGLX_DRI_LOADER, test "x$DRI" = xyes && test "x$AIGLX" = xyes) @@ -690,8 +690,7 @@ ProcDbeGetVisualInfo(ClientPtr client) } count = (stuff->n == 0) ? screenInfo.numScreens : stuff->n; - if (!(pScrVisInfo = (XdbeScreenVisualInfo *)malloc(count * - sizeof(XdbeScreenVisualInfo)))) + if (!(pScrVisInfo = calloc(count, sizeof(XdbeScreenVisualInfo)))) { free(pDrawables); @@ -707,21 +706,16 @@ ProcDbeGetVisualInfo(ClientPtr client) pDbeScreenPriv = DBE_SCREEN_PRIV(pScreen); rc = XaceHook(XACE_SCREEN_ACCESS, client, pScreen, DixGetAttrAccess); - if ((rc != Success) || - !(*pDbeScreenPriv->GetVisualInfo)(pScreen, &pScrVisInfo[i])) + if (rc != Success) + goto freeScrVisInfo; + + if (!(*pDbeScreenPriv->GetVisualInfo)(pScreen, &pScrVisInfo[i])) { /* We failed to alloc pScrVisInfo[i].visinfo. */ + rc = BadAlloc; /* Free visinfos that we allocated for previous screen infos.*/ - for (j = 0; j < i; j++) - { - free(pScrVisInfo[j].visinfo); - } - - /* Free pDrawables if we needed to allocate it above. */ - free(pDrawables); - - return (rc == Success) ? BadAlloc : rc; + goto freeScrVisInfo; } /* Account for n, number of xDbeVisInfo items in list. */ @@ -790,6 +784,9 @@ ProcDbeGetVisualInfo(ClientPtr client) } } + rc = Success; + + freeScrVisInfo: /* Clean up memory. */ for (i = 0; i < count; i++) { @@ -799,7 +796,7 @@ ProcDbeGetVisualInfo(ClientPtr client) free(pDrawables); - return Success; + return rc; } /* ProcDbeGetVisualInfo() */ diff --git a/dix/devices.c b/dix/devices.c index 55f22cbaf..fed05f5e2 100644 --- a/dix/devices.c +++ b/dix/devices.c @@ -1221,13 +1221,46 @@ InitButtonClassDeviceStruct(DeviceIntPtr dev, int numButtons, Atom* labels, return TRUE; } +/** + * Allocate a valuator class and set up the pointers for the axis values + * appropriately. + * + * @param src If non-NULL, the memory is reallocated from src. If NULL, the + * memory is calloc'd. + * @parma numAxes Number of axes to allocate. + * @return The allocated valuator struct. + */ +ValuatorClassPtr +AllocValuatorClass(ValuatorClassPtr src, int numAxes) +{ + ValuatorClassPtr v; + /* force alignment with double */ + union align_u { ValuatorClassRec valc; double d; } *align; + int size; + + size = sizeof(union align_u) + numAxes * (sizeof(double) + sizeof(AxisInfo)); + align = (union align_u *) realloc(src, size); + + if (!align) + return NULL; + + if (!src) + memset(align, 0, size); + + v = &align->valc; + v->numAxes = numAxes; + v->axisVal = (double*)(align + 1); + v->axes = (AxisInfoPtr)(v->axisVal + numAxes); + + return v; +} + Bool InitValuatorClassDeviceStruct(DeviceIntPtr dev, int numAxes, Atom *labels, int numMotionEvents, int mode) { int i; ValuatorClassPtr valc; - union align_u { ValuatorClassRec valc; double d; } *align; if (!dev) return FALSE; @@ -1240,13 +1273,10 @@ InitValuatorClassDeviceStruct(DeviceIntPtr dev, int numAxes, Atom *labels, numAxes = MAX_VALUATORS; } - align = (union align_u *) calloc(1, sizeof(union align_u) + - numAxes * sizeof(double) + - numAxes * sizeof(AxisInfo)); - if (!align) - return FALSE; + valc = AllocValuatorClass(NULL, numAxes); + if (!valc) + return FALSE; - valc = &align->valc; valc->sourceid = dev->id; valc->motion = NULL; valc->first_motion = 0; @@ -1254,9 +1284,6 @@ InitValuatorClassDeviceStruct(DeviceIntPtr dev, int numAxes, Atom *labels, valc->numMotionEvents = numMotionEvents; valc->motionHintWindow = NullWindow; - valc->numAxes = numAxes; - valc->axisVal = (double *)(align + 1); - valc->axes = (AxisInfoPtr)(valc->axisVal + numAxes); if (mode & OutOfProximity) InitProximityClassDeviceStruct(dev); diff --git a/dix/main.c b/dix/main.c index 84fd4a2c5..30082e53d 100644 --- a/dix/main.c +++ b/dix/main.c @@ -120,9 +120,9 @@ extern void Dispatch(void); #ifdef XQUARTZ #include <pthread.h> -BOOL serverInitComplete = FALSE; -pthread_mutex_t serverInitCompleteMutex = PTHREAD_MUTEX_INITIALIZER; -pthread_cond_t serverInitCompleteCond = PTHREAD_COND_INITIALIZER; +BOOL serverRunning = FALSE; +pthread_mutex_t serverRunningMutex = PTHREAD_MUTEX_INITIALIZER; +pthread_cond_t serverRunningCond = PTHREAD_COND_INITIALIZER; int dix_main(int argc, char *argv[], char *envp[]); @@ -282,18 +282,25 @@ int main(int argc, char *argv[], char *envp[]) } #ifdef XQUARTZ - /* Let the other threads know the server is done with its init */ - pthread_mutex_lock(&serverInitCompleteMutex); - serverInitComplete = TRUE; - pthread_cond_broadcast(&serverInitCompleteCond); - pthread_mutex_unlock(&serverInitCompleteMutex); + /* Let the other threads know the server is done with its init */ + pthread_mutex_lock(&serverRunningMutex); + serverRunning = TRUE; + pthread_cond_broadcast(&serverRunningCond); + pthread_mutex_unlock(&serverRunningMutex); #endif NotifyParentProcess(); Dispatch(); - UndisplayDevices(); +#ifdef XQUARTZ + /* Let the other threads know the server is no longer running */ + pthread_mutex_lock(&serverRunningMutex); + serverRunning = FALSE; + pthread_mutex_unlock(&serverRunningMutex); +#endif + + UndisplayDevices(); /* Now free up whatever must be freed */ if (screenIsSaved == SCREEN_SAVER_ON) diff --git a/dix/ptrveloc.c b/dix/ptrveloc.c index 8f0332161..4d5dad764 100644 --- a/dix/ptrveloc.c +++ b/dix/ptrveloc.c @@ -392,7 +392,7 @@ DoGetDirection(int dx, int dy){ float r; int i1, i2; /* on insignificant mickeys, flag 135 degrees */ - if(abs(dx) < 2 && abs(dy < 2)){ + if(abs(dx) < 2 && abs(dy) < 2){ /* first check diagonal cases */ if(dx > 0 && dy > 0) return 4+8+16; diff --git a/glx/Makefile.am b/glx/Makefile.am index 2397d4a49..7fb28fb50 100644 --- a/glx/Makefile.am +++ b/glx/Makefile.am @@ -47,8 +47,11 @@ glapi_sources = \ glprocs.h \ glthread.h -libglxdri_la_SOURCES = \ - glxdri.c +libglxdri_la_SOURCES = + +if DRI +libglxdri_la_SOURCES += glxdri.c +endif if DRI2_AIGLX libglxdri_la_SOURCES += glxdri2.c diff --git a/glx/glapi.h b/glx/glapi.h index ab80f7e67..6521f3142 100644 --- a/glx/glapi.h +++ b/glx/glapi.h @@ -107,65 +107,37 @@ extern struct _glapi_table *_glapi_Dispatch; **/ extern void -_glapi_noop_enable_warnings(GLboolean enable); - -extern void -_glapi_set_warning_func(_glapi_warning_func func); - -extern void _glapi_check_multithread(void); - extern void _glapi_set_context(void *context); - extern void * _glapi_get_context(void); - extern void _glapi_set_dispatch(struct _glapi_table *dispatch); - extern struct _glapi_table * _glapi_get_dispatch(void); - extern int _glapi_begin_dispatch_override(struct _glapi_table *override); - extern void _glapi_end_dispatch_override(int layer); - struct _glapi_table * _glapi_get_override_dispatch(int layer); - extern GLuint _glapi_get_dispatch_table_size(void); - -extern void -_glapi_check_table(const struct _glapi_table *table); - - extern int _glapi_add_dispatch( const char * const * function_names, const char * parameter_signature ); -extern GLint -_glapi_get_proc_offset(const char *funcName); - - extern _glapi_proc _glapi_get_proc_address(const char *funcName); - -extern const char * -_glapi_get_proc_name(GLuint offset); - - #endif diff --git a/glx/glxcmds.c b/glx/glxcmds.c index 60c80737f..1753be4a3 100644 --- a/glx/glxcmds.c +++ b/glx/glxcmds.c @@ -136,9 +136,9 @@ validGlxContext(ClientPtr client, XID id, int access_mode, { *err = dixLookupResourceByType((pointer *) context, id, __glXContextRes, client, access_mode); - if (*err != Success) { + if (*err != Success || (*context)->idExists == GL_FALSE) { client->errorValue = id; - if (*err == BadValue) + if (*err == BadValue || *err == Success) *err = __glXError(GLXBadContext); return FALSE; } @@ -376,6 +376,7 @@ int __glXDisp_CreateContextWithConfigSGIX(__GLXclientState *cl, GLbyte *pc) return DoCreateContext(cl, req->context, req->shareList, config, pGlxScreen, req->isDirect); } + int __glXDisp_DestroyContext(__GLXclientState *cl, GLbyte *pc) { ClientPtr client = cl->client; @@ -389,77 +390,31 @@ int __glXDisp_DestroyContext(__GLXclientState *cl, GLbyte *pc) &glxc, &err)) return err; - FreeResourceByType(req->context, __glXContextRes, FALSE); - return Success; -} - -/*****************************************************************************/ - -/* -** For each client, the server keeps a table of all the contexts that are -** current for that client (each thread of a client may have its own current -** context). These routines add, change, and lookup contexts in the table. -*/ - -/* -** Add a current context, and return the tag that will be used to refer to it. -*/ -static int AddCurrentContext(__GLXclientState *cl, __GLXcontext *glxc) -{ - int i; - int num = cl->numCurrentContexts; - __GLXcontext **table = cl->currentContexts; - - if (!glxc) return -1; - - /* - ** Try to find an empty slot and use it. - */ - for (i=0; i < num; i++) { - if (!table[i]) { - table[i] = glxc; - return i+1; - } - } - /* - ** Didn't find a free slot, so we'll have to grow the table. - */ - if (!num) { - table = (__GLXcontext **) malloc(sizeof(__GLXcontext *)); - } else { - table = (__GLXcontext **) realloc(table, - (num+1)*sizeof(__GLXcontext *)); - } - table[num] = glxc; - cl->currentContexts = table; - cl->numCurrentContexts++; - return num+1; -} + glxc->idExists = GL_FALSE; + if (!glxc->isCurrent) + FreeResourceByType(req->context, __glXContextRes, FALSE); -/* -** Given a tag, change the current context for the corresponding entry. -*/ -static void ChangeCurrentContext(__GLXclientState *cl, __GLXcontext *glxc, - GLXContextTag tag) -{ - __GLXcontext **table = cl->currentContexts; - table[tag-1] = glxc; + return Success; } /* -** For this implementation we have chosen to simply use the index of the -** context's entry in the table as the context tag. A tag must be greater -** than 0. -*/ + * This will return "deleted" contexts, ie, where idExists is GL_FALSE. + * Contrast validGlxContext, which will not. We're cheating here and + * using the XID as the context tag, which is fine as long as we defer + * actually destroying the context until it's no longer referenced, and + * block clients from trying to MakeCurrent on contexts that are on the + * way to destruction. Notice that DoMakeCurrent calls validGlxContext + * for new contexts but __glXLookupContextByTag for previous contexts. + */ __GLXcontext *__glXLookupContextByTag(__GLXclientState *cl, GLXContextTag tag) { - int num = cl->numCurrentContexts; + __GLXcontext *ret; - if (tag < 1 || tag > num) { - return 0; - } else { - return cl->currentContexts[tag-1]; - } + if (dixLookupResourceByType((void **)&ret, tag, __glXContextRes, + cl->client, DixUseAccess) == Success) + return ret; + + return NULL; } /*****************************************************************************/ @@ -473,7 +428,7 @@ static void StopUsingContext(__GLXcontext *glxc) } glxc->isCurrent = GL_FALSE; if (!glxc->idExists) { - __glXFreeContext(glxc); + FreeResourceByType(glxc->id, __glXContextRes, FALSE); } } } @@ -676,16 +631,11 @@ DoMakeCurrent(__GLXclientState *cl, glxc->isCurrent = GL_TRUE; } - if (prevglxc) { - ChangeCurrentContext(cl, glxc, tag); - StopUsingContext(prevglxc); - } else { - tag = AddCurrentContext(cl, glxc); - } + StopUsingContext(prevglxc); if (glxc) { StartUsingContext(cl, glxc); - reply.contextTag = tag; + reply.contextTag = glxc->id; } else { reply.contextTag = 0; } @@ -1184,10 +1134,11 @@ DoCreateGLXDrawable(ClientPtr client, __GLXscreen *pGlxScreen, return BadAlloc; } - /* Add the glx drawable under the XID of the underlying X drawable - * too. That way we'll get a callback in DrawableGone and can - * clean up properly when the drawable is destroyed. */ - if (drawableId != glxDrawableId && + /* + * Windows aren't refcounted, so track both the X and the GLX window + * so we get called regardless of destruction order. + */ + if (drawableId != glxDrawableId && type == GLX_DRAWABLE_WINDOW && !AddResource(pDraw->id, __glXDrawableRes, pGlxDraw)) { pGlxDraw->destroy (pGlxDraw); return BadAlloc; @@ -1218,6 +1169,8 @@ DoCreateGLXPixmap(ClientPtr client, __GLXscreen *pGlxScreen, __GLXconfig *config err = DoCreateGLXDrawable(client, pGlxScreen, config, pDraw, drawableId, glxDrawableId, GLX_DRAWABLE_PIXMAP); + ((PixmapPtr)pDraw)->refcnt++; + return err; } diff --git a/glx/glxdri2.c b/glx/glxdri2.c index 8d21c937b..c4b7ba4c6 100644 --- a/glx/glxdri2.c +++ b/glx/glxdri2.c @@ -184,6 +184,7 @@ __glXdriSwapEvent(ClientPtr client, void *data, int type, CARD64 ust, break; default: /* unknown swap completion type */ + wire.event_type = 0; break; } wire.drawable = drawable->drawId; diff --git a/glx/glxdriswrast.c b/glx/glxdriswrast.c index f1211ee09..13752f868 100644 --- a/glx/glxdriswrast.c +++ b/glx/glxdriswrast.c @@ -201,6 +201,14 @@ __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 +#endif texBuffer->setTexBuffer(context->driContext, glxPixmap->target, drawable->driDrawable); diff --git a/glx/glxext.c b/glx/glxext.c index 1ee22fab3..625f8ee27 100644 --- a/glx/glxext.c +++ b/glx/glxext.c @@ -124,54 +124,37 @@ static Bool DrawableGone(__GLXdrawable *glxPriv, XID xid) { __GLXcontext *c, *next; - /* If this drawable was created using glx 1.3 drawable - * constructors, we added it as a glx drawable resource under both - * its glx drawable ID and it X drawable ID. Remove the other - * resource now so we don't a callback for freed memory. */ - if (glxPriv->drawId != glxPriv->pDraw->id) { - if (xid == glxPriv->drawId) - FreeResourceByType(glxPriv->pDraw->id, __glXDrawableRes, TRUE); - else - FreeResourceByType(glxPriv->drawId, __glXDrawableRes, TRUE); + if (glxPriv->type == GLX_DRAWABLE_WINDOW) { + /* If this was created by glXCreateWindow, free the matching resource */ + if (glxPriv->drawId != glxPriv->pDraw->id) { + if (xid == glxPriv->drawId) + FreeResourceByType(glxPriv->pDraw->id, __glXDrawableRes, TRUE); + else + FreeResourceByType(glxPriv->drawId, __glXDrawableRes, TRUE); + } + /* otherwise this window was implicitly created by MakeCurrent */ } for (c = glxAllContexts; c; c = next) { next = c->next; if (c->isCurrent && (c->drawPriv == glxPriv || c->readPriv == glxPriv)) { - int i; - FlushContext(c); (*c->loseCurrent)(c); c->isCurrent = GL_FALSE; if (c == __glXLastContext) __glXFlushContextCache(); - - if (!c->idExists) { - for (i = 1; i < currentMaxClients; i++) { - if (clients[i]) { - __GLXclientState *cl = glxGetClient(clients[i]); - - if (cl->inUse) { - int j; - - for (j = 0; j < cl->numCurrentContexts; j++) { - if (cl->currentContexts[j] == c) - cl->currentContexts[j] = NULL; - } - } - } - } - } } if (c->drawPriv == glxPriv) c->drawPriv = NULL; if (c->readPriv == glxPriv) c->readPriv = NULL; - if (!c->idExists && !c->isCurrent) - __glXFreeContext(c); } + /* drop our reference to any backing pixmap */ + if (glxPriv->type == GLX_DRAWABLE_PIXMAP) + glxPriv->pDraw->pScreen->DestroyPixmap((PixmapPtr)glxPriv->pDraw); + glxPriv->destroy(glxPriv); return True; @@ -287,8 +270,6 @@ glxClientCallback (CallbackListPtr *list, NewClientInfoRec *clientinfo = (NewClientInfoRec *) data; ClientPtr pClient = clientinfo->client; __GLXclientState *cl = glxGetClient(pClient); - __GLXcontext *cx; - int i; switch (pClient->clientState) { case ClientStateRunning: @@ -302,18 +283,8 @@ glxClientCallback (CallbackListPtr *list, break; case ClientStateGone: - for (i = 0; i < cl->numCurrentContexts; i++) { - cx = cl->currentContexts[i]; - if (cx) { - cx->isCurrent = GL_FALSE; - if (!cx->idExists) - __glXFreeContext(cx); - } - } - free(cl->returnBuf); free(cl->largeCmdBuf); - free(cl->currentContexts); free(cl->GLClientextensions); break; diff --git a/glx/glxserver.h b/glx/glxserver.h index 1daf97758..f10c8fe12 100644 --- a/glx/glxserver.h +++ b/glx/glxserver.h @@ -158,13 +158,6 @@ struct __GLXclientStateRec { GLbyte *largeCmdBuf; GLint largeCmdBufSize; - /* - ** Keep a list of all the contexts that are current for this client's - ** threads. - */ - __GLXcontext **currentContexts; - GLint numCurrentContexts; - /* Back pointer to X client record */ ClientPtr client; diff --git a/hw/xfree86/Makefile.am b/hw/xfree86/Makefile.am index c23b1fd6c..93995c69b 100644 --- a/hw/xfree86/Makefile.am +++ b/hw/xfree86/Makefile.am @@ -114,7 +114,7 @@ CONF_SUBSTS = -e 's|__filemansuffix__|$(FILE_MAN_SUFFIX)|g' \ -e 's|DEFAULTFONTPATH|$(COMPILEDDEFAULTFONTPATH)|g' xorg.conf.example: xorgconf.cpp - $(AM_V_GEN)$(SED) $(CONF_SUBSTS) < $< > $@ + $(AM_V_GEN)$(SED) $(CONF_SUBSTS) < $(srcdir)/xorgconf.cpp > $@ relink: $(AM_V_at)rm -f Xorg && $(MAKE) Xorg diff --git a/hw/xquartz/GL/indirect.c b/hw/xquartz/GL/indirect.c index 46a4d954a..3555d4585 100644 --- a/hw/xquartz/GL/indirect.c +++ b/hw/xquartz/GL/indirect.c @@ -682,17 +682,8 @@ GLuint __glFloorLog2(GLuint val) return c; } -void warn_func(void * p1, char *format, ...) { - va_list v; - va_start(v, format); - vfprintf(stderr, format, v); - va_end(v); -} - static void setup_dispatch_table(void) { struct _glapi_table *disp=_glapi_get_dispatch(); - _glapi_set_warning_func((_glapi_warning_func)warn_func); - _glapi_noop_enable_warnings(TRUE); /* to update: * for f in $(grep 'define SET_' ../../../glx/dispatch.h | cut -f2 -d' ' | cut -f1 -d\( | sort -u); do grep -q $f indirect.c || echo $f ; done | grep -v by_offset | sed 's:SET_\(.*\)$:SET_\1(disp, gl\1)\;:' | pbcopy diff --git a/hw/xquartz/X11Application.m b/hw/xquartz/X11Application.m index 3521517a2..988a86bae 100644 --- a/hw/xquartz/X11Application.m +++ b/hw/xquartz/X11Application.m @@ -950,7 +950,7 @@ environment the next time you start X11?", @"Startup xinitrc dialog"); [X11App prefs_synchronize]; } -static inline pthread_t create_thread(void *func, void *arg) { +static inline pthread_t create_thread(void *(*func)(void *), void *arg) { pthread_attr_t attr; pthread_t tid; diff --git a/hw/xquartz/applewmExt.h b/hw/xquartz/applewmExt.h index 5ef8b5496..c46a7bde4 100644 --- a/hw/xquartz/applewmExt.h +++ b/hw/xquartz/applewmExt.h @@ -32,16 +32,23 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #define _APPLEWMEXT_H_ #include "window.h" +#include <Xplugin.h> + +#if XPLUGIN_VERSION < 4 +typedef int xp_frame_attr; +typedef int xp_frame_class; +typedef int xp_frame_rect; +#endif typedef int (*DisableUpdateProc)(void); typedef int (*EnableUpdateProc)(void); typedef int (*SetWindowLevelProc)(WindowPtr pWin, int level); -typedef int (*FrameGetRectProc)(int type, int class, const BoxRec *outer, +typedef int (*FrameGetRectProc)(xp_frame_rect type, xp_frame_class class, const BoxRec *outer, const BoxRec *inner, BoxRec *ret); -typedef int (*FrameHitTestProc)(int class, int x, int y, +typedef int (*FrameHitTestProc)(xp_frame_class class, int x, int y, const BoxRec *outer, const BoxRec *inner, int *ret); -typedef int (*FrameDrawProc)(WindowPtr pWin, int class, unsigned int attr, +typedef int (*FrameDrawProc)(WindowPtr pWin, xp_frame_class class, xp_frame_attr attr, const BoxRec *outer, const BoxRec *inner, unsigned int title_len, const unsigned char *title_bytes); diff --git a/hw/xquartz/bundle/Info.plist.cpp b/hw/xquartz/bundle/Info.plist.cpp index 4ecf8e49b..887311893 100644 --- a/hw/xquartz/bundle/Info.plist.cpp +++ b/hw/xquartz/bundle/Info.plist.cpp @@ -19,9 +19,9 @@ <key>CFBundlePackageType</key> <string>APPL</string> <key>CFBundleShortVersionString</key> - <string>2.6.2</string> + <string>2.6.3</string> <key>CFBundleVersion</key> - <string>2.6.2</string> + <string>2.6.3</string> <key>CFBundleSignature</key> <string>x11a</string> <key>CSResourcesFileMapped</key> diff --git a/hw/xquartz/darwinEvents.c b/hw/xquartz/darwinEvents.c index 16fec4a01..edf60c89c 100644 --- a/hw/xquartz/darwinEvents.c +++ b/hw/xquartz/darwinEvents.c @@ -61,6 +61,7 @@ in this Software without prior written authorization from The Open Group. #include <unistd.h> #include <pthread.h> #include <errno.h> +#include <time.h> #include <IOKit/hidsystem/IOLLEvent.h> @@ -93,7 +94,7 @@ static pthread_mutex_t mieq_lock = PTHREAD_MUTEX_INITIALIZER; static pthread_cond_t mieq_ready_cond = PTHREAD_COND_INITIALIZER; /*** Pthread Magics ***/ -static pthread_t create_thread(void *func, void *arg) { +static pthread_t create_thread(void *(*func)(void *), void *arg) { pthread_attr_t attr; pthread_t tid; @@ -304,7 +305,28 @@ void DarwinListenOnOpenFD(int fd) { pthread_mutex_unlock(&fd_add_lock); } -static void DarwinProcessFDAdditionQueue_thread(void *args) { +static void *DarwinProcessFDAdditionQueue_thread(void *args) { + /* TODO: Possibly adjust this to no longer be a race... maybe trigger this + * once a client connects and claims to be the WM. + * + * From ajax: + * There's already an internal callback chain for setting selection [in 1.5] + * ownership. See the CallSelectionCallback at the bottom of + * ProcSetSelectionOwner, and xfixes/select.c for an example of how to hook + * into it. + */ + + struct timespec sleep_for; + struct timespec sleep_remaining; + + sleep_for.tv_sec = 3; + sleep_for.tv_nsec = 0; + + ErrorF("X11.app: DarwinProcessFDAdditionQueue_thread: Sleeping to allow xinitrc to catchup.\n"); + while(nanosleep(&sleep_for, &sleep_remaining) != 0) { + sleep_for = sleep_remaining; + } + pthread_mutex_lock(&fd_add_lock); while(true) { while(fd_add_count) { @@ -312,6 +334,8 @@ static void DarwinProcessFDAdditionQueue_thread(void *args) { } pthread_cond_wait(&fd_add_ready_cond, &fd_add_lock); } + + return NULL; } Bool DarwinEQInit(void) { diff --git a/hw/xquartz/mach-startup/bundle-main.c b/hw/xquartz/mach-startup/bundle-main.c index 75b39392a..1ddaa2ce1 100644 --- a/hw/xquartz/mach-startup/bundle-main.c +++ b/hw/xquartz/mach-startup/bundle-main.c @@ -36,6 +36,7 @@ #endif #include <X11/Xlib.h> +#include <assert.h> #include <unistd.h> #include <stdio.h> #include <string.h> @@ -47,7 +48,6 @@ #include <sys/socket.h> #include <sys/un.h> -#include <sys/time.h> #include <fcntl.h> #include <mach/mach.h> @@ -95,8 +95,12 @@ int server_main(int argc, char **argv, char **envp); static int execute(const char *command); static char *command_from_prefs(const char *key, const char *default_value); +static char *pref_app_to_run; +static char *pref_login_shell; +static char *pref_startx_script; + /*** Pthread Magics ***/ -static pthread_t create_thread(void *func, void *arg) { +static pthread_t create_thread(void *(*func)(void *), void *arg) { pthread_attr_t attr; pthread_t tid; @@ -200,11 +204,10 @@ typedef struct { /* This thread accepts an incoming connection and hands off the file * descriptor for the new connection to accept_fd_handoff() */ -static void socket_handoff_thread(void *arg) { +static void *socket_handoff_thread(void *arg) { socket_handoff_t *handoff_data = (socket_handoff_t *)arg; int launchd_fd = -1; int connected_fd; - unsigned remain; /* Now actually get the passed file descriptor from this connection * If we encounter an error, keep listening. @@ -227,22 +230,11 @@ static void socket_handoff_thread(void *arg) { close(handoff_data->fd); unlink(handoff_data->filename); free(handoff_data); - - /* TODO: Clean up this race better... giving xinitrc time to run... need to wait for 1.5 branch: - * - * From ajax: - * There's already an internal callback chain for setting selection [in 1.5] - * ownership. See the CallSelectionCallback at the bottom of - * ProcSetSelectionOwner, and xfixes/select.c for an example of how to hook - * into it. - */ - - remain = 3000000; - fprintf(stderr, "X11.app: Received new $DISPLAY fd: %d ... sleeping to allow xinitrc to catchup.\n", launchd_fd); - while((remain = usleep(remain)) > 0); - + fprintf(stderr, "X11.app Handing off fd to server thread via DarwinListenOnOpenFD(%d)\n", launchd_fd); DarwinListenOnOpenFD(launchd_fd); + + return NULL; } static int create_socket(char *filename_out) { @@ -428,7 +420,7 @@ static int startup_trigger(int argc, char **argv, char **envp) { /* Could open the display, start the launcher */ XCloseDisplay(display); - return execute(command_from_prefs("app_to_run", DEFAULT_CLIENT)); + return execute(pref_app_to_run); } } @@ -439,7 +431,7 @@ static int startup_trigger(int argc, char **argv, char **envp) { } else { fprintf(stderr, "X11.app: Could not connect to server (DISPLAY is not set). Starting X server.\n"); } - return execute(command_from_prefs("startx_script", DEFAULT_STARTX)); + return execute(pref_startx_script); } /** Setup the environment we want our child processes to inherit */ @@ -576,6 +568,15 @@ int main(int argc, char **argv, char **envp) { pid_t child1, child2; int status; + pref_app_to_run = command_from_prefs("app_to_run", DEFAULT_CLIENT); + assert(pref_app_to_run); + + pref_login_shell = command_from_prefs("login_shell", DEFAULT_SHELL); + assert(pref_login_shell); + + pref_startx_script = command_from_prefs("startx_script", DEFAULT_STARTX); + assert(pref_startx_script); + /* Do the fork-twice trick to avoid having to reap zombies */ child1 = fork(); switch (child1) { @@ -611,6 +612,10 @@ int main(int argc, char **argv, char **envp) { default: /* parent */ waitpid(child1, &status, 0); } + + free(pref_app_to_run); + free(pref_login_shell); + free(pref_startx_script); } /* Main event loop */ @@ -628,7 +633,7 @@ static int execute(const char *command) { const char *newargv[4]; const char **p; - newargv[0] = command_from_prefs("login_shell", DEFAULT_SHELL); + newargv[0] = pref_login_shell; newargv[1] = "-c"; newargv[2] = command; newargv[3] = NULL; diff --git a/hw/xquartz/pbproxy/app-main.m b/hw/xquartz/pbproxy/app-main.m index b00e90a6d..0e85101fd 100644 --- a/hw/xquartz/pbproxy/app-main.m +++ b/hw/xquartz/pbproxy/app-main.m @@ -39,9 +39,9 @@ CFStringRef app_prefs_domain_cfstr; /* Stubs */ char *display = NULL; -BOOL serverInitComplete = YES; -pthread_mutex_t serverInitCompleteMutex = PTHREAD_MUTEX_INITIALIZER; -pthread_cond_t serverInitCompleteCond = PTHREAD_COND_INITIALIZER; +BOOL serverRunning = YES; +pthread_mutex_t serverRunningMutex = PTHREAD_MUTEX_INITIALIZER; +pthread_cond_t serverRunningCond = PTHREAD_COND_INITIALIZER; static void signal_handler (int sig) { switch(sig) { diff --git a/hw/xquartz/pbproxy/main.m b/hw/xquartz/pbproxy/main.m index bb0646502..f300c37c2 100644 --- a/hw/xquartz/pbproxy/main.m +++ b/hw/xquartz/pbproxy/main.m @@ -47,17 +47,17 @@ BOOL xpbproxy_is_standalone = NO; x_selection *_selection_object; -extern BOOL serverInitComplete; -extern pthread_mutex_t serverInitCompleteMutex; -extern pthread_cond_t serverInitCompleteCond; +extern BOOL serverRunning; +extern pthread_mutex_t serverRunningMutex; +extern pthread_cond_t serverRunningCond; static inline void wait_for_server_init(void) { /* If the server hasn't finished initializing, wait for it... */ - if(!serverInitComplete) { - pthread_mutex_lock(&serverInitCompleteMutex); - while(!serverInitComplete) - pthread_cond_wait(&serverInitCompleteCond, &serverInitCompleteMutex); - pthread_mutex_unlock(&serverInitCompleteMutex); + if(!serverRunning) { + pthread_mutex_lock(&serverRunningMutex); + while(!serverRunning) + pthread_cond_wait(&serverRunningCond, &serverRunningMutex); + pthread_mutex_unlock(&serverRunningMutex); } } diff --git a/hw/xquartz/pbproxy/x-selection.m b/hw/xquartz/pbproxy/x-selection.m index ef84f8bfb..ed4b754b4 100644 --- a/hw/xquartz/pbproxy/x-selection.m +++ b/hw/xquartz/pbproxy/x-selection.m @@ -175,7 +175,12 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato #endif /* Format is the number of bits. */ - chunkbytesize = numitems * (format / 8); + if (format == 8) + chunkbytesize = numitems; + else if (format == 16) + chunkbytesize = numitems * sizeof(short); + else if (format == 32) + chunkbytesize = numitems * sizeof(long); #ifdef TEST printf("chunkbytesize %zu\n", chunkbytesize); @@ -235,9 +240,9 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato return None; } - for (i = 0, step = pdata->format >> 3; i < pdata->length; i += step) + for (i = 0, step = sizeof(long); i < pdata->length; i += step) { - a = (Atom)*(uint32_t *)(pdata->data + i); + a = (Atom)*(long *)(pdata->data + i); if (a == atoms->image_png) { diff --git a/hw/xquartz/quartz.c b/hw/xquartz/quartz.c index 11e5a74d7..226cb2f11 100644 --- a/hw/xquartz/quartz.c +++ b/hw/xquartz/quartz.c @@ -239,8 +239,6 @@ void QuartzUpdateScreens(void) { AppleWMSetScreenOrigin(pRoot); pScreen->ResizeWindow(pRoot, x - sx, y - sy, width, height, NULL); - miPaintWindow(pRoot, &pRoot->borderClip, PW_BACKGROUND); - /* <rdar://problem/7770779> pointer events are clipped to old display region after display reconfiguration * http://xquartz.macosforge.org/trac/ticket/346 */ @@ -268,6 +266,9 @@ void QuartzUpdateScreens(void) { quartzProcs->UpdateScreen(pScreen); + /* miPaintWindow needs to be called after RootlessUpdateScreenPixmap (from xprUpdateScreen) */ + miPaintWindow(pRoot, &pRoot->borderClip, PW_BACKGROUND); + /* Tell RandR about the new size, so new connections get the correct info */ RRScreenSizeNotify(pScreen); } @@ -464,11 +465,15 @@ void QuartzSpaceChanged(uint32_t space_id) { void QuartzCopyDisplayIDs(ScreenPtr pScreen, int displayCount, CGDirectDisplayID *displayIDs) { QuartzScreenPtr pQuartzScreen = QUARTZ_PRIV(pScreen); - int size = displayCount * sizeof(CGDirectDisplayID); free(pQuartzScreen->displayIDs); - pQuartzScreen->displayIDs = malloc(size); - memcpy(pQuartzScreen->displayIDs, displayIDs, size); + if(displayCount) { + size_t size = displayCount * sizeof(CGDirectDisplayID); + pQuartzScreen->displayIDs = malloc(size); + memcpy(pQuartzScreen->displayIDs, displayIDs, size); + } else { + pQuartzScreen->displayIDs = NULL; + } pQuartzScreen->displayCount = displayCount; } diff --git a/hw/xquartz/quartzRandR.c b/hw/xquartz/quartzRandR.c index 05641a65d..98b382d65 100644 --- a/hw/xquartz/quartzRandR.c +++ b/hw/xquartz/quartzRandR.c @@ -3,7 +3,7 @@ * * Copyright (c) 2001-2004 Greg Parker and Torrey T. Lyons, * 2010 Jan Hauffa. - * 2010 Apple Inc. + * 2010-2011 Apple Inc. * All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a @@ -124,44 +124,48 @@ static Bool QuartzRandRSetCGMode (CGDirectDisplayID screenId, static Bool QuartzRandREnumerateModes (ScreenPtr pScreen, QuartzModeCallback callback, void *data) { - CFDictionaryRef curModeRef, modeRef; - long curBpp; - CFArrayRef modes; - QuartzModeInfo modeInfo; - int i; - BOOL retval = FALSE; + Bool retval = FALSE; QuartzScreenPtr pQuartzScreen = QUARTZ_PRIV(pScreen); - CGDirectDisplayID screenId = pQuartzScreen->displayIDs[0]; - curModeRef = CGDisplayCurrentMode(screenId); - if (!curModeRef) - return FALSE; - curBpp = getDictLong(curModeRef, kCGDisplayBitsPerPixel); + /* Just an 800x600 fallback if we have no attached heads */ + if(pQuartzScreen->displayIDs) { + CFDictionaryRef curModeRef, modeRef; + long curBpp; + CFArrayRef modes; + QuartzModeInfo modeInfo; + int i; + CGDirectDisplayID screenId = pQuartzScreen->displayIDs[0]; + + curModeRef = CGDisplayCurrentMode(screenId); + if (!curModeRef) + return FALSE; + curBpp = getDictLong(curModeRef, kCGDisplayBitsPerPixel); - modes = CGDisplayAvailableModes(screenId); - if (!modes) - return FALSE; - for (i = 0; i < CFArrayGetCount(modes); i++) { - int cb; - modeRef = (CFDictionaryRef) CFArrayGetValueAtIndex(modes, i); - - /* Skip modes that are not usable on the current display or have a - different pixel encoding than the current mode. */ - if (((unsigned long) getDictLong(modeRef, kCGDisplayIOFlags) & - kDisplayModeUsableFlags) != kDisplayModeUsableFlags) - continue; - if (getDictLong(modeRef, kCGDisplayBitsPerPixel) != curBpp) - continue; - - QuartzRandRGetModeInfo(modeRef, &modeInfo); - modeInfo.ref = (void *)modeRef; - cb = callback(pScreen, &modeInfo, data); - if (cb == CALLBACK_CONTINUE) - retval = TRUE; - else if (cb == CALLBACK_SUCCESS) - return TRUE; - else if (cb == CALLBACK_ERROR) + modes = CGDisplayAvailableModes(screenId); + if (!modes) return FALSE; + for (i = 0; i < CFArrayGetCount(modes); i++) { + int cb; + modeRef = (CFDictionaryRef) CFArrayGetValueAtIndex(modes, i); + + /* Skip modes that are not usable on the current display or have a + different pixel encoding than the current mode. */ + if (((unsigned long) getDictLong(modeRef, kCGDisplayIOFlags) & + kDisplayModeUsableFlags) != kDisplayModeUsableFlags) + continue; + if (getDictLong(modeRef, kCGDisplayBitsPerPixel) != curBpp) + continue; + + QuartzRandRGetModeInfo(modeRef, &modeInfo); + modeInfo.ref = (void *)modeRef; + cb = callback(pScreen, &modeInfo, data); + if (cb == CALLBACK_CONTINUE) + retval = TRUE; + else if (cb == CALLBACK_SUCCESS) + return TRUE; + else if (cb == CALLBACK_ERROR) + return FALSE; + } } switch(callback(pScreen, &pQuartzScreen->rootlessMode, data)) { @@ -225,61 +229,64 @@ static Bool QuartzRandRSetCGMode (CGDirectDisplayID screenId, static Bool QuartzRandREnumerateModes (ScreenPtr pScreen, QuartzModeCallback callback, void *data) { - CGDisplayModeRef curModeRef, modeRef; - CFStringRef curPixelEnc, pixelEnc; - CFComparisonResult pixelEncEqual; - CFArrayRef modes; - QuartzModeInfo modeInfo; - int i; Bool retval = FALSE; - QuartzScreenPtr pQuartzScreen = QUARTZ_PRIV(pScreen); - CGDirectDisplayID screenId = pQuartzScreen->displayIDs[0]; - curModeRef = CGDisplayCopyDisplayMode(screenId); - if (!curModeRef) - return FALSE; - curPixelEnc = CGDisplayModeCopyPixelEncoding(curModeRef); - CGDisplayModeRelease(curModeRef); + /* Just an 800x600 fallback if we have no attached heads */ + if(pQuartzScreen->displayIDs) { + CGDisplayModeRef curModeRef, modeRef; + CFStringRef curPixelEnc, pixelEnc; + CFComparisonResult pixelEncEqual; + CFArrayRef modes; + QuartzModeInfo modeInfo; + int i; + CGDirectDisplayID screenId = pQuartzScreen->displayIDs[0]; + + curModeRef = CGDisplayCopyDisplayMode(screenId); + if (!curModeRef) + return FALSE; + curPixelEnc = CGDisplayModeCopyPixelEncoding(curModeRef); + CGDisplayModeRelease(curModeRef); - modes = CGDisplayCopyAllDisplayModes(screenId, NULL); - if (!modes) { - CFRelease(curPixelEnc); - return FALSE; - } - for (i = 0; i < CFArrayGetCount(modes); i++) { - int cb; - modeRef = (CGDisplayModeRef) CFArrayGetValueAtIndex(modes, i); - - /* Skip modes that are not usable on the current display or have a - different pixel encoding than the current mode. */ - if ((CGDisplayModeGetIOFlags(modeRef) & kDisplayModeUsableFlags) != - kDisplayModeUsableFlags) - continue; - pixelEnc = CGDisplayModeCopyPixelEncoding(modeRef); - pixelEncEqual = CFStringCompare(pixelEnc, curPixelEnc, 0); - CFRelease(pixelEnc); - if (pixelEncEqual != kCFCompareEqualTo) - continue; - - QuartzRandRGetModeInfo(modeRef, &modeInfo); - modeInfo.ref = modeRef; - cb = callback(pScreen, &modeInfo, data); - if (cb == CALLBACK_CONTINUE) { - retval = TRUE; - } else if (cb == CALLBACK_SUCCESS) { - CFRelease(modes); - CFRelease(curPixelEnc); - return TRUE; - } else if (cb == CALLBACK_ERROR) { - CFRelease(modes); + modes = CGDisplayCopyAllDisplayModes(screenId, NULL); + if (!modes) { CFRelease(curPixelEnc); return FALSE; } - } + for (i = 0; i < CFArrayGetCount(modes); i++) { + int cb; + modeRef = (CGDisplayModeRef) CFArrayGetValueAtIndex(modes, i); + + /* Skip modes that are not usable on the current display or have a + different pixel encoding than the current mode. */ + if ((CGDisplayModeGetIOFlags(modeRef) & kDisplayModeUsableFlags) != + kDisplayModeUsableFlags) + continue; + pixelEnc = CGDisplayModeCopyPixelEncoding(modeRef); + pixelEncEqual = CFStringCompare(pixelEnc, curPixelEnc, 0); + CFRelease(pixelEnc); + if (pixelEncEqual != kCFCompareEqualTo) + continue; + + QuartzRandRGetModeInfo(modeRef, &modeInfo); + modeInfo.ref = modeRef; + cb = callback(pScreen, &modeInfo, data); + if (cb == CALLBACK_CONTINUE) { + retval = TRUE; + } else if (cb == CALLBACK_SUCCESS) { + CFRelease(modes); + CFRelease(curPixelEnc); + return TRUE; + } else if (cb == CALLBACK_ERROR) { + CFRelease(modes); + CFRelease(curPixelEnc); + return FALSE; + } + } - CFRelease(modes); - CFRelease(curPixelEnc); + CFRelease(modes); + CFRelease(curPixelEnc); + } switch(callback(pScreen, &pQuartzScreen->rootlessMode, data)) { case CALLBACK_SUCCESS: @@ -347,9 +354,13 @@ static int QuartzRandRRegisterModeCallback (ScreenPtr pScreen, static Bool QuartzRandRSetMode(ScreenPtr pScreen, QuartzModeInfoPtr pMode, BOOL doRegister) { QuartzScreenPtr pQuartzScreen = QUARTZ_PRIV(pScreen); - CGDirectDisplayID screenId = pQuartzScreen->displayIDs[0]; Bool captureDisplay = (pMode->refresh != FAKE_REFRESH_FULLSCREEN && pMode->refresh != FAKE_REFRESH_ROOTLESS); + CGDirectDisplayID screenId; + + if(pQuartzScreen->displayIDs == NULL) + return FALSE; + screenId = pQuartzScreen->displayIDs[0]; if(XQuartzShieldingWindowLevel == 0 && captureDisplay) { if(!X11ApplicationCanEnterRandR()) return FALSE; @@ -379,7 +390,8 @@ static Bool QuartzRandRSetMode(ScreenPtr pScreen, QuartzModeInfoPtr pMode, BOOL if(pQuartzScreen->currentMode.ref) CFRelease(pQuartzScreen->currentMode.ref); pQuartzScreen->currentMode = *pMode; - CFRetain(pQuartzScreen->currentMode.ref); + if(pQuartzScreen->currentMode.ref) + CFRetain(pQuartzScreen->currentMode.ref); if(XQuartzShieldingWindowLevel != 0 && !captureDisplay) { CGReleaseAllDisplays(); @@ -406,13 +418,8 @@ static int QuartzRandRSetModeCallback (ScreenPtr pScreen, } static Bool QuartzRandRGetInfo (ScreenPtr pScreen, Rotation *rotations) { - QuartzScreenPtr pQuartzScreen = QUARTZ_PRIV(pScreen); - *rotations = RR_Rotate_0; /* TODO: support rotation */ - if (pQuartzScreen->displayCount == 0) - return FALSE; - return QuartzRandREnumerateModes(pScreen, QuartzRandRRegisterModeCallback, NULL); } @@ -427,9 +434,6 @@ static Bool QuartzRandRSetConfig (ScreenPtr pScreen, reqMode.height = pSize->height; reqMode.refresh = rate; - if (pQuartzScreen->displayCount == 0) - return FALSE; - /* Do not switch modes if requested mode is equal to current mode. */ if (QuartzRandRModesEqual(&reqMode, &pQuartzScreen->currentMode)) return TRUE; @@ -444,26 +448,36 @@ static Bool QuartzRandRSetConfig (ScreenPtr pScreen, static Bool _QuartzRandRUpdateFakeModes (ScreenPtr pScreen) { QuartzScreenPtr pQuartzScreen = QUARTZ_PRIV(pScreen); + QuartzModeInfo activeMode; + + if(pQuartzScreen->displayCount > 0) { + if(!QuartzRandRCopyCurrentModeInfo(pQuartzScreen->displayIDs[0], &activeMode)) { + ErrorF("Unable to determine current display mode.\n"); + return FALSE; + } + } else { + memset(&activeMode, 0, sizeof(activeMode)); + activeMode.width = 800; + activeMode.height = 600; + activeMode.refresh = 60; + } if(pQuartzScreen->fullscreenMode.ref) CFRelease(pQuartzScreen->fullscreenMode.ref); if(pQuartzScreen->currentMode.ref) CFRelease(pQuartzScreen->currentMode.ref); - - if (!QuartzRandRCopyCurrentModeInfo(pQuartzScreen->displayIDs[0], - &pQuartzScreen->fullscreenMode)) - return FALSE; - if (pQuartzScreen->displayCount > 1) { - pQuartzScreen->fullscreenMode.width = pScreen->width; - pQuartzScreen->fullscreenMode.height = pScreen->height; + if(pQuartzScreen->displayCount > 1) { + activeMode.width = pScreen->width; + activeMode.height = pScreen->height; if(XQuartzIsRootless) - pQuartzScreen->fullscreenMode.height += aquaMenuBarHeight; + activeMode.height += aquaMenuBarHeight; } + pQuartzScreen->fullscreenMode = activeMode; pQuartzScreen->fullscreenMode.refresh = FAKE_REFRESH_FULLSCREEN; - pQuartzScreen->rootlessMode = pQuartzScreen->fullscreenMode; + pQuartzScreen->rootlessMode = activeMode; pQuartzScreen->rootlessMode.refresh = FAKE_REFRESH_ROOTLESS; pQuartzScreen->rootlessMode.height -= aquaMenuBarHeight; @@ -476,7 +490,8 @@ static Bool _QuartzRandRUpdateFakeModes (ScreenPtr pScreen) { /* This extra retain is for currentMode's copy. * fullscreen and rootless share a retain. */ - CFRetain(pQuartzScreen->currentMode.ref); + if(pQuartzScreen->currentMode.ref) + CFRetain(pQuartzScreen->currentMode.ref); DEBUG_LOG("rootlessMode: %d x %d\n", (int)pQuartzScreen->rootlessMode.width, (int)pQuartzScreen->rootlessMode.height); DEBUG_LOG("fullscreenMode: %d x %d\n", (int)pQuartzScreen->fullscreenMode.width, (int)pQuartzScreen->fullscreenMode.height); diff --git a/hw/xquartz/xpr/xprAppleWM.c b/hw/xquartz/xpr/xprAppleWM.c index 21e6f98fa..b6b9a5fc8 100644 --- a/hw/xquartz/xpr/xprAppleWM.c +++ b/hw/xquartz/xpr/xprAppleWM.c @@ -114,8 +114,8 @@ static int xprAttachTransient(WindowPtr pWinChild, WindowPtr pWinParent) { static int xprFrameDraw( WindowPtr pWin, - int class, - unsigned int attr, + xp_frame_class class, + xp_frame_attr attr, const BoxRec *outer, const BoxRec *inner, unsigned int title_len, diff --git a/hw/xquartz/xpr/xprScreen.c b/hw/xquartz/xpr/xprScreen.c index 972278b75..3684ad51b 100644 --- a/hw/xquartz/xpr/xprScreen.c +++ b/hw/xquartz/xpr/xprScreen.c @@ -193,6 +193,7 @@ xprAddPseudoramiXScreens(int *x, int *y, int *width, int *height, ScreenPtr pScr *width = 800; *height = 600; PseudoramiXAddScreen(*x, *y, *width, *height); + QuartzCopyDisplayIDs(pScreen, 0, NULL); return; } diff --git a/include/input.h b/include/input.h index f96a0a988..908e595e5 100644 --- a/include/input.h +++ b/include/input.h @@ -102,6 +102,7 @@ typedef unsigned long Leds; typedef struct _OtherClients *OtherClientsPtr; typedef struct _InputClients *InputClientsPtr; typedef struct _DeviceIntRec *DeviceIntPtr; +typedef struct _ValuatorClassRec *ValuatorClassPtr; typedef struct _ClassesRec *ClassesPtr; typedef struct _SpriteRec *SpritePtr; typedef union _GrabMask GrabMask; @@ -297,6 +298,10 @@ extern _X_EXPORT Bool InitButtonClassDeviceStruct( Atom* /* labels */, CARD8* /*map*/); +extern _X_INTERNAL ValuatorClassPtr AllocValuatorClass( + ValuatorClassPtr src, + int numAxes); + extern _X_EXPORT Bool InitValuatorClassDeviceStruct( DeviceIntPtr /*device*/, int /*numAxes*/, diff --git a/include/inputstr.h b/include/inputstr.h index b74ee0454..2ee2fd835 100644 --- a/include/inputstr.h +++ b/include/inputstr.h @@ -282,7 +282,7 @@ typedef struct _ValuatorClassRec { unsigned short numAxes; double *axisVal; /* always absolute, but device-coord system */ ValuatorAccelerationRec accelScheme; -} ValuatorClassRec, *ValuatorClassPtr; +} ValuatorClassRec; typedef struct _ButtonClassRec { int sourceid; @@ -83,17 +83,17 @@ static EventQueueRec miEventQueue; #include <pthread.h> static pthread_mutex_t miEventQueueMutex = PTHREAD_MUTEX_INITIALIZER; -extern BOOL serverInitComplete; -extern pthread_mutex_t serverInitCompleteMutex; -extern pthread_cond_t serverInitCompleteCond; +extern BOOL serverRunning; +extern pthread_mutex_t serverRunningMutex; +extern pthread_cond_t serverRunningCond; static inline void wait_for_server_init(void) { /* If the server hasn't finished initializing, wait for it... */ - if(!serverInitComplete) { - pthread_mutex_lock(&serverInitCompleteMutex); - while(!serverInitComplete) - pthread_cond_wait(&serverInitCompleteCond, &serverInitCompleteMutex); - pthread_mutex_unlock(&serverInitCompleteMutex); + if(!serverRunning) { + pthread_mutex_lock(&serverRunningMutex); + while(!serverRunning) + pthread_cond_wait(&serverRunningCond, &serverRunningMutex); + pthread_mutex_unlock(&serverRunningMutex); } } #endif diff --git a/miext/rootless/rootlessScreen.c b/miext/rootless/rootlessScreen.c index 510d6fdb1..3211c0fe2 100644 --- a/miext/rootless/rootlessScreen.c +++ b/miext/rootless/rootlessScreen.c @@ -325,7 +325,7 @@ RootlessGlyphs(CARD8 op, PicturePtr pSrc, PicturePtr pDst, box.x1 = x - glyph->info.x; box.y1 = y - glyph->info.y; box.x2 = box.x1 + glyph->info.width; - box.y2 = box.y2 + glyph->info.height; + box.y2 = box.y1 + glyph->info.height; x += glyph->info.xOff; y += glyph->info.yOff; diff --git a/os/access.c b/os/access.c index eb1a21d42..be9c0d5cb 100644 --- a/os/access.c +++ b/os/access.c @@ -1508,7 +1508,7 @@ InvalidHost ( } for (host = validhosts; host; host = host->next) { - if ((host->family == FamilyServerInterpreted)) { + if (host->family == FamilyServerInterpreted) { if (siAddrMatch (family, addr, len, host, client)) { return 0; } @@ -102,6 +102,10 @@ OR PERFORMANCE OF THIS SOFTWARE. #include "xf86bigfontsrv.h" #endif +#ifdef __clang__ +#pragma clang diagnostic ignored "-Wformat-nonliteral" +#endif + #ifdef DDXOSVERRORF void (*OsVendorVErrorFProc)(const char *, va_list args) = NULL; #endif diff --git a/os/xstrans.c b/os/xstrans.c index c086e225b..44ff976a9 100644 --- a/os/xstrans.c +++ b/os/xstrans.c @@ -2,6 +2,11 @@ #include <dix-config.h> #endif +#include <X11/Xfuncproto.h> + +/* ErrorF is used by xtrans */ +extern _X_EXPORT void ErrorF(const char *f, ...) _X_ATTRIBUTE_PRINTF(1,2); + #define TRANS_REOPEN #define TRANS_SERVER #define XSERV_t diff --git a/record/record.c b/record/record.c index facaebb02..f46675875 100644 --- a/record/record.c +++ b/record/record.c @@ -1956,7 +1956,7 @@ ProcRecordCreateContext(ClientPtr client) else { RecordDeleteContext((pointer)pContext, pContext->id); - err = BadAlloc; + return BadAlloc; } bailout: free(pContext); diff --git a/test/input.c b/test/input.c index e0e9e6af7..4d840b9b4 100644 --- a/test/input.c +++ b/test/input.c @@ -1199,6 +1199,28 @@ static void include_bit_test_macros(void) } } +/** + * Ensure that val->axisVal and val->axes are aligned on doubles. + */ +static void dix_valuator_alloc(void) +{ + ValuatorClassPtr v = NULL; + int num_axes = 0; + + while (num_axes < 5) + { + v = AllocValuatorClass(v, num_axes); + + g_assert(v); + g_assert(v->numAxes == num_axes); + g_assert(((void*)v->axisVal - (void*)v) % sizeof(double) == 0); + g_assert(((void*)v->axes - (void*)v) % sizeof(double) == 0); + num_axes ++; + } + + free(v); +} + int main(int argc, char** argv) { g_test_init(&argc, &argv,NULL); @@ -1216,7 +1238,7 @@ int main(int argc, char** argv) g_test_add_func("/include/byte_padding_macros", include_byte_padding_macros); g_test_add_func("/include/bit_test_macros", include_bit_test_macros); g_test_add_func("/Xi/xiproperty/register-unregister", xi_unregister_handlers); - + g_test_add_func("/dix/input/valuator-alloc", dix_valuator_alloc); return g_test_run(); } |