diff options
author | Matthieu Herrb <matthieu@cvs.openbsd.org> | 2008-06-15 00:17:34 +0000 |
---|---|---|
committer | Matthieu Herrb <matthieu@cvs.openbsd.org> | 2008-06-15 00:17:34 +0000 |
commit | 86fc487fbc0e5e6f7146a43099dc7ce1791c84f0 (patch) | |
tree | 86479ce8d7fc54c515b1aac90f960401587caef0 /xserver | |
parent | f629cb662c6469d23587f9dffc2352a8b6505b7b (diff) |
Update to xserver 1.4.2. Tested by landry@, ckuethe@, jsing@ mbalmer@.
Diffstat (limited to 'xserver')
45 files changed, 3285 insertions, 1097 deletions
diff --git a/xserver/GL/glx/glxdri.c b/xserver/GL/glx/glxdri.c index 170662c7e..09abca3f9 100644 --- a/xserver/GL/glx/glxdri.c +++ b/xserver/GL/glx/glxdri.c @@ -76,6 +76,11 @@ struct __GLXDRIscreen { xf86EnterVTProc *enterVT; xf86LeaveVTProc *leaveVT; + DRITexOffsetStartProcPtr texOffsetStart; + DRITexOffsetFinishProcPtr texOffsetFinish; + __GLXpixmap* texOffsetOverride[16]; + GLuint lastTexOffsetOverride; + unsigned char glx_enable_bits[__GLX_EXT_BYTES]; }; @@ -125,30 +130,75 @@ struct __GLXDRIdrawable { static const char CREATE_NEW_SCREEN_FUNC[] = "__driCreateNewScreen_" STRINGIFY (INTERNAL_VERSION); -/* The DRI driver entry point version wasn't bumped when the - * copySubBuffer functionality was added to the DRI drivers, but the - * functionality is still conditional on the value of the - * internal_api_version passed to __driCreateNewScreen. However, the - * screen constructor doesn't fail for a DRI driver that's older than - * the passed in version number, so there's no way we can know for - * sure that we can actually use the copySubBuffer functionality. But - * since the earliest (and at this point only) released mesa version - * (6.5) that uses the 20050727 entry point does have copySubBuffer, - * we'll just settle for that. We still have to pass in a higher to - * the screen constructor to enable the functionality. - */ -#define COPY_SUB_BUFFER_INTERNAL_VERSION 20060314 static void -__glXDRIleaveServer(void) +__glXDRIleaveServer(GLboolean rendering) { - DRIBlockHandler(NULL, NULL, NULL); + int i; + + for (i = 0; rendering && i < screenInfo.numScreens; i++) { + __GLXDRIscreen * const screen = + (__GLXDRIscreen *) __glXgetActiveScreen(i); + GLuint lastOverride = screen->lastTexOffsetOverride; + + if (lastOverride) { + __GLXpixmap **texOffsetOverride = screen->texOffsetOverride; + int j; + + for (j = 0; j < lastOverride; j++) { + __GLXpixmap *pGlxPix = texOffsetOverride[j]; + + if (pGlxPix && pGlxPix->texname) { + pGlxPix->offset = + screen->texOffsetStart((PixmapPtr)pGlxPix->pDraw); + } + } + } + } + + DRIBlockHandler(NULL, NULL, NULL); + + for (i = 0; rendering && i < screenInfo.numScreens; i++) { + __GLXDRIscreen * const screen = + (__GLXDRIscreen *) __glXgetActiveScreen(i); + GLuint lastOverride = screen->lastTexOffsetOverride; + + if (lastOverride) { + __GLXpixmap **texOffsetOverride = screen->texOffsetOverride; + int j; + + for (j = 0; j < lastOverride; j++) { + __GLXpixmap *pGlxPix = texOffsetOverride[j]; + + if (pGlxPix && pGlxPix->texname) { + screen->driScreen.setTexOffset(pGlxPix->pDRICtx, + pGlxPix->texname, + pGlxPix->offset, + pGlxPix->pDraw->depth, + ((PixmapPtr)pGlxPix->pDraw)-> + devKind); + } + } + } + } } static void -__glXDRIenterServer(void) +__glXDRIenterServer(GLboolean rendering) { - DRIWakeupHandler(NULL, 0, NULL); + int i; + + for (i = 0; rendering && i < screenInfo.numScreens; i++) { + __GLXDRIscreen * const screen = + (__GLXDRIscreen *) __glXgetActiveScreen(i); + + if (screen->lastTexOffsetOverride) { + CALL_Flush(GET_DISPATCH(), ()); + break; + } + } + + DRIWakeupHandler(NULL, 0, NULL); } /** @@ -289,19 +339,6 @@ __glXDRIcontextForceCurrent(__GLXcontext *baseContext) &context->driContext); } -static int -glxCountBits(int word) -{ - int ret = 0; - - while (word) { - ret += (word & 1); - word >>= 1; - } - - return ret; -} - static void glxFillAlphaChannel (PixmapPtr pixmap, int x, int y, int width, int height) { @@ -335,19 +372,68 @@ __glXDRIbindTexImage(__GLXcontext *baseContext, int buffer, __GLXpixmap *glxPixmap) { - RegionPtr pRegion; + RegionPtr pRegion = NULL; PixmapPtr pixmap; - int bpp; - GLenum target, format, type; + int bpp, override = 0; + GLenum format, type; + ScreenPtr pScreen = glxPixmap->pScreen; + __GLXDRIscreen * const screen = + (__GLXDRIscreen *) __glXgetActiveScreen(pScreen->myNum); pixmap = (PixmapPtr) glxPixmap->pDraw; + + if (screen->texOffsetStart && screen->driScreen.setTexOffset) { + __GLXpixmap **texOffsetOverride = screen->texOffsetOverride; + int i, firstEmpty = 16, texname; + + for (i = 0; i < 16; i++) { + if (texOffsetOverride[i] == glxPixmap) + goto alreadyin; + + if (firstEmpty == 16 && !texOffsetOverride[i]) + firstEmpty = i; + } + + if (firstEmpty == 16) { + ErrorF("%s: Failed to register texture offset override\n", __func__); + goto nooverride; + } + + if (firstEmpty >= screen->lastTexOffsetOverride) + screen->lastTexOffsetOverride = firstEmpty + 1; + + texOffsetOverride[firstEmpty] = glxPixmap; + +alreadyin: + override = 1; + + glxPixmap->pDRICtx = &((__GLXDRIcontext*)baseContext)->driContext; + + CALL_GetIntegerv(GET_DISPATCH(), (glxPixmap->target == GL_TEXTURE_2D ? + GL_TEXTURE_BINDING_2D : + GL_TEXTURE_BINDING_RECTANGLE_NV, + &texname)); + + if (texname == glxPixmap->texname) + return Success; + + glxPixmap->texname = texname; + + screen->driScreen.setTexOffset(glxPixmap->pDRICtx, texname, 0, + pixmap->drawable.depth, pixmap->devKind); + } +nooverride: + if (!glxPixmap->pDamage) { - glxPixmap->pDamage = DamageCreate(NULL, NULL, DamageReportNone, - TRUE, glxPixmap->pScreen, NULL); - if (!glxPixmap->pDamage) - return BadAlloc; + if (!override) { + glxPixmap->pDamage = DamageCreate(NULL, NULL, DamageReportNone, + TRUE, pScreen, NULL); + if (!glxPixmap->pDamage) + return BadAlloc; + + DamageRegister ((DrawablePtr) pixmap, glxPixmap->pDamage); + } - DamageRegister ((DrawablePtr) pixmap, glxPixmap->pDamage); pRegion = NULL; } else { pRegion = DamageRegion(glxPixmap->pDamage); @@ -360,30 +446,22 @@ __glXDRIbindTexImage(__GLXcontext *baseContext, bpp = 4; format = GL_BGRA; type = -#if X_BYTE_ORDER == X_LITTLE_ENDIAN - GL_UNSIGNED_BYTE; -#else - GL_UNSIGNED_INT_8_8_8_8_REV; +#if X_BYTE_ORDER == X_BIG_ENDIAN + !override ? GL_UNSIGNED_INT_8_8_8_8_REV : #endif + GL_UNSIGNED_BYTE; } else { bpp = 2; format = GL_RGB; type = GL_UNSIGNED_SHORT_5_6_5; } - if (!(glxCountBits(pixmap->drawable.width) == 1 && - glxCountBits(pixmap->drawable.height) == 1) - /* || strstr(CALL_GetString(GL_EXTENSIONS, - "GL_ARB_texture_non_power_of_two")) */) - target = GL_TEXTURE_RECTANGLE_ARB; - else - target = GL_TEXTURE_2D; - CALL_PixelStorei( GET_DISPATCH(), (GL_UNPACK_ROW_LENGTH, pixmap->devKind / bpp) ); + if (pRegion == NULL) { - if (pixmap->drawable.depth == 24) + if (!override && pixmap->drawable.depth == 24) glxFillAlphaChannel(pixmap, pixmap->drawable.x, pixmap->drawable.y, @@ -396,7 +474,7 @@ __glXDRIbindTexImage(__GLXcontext *baseContext, pixmap->drawable.y) ); CALL_TexImage2D( GET_DISPATCH(), - (target, + (glxPixmap->target, 0, bpp == 4 ? 4 : 3, pixmap->drawable.width, @@ -404,8 +482,8 @@ __glXDRIbindTexImage(__GLXcontext *baseContext, 0, format, type, - pixmap->devPrivate.ptr) ); - } else { + override ? NULL : pixmap->devPrivate.ptr) ); + } else if (!override) { int i, numRects; BoxPtr p; @@ -426,7 +504,7 @@ __glXDRIbindTexImage(__GLXcontext *baseContext, pixmap->drawable.y + p[i].y1) ); CALL_TexSubImage2D( GET_DISPATCH(), - (target, + (glxPixmap->target, 0, p[i].x1, p[i].y1, p[i].x2 - p[i].x1, p[i].y2 - p[i].y1, @@ -436,7 +514,8 @@ __glXDRIbindTexImage(__GLXcontext *baseContext, } } - DamageEmpty(glxPixmap->pDamage); + if (!override) + DamageEmpty(glxPixmap->pDamage); return Success; } @@ -446,6 +525,40 @@ __glXDRIreleaseTexImage(__GLXcontext *baseContext, int buffer, __GLXpixmap *pixmap) { + ScreenPtr pScreen = pixmap->pScreen; + __GLXDRIscreen * const screen = + (__GLXDRIscreen *) __glXgetActiveScreen(pScreen->myNum); + GLuint lastOverride = screen->lastTexOffsetOverride; + + if (lastOverride) { + __GLXpixmap **texOffsetOverride = screen->texOffsetOverride; + int i; + + for (i = 0; i < lastOverride; i++) { + if (texOffsetOverride[i] == pixmap) { + if (screen->texOffsetFinish) + screen->texOffsetFinish((PixmapPtr)pixmap->pDraw); + + texOffsetOverride[i] = NULL; + + if (i + 1 == lastOverride) { + lastOverride = 0; + + while (i--) { + if (texOffsetOverride[i]) { + lastOverride = i + 1; + break; + } + } + + screen->lastTexOffsetOverride = lastOverride; + + break; + } + } + } + } + return Success; } @@ -485,6 +598,9 @@ __glXDRIscreenCreateContext(__GLXscreen *baseScreen, else sharePrivate = NULL; + if (baseShareContext && baseShareContext->isDirect) + return NULL; + context = xalloc(sizeof *context); if (context == NULL) return NULL; @@ -495,6 +611,7 @@ __glXDRIscreenCreateContext(__GLXscreen *baseScreen, context->base.loseCurrent = __glXDRIcontextLoseCurrent; context->base.copy = __glXDRIcontextCopy; context->base.forceCurrent = __glXDRIcontextForceCurrent; + context->base.pScreen = screen->base.pScreen; context->base.textureFromPixmap = &__glXDRItextureFromPixmap; @@ -503,6 +620,11 @@ __glXDRIscreenCreateContext(__GLXscreen *baseScreen, 0, /* render type */ sharePrivate, &context->driContext); + + if (!context->driContext.private) { + xfree(context); + return NULL; + } context->driContext.mode = modes; @@ -637,9 +759,16 @@ static __DRIscreen *findScreen(__DRInativeDisplay *dpy, int scrn) static GLboolean windowExists(__DRInativeDisplay *dpy, __DRIid draw) { - WindowPtr pWin = (WindowPtr) LookupIDByType(draw, RT_WINDOW); - - return pWin == NULL ? GL_FALSE : GL_TRUE; + DrawablePtr pDrawable = (DrawablePtr) LookupIDByType(draw, RT_WINDOW); + int unused; + drm_clip_rect_t *pRects; + + return pDrawable ? DRIGetDrawableInfo(pDrawable->pScreen, pDrawable, + (unsigned*)&unused, (unsigned*)&unused, + &unused, &unused, &unused, &unused, + &unused, &pRects, &unused, &unused, + &unused, &pRects) + : GL_FALSE; } static GLboolean createContext(__DRInativeDisplay *dpy, int screen, @@ -665,9 +794,9 @@ static GLboolean createContext(__DRInativeDisplay *dpy, int screen, fakeID = FakeClientID(0); *(XID *) contextID = fakeID; - __glXDRIenterServer(); + __glXDRIenterServer(GL_FALSE); retval = DRICreateContext(pScreen, visual, fakeID, hw_context); - __glXDRIleaveServer(); + __glXDRIleaveServer(GL_FALSE); return retval; } @@ -676,9 +805,9 @@ static GLboolean destroyContext(__DRInativeDisplay *dpy, int screen, { GLboolean retval; - __glXDRIenterServer(); + __glXDRIenterServer(GL_FALSE); retval = DRIDestroyContext(screenInfo.screens[screen], context); - __glXDRIleaveServer(); + __glXDRIleaveServer(GL_FALSE); return retval; } @@ -693,12 +822,10 @@ createDrawable(__DRInativeDisplay *dpy, int screen, if (!pDrawable) return GL_FALSE; - __glXDRIenterServer(); - retval = DRICreateDrawable(screenInfo.screens[screen], - drawable, - pDrawable, - hHWDrawable); - __glXDRIleaveServer(); + __glXDRIenterServer(GL_FALSE); + retval = DRICreateDrawable(screenInfo.screens[screen], __pGlxClient, + pDrawable, hHWDrawable); + __glXDRIleaveServer(GL_FALSE); return retval; } @@ -712,11 +839,10 @@ destroyDrawable(__DRInativeDisplay *dpy, int screen, __DRIid drawable) if (!pDrawable) return GL_FALSE; - __glXDRIenterServer(); - retval = DRIDestroyDrawable(screenInfo.screens[screen], - drawable, - pDrawable); - __glXDRIleaveServer(); + __glXDRIenterServer(GL_FALSE); + retval = DRIDestroyDrawable(screenInfo.screens[screen], __pGlxClient, + pDrawable); + __glXDRIleaveServer(GL_FALSE); return retval; } @@ -753,20 +879,44 @@ getDrawableInfo(__DRInativeDisplay *dpy, int screen, return GL_FALSE; } - __glXDRIenterServer(); + __glXDRIenterServer(GL_FALSE); retval = DRIGetDrawableInfo(screenInfo.screens[screen], pDrawable, index, stamp, x, y, width, height, numClipRects, &pClipRects, backX, backY, numBackClipRects, &pBackClipRects); - __glXDRIleaveServer(); + __glXDRIleaveServer(GL_FALSE); if (*numClipRects > 0) { size = sizeof (drm_clip_rect_t) * *numClipRects; *ppClipRects = xalloc (size); - if (*ppClipRects != NULL) - memcpy (*ppClipRects, pClipRects, size); + + /* Clip cliprects to screen dimensions (redirected windows) */ + if (*ppClipRects != NULL) { + ScreenPtr pScreen = screenInfo.screens[screen]; + int i, j; + + for (i = 0, j = 0; i < *numClipRects; i++) { + (*ppClipRects)[j].x1 = max(pClipRects[i].x1, 0); + (*ppClipRects)[j].y1 = max(pClipRects[i].y1, 0); + (*ppClipRects)[j].x2 = min(pClipRects[i].x2, pScreen->width); + (*ppClipRects)[j].y2 = min(pClipRects[i].y2, pScreen->height); + + if ((*ppClipRects)[j].x1 < (*ppClipRects)[j].x2 && + (*ppClipRects)[j].y1 < (*ppClipRects)[j].y2) { + j++; + } + } + + if (*numClipRects != j) { + *numClipRects = j; + *ppClipRects = xrealloc (*ppClipRects, + sizeof (drm_clip_rect_t) * + *numClipRects); + } + } else + *numClipRects = 0; } else { *ppClipRects = NULL; @@ -782,7 +932,7 @@ getDrawableInfo(__DRInativeDisplay *dpy, int screen, *ppBackClipRects = NULL; } - return GL_TRUE; + return retval; } static int @@ -831,9 +981,12 @@ glxDRIEnterVT (int index, int flags) LogMessage(X_INFO, "AIGLX: Resuming AIGLX clients after VT switch\n"); + if (!(*screen->enterVT) (index, flags)) + return FALSE; + glxResumeClients(); - return (*screen->enterVT) (index, flags); + return TRUE; } static void @@ -861,9 +1014,10 @@ __glXDRIscreenProbe(ScreenPtr pScreen) __DRIframebuffer framebuffer; int fd = -1; int status; - int api_ver = COPY_SUB_BUFFER_INTERNAL_VERSION; + int api_ver = 20070121; drm_magic_t magic; drmVersionPtr version; + int newlyopened; char *driverName; drm_handle_t hFB; int junk; @@ -875,13 +1029,10 @@ __glXDRIscreenProbe(ScreenPtr pScreen) size_t buffer_size; ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; - if (!xf86LoaderCheckSymbol("DRIQueryDirectRenderingCapable")) { - LogMessage(X_ERROR, "AIGLX: DRI module not loaded\n"); - return NULL; - } - - if (!DRIQueryDirectRenderingCapable(pScreen, &isCapable) || !isCapable) { - LogMessage(X_ERROR, + if (!xf86LoaderCheckSymbol("DRIQueryDirectRenderingCapable") || + !DRIQueryDirectRenderingCapable(pScreen, &isCapable) || + !isCapable) { + LogMessage(X_INFO, "AIGLX: Screen %d is not DRI capable\n", pScreen->myNum); return NULL; } @@ -914,10 +1065,10 @@ __glXDRIscreenProbe(ScreenPtr pScreen) goto handle_error; } - fd = drmOpen(NULL, BusID); + fd = drmOpenOnce(NULL, BusID, &newlyopened); if (fd < 0) { - LogMessage(X_ERROR, "AIGLX error: drmOpen failed (%s)\n", + LogMessage(X_ERROR, "AIGLX error: drmOpenOnce failed (%s)\n", strerror(-fd)); goto handle_error; } @@ -940,7 +1091,7 @@ __glXDRIscreenProbe(ScreenPtr pScreen) drm_version.patch = -1; } - if (!DRIAuthConnection(pScreen, magic)) { + if (newlyopened && !DRIAuthConnection(pScreen, magic)) { LogMessage(X_ERROR, "AIGLX error: DRIAuthConnection failed\n"); goto handle_error; } @@ -1042,6 +1193,9 @@ __glXDRIscreenProbe(ScreenPtr pScreen) goto handle_error; } + DRIGetTexOffsetFuncs(pScreen, &screen->texOffsetStart, + &screen->texOffsetFinish); + __glXScreenInit(&screen->base, pScreen); buffer_size = __glXGetExtensionString(screen->glx_enable_bits, NULL); @@ -1082,7 +1236,7 @@ __glXDRIscreenProbe(ScreenPtr pScreen) xfree(dev_priv); if (fd >= 0) - drmClose(fd); + drmCloseOnce(fd); DRICloseConnection(pScreen); diff --git a/xserver/Xext/dpms.c b/xserver/Xext/dpms.c index aced40639..0557523f6 100644 --- a/xserver/Xext/dpms.c +++ b/xserver/Xext/dpms.c @@ -200,12 +200,15 @@ static int ProcDPMSEnable(client) register ClientPtr client; { - /* REQUEST(xDPMSEnableReq); */ + Bool was_enabled = DPMSEnabled; REQUEST_SIZE_MATCH(xDPMSEnableReq); - if (DPMSCapableFlag) + if (DPMSCapableFlag) { DPMSEnabled = TRUE; + if (!was_enabled) + SetScreenSaverTimer(); + } return(client->noClientException); } diff --git a/xserver/Xext/shm.c b/xserver/Xext/shm.c index 376f12348..3c0d1eef0 100644 --- a/xserver/Xext/shm.c +++ b/xserver/Xext/shm.c @@ -154,7 +154,7 @@ static ShmFuncs fbFuncs = {fbShmCreatePixmap, fbShmPutImage}; } -#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__CYGWIN__) +#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__CYGWIN__) || defined(__DragonFly__) #include <sys/signal.h> static Bool badSysCall = FALSE; diff --git a/xserver/Xext/xf86bigfont.c b/xserver/Xext/xf86bigfont.c index bd250569e..c2f891a7e 100644 --- a/xserver/Xext/xf86bigfont.c +++ b/xserver/Xext/xf86bigfont.c @@ -104,7 +104,7 @@ static unsigned int pagesize; static Bool badSysCall = FALSE; -#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__CYGWIN__) +#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__CYGWIN__) || defined(__DragonFly__) #include <sys/signal.h> @@ -445,11 +445,10 @@ ProcXF86BigfontQueryFont( #endif client->errorValue = stuff->id; /* EITHER font or gc */ pFont = (FontPtr)SecurityLookupIDByType(client, stuff->id, RT_FONT, - SecurityReadAccess); + DixReadAccess); if (!pFont) { - /* can't use VERIFY_GC because it might return BadGC */ GC *pGC = (GC *) SecurityLookupIDByType(client, stuff->id, RT_GC, - SecurityReadAccess); + DixReadAccess); if (!pGC) { client->errorValue = stuff->id; return BadFont; /* procotol spec says only error is BadFont */ diff --git a/xserver/Xi/exevents.c b/xserver/Xi/exevents.c index 2932ab2d2..0de5ea8a4 100644 --- a/xserver/Xi/exevents.c +++ b/xserver/Xi/exevents.c @@ -71,8 +71,11 @@ SOFTWARE. #include "exglobals.h" #include "dixevents.h" /* DeliverFocusedEvent */ #include "dixgrabs.h" /* CreateGrab() */ +#include "scrnintstr.h" -#include "chgptr.h" +#ifdef XKB +#include "xkbsrv.h" +#endif #define WID(w) ((w) ? ((w)->drawable.id) : 0) #define AllModifiersMask ( \ @@ -105,12 +108,12 @@ RegisterOtherDevice(DeviceIntPtr device) } /*ARGSUSED*/ void -ProcessOtherEvent(xEventPtr xE, register DeviceIntPtr other, int count) +ProcessOtherEvent(xEventPtr xE, DeviceIntPtr other, int count) { - register BYTE *kptr; - register int i; - register CARD16 modifiers; - register CARD16 mask; + BYTE *kptr; + int i; + CARD16 modifiers; + CARD16 mask; GrabPtr grab = other->grab; Bool deactivateDeviceGrab = FALSE; int key = 0, bit = 0, rootX, rootY; @@ -120,9 +123,14 @@ ProcessOtherEvent(xEventPtr xE, register DeviceIntPtr other, int count) deviceValuator *xV = (deviceValuator *) xE; if (xE->u.u.type != DeviceValuator) { - GetSpritePosition(&rootX, &rootY); - xE->u.keyButtonPointer.rootX = rootX; - xE->u.keyButtonPointer.rootY = rootY; + /* Other types already have root{X,Y} filled in. */ + if (xE->u.u.type == DeviceKeyPress || + xE->u.u.type == DeviceKeyRelease) { + GetSpritePosition(&rootX, &rootY); + xE->u.keyButtonPointer.rootX = rootX; + xE->u.keyButtonPointer.rootY = rootY; + } + key = xE->u.u.detail; NoticeEventTime(xE); xE->u.keyButtonPointer.state = inputInfo.keyboard->key->state | @@ -241,7 +249,7 @@ ProcessOtherEvent(xEventPtr xE, register DeviceIntPtr other, int count) other->valuator->motionHintWindow = NullWindow; b->buttonsDown++; b->motionMask = DeviceButtonMotionMask; - xE->u.u.detail = b->map[key]; + xE->u.u.detail = key; if (xE->u.u.detail == 0) return; if (xE->u.u.detail <= 5) @@ -249,7 +257,9 @@ ProcessOtherEvent(xEventPtr xE, register DeviceIntPtr other, int count) SetMaskForEvent(Motion_Filter(b), DeviceMotionNotify); if (!grab) if (CheckDeviceGrabs(other, xE, 0, count)) - return; + /* if a passive grab was activated, the event has been sent + * already */ + return; } else if (xE->u.u.type == DeviceButtonRelease) { if (!b) @@ -259,9 +269,9 @@ ProcessOtherEvent(xEventPtr xE, register DeviceIntPtr other, int count) *kptr &= ~bit; if (other->valuator) other->valuator->motionHintWindow = NullWindow; - if (!--b->buttonsDown) + if (b->buttonsDown >= 1 && !--b->buttonsDown) b->motionMask = 0; - xE->u.u.detail = b->map[key]; + xE->u.u.detail = key; if (xE->u.u.detail == 0) return; if (xE->u.u.detail <= 5) @@ -289,7 +299,7 @@ ProcessOtherEvent(xEventPtr xE, register DeviceIntPtr other, int count) _X_EXPORT int InitProximityClassDeviceStruct(DeviceIntPtr dev) { - register ProximityClassPtr proxc; + ProximityClassPtr proxc; proxc = (ProximityClassPtr) xalloc(sizeof(ProximityClassRec)); if (!proxc) @@ -302,7 +312,12 @@ _X_EXPORT void InitValuatorAxisStruct(DeviceIntPtr dev, int axnum, int minval, int maxval, int resolution, int min_res, int max_res) { - register AxisInfoPtr ax = dev->valuator->axes + axnum; + AxisInfoPtr ax; + + if (!dev || !dev->valuator) + return; + + ax = dev->valuator->axes + axnum; ax->min_value = minval; ax->max_value = maxval; @@ -374,7 +389,7 @@ FixDeviceValuator(DeviceIntPtr dev, deviceValuator * ev, ValuatorClassPtr v, void DeviceFocusEvent(DeviceIntPtr dev, int type, int mode, int detail, - register WindowPtr pWin) + WindowPtr pWin) { deviceFocus event; @@ -501,6 +516,7 @@ GrabButton(ClientPtr client, DeviceIntPtr dev, BYTE this_device_mode, WindowPtr pWin, confineTo; CursorPtr cursor; GrabPtr grab; + int rc; if ((this_device_mode != GrabModeSync) && (this_device_mode != GrabModeAsync)) { @@ -520,15 +536,15 @@ GrabButton(ClientPtr client, DeviceIntPtr dev, BYTE this_device_mode, client->errorValue = ownerEvents; return BadValue; } - pWin = LookupWindow(grabWindow, client); - if (!pWin) - return BadWindow; + rc = dixLookupWindow(&pWin, grabWindow, client, DixUnknownAccess); + if (rc != Success) + return rc; if (rconfineTo == None) confineTo = NullWindow; else { - confineTo = LookupWindow(rconfineTo, client); - if (!confineTo) - return BadWindow; + rc = dixLookupWindow(&confineTo, rconfineTo, client, DixUnknownAccess); + if (rc != Success) + return rc; } if (rcursor == None) cursor = NullCursor; @@ -558,6 +574,7 @@ GrabKey(ClientPtr client, DeviceIntPtr dev, BYTE this_device_mode, WindowPtr pWin; GrabPtr grab; KeyClassPtr k = dev->key; + int rc; if (k == NULL) return BadMatch; @@ -584,9 +601,9 @@ GrabKey(ClientPtr client, DeviceIntPtr dev, BYTE this_device_mode, client->errorValue = ownerEvents; return BadValue; } - pWin = LookupWindow(grabWindow, client); - if (!pWin) - return BadWindow; + rc = dixLookupWindow(&pWin, grabWindow, client, DixUnknownAccess); + if (rc != Success) + return rc; grab = CreateGrab(client->index, dev, pWin, mask, ownerEvents, this_device_mode, other_devices_mode, @@ -697,9 +714,9 @@ MakeInputMasks(WindowPtr pWin) void RecalculateDeviceDeliverableEvents(WindowPtr pWin) { - register InputClientsPtr others; + InputClientsPtr others; struct _OtherInputMasks *inputMasks; /* default: NULL */ - register WindowPtr pChild, tmp; + WindowPtr pChild, tmp; int i; pChild = pWin; @@ -733,9 +750,9 @@ RecalculateDeviceDeliverableEvents(WindowPtr pWin) } int -InputClientGone(register WindowPtr pWin, XID id) +InputClientGone(WindowPtr pWin, XID id) { - register InputClientsPtr other, prev; + InputClientsPtr other, prev; if (!wOtherInputMasks(pWin)) return (Success); @@ -806,7 +823,7 @@ SendEvent(ClientPtr client, DeviceIntPtr d, Window dest, Bool propagate, } else effectiveFocus = pWin = inputFocus; } else - pWin = LookupWindow(dest, client); + dixLookupWindow(&pWin, dest, client, DixUnknownAccess); if (!pWin) return BadWindow; if ((propagate != xFalse) && (propagate != xTrue)) { @@ -833,7 +850,7 @@ SendEvent(ClientPtr client, DeviceIntPtr d, Window dest, Bool propagate, int SetButtonMapping(ClientPtr client, DeviceIntPtr dev, int nElts, BYTE * map) { - register int i; + int i; ButtonClassPtr b = dev->button; if (b == NULL) @@ -859,7 +876,7 @@ SetModifierMapping(ClientPtr client, DeviceIntPtr dev, int len, int rlen, { KeyCode *map = NULL; int inputMapLen; - register int i; + int i; *k = dev->key; if (*k == NULL) @@ -898,7 +915,7 @@ SetModifierMapping(ClientPtr client, DeviceIntPtr dev, int len, int rlen, return MappingBusy; } else { for (i = 0; i < inputMapLen; i++) { - if (inputMap[i] && !LegalModifier(inputMap[i], (DevicePtr) dev)) { + if (inputMap[i] && !LegalModifier(inputMap[i], dev)) { return MappingFailed; } } @@ -934,7 +951,7 @@ SetModifierMapping(ClientPtr client, DeviceIntPtr dev, int len, int rlen, } void -SendDeviceMappingNotify(CARD8 request, +SendDeviceMappingNotify(ClientPtr client, CARD8 request, KeyCode firstKeyCode, CARD8 count, DeviceIntPtr dev) { xEvent event; @@ -949,6 +966,11 @@ SendDeviceMappingNotify(CARD8 request, ev->count = count; } +#ifdef XKB + if (request == MappingKeyboard || request == MappingModifier) + XkbApplyMappingChange(dev, request, firstKeyCode, count, client); +#endif + SendEventToAllWindows(dev, DeviceMappingNotifyMask, (xEvent *) ev, 1); } @@ -984,37 +1006,11 @@ ChangeKeyMapping(ClientPtr client, keysyms.map = map; if (!SetKeySymsMap(&k->curKeySyms, &keysyms)) return BadAlloc; - SendDeviceMappingNotify(MappingKeyboard, firstKeyCode, keyCodes, dev); + SendDeviceMappingNotify(client, MappingKeyboard, firstKeyCode, keyCodes, dev); return client->noClientException; } -void -DeleteWindowFromAnyExtEvents(WindowPtr pWin, Bool freeResources) -{ - int i; - DeviceIntPtr dev; - InputClientsPtr ic; - struct _OtherInputMasks *inputMasks; - - for (dev = inputInfo.devices; dev; dev = dev->next) { - if (dev == inputInfo.pointer || dev == inputInfo.keyboard) - continue; - DeleteDeviceFromAnyExtEvents(pWin, dev); - } - - for (dev = inputInfo.off_devices; dev; dev = dev->next) - DeleteDeviceFromAnyExtEvents(pWin, dev); - - if (freeResources) - while ((inputMasks = wOtherInputMasks(pWin)) != 0) { - ic = inputMasks->inputClients; - for (i = 0; i < EMASKSIZE; i++) - inputMasks->dontPropagateMask[i] = 0; - FreeResource(ic->resource, RT_NONE); - } -} - -void +static void DeleteDeviceFromAnyExtEvents(WindowPtr pWin, DeviceIntPtr dev) { WindowPtr parent; @@ -1079,6 +1075,32 @@ DeleteDeviceFromAnyExtEvents(WindowPtr pWin, DeviceIntPtr dev) dev->valuator->motionHintWindow = NullWindow; } +void +DeleteWindowFromAnyExtEvents(WindowPtr pWin, Bool freeResources) +{ + int i; + DeviceIntPtr dev; + InputClientsPtr ic; + struct _OtherInputMasks *inputMasks; + + for (dev = inputInfo.devices; dev; dev = dev->next) { + if (dev == inputInfo.pointer || dev == inputInfo.keyboard) + continue; + DeleteDeviceFromAnyExtEvents(pWin, dev); + } + + for (dev = inputInfo.off_devices; dev; dev = dev->next) + DeleteDeviceFromAnyExtEvents(pWin, dev); + + if (freeResources) + while ((inputMasks = wOtherInputMasks(pWin)) != 0) { + ic = inputMasks->inputClients; + for (i = 0; i < EMASKSIZE; i++) + inputMasks->dontPropagateMask[i] = 0; + FreeResource(ic->resource, RT_NONE); + } +} + int MaybeSendDeviceMotionNotifyHint(deviceKeyButtonPointer * pEvents, Mask mask) { @@ -1132,10 +1154,10 @@ CheckDeviceGrabAndHintWindow(WindowPtr pWin, int type, } } -Mask +static Mask DeviceEventMaskForClient(DeviceIntPtr dev, WindowPtr pWin, ClientPtr client) { - register InputClientsPtr other; + InputClientsPtr other; if (!wOtherInputMasks(pWin)) return 0; @@ -1148,7 +1170,7 @@ DeviceEventMaskForClient(DeviceIntPtr dev, WindowPtr pWin, ClientPtr client) } void -MaybeStopDeviceHint(register DeviceIntPtr dev, ClientPtr client) +MaybeStopDeviceHint(DeviceIntPtr dev, ClientPtr client) { WindowPtr pWin; GrabPtr grab = dev->grab; @@ -1209,3 +1231,44 @@ ShouldFreeInputMasks(WindowPtr pWin, Bool ignoreSelectedEvents) else return FALSE; } + +/*********************************************************************** + * + * Walk through the window tree, finding all clients that want to know + * about the Event. + * + */ + +static void +FindInterestedChildren(DeviceIntPtr dev, WindowPtr p1, Mask mask, + xEvent * ev, int count) +{ + WindowPtr p2; + + while (p1) { + p2 = p1->firstChild; + (void)DeliverEventsToWindow(p1, ev, count, mask, NullGrab, dev->id); + FindInterestedChildren(dev, p2, mask, ev, count); + p1 = p1->nextSib; + } +} + +/*********************************************************************** + * + * Send an event to interested clients in all windows on all screens. + * + */ + +void +SendEventToAllWindows(DeviceIntPtr dev, Mask mask, xEvent * ev, int count) +{ + int i; + WindowPtr pWin, p1; + + for (i = 0; i < screenInfo.numScreens; i++) { + pWin = WindowTable[i]; + (void)DeliverEventsToWindow(pWin, ev, count, mask, NullGrab, dev->id); + p1 = pWin->firstChild; + FindInterestedChildren(dev, p1, mask, ev, count); + } +} diff --git a/xserver/aclocal.m4 b/xserver/aclocal.m4 index 1ecc8387b..11120e650 100644 --- a/xserver/aclocal.m4 +++ b/xserver/aclocal.m4 @@ -8182,6 +8182,12 @@ AC_DEFUN([XTRANS_TCP_FLAGS],[ #include <sys/socket.h> #include <netinet/in.h> ]) + + # POSIX.1g changed the type of pointer passed to getsockname/getpeername/etc. + AC_CHECK_TYPES([socklen_t], [], [], [ +AC_INCLUDES_DEFAULT +#include <sys/socket.h>]) + ]) # XTRANS_TCP_FLAGS # XTRANS_CONNECTION_FLAGS() @@ -8191,17 +8197,21 @@ AC_DEFUN([XTRANS_TCP_FLAGS],[ AC_DEFUN([XTRANS_CONNECTION_FLAGS],[ AC_REQUIRE([AC_CANONICAL_HOST]) AC_REQUIRE([AC_TYPE_SIGNAL]) + [case $host_os in + mingw*) unixdef="no" ;; + *) unixdef="yes" ;; + esac] AC_ARG_ENABLE(unix-transport, AC_HELP_STRING([--enable-unix-transport],[Enable UNIX domain socket transport]), - [UNIXCONN=$enableval], [UNIXCONN=yes]) - AC_ARG_ENABLE(tcp-transport, - AC_HELP_STRING([--enable-tcp-transport],[Enable TCP socket transport]), - [TCPCONN=$enableval], [TCPCONN=yes]) + [UNIXCONN=$enableval], [UNIXCONN=$unixdef]) AC_MSG_CHECKING([if Xtrans should support UNIX socket connections]) if test "$UNIXCONN" = "yes"; then AC_DEFINE(UNIXCONN,1,[Support UNIX socket connections]) fi AC_MSG_RESULT($UNIXCONN) + AC_ARG_ENABLE(tcp-transport, + AC_HELP_STRING([--enable-tcp-transport],[Enable TCP socket transport]), + [TCPCONN=$enableval], [TCPCONN=yes]) AC_MSG_CHECKING([if Xtrans should support TCP socket connections]) AC_MSG_RESULT($TCPCONN) if test "$TCPCONN" = "yes"; then diff --git a/xserver/composite/compwindow.c b/xserver/composite/compwindow.c index b9ff1f529..65f77cfea 100644 --- a/xserver/composite/compwindow.c +++ b/xserver/composite/compwindow.c @@ -1,6 +1,4 @@ /* - * $Id: compwindow.c,v 1.1 2006/11/26 18:16:15 matthieu Exp $ - * * Copyright © 2006 Sun Microsystems * * Permission to use, copy, modify, distribute, and sell this software and its @@ -59,10 +57,10 @@ compCheckWindow (WindowPtr pWin, pointer data) if (!pWin->parent) { - assert (!pWin->redirectDraw); + assert (pWin->redirectDraw == RedirectDrawNone); assert (pWinPixmap == pScreenPixmap); } - else if (pWin->redirectDraw) + else if (pWin->redirectDraw != RedirectDrawNone) { assert (pWinPixmap != pParentPixmap); assert (pWinPixmap != pScreenPixmap); @@ -93,10 +91,10 @@ typedef struct _compPixmapVisit { static Bool compRepaintBorder (ClientPtr pClient, pointer closure) { - WindowPtr pWindow = LookupWindow ((XID) closure, pClient); + WindowPtr pWindow; + int rc = dixLookupWindow(&pWindow, (XID)closure, pClient,DixUnknownAccess); - if (pWindow) - { + if (rc == Success) { RegionRec exposed; REGION_NULL(pScreen, &exposed); @@ -113,7 +111,7 @@ compSetPixmapVisitWindow (WindowPtr pWindow, pointer data) CompPixmapVisitPtr pVisit = (CompPixmapVisitPtr) data; ScreenPtr pScreen = pWindow->drawable.pScreen; - if (pWindow != pVisit->pWindow && pWindow->redirectDraw) + if (pWindow != pVisit->pWindow && pWindow->redirectDraw != RedirectDrawNone) return WT_DONTWALKCHILDREN; (*pScreen->SetWindowPixmap) (pWindow, pVisit->pPixmap); /* @@ -148,8 +146,8 @@ compCheckRedirect (WindowPtr pWin) Bool should; should = pWin->realized && (pWin->drawable.class != InputOnly) && - (cw != NULL); - + (cw != NULL) && (pWin->parent != NULL); + /* Never redirect the overlay window */ if (cs->pOverlayWin != NULL) { if (pWin == cs->pOverlayWin) { @@ -157,7 +155,7 @@ compCheckRedirect (WindowPtr pWin) } } - if (should != pWin->redirectDraw) + if (should != (pWin->redirectDraw != RedirectDrawNone)) { if (should) return compAllocPixmap (pWin); @@ -167,6 +165,29 @@ compCheckRedirect (WindowPtr pWin) return TRUE; } +static int +updateOverlayWindow(ScreenPtr pScreen) +{ + CompScreenPtr cs; + WindowPtr pWin; /* overlay window */ + XID vlist[2]; + + cs = GetCompScreen(pScreen); + if ((pWin = cs->pOverlayWin) != NULL) { + if ((pWin->drawable.width == pScreen->width) && + (pWin->drawable.height == pScreen->height)) + return Success; + + /* Let's resize the overlay window. */ + vlist[0] = pScreen->width; + vlist[1] = pScreen->height; + return ConfigureWindow(pWin, CWWidth | CWHeight, vlist, wClient(pWin)); + } + + /* Let's be on the safe side and not assume an overlay window is always allocated. */ + return Success; +} + Bool compPositionWindow (WindowPtr pWin, int x, int y) { @@ -181,10 +202,11 @@ compPositionWindow (WindowPtr pWin, int x, int y) compCheckRedirect (pWin); */ #ifdef COMPOSITE_DEBUG - if (pWin->redirectDraw != (pWin->viewable && (GetCompWindow(pWin) != NULL))) + if ((pWin->redirectDraw != RedirectDrawNone) != + (pWin->viewable && (GetCompWindow(pWin) != NULL))) abort (); #endif - if (pWin->redirectDraw) + if (pWin->redirectDraw != RedirectDrawNone) { PixmapPtr pPixmap = (*pScreen->GetWindowPixmap) (pWin); int bw = wBorderWidth (pWin); @@ -204,6 +226,8 @@ compPositionWindow (WindowPtr pWin, int x, int y) cs->PositionWindow = pScreen->PositionWindow; pScreen->PositionWindow = compPositionWindow; compCheckTree (pWin->drawable.pScreen); + if (updateOverlayWindow(pScreen) != Success) + ret = FALSE; return ret; } @@ -331,7 +355,7 @@ compMoveWindow (WindowPtr pWin, int x, int y, WindowPtr pSib, VTKind kind) CompScreenPtr cs = GetCompScreen (pScreen); compCheckTree (pScreen); - if (pWin->redirectDraw) + if (pWin->redirectDraw != RedirectDrawNone) { WindowPtr pParent; int draw_x, draw_y; @@ -355,7 +379,7 @@ compMoveWindow (WindowPtr pWin, int x, int y, WindowPtr pSib, VTKind kind) cs->MoveWindow = pScreen->MoveWindow; pScreen->MoveWindow = compMoveWindow; - if (pWin->redirectDraw) + if (pWin->redirectDraw != RedirectDrawNone) { CompWindowPtr cw = GetCompWindow (pWin); if (cw->pOldPixmap) @@ -376,7 +400,7 @@ compResizeWindow (WindowPtr pWin, int x, int y, CompScreenPtr cs = GetCompScreen (pScreen); compCheckTree (pScreen); - if (pWin->redirectDraw) + if (pWin->redirectDraw != RedirectDrawNone) { WindowPtr pParent; int draw_x, draw_y; @@ -397,7 +421,7 @@ compResizeWindow (WindowPtr pWin, int x, int y, (*pScreen->ResizeWindow) (pWin, x, y, w, h, pSib); cs->ResizeWindow = pScreen->ResizeWindow; pScreen->ResizeWindow = compResizeWindow; - if (pWin->redirectDraw) + if (pWin->redirectDraw != RedirectDrawNone) { CompWindowPtr cw = GetCompWindow (pWin); if (cw->pOldPixmap) @@ -416,7 +440,7 @@ compChangeBorderWidth (WindowPtr pWin, unsigned int bw) CompScreenPtr cs = GetCompScreen (pScreen); compCheckTree (pScreen); - if (pWin->redirectDraw) + if (pWin->redirectDraw != RedirectDrawNone) { WindowPtr pParent; int draw_x, draw_y; @@ -438,7 +462,7 @@ compChangeBorderWidth (WindowPtr pWin, unsigned int bw) (*pScreen->ChangeBorderWidth) (pWin, bw); cs->ChangeBorderWidth = pScreen->ChangeBorderWidth; pScreen->ChangeBorderWidth = compChangeBorderWidth; - if (pWin->redirectDraw) + if (pWin->redirectDraw != RedirectDrawNone) { CompWindowPtr cw = GetCompWindow (pWin); if (cw->pOldPixmap) @@ -482,7 +506,7 @@ compReparentWindow (WindowPtr pWin, WindowPtr pPriorParent) /* * Reset pixmap pointers as appropriate */ - if (pWin->parent && !pWin->redirectDraw) + if (pWin->parent && pWin->redirectDraw == RedirectDrawNone) compSetPixmap (pWin, (*pScreen->GetWindowPixmap) (pWin->parent)); /* * Call down to next function @@ -501,7 +525,7 @@ compCopyWindow (WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr prgnSrc) CompScreenPtr cs = GetCompScreen (pScreen); int dx = 0, dy = 0; - if (pWin->redirectDraw) + if (pWin->redirectDraw != RedirectDrawNone) { PixmapPtr pPixmap = (*pScreen->GetWindowPixmap) (pWin); CompWindowPtr cw = GetCompWindow (pWin); @@ -626,7 +650,7 @@ compDestroyWindow (WindowPtr pWin) while ((csw = GetCompSubwindows (pWin))) FreeResource (csw->clients->id, RT_NONE); - if (pWin->redirectDraw) + if (pWin->redirectDraw != RedirectDrawNone) compFreePixmap (pWin); ret = (*pScreen->DestroyWindow) (pWin); cs->DestroyWindow = pScreen->DestroyWindow; @@ -686,7 +710,7 @@ compGetWindowVisual (WindowPtr pWin) return 0; } -static PictFormatPtr +PictFormatPtr compWindowFormat (WindowPtr pWin) { ScreenPtr pScreen = pWin->drawable.pScreen; @@ -770,7 +794,7 @@ compWindowUpdate (WindowPtr pWin) for (pChild = pWin->lastChild; pChild; pChild = pChild->prevSib) compWindowUpdate (pChild); - if (pWin->redirectDraw) + if (pWin->redirectDraw != RedirectDrawNone) { CompWindowPtr cw = GetCompWindow(pWin); diff --git a/xserver/config/dbus-core.c b/xserver/config/dbus-core.c index 28881596f..9cf153076 100644 --- a/xserver/config/dbus-core.c +++ b/xserver/config/dbus-core.c @@ -76,7 +76,7 @@ teardown(void) struct config_dbus_core_hook *hook; if (bus_info.timer) { - TimerCancel(bus_info.timer); + TimerFree(bus_info.timer); bus_info.timer = NULL; } @@ -87,7 +87,8 @@ teardown(void) dbus_connection_unref(bus_info.connection); RemoveBlockAndWakeupHandlers(block_handler, wakeup_handler, &bus_info); - RemoveGeneralSocket(bus_info.fd); + if (bus_info.fd != -1) + RemoveGeneralSocket(bus_info.fd); bus_info.fd = -1; bus_info.connection = NULL; @@ -115,6 +116,8 @@ message_filter(DBusConnection *connection, DBusMessage *message, void *data) bus_info.connection = NULL; teardown(); + if (bus_info.timer) + TimerFree(bus_info.timer); bus_info.timer = TimerSet(NULL, 0, 1, reconnect_timer, NULL); return DBUS_HANDLER_RESULT_HANDLED; @@ -185,6 +188,7 @@ static CARD32 reconnect_timer(OsTimerPtr timer, CARD32 time, pointer arg) { if (connect_to_bus()) { + TimerFree(bus_info.timer); bus_info.timer = NULL; return 0; } diff --git a/xserver/config/hal.c b/xserver/config/hal.c index d7835e653..bdf7d6c13 100644 --- a/xserver/config/hal.c +++ b/xserver/config/hal.c @@ -63,7 +63,7 @@ remove_device(DeviceIntPtr dev) static void device_removed(LibHalContext *ctx, const char *udi) { - DeviceIntPtr dev; + DeviceIntPtr dev, next; char *value; value = xalloc(strlen(udi) + 5); /* "hal:" + NULL */ @@ -71,11 +71,13 @@ device_removed(LibHalContext *ctx, const char *udi) return; sprintf(value, "hal:%s", udi); - for (dev = inputInfo.devices; dev; dev = dev->next) { + for (dev = inputInfo.devices; dev; dev = next) { + next = dev->next; if (dev->config_info && strcmp(dev->config_info, value) == 0) remove_device(dev); } - for (dev = inputInfo.off_devices; dev; dev = dev->next) { + for (dev = inputInfo.off_devices; dev; dev = next) { + next = dev->next; if (dev->config_info && strcmp(dev->config_info, value) == 0) remove_device(dev); } @@ -92,6 +94,8 @@ add_option(InputOption **options, const char *key, const char *value) for (; *options; options = &(*options)->next) ; *options = xcalloc(sizeof(**options), 1); + if (!*options) /* Yeesh. */ + return; (*options)->key = xstrdup(key); (*options)->value = xstrdup(value); (*options)->next = NULL; @@ -134,10 +138,11 @@ get_prop_string_array(LibHalContext *hal_ctx, const char *udi, const char *prop) str = ret; for (i = 0; props[i]; i++) { - str = strcpy(str, props[i]); + strcpy(str, props[i]); + str += strlen(props[i]); *str++ = ','; } - *str = '\0'; + *(str-1) = '\0'; libhal_free_string_array(props); } @@ -155,7 +160,7 @@ device_added(LibHalContext *hal_ctx, const char *udi) char *path = NULL, *driver = NULL, *name = NULL, *xkb_rules = NULL; char *xkb_model = NULL, *xkb_layout = NULL, *xkb_variant = NULL; char *xkb_options = NULL, *config_info = NULL; - InputOption *options = NULL; + InputOption *options = NULL, *tmpo = NULL; DeviceIntPtr dev; DBusError error; int type = TYPE_NONE; @@ -177,7 +182,8 @@ device_added(LibHalContext *hal_ctx, const char *udi) if (strcmp(props[i], "input.keys") == 0 || strcmp(props[i], "input.keyboard") == 0) type |= TYPE_KEYS; - if (strcmp(props[i], "input.mouse") == 0) + if (strcmp(props[i], "input.mouse") == 0 || + strcmp(props[i], "input.touchpad") == 0) type |= TYPE_POINTER; } libhal_free_string_array(props); @@ -230,6 +236,7 @@ device_added(LibHalContext *hal_ctx, const char *udi) if (NewInputDeviceRequest(options, &dev) != Success) { DebugF("[config/hal] NewInputDeviceRequest failed\n"); + dev = NULL; goto unwind; } @@ -253,6 +260,12 @@ unwind: xfree(xkb_options); if (config_info) xfree(config_info); + while (!dev && (tmpo = options)) { + options = tmpo->next; + xfree(tmpo->key); + xfree(tmpo->value); + xfree(tmpo); + } out_error: dbus_error_free(&error); diff --git a/xserver/configure b/xserver/configure index eb592397d..93ffb6ea8 100644 --- a/xserver/configure +++ b/xserver/configure @@ -1,6 +1,6 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.59 for xorg-server 1.4.0.90. +# Generated by GNU Autoconf 2.59 for xorg-server 1.4.2. # # Report bugs to <https://bugs.freedesktop.org/enter_bug.cgi?product=xorg>. # @@ -423,8 +423,8 @@ SHELL=${CONFIG_SHELL-/bin/sh} # Identity of this package. PACKAGE_NAME='xorg-server' PACKAGE_TARNAME='xorg-server' -PACKAGE_VERSION='1.4.0.90' -PACKAGE_STRING='xorg-server 1.4.0.90' +PACKAGE_VERSION='1.4.2' +PACKAGE_STRING='xorg-server 1.4.2' PACKAGE_BUGREPORT='https://bugs.freedesktop.org/enter_bug.cgi?product=xorg' ac_unique_file="Makefile.am" @@ -465,7 +465,7 @@ ac_includes_default="\ # include <unistd.h> #endif" -ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA CYGPATH_W PACKAGE VERSION ACLOCAL AUTOCONF AUTOMAKE AUTOHEADER MAKEINFO install_sh STRIP ac_ct_STRIP INSTALL_STRIP_PROGRAM mkdir_p AWK SET_MAKE am__leading_dot AMTAR am__tar am__untar MAINTAINER_MODE_TRUE MAINTAINER_MODE_FALSE MAINT CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT DEPDIR am__include am__quote AMDEP_TRUE AMDEP_FALSE AMDEPBACKSLASH CCDEPMODE am__fastdepCC_TRUE am__fastdepCC_FALSE CCAS CCASFLAGS LN_S build build_cpu build_vendor build_os host host_cpu host_vendor host_os SED EGREP ECHO AR ac_ct_AR RANLIB ac_ct_RANLIB DSYMUTIL ac_ct_DSYMUTIL NMEDIT ac_ct_NMEDIT DLLTOOL ac_ct_DLLTOOL AS ac_ct_AS OBJDUMP ac_ct_OBJDUMP CPP CXX CXXFLAGS ac_ct_CXX CXXDEPMODE am__fastdepCXX_TRUE am__fastdepCXX_FALSE CXXCPP F77 FFLAGS ac_ct_F77 LIBTOOL PKG_CONFIG ac_pt_PKG_CONFIG LEX LEXLIB LEX_OUTPUT_ROOT YACC RAWCPP RAWCPPFLAGS DTRACE XSERVER_DTRACE_TRUE XSERVER_DTRACE_FALSE XERRORDB_PATH ALLOCA NEED_STRLCAT_TRUE NEED_STRLCAT_FALSE NEED_VSNPRINTF_TRUE NEED_VSNPRINTF_FALSE AGP_TRUE AGP_FALSE LNXAPM_TRUE LNXAPM_FALSE FBDEVHW_TRUE FBDEVHW_FALSE FREEBSD_KLDLOAD_TRUE FREEBSD_KLDLOAD_FALSE BSD_APM_TRUE BSD_APM_FALSE BSD_KQUEUE_APM_TRUE BSD_KQUEUE_APM_FALSE ALPHA_VIDEO_TRUE ALPHA_VIDEO_FALSE ARM_VIDEO_TRUE ARM_VIDEO_FALSE HP300_VIDEO_TRUE HP300_VIDEO_FALSE HPPA_VIDEO_TRUE HPPA_VIDEO_FALSE I386_VIDEO_TRUE I386_VIDEO_FALSE PPC_VIDEO_TRUE PPC_VIDEO_FALSE SGI_VIDEO_TRUE SGI_VIDEO_FALSE SPARC64_VIDEO_TRUE SPARC64_VIDEO_FALSE KDRIVE_HW_TRUE KDRIVE_HW_FALSE X_PRIVSEP_TRUE X_PRIVSEP_FALSE INSTALL_SETUID_TRUE INSTALL_SETUID_FALSE SECURE_RPC_TRUE SECURE_RPC_FALSE INT10_VM86_TRUE INT10_VM86_FALSE INT10_X86EMU_TRUE INT10_X86EMU_FALSE INT10_STUB_TRUE INT10_STUB_FALSE BUILDDOCS_TRUE BUILDDOCS_FALSE LINUXDOC PS2PDF BUILD_LINUXDOC_TRUE BUILD_LINUXDOC_FALSE BUILD_PDFDOC_TRUE BUILD_PDFDOC_FALSE MAKE_TEXT MAKE_PS MAKE_PDF MAKE_HTML INSTALL_LIBXF86CONFIG_TRUE INSTALL_LIBXF86CONFIG_FALSE PIXMAN_CFLAGS PIXMAN_LIBS DBUS_CFLAGS DBUS_LIBS HAVE_DBUS_TRUE HAVE_DBUS_FALSE CONFIG_DBUS_API_TRUE CONFIG_DBUS_API_FALSE HAL_CFLAGS HAL_LIBS CONFIG_HAL_TRUE CONFIG_HAL_FALSE XV_TRUE XV_FALSE XVMC_TRUE XVMC_FALSE COMPOSITE_TRUE COMPOSITE_FALSE MITSHM_TRUE MITSHM_FALSE XTRAP_TRUE XTRAP_FALSE RECORD_TRUE RECORD_FALSE SCREENSAVER_TRUE SCREENSAVER_FALSE RES_TRUE RES_FALSE XLIB_CFLAGS XLIB_LIBS GL_CFLAGS GL_LIBS GLX_TRUE GLX_FALSE MESA_SOURCE AIGLX_TRUE AIGLX_FALSE GLX_DEFINES DRI_TRUE DRI_FALSE DRIPROTO_CFLAGS DRIPROTO_LIBS LIBDRM_CFLAGS LIBDRM_LIBS XINERAMA_TRUE XINERAMA_FALSE XACE_TRUE XACE_FALSE XCSECURITY_TRUE XCSECURITY_FALSE XEVIE_TRUE XEVIE_FALSE APPGROUP_TRUE APPGROUP_FALSE CUP_TRUE CUP_FALSE EVI_TRUE EVI_FALSE MULTIBUFFER_TRUE MULTIBUFFER_FALSE FONTCACHE_TRUE FONTCACHE_FALSE DBE_TRUE DBE_FALSE XF86BIGFONT_TRUE XF86BIGFONT_FALSE DPMSExtension_TRUE DPMSExtension_FALSE XPRINTPROTO_CFLAGS XPRINTPROTO_LIBS XPRINT_TRUE XPRINT_FALSE XCALIBRATE_TRUE XCALIBRATE_FALSE XF86UTILS_TRUE XF86UTILS_FALSE XDMCP_CFLAGS XDMCP_LIBS XDMCP_TRUE XDMCP_FALSE XDMAUTH_TRUE XDMAUTH_FALSE USE_RGB_BUILTIN_TRUE USE_RGB_BUILTIN_FALSE COMPILEDDEFAULTFONTPATH RGB_DB SERVERCONFIGdir BASE_FONT_PATH DRI_DRIVER_PATH VENDOR_NAME VENDOR_NAME_SHORT VENDOR_RELEASE VENDOR_MAN_VERSION DEBUG_TRUE DEBUG_FALSE XSERVERCFLAGS_CFLAGS XSERVERCFLAGS_LIBS XSERVERLIBS_CFLAGS XSERVERLIBS_LIBS SYS_LIBS LD_EXPORT_SYMBOLS_FLAG XSERVER_LIBS DMXMODULES_CFLAGS DMXMODULES_LIBS DMX_TRUE DMX_FALSE XDMX_LIBS XDMXCONFIG_DEP_CFLAGS XDMXCONFIG_DEP_LIBS DMXEXAMPLES_DEP_CFLAGS DMXEXAMPLES_DEP_LIBS DMXXMUEXAMPLES_DEP_CFLAGS DMXXMUEXAMPLES_DEP_LIBS DMXXIEXAMPLES_DEP_CFLAGS DMXXIEXAMPLES_DEP_LIBS XTSTEXAMPLES_DEP_CFLAGS XTSTEXAMPLES_DEP_LIBS XRESEXAMPLES_DEP_CFLAGS XRESEXAMPLES_DEP_LIBS X11EXAMPLES_DEP_CFLAGS X11EXAMPLES_DEP_LIBS DMX_BUILD_LNX_TRUE DMX_BUILD_LNX_FALSE DMX_BUILD_USB_TRUE DMX_BUILD_USB_FALSE XVFB_TRUE XVFB_FALSE XVFB_LIBS XNESTMODULES_CFLAGS XNESTMODULES_LIBS XNEST_TRUE XNEST_FALSE XNEST_LIBS XGLMODULES_CFLAGS XGLMODULES_LIBS XGL_TRUE XGL_FALSE XGL_LIBS xglmoduledir XGL_MODULE_PATH XEGLMODULES_CFLAGS XEGLMODULES_LIBS XEGL_TRUE XEGL_FALSE XEGL_LIBS XGLXMODULES_CFLAGS XGLXMODULES_LIBS XGLX_TRUE XGLX_FALSE XGLX_LIBS XORG_CORE_LIBS DARWIN_LIBS APPLE_APPLICATIONS_DIR PLIST_VERSION_STRING PLIST_VENDOR_WEB SOLARIS_INOUT_ARCH SOLARIS_ASM_CFLAGS DGA_CFLAGS DGA_LIBS XF86MISC_CFLAGS XF86MISC_LIBS XF86VIDMODE_CFLAGS XF86VIDMODE_LIBS XORG_MODULES_CFLAGS XORG_MODULES_LIBS XORG_LIBS XORG_INCS XORG_OS XORG_OS_SUBDIR PERL XORG_CFLAGS __XCONFIGFILE__ XF86CONFIGFILE DEFAULT_MODULE_PATH DEFAULT_LIBRARY_PATH DEFAULT_LOGPREFIX moduledir driverdir sdkdir extdir logdir XORG_TRUE XORG_FALSE XORG_BUS_LINUXPCI_TRUE XORG_BUS_LINUXPCI_FALSE XORG_BUS_FREEBSDPCI_TRUE XORG_BUS_FREEBSDPCI_FALSE XORG_BUS_NETBSDPCI_TRUE XORG_BUS_NETBSDPCI_FALSE XORG_BUS_IX86PCI_TRUE XORG_BUS_IX86PCI_FALSE XORG_BUS_PPCPCI_TRUE XORG_BUS_PPCPCI_FALSE XORG_BUS_SPARCPCI_TRUE XORG_BUS_SPARCPCI_FALSE XORG_BUS_SPARC_TRUE XORG_BUS_SPARC_FALSE XORG_LOADER_SPARC_TRUE XORG_LOADER_SPARC_FALSE LINUX_IA64_TRUE LINUX_IA64_FALSE LINUX_ALPHA_TRUE LINUX_ALPHA_FALSE LNXACPI_TRUE LNXACPI_FALSE SOLARIS_USL_CONSOLE_TRUE SOLARIS_USL_CONSOLE_FALSE SOLARIS_ASM_INLINE_TRUE SOLARIS_ASM_INLINE_FALSE BUILD_DARWIN_TRUE BUILD_DARWIN_FALSE XQUARTZ_TRUE XQUARTZ_FALSE DGA_TRUE DGA_FALSE XF86MISC_TRUE XF86MISC_FALSE XF86VIDMODE_TRUE XF86VIDMODE_FALSE MFB_TRUE MFB_FALSE CFB_TRUE CFB_FALSE AFB_TRUE AFB_FALSE XPRINT_CFLAGS XPRINT_LIBS xpconfigdir MKFONTSCALE MKFONTDIR FREETYPE_CFLAGS FREETYPE_LIBS ft_config FREETYPE_REQUIRES XP_USE_FREETYPE_TRUE XP_USE_FREETYPE_FALSE XWIN_LIBS XWINMODULES_CFLAGS XWINMODULES_LIBS XWIN_SERVER_NAME XWIN_SYSTEM_LIBS XWIN_TRUE XWIN_FALSE XWIN_MULTIWINDOW_TRUE XWIN_MULTIWINDOW_FALSE XWIN_MULTIWINDOWEXTWM_TRUE XWIN_MULTIWINDOWEXTWM_FALSE XWIN_CLIPBOARD_TRUE XWIN_CLIPBOARD_FALSE XWIN_GLX_WINDOWS_TRUE XWIN_GLX_WINDOWS_FALSE XWIN_NATIVEGDI_TRUE XWIN_NATIVEGDI_FALSE XWIN_PRIMARYFB_TRUE XWIN_PRIMARYFB_FALSE XWIN_RANDR_TRUE XWIN_RANDR_FALSE XWIN_XV_TRUE XWIN_XV_FALSE HAVE_X_PLUGIN_TRUE HAVE_X_PLUGIN_FALSE HAVE_AGL_FRAMEWORK_TRUE HAVE_AGL_FRAMEWORK_FALSE OBJC OBJCCLD OBJCLINK OBJCFLAGS OBJCDEPMODE am__fastdepOBJC_TRUE am__fastdepOBJC_FALSE KDRIVE_TRUE KDRIVE_FALSE XEPHYR_CFLAGS XEPHYR_LIBS TSLIB_CFLAGS TSLIB_LIBS XEPHYR_INCS XSDL_LIBS XSDL_INCS KDRIVE_INCS KDRIVE_PURE_INCS KDRIVE_CFLAGS KDRIVE_PURE_LIBS KDRIVE_LOCAL_LIBS KDRIVE_LIBS KDRIVELINUX_TRUE KDRIVELINUX_FALSE KDRIVEOPENBSD_TRUE KDRIVEOPENBSD_FALSE TSLIB_TRUE TSLIB_FALSE H3600_TS_TRUE H3600_TS_FALSE KDRIVEVESA_TRUE KDRIVEVESA_FALSE KDRIVEFBDEV_TRUE KDRIVEFBDEV_FALSE KDRIVEWSCONS_TRUE KDRIVEWSCONS_FALSE XSDLSERVER_TRUE XSDLSERVER_FALSE XEPHYR_TRUE XEPHYR_FALSE BUILD_KDRIVEFBDEVLIB_TRUE BUILD_KDRIVEFBDEVLIB_FALSE XFAKESERVER_TRUE XFAKESERVER_FALSE XKB_BASE_DIRECTORY XKB_BIN_DIRECTORY XKM_OUTPUT_DIR XKB_COMPILED_DIR PROJECTROOT XORGCONFIG_DEP_CFLAGS XORGCONFIG_DEP_LIBS XORGCFG_DEP_CFLAGS XORGCFG_DEP_LIBS APPDEFAULTDIR BUILD_XORGCFG_TRUE BUILD_XORGCFG_FALSE USE_CURSES_TRUE USE_CURSES_FALSE BUILD_KBD_MODE_TRUE BUILD_KBD_MODE_FALSE BSD_KBD_MODE_TRUE BSD_KBD_MODE_FALSE SUN_KBD_MODE_TRUE SUN_KBD_MODE_FALSE BUILD_IOPORT_TRUE BUILD_IOPORT_FALSE BUILD_DATE BUILD_TIME DIX_CFLAGS libdir exec_prefix prefix APP_MAN_SUFFIX LIB_MAN_SUFFIX FILE_MAN_SUFFIX MISC_MAN_SUFFIX DRIVER_MAN_SUFFIX ADMIN_MAN_SUFFIX APP_MAN_DIR LIB_MAN_DIR FILE_MAN_DIR MISC_MAN_DIR DRIVER_MAN_DIR ADMIN_MAN_DIR LIBOBJS LTLIBOBJS' +ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA CYGPATH_W PACKAGE VERSION ACLOCAL AUTOCONF AUTOMAKE AUTOHEADER MAKEINFO install_sh STRIP ac_ct_STRIP INSTALL_STRIP_PROGRAM mkdir_p AWK SET_MAKE am__leading_dot AMTAR am__tar am__untar MAINTAINER_MODE_TRUE MAINTAINER_MODE_FALSE MAINT CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT DEPDIR am__include am__quote AMDEP_TRUE AMDEP_FALSE AMDEPBACKSLASH CCDEPMODE am__fastdepCC_TRUE am__fastdepCC_FALSE CCAS CCASFLAGS LN_S build build_cpu build_vendor build_os host host_cpu host_vendor host_os SED EGREP ECHO AR ac_ct_AR RANLIB ac_ct_RANLIB DSYMUTIL ac_ct_DSYMUTIL NMEDIT ac_ct_NMEDIT DLLTOOL ac_ct_DLLTOOL AS ac_ct_AS OBJDUMP ac_ct_OBJDUMP CPP CXX CXXFLAGS ac_ct_CXX CXXDEPMODE am__fastdepCXX_TRUE am__fastdepCXX_FALSE CXXCPP F77 FFLAGS ac_ct_F77 LIBTOOL PKG_CONFIG ac_pt_PKG_CONFIG LEX LEXLIB LEX_OUTPUT_ROOT YACC RAWCPP RAWCPPFLAGS DTRACE XSERVER_DTRACE_TRUE XSERVER_DTRACE_FALSE XERRORDB_PATH ALLOCA NEED_STRLCAT_TRUE NEED_STRLCAT_FALSE NEED_VSNPRINTF_TRUE NEED_VSNPRINTF_FALSE AGP_TRUE AGP_FALSE LNXAPM_TRUE LNXAPM_FALSE FBDEVHW_TRUE FBDEVHW_FALSE FREEBSD_KLDLOAD_TRUE FREEBSD_KLDLOAD_FALSE BSD_APM_TRUE BSD_APM_FALSE BSD_KQUEUE_APM_TRUE BSD_KQUEUE_APM_FALSE ALPHA_VIDEO_TRUE ALPHA_VIDEO_FALSE ARM_VIDEO_TRUE ARM_VIDEO_FALSE HP300_VIDEO_TRUE HP300_VIDEO_FALSE HPPA_VIDEO_TRUE HPPA_VIDEO_FALSE I386_VIDEO_TRUE I386_VIDEO_FALSE PPC_VIDEO_TRUE PPC_VIDEO_FALSE SGI_VIDEO_TRUE SGI_VIDEO_FALSE SPARC64_VIDEO_TRUE SPARC64_VIDEO_FALSE KDRIVE_HW_TRUE KDRIVE_HW_FALSE X_PRIVSEP_TRUE X_PRIVSEP_FALSE INSTALL_SETUID_TRUE INSTALL_SETUID_FALSE SECURE_RPC_TRUE SECURE_RPC_FALSE INT10_VM86_TRUE INT10_VM86_FALSE INT10_X86EMU_TRUE INT10_X86EMU_FALSE INT10_STUB_TRUE INT10_STUB_FALSE BUILDDOCS_TRUE BUILDDOCS_FALSE LINUXDOC PS2PDF BUILD_LINUXDOC_TRUE BUILD_LINUXDOC_FALSE BUILD_PDFDOC_TRUE BUILD_PDFDOC_FALSE MAKE_TEXT MAKE_PS MAKE_PDF MAKE_HTML INSTALL_LIBXF86CONFIG_TRUE INSTALL_LIBXF86CONFIG_FALSE PIXMAN_CFLAGS PIXMAN_LIBS DBUS_CFLAGS DBUS_LIBS HAVE_DBUS_TRUE HAVE_DBUS_FALSE CONFIG_DBUS_API_TRUE CONFIG_DBUS_API_FALSE HAL_CFLAGS HAL_LIBS CONFIG_HAL_TRUE CONFIG_HAL_FALSE XV_TRUE XV_FALSE XVMC_TRUE XVMC_FALSE COMPOSITE_TRUE COMPOSITE_FALSE MITSHM_TRUE MITSHM_FALSE XTRAP_TRUE XTRAP_FALSE RECORD_TRUE RECORD_FALSE SCREENSAVER_TRUE SCREENSAVER_FALSE RES_TRUE RES_FALSE XLIB_CFLAGS XLIB_LIBS GL_CFLAGS GL_LIBS GLX_TRUE GLX_FALSE MESA_SOURCE AIGLX_TRUE AIGLX_FALSE GLX_DEFINES DRI_TRUE DRI_FALSE DRIPROTO_CFLAGS DRIPROTO_LIBS LIBDRM_CFLAGS LIBDRM_LIBS XINERAMA_TRUE XINERAMA_FALSE XACE_TRUE XACE_FALSE XCSECURITY_TRUE XCSECURITY_FALSE XEVIE_TRUE XEVIE_FALSE APPGROUP_TRUE APPGROUP_FALSE CUP_TRUE CUP_FALSE EVI_TRUE EVI_FALSE MULTIBUFFER_TRUE MULTIBUFFER_FALSE FONTCACHE_TRUE FONTCACHE_FALSE DBE_TRUE DBE_FALSE XF86BIGFONT_TRUE XF86BIGFONT_FALSE DPMSExtension_TRUE DPMSExtension_FALSE XPRINTPROTO_CFLAGS XPRINTPROTO_LIBS XPRINT_TRUE XPRINT_FALSE XCALIBRATE_TRUE XCALIBRATE_FALSE XF86UTILS_TRUE XF86UTILS_FALSE XDMCP_CFLAGS XDMCP_LIBS XDMCP_TRUE XDMCP_FALSE XDMAUTH_TRUE XDMAUTH_FALSE USE_RGB_BUILTIN_TRUE USE_RGB_BUILTIN_FALSE COMPILEDDEFAULTFONTPATH RGB_DB SERVERCONFIGdir BASE_FONT_PATH DRI_DRIVER_PATH VENDOR_NAME VENDOR_NAME_SHORT VENDOR_RELEASE VENDOR_MAN_VERSION DEBUG_TRUE DEBUG_FALSE XSERVERCFLAGS_CFLAGS XSERVERCFLAGS_LIBS XSERVERLIBS_CFLAGS XSERVERLIBS_LIBS SYS_LIBS LD_EXPORT_SYMBOLS_FLAG XSERVER_LIBS DMXMODULES_CFLAGS DMXMODULES_LIBS DMX_TRUE DMX_FALSE XDMX_LIBS XDMXCONFIG_DEP_CFLAGS XDMXCONFIG_DEP_LIBS DMXEXAMPLES_DEP_CFLAGS DMXEXAMPLES_DEP_LIBS DMXXMUEXAMPLES_DEP_CFLAGS DMXXMUEXAMPLES_DEP_LIBS DMXXIEXAMPLES_DEP_CFLAGS DMXXIEXAMPLES_DEP_LIBS XTSTEXAMPLES_DEP_CFLAGS XTSTEXAMPLES_DEP_LIBS XRESEXAMPLES_DEP_CFLAGS XRESEXAMPLES_DEP_LIBS X11EXAMPLES_DEP_CFLAGS X11EXAMPLES_DEP_LIBS DMX_BUILD_LNX_TRUE DMX_BUILD_LNX_FALSE DMX_BUILD_USB_TRUE DMX_BUILD_USB_FALSE XVFB_TRUE XVFB_FALSE XVFB_LIBS XNESTMODULES_CFLAGS XNESTMODULES_LIBS XNEST_TRUE XNEST_FALSE XNEST_LIBS XGLMODULES_CFLAGS XGLMODULES_LIBS XGL_TRUE XGL_FALSE XGL_LIBS xglmoduledir XGL_MODULE_PATH XEGLMODULES_CFLAGS XEGLMODULES_LIBS XEGL_TRUE XEGL_FALSE XEGL_LIBS XGLXMODULES_CFLAGS XGLXMODULES_LIBS XGLX_TRUE XGLX_FALSE XGLX_LIBS XORG_CORE_LIBS DARWIN_LIBS APPLE_APPLICATIONS_DIR PLIST_VERSION_STRING PLIST_VENDOR_WEB SOLARIS_INOUT_ARCH SOLARIS_ASM_CFLAGS DGA_CFLAGS DGA_LIBS XF86MISC_CFLAGS XF86MISC_LIBS XF86VIDMODE_CFLAGS XF86VIDMODE_LIBS XORG_MODULES_CFLAGS XORG_MODULES_LIBS XORG_LIBS XORG_INCS XORG_OS XORG_OS_SUBDIR PERL XORG_CFLAGS __XCONFIGFILE__ XF86CONFIGFILE DEFAULT_MODULE_PATH DEFAULT_LIBRARY_PATH DEFAULT_LOGPREFIX moduledir driverdir sdkdir extdir logdir XORG_TRUE XORG_FALSE XORG_BUS_LINUXPCI_TRUE XORG_BUS_LINUXPCI_FALSE XORG_BUS_FREEBSDPCI_TRUE XORG_BUS_FREEBSDPCI_FALSE XORG_BUS_NETBSDPCI_TRUE XORG_BUS_NETBSDPCI_FALSE XORG_BUS_IX86PCI_TRUE XORG_BUS_IX86PCI_FALSE XORG_BUS_PPCPCI_TRUE XORG_BUS_PPCPCI_FALSE XORG_BUS_SPARCPCI_TRUE XORG_BUS_SPARCPCI_FALSE XORG_BUS_SPARC_TRUE XORG_BUS_SPARC_FALSE XORG_LOADER_SPARC_TRUE XORG_LOADER_SPARC_FALSE LINUX_IA64_TRUE LINUX_IA64_FALSE LINUX_ALPHA_TRUE LINUX_ALPHA_FALSE LNXACPI_TRUE LNXACPI_FALSE SOLARIS_USL_CONSOLE_TRUE SOLARIS_USL_CONSOLE_FALSE SOLARIS_ASM_INLINE_TRUE SOLARIS_ASM_INLINE_FALSE BUILD_DARWIN_TRUE BUILD_DARWIN_FALSE XQUARTZ_TRUE XQUARTZ_FALSE DGA_TRUE DGA_FALSE XF86MISC_TRUE XF86MISC_FALSE XF86VIDMODE_TRUE XF86VIDMODE_FALSE MFB_TRUE MFB_FALSE CFB_TRUE CFB_FALSE AFB_TRUE AFB_FALSE XPRINT_CFLAGS XPRINT_LIBS xpconfigdir MKFONTSCALE MKFONTDIR FREETYPE_CFLAGS FREETYPE_LIBS ft_config FREETYPE_REQUIRES XP_USE_FREETYPE_TRUE XP_USE_FREETYPE_FALSE XWIN_LIBS XWINMODULES_CFLAGS XWINMODULES_LIBS XWIN_SERVER_NAME XWIN_SYSTEM_LIBS XWIN_TRUE XWIN_FALSE XWIN_MULTIWINDOW_TRUE XWIN_MULTIWINDOW_FALSE XWIN_MULTIWINDOWEXTWM_TRUE XWIN_MULTIWINDOWEXTWM_FALSE XWIN_CLIPBOARD_TRUE XWIN_CLIPBOARD_FALSE XWIN_GLX_WINDOWS_TRUE XWIN_GLX_WINDOWS_FALSE XWIN_NATIVEGDI_TRUE XWIN_NATIVEGDI_FALSE XWIN_PRIMARYFB_TRUE XWIN_PRIMARYFB_FALSE XWIN_RANDR_TRUE XWIN_RANDR_FALSE XWIN_XV_TRUE XWIN_XV_FALSE HAVE_X_PLUGIN_TRUE HAVE_X_PLUGIN_FALSE HAVE_AGL_FRAMEWORK_TRUE HAVE_AGL_FRAMEWORK_FALSE OBJC OBJCCLD OBJCLINK OBJCFLAGS OBJCDEPMODE am__fastdepOBJC_TRUE am__fastdepOBJC_FALSE KDRIVE_TRUE KDRIVE_FALSE XEPHYR_CFLAGS XEPHYR_LIBS TSLIB_CFLAGS TSLIB_LIBS XEPHYR_INCS XSDL_LIBS XSDL_INCS KDRIVE_INCS KDRIVE_PURE_INCS KDRIVE_CFLAGS KDRIVE_PURE_LIBS KDRIVE_LOCAL_LIBS KDRIVE_LIBS KDRIVELINUX_TRUE KDRIVELINUX_FALSE KDRIVEOPENBSD_TRUE KDRIVEOPENBSD_FALSE TSLIB_TRUE TSLIB_FALSE H3600_TS_TRUE H3600_TS_FALSE KDRIVEVESA_TRUE KDRIVEVESA_FALSE KDRIVEFBDEV_TRUE KDRIVEFBDEV_FALSE KDRIVEWSCONS_TRUE KDRIVEWSCONS_FALSE XSDLSERVER_TRUE XSDLSERVER_FALSE XEPHYR_TRUE XEPHYR_FALSE BUILD_KDRIVEFBDEVLIB_TRUE BUILD_KDRIVEFBDEVLIB_FALSE XFAKESERVER_TRUE XFAKESERVER_FALSE XKB_BASE_DIRECTORY XKB_BIN_DIRECTORY XKM_OUTPUT_DIR XKB_COMPILED_DIR PROJECTROOT XORGCONFIG_DEP_CFLAGS XORGCONFIG_DEP_LIBS XORGCFG_DEP_CFLAGS XORGCFG_DEP_LIBS APPDEFAULTDIR BUILD_XORGCFG_TRUE BUILD_XORGCFG_FALSE USE_CURSES_TRUE USE_CURSES_FALSE BUILD_KBD_MODE_TRUE BUILD_KBD_MODE_FALSE BSD_KBD_MODE_TRUE BSD_KBD_MODE_FALSE SUN_KBD_MODE_TRUE SUN_KBD_MODE_FALSE BUILD_IOPORT_TRUE BUILD_IOPORT_FALSE BUILD_DATE BUILD_TIME DIX_CFLAGS APP_MAN_SUFFIX LIB_MAN_SUFFIX FILE_MAN_SUFFIX MISC_MAN_SUFFIX DRIVER_MAN_SUFFIX ADMIN_MAN_SUFFIX APP_MAN_DIR LIB_MAN_DIR FILE_MAN_DIR MISC_MAN_DIR DRIVER_MAN_DIR ADMIN_MAN_DIR LIBOBJS LTLIBOBJS' ac_subst_files='' # Initialize some variables set by options. @@ -1230,7 +1230,7 @@ if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures xorg-server 1.4.0.90 to adapt to many kinds of systems. +\`configure' configures xorg-server 1.4.2 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1296,7 +1296,7 @@ fi if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of xorg-server 1.4.0.90:";; + short | recursive ) echo "Configuration of xorg-server 1.4.2:";; esac cat <<\_ACEOF @@ -1679,7 +1679,7 @@ fi test -n "$ac_init_help" && exit 0 if $ac_init_version; then cat <<\_ACEOF -xorg-server configure 1.4.0.90 +xorg-server configure 1.4.2 generated by GNU Autoconf 2.59 Copyright (C) 2003 Free Software Foundation, Inc. @@ -1693,7 +1693,7 @@ cat >&5 <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by xorg-server $as_me 1.4.0.90, which was +It was created by xorg-server $as_me 1.4.2, which was generated by GNU Autoconf 2.59. Invocation command line was $ $0 $@ @@ -2292,7 +2292,7 @@ fi # Define the identity of the package. PACKAGE='xorg-server' - VERSION='1.4.0.90' + VERSION='1.4.2' cat >>confdefs.h <<_ACEOF @@ -20837,6 +20837,154 @@ See \`config.log' for more details." >&2;} { (exit 1); exit 1; }; } fi WDTRACE="no" + else + if test "${ac_cv_header_sys_sdt_h+set}" = set; then + echo "$as_me:$LINENO: checking for sys/sdt.h" >&5 +echo $ECHO_N "checking for sys/sdt.h... $ECHO_C" >&6 +if test "${ac_cv_header_sys_sdt_h+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +fi +echo "$as_me:$LINENO: result: $ac_cv_header_sys_sdt_h" >&5 +echo "${ECHO_T}$ac_cv_header_sys_sdt_h" >&6 +else + # Is the header compilable? +echo "$as_me:$LINENO: checking sys/sdt.h usability" >&5 +echo $ECHO_N "checking sys/sdt.h usability... $ECHO_C" >&6 +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +#include <sys/sdt.h> +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_header_compiler=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_header_compiler=no +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 +echo "${ECHO_T}$ac_header_compiler" >&6 + +# Is the header present? +echo "$as_me:$LINENO: checking sys/sdt.h presence" >&5 +echo $ECHO_N "checking sys/sdt.h presence... $ECHO_C" >&6 +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include <sys/sdt.h> +_ACEOF +if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 + (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null; then + if test -s conftest.err; then + ac_cpp_err=$ac_c_preproc_warn_flag + ac_cpp_err=$ac_cpp_err$ac_c_werror_flag + else + ac_cpp_err= + fi +else + ac_cpp_err=yes +fi +if test -z "$ac_cpp_err"; then + ac_header_preproc=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_header_preproc=no +fi +rm -f conftest.err conftest.$ac_ext +echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 +echo "${ECHO_T}$ac_header_preproc" >&6 + +# So? What about this header? +case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in + yes:no: ) + { echo "$as_me:$LINENO: WARNING: sys/sdt.h: accepted by the compiler, rejected by the preprocessor!" >&5 +echo "$as_me: WARNING: sys/sdt.h: accepted by the compiler, rejected by the preprocessor!" >&2;} + { echo "$as_me:$LINENO: WARNING: sys/sdt.h: proceeding with the compiler's result" >&5 +echo "$as_me: WARNING: sys/sdt.h: proceeding with the compiler's result" >&2;} + ac_header_preproc=yes + ;; + no:yes:* ) + { echo "$as_me:$LINENO: WARNING: sys/sdt.h: present but cannot be compiled" >&5 +echo "$as_me: WARNING: sys/sdt.h: present but cannot be compiled" >&2;} + { echo "$as_me:$LINENO: WARNING: sys/sdt.h: check for missing prerequisite headers?" >&5 +echo "$as_me: WARNING: sys/sdt.h: check for missing prerequisite headers?" >&2;} + { echo "$as_me:$LINENO: WARNING: sys/sdt.h: see the Autoconf documentation" >&5 +echo "$as_me: WARNING: sys/sdt.h: see the Autoconf documentation" >&2;} + { echo "$as_me:$LINENO: WARNING: sys/sdt.h: section \"Present But Cannot Be Compiled\"" >&5 +echo "$as_me: WARNING: sys/sdt.h: section \"Present But Cannot Be Compiled\"" >&2;} + { echo "$as_me:$LINENO: WARNING: sys/sdt.h: proceeding with the preprocessor's result" >&5 +echo "$as_me: WARNING: sys/sdt.h: proceeding with the preprocessor's result" >&2;} + { echo "$as_me:$LINENO: WARNING: sys/sdt.h: in the future, the compiler will take precedence" >&5 +echo "$as_me: WARNING: sys/sdt.h: in the future, the compiler will take precedence" >&2;} + ( + cat <<\_ASBOX +## ---------------------------------------------------------------------- ## +## Report this to https://bugs.freedesktop.org/enter_bug.cgi?product=xorg ## +## ---------------------------------------------------------------------- ## +_ASBOX + ) | + sed "s/^/$as_me: WARNING: /" >&2 + ;; +esac +echo "$as_me:$LINENO: checking for sys/sdt.h" >&5 +echo $ECHO_N "checking for sys/sdt.h... $ECHO_C" >&6 +if test "${ac_cv_header_sys_sdt_h+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_cv_header_sys_sdt_h=$ac_header_preproc +fi +echo "$as_me:$LINENO: result: $ac_cv_header_sys_sdt_h" >&5 +echo "${ECHO_T}$ac_cv_header_sys_sdt_h" >&6 + +fi +if test $ac_cv_header_sys_sdt_h = yes; then + HAS_SDT_H="yes" +else + HAS_SDT_H="no" +fi + + + if test "x$WDTRACE" = "xauto" -a "x$HAS_SDT_H" = "xno" ; then + WDTRACE="no" + fi fi fi if test "x$WDTRACE" != "xno" ; then @@ -26223,6 +26371,10 @@ _ACEOF #define USE_DEV_IO 1 _ACEOF ;; + *dragonfly*) cat >>confdefs.h <<\_ACEOF +#define USE_DEV_IO 1 +_ACEOF + ;; *netbsd*) cat >>confdefs.h <<\_ACEOF #define USE_I386_IOPL 1 _ACEOF @@ -26266,6 +26418,11 @@ cat >>confdefs.h <<\_ACEOF #define USE_DEV_IO 1 _ACEOF ;; + *dragonfly*) +cat >>confdefs.h <<\_ACEOF +#define USE_DEV_IO 1 +_ACEOF + ;; *netbsd*) cat >>confdefs.h <<\_ACEOF #define USE_I386_IOPL 1 @@ -26368,7 +26525,7 @@ fi DRI=no KDRIVE_HW=no case $host_os in - *freebsd*) + *freebsd* | *dragonfly*) case $host_os in kfreebsd*-gnu) ;; *) @@ -26513,7 +26670,7 @@ VENDOR_MAN_VERSION="Version ${PACKAGE_VERSION}" VENDOR_NAME="The X.Org Foundation" VENDOR_NAME_SHORT="X.Org" -RELEASE_DATE="5 September 2007" +RELEASE_DATE="11 June 2008" VENDOR_WEB="http://wiki.x.org" @@ -27163,19 +27320,16 @@ fi + case $host_os in + mingw*) unixdef="no" ;; + *) unixdef="yes" ;; + esac # Check whether --enable-unix-transport or --disable-unix-transport was given. if test "${enable_unix_transport+set}" = set; then enableval="$enable_unix_transport" UNIXCONN=$enableval else - UNIXCONN=yes -fi; - # Check whether --enable-tcp-transport or --disable-tcp-transport was given. -if test "${enable_tcp_transport+set}" = set; then - enableval="$enable_tcp_transport" - TCPCONN=$enableval -else - TCPCONN=yes + UNIXCONN=$unixdef fi; echo "$as_me:$LINENO: checking if Xtrans should support UNIX socket connections" >&5 echo $ECHO_N "checking if Xtrans should support UNIX socket connections... $ECHO_C" >&6 @@ -27188,6 +27342,13 @@ _ACEOF fi echo "$as_me:$LINENO: result: $UNIXCONN" >&5 echo "${ECHO_T}$UNIXCONN" >&6 + # Check whether --enable-tcp-transport or --disable-tcp-transport was given. +if test "${enable_tcp_transport+set}" = set; then + enableval="$enable_tcp_transport" + TCPCONN=$enableval +else + TCPCONN=yes +fi; echo "$as_me:$LINENO: checking if Xtrans should support TCP socket connections" >&5 echo $ECHO_N "checking if Xtrans should support TCP socket connections... $ECHO_C" >&6 echo "$as_me:$LINENO: result: $TCPCONN" >&5 @@ -27689,6 +27850,77 @@ _ACEOF fi + # POSIX.1g changed the type of pointer passed to getsockname/getpeername/etc. + echo "$as_me:$LINENO: checking for socklen_t" >&5 +echo $ECHO_N "checking for socklen_t... $ECHO_C" >&6 +if test "${ac_cv_type_socklen_t+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +$ac_includes_default +#include <sys/socket.h> + +int +main () +{ +if ((socklen_t *) 0) + return 0; +if (sizeof (socklen_t)) + return 0; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_type_socklen_t=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_type_socklen_t=no +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: $ac_cv_type_socklen_t" >&5 +echo "${ECHO_T}$ac_cv_type_socklen_t" >&6 +if test $ac_cv_type_socklen_t = yes; then + +cat >>confdefs.h <<_ACEOF +#define HAVE_SOCKLEN_T 1 +_ACEOF + + +fi + + + fi case $host_os in solaris*|sco*|sysv4*) localdef="yes" ;; @@ -33218,7 +33450,7 @@ echo "$as_me: Disabling DGA extension" >&6;} ;; esac ;; - freebsd* | kfreebsd*-gnu) + freebsd* | kfreebsd*-gnu | dragonfly*) XORG_OS="freebsd" XORG_OS_SUBDIR="bsd" case $host_cpu in @@ -36188,12 +36420,12 @@ if test -n "$PKG_CONFIG"; then pkg_cv_XEPHYR_CFLAGS="$XEPHYR_CFLAGS" else if test -n "$PKG_CONFIG" && \ - { (echo "$as_me:$LINENO: \$PKG_CONFIG --exists --print-errors \"x11 xext xfont xau xdmcp\"") >&5 - ($PKG_CONFIG --exists --print-errors "x11 xext xfont xau xdmcp") 2>&5 + { (echo "$as_me:$LINENO: \$PKG_CONFIG --exists --print-errors \"x11 xext xfont xau xdmcp \$PIXMAN\"") >&5 + ($PKG_CONFIG --exists --print-errors "x11 xext xfont xau xdmcp $PIXMAN") 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; then - pkg_cv_XEPHYR_CFLAGS=`$PKG_CONFIG --cflags "x11 xext xfont xau xdmcp" 2>/dev/null` + pkg_cv_XEPHYR_CFLAGS=`$PKG_CONFIG --cflags "x11 xext xfont xau xdmcp $PIXMAN" 2>/dev/null` else pkg_failed=yes fi @@ -36206,12 +36438,12 @@ if test -n "$PKG_CONFIG"; then pkg_cv_XEPHYR_LIBS="$XEPHYR_LIBS" else if test -n "$PKG_CONFIG" && \ - { (echo "$as_me:$LINENO: \$PKG_CONFIG --exists --print-errors \"x11 xext xfont xau xdmcp\"") >&5 - ($PKG_CONFIG --exists --print-errors "x11 xext xfont xau xdmcp") 2>&5 + { (echo "$as_me:$LINENO: \$PKG_CONFIG --exists --print-errors \"x11 xext xfont xau xdmcp \$PIXMAN\"") >&5 + ($PKG_CONFIG --exists --print-errors "x11 xext xfont xau xdmcp $PIXMAN") 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; then - pkg_cv_XEPHYR_LIBS=`$PKG_CONFIG --libs "x11 xext xfont xau xdmcp" 2>/dev/null` + pkg_cv_XEPHYR_LIBS=`$PKG_CONFIG --libs "x11 xext xfont xau xdmcp $PIXMAN" 2>/dev/null` else pkg_failed=yes fi @@ -36230,9 +36462,9 @@ else _pkg_short_errors_supported=no fi if test $_pkg_short_errors_supported = yes; then - XEPHYR_PKG_ERRORS=`$PKG_CONFIG --short-errors --errors-to-stdout --print-errors "x11 xext xfont xau xdmcp"` + XEPHYR_PKG_ERRORS=`$PKG_CONFIG --short-errors --errors-to-stdout --print-errors "x11 xext xfont xau xdmcp $PIXMAN"` else - XEPHYR_PKG_ERRORS=`$PKG_CONFIG --errors-to-stdout --print-errors "x11 xext xfont xau xdmcp"` + XEPHYR_PKG_ERRORS=`$PKG_CONFIG --errors-to-stdout --print-errors "x11 xext xfont xau xdmcp $PIXMAN"` fi # Put the nasty error message in config.log where it belongs echo "$XEPHYR_PKG_ERRORS" >&5 @@ -37357,6 +37589,8 @@ DIX_CFLAGS="-DHAVE_DIX_CONFIG_H $XSERVER_CFLAGS" + + # Man page sections - used in config utils & generating man pages @@ -38675,7 +38909,7 @@ _ASBOX } >&5 cat >&5 <<_CSEOF -This file was extended by xorg-server $as_me 1.4.0.90, which was +This file was extended by xorg-server $as_me 1.4.2, which was generated by GNU Autoconf 2.59. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -38738,7 +38972,7 @@ _ACEOF cat >>$CONFIG_STATUS <<_ACEOF ac_cs_version="\\ -xorg-server config.status 1.4.0.90 +xorg-server config.status 1.4.2 configured by $0, generated by GNU Autoconf 2.59, with options \\"`echo "$ac_configure_args" | sed 's/[\\""\`\$]/\\\\&/g'`\\" @@ -39616,9 +39850,6 @@ s,@BUILD_IOPORT_FALSE@,$BUILD_IOPORT_FALSE,;t t s,@BUILD_DATE@,$BUILD_DATE,;t t s,@BUILD_TIME@,$BUILD_TIME,;t t s,@DIX_CFLAGS@,$DIX_CFLAGS,;t t -s,@libdir@,$libdir,;t t -s,@exec_prefix@,$exec_prefix,;t t -s,@prefix@,$prefix,;t t s,@APP_MAN_SUFFIX@,$APP_MAN_SUFFIX,;t t s,@LIB_MAN_SUFFIX@,$LIB_MAN_SUFFIX,;t t s,@FILE_MAN_SUFFIX@,$FILE_MAN_SUFFIX,;t t diff --git a/xserver/configure.ac b/xserver/configure.ac index 81a250a06..bf46f5997 100644 --- a/xserver/configure.ac +++ b/xserver/configure.ac @@ -26,7 +26,7 @@ dnl dnl Process this file with autoconf to create configure. AC_PREREQ(2.57) -AC_INIT([xorg-server], 1.4.0.90, [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg], xorg-server) +AC_INIT([xorg-server], 1.4.2, [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg], xorg-server) AC_CONFIG_SRCDIR([Makefile.am]) AM_INIT_AUTOMAKE([dist-bzip2 foreign]) AM_MAINTAINER_MODE @@ -66,6 +66,8 @@ AC_SYS_LARGEFILE XORG_PROG_RAWCPP dnl Check for dtrace program (needed to build Xserver dtrace probes) +dnl Also checks for <sys/sdt.h>, since some Linux distros have an +dnl ISDN trace program named dtrace AC_ARG_WITH(dtrace, AS_HELP_STRING([--with-dtrace=PATH], [Enable dtrace probes (default: enabled if dtrace found)]), [WDTRACE=$withval], [WDTRACE=auto]) @@ -76,6 +78,11 @@ if test "x$WDTRACE" = "xyes" -o "x$WDTRACE" = "xauto" ; then AC_MSG_FAILURE([dtrace requested but not found]) fi WDTRACE="no" + else + AC_CHECK_HEADER(sys/sdt.h, [HAS_SDT_H="yes"], [HAS_SDT_H="no"]) + if test "x$WDTRACE" = "xauto" -a "x$HAS_SDT_H" = "xno" ; then + WDTRACE="no" + fi fi fi if test "x$WDTRACE" != "xno" ; then @@ -306,6 +313,7 @@ case $host_cpu in darwin*) use_x86_asm="no" ;; *linux*) DEFAULT_INT10=vm86 ;; *freebsd*) AC_DEFINE(USE_DEV_IO) ;; + *dragonfly*) AC_DEFINE(USE_DEV_IO) ;; *netbsd*) AC_DEFINE(USE_I386_IOPL) SYS_LIBS=-li386 ;; @@ -339,6 +347,7 @@ case $host_cpu in case $host_os in darwin*) use_x86_asm="no" ;; *freebsd*) AC_DEFINE(USE_DEV_IO, 1, [BSD /dev/io]) ;; + *dragonfly*) AC_DEFINE(USE_DEV_IO, 1, [BSD /dev/io]) ;; *netbsd*) AC_DEFINE(USE_I386_IOPL, 1, [BSD i386 iopl]) SYS_LIBS=-lx86_64 ;; @@ -363,7 +372,7 @@ DRI=no KDRIVE_HW=no dnl it would be nice to autodetect these *CONS_SUPPORTs case $host_os in - *freebsd*) + *freebsd* | *dragonfly*) case $host_os in kfreebsd*-gnu) ;; *) AC_DEFINE(CSRG_BASED, 1, [System is BSD-like]) ;; @@ -410,7 +419,7 @@ VENDOR_MAN_VERSION="Version ${PACKAGE_VERSION}" VENDOR_NAME="The X.Org Foundation" VENDOR_NAME_SHORT="X.Org" -RELEASE_DATE="5 September 2007" +RELEASE_DATE="11 June 2008" VENDOR_WEB="http://wiki.x.org" m4_ifdef([AS_HELP_STRING], , [m4_define([AS_HELP_STRING], m4_defn([AC_HELP_STRING]))]) @@ -1409,7 +1418,7 @@ return 0;} ;; esac ;; - freebsd* | kfreebsd*-gnu) + freebsd* | kfreebsd*-gnu | dragonfly*) XORG_OS="freebsd" XORG_OS_SUBDIR="bsd" case $host_cpu in @@ -1862,7 +1871,7 @@ if test "$KDRIVE" = yes; then XSDL_INCS="`sdl-config --cflags` $XSERVER_CFLAGS" fi - PKG_CHECK_MODULES(XEPHYR, x11 xext xfont xau xdmcp, [xephyr="yes"], [xephyr="no"]) + PKG_CHECK_MODULES(XEPHYR, x11 xext xfont xau xdmcp $PIXMAN, [xephyr="yes"], [xephyr="no"]) if test "x$XEPHYR" = xauto; then XEPHYR=$xephyr fi @@ -2030,7 +2039,9 @@ DIX_CFLAGS="-DHAVE_DIX_CONFIG_H $XSERVER_CFLAGS" AC_SUBST([DIX_CFLAGS]) -AC_SUBST([libdir exec_prefix prefix]) +AC_SUBST([libdir]) +AC_SUBST([exec_prefix]) +AC_SUBST([prefix]) # Man page sections - used in config utils & generating man pages XORG_MANPAGE_SECTIONS diff --git a/xserver/dix/devices.c b/xserver/dix/devices.c index 7aa6827da..87519ebce 100644 --- a/xserver/dix/devices.c +++ b/xserver/dix/devices.c @@ -473,7 +473,8 @@ InitAndStartDevices(void) for (dev = inputInfo.off_devices; dev; dev = dev->next) { DebugF("(dix) initialising device %d\n", dev->id); - ActivateDevice(dev); + if (!dev->inited) + ActivateDevice(dev); } for (dev = inputInfo.off_devices; dev; dev = next) { diff --git a/xserver/dix/getevents.c b/xserver/dix/getevents.c index f92a0211a..c96ee68cd 100644 --- a/xserver/dix/getevents.c +++ b/xserver/dix/getevents.c @@ -95,7 +95,14 @@ set_key_up(DeviceIntPtr pDev, int key_code) static Bool key_is_down(DeviceIntPtr pDev, int key_code) { - return pDev->key->postdown[key_code >> 3] >> (key_code & 7); + return !!(pDev->key->postdown[key_code >> 3] & (1 << (key_code & 7))); +} + +static Bool +key_autorepeats(DeviceIntPtr pDev, int key_code) +{ + return !!(pDev->kbdfeed->ctrl.autoRepeats[key_code >> 3] & + (1 << (key_code & 7))); } /** @@ -299,10 +306,13 @@ clipAxis(DeviceIntPtr pDev, int axisNum, int *val) { AxisInfoPtr axes = pDev->valuator->axes + axisNum; - if (*val < axes->min_value) - *val = axes->min_value; - if (axes->max_value >= 0 && *val > axes->max_value) - *val = axes->max_value; + /* No clipping if the value-range <= 0 */ + if(axes->min_value < axes->min_value) { + if (*val < axes->min_value) + *val = axes->min_value; + if (*val > axes->max_value) + *val = axes->max_value; + } } /** @@ -337,7 +347,7 @@ getValuatorEvents(xEvent *events, DeviceIntPtr pDev, int first_valuator, for (i = first_valuator; i < final_valuator; i += 6, xv++, events++) { xv->type = DeviceValuator; xv->first_valuator = i; - xv->num_valuators = num_valuators; + xv->num_valuators = ((final_valuator - i) > 6) ? 6 : (final_valuator - i); xv->deviceid = pDev->id; switch (final_valuator - i) { case 6: @@ -402,6 +412,7 @@ GetKeyboardValuatorEvents(xEvent *events, DeviceIntPtr pDev, int type, if (!events) return 0; + /* DO NOT WANT */ if (type != KeyPress && type != KeyRelease) return 0; @@ -409,6 +420,9 @@ GetKeyboardValuatorEvents(xEvent *events, DeviceIntPtr pDev, int type, (pDev->coreEvents && !inputInfo.keyboard->key)) return 0; + if (key_code < 8 || key_code > 255) + return 0; + if (pDev->coreEvents) numEvents = 2; else @@ -440,10 +454,11 @@ GetKeyboardValuatorEvents(xEvent *events, DeviceIntPtr pDev, int type, * FIXME: In theory, if you're repeating with two keyboards in non-XKB, * you could get unbalanced events here. */ if (type == KeyPress && key_is_down(pDev, key_code)) { + /* If autorepeating is disabled either globally or just for that key, + * or we have a modifier, don't generate a repeat event. */ if (!pDev->kbdfeed->ctrl.autoRepeat || - pDev->key->modifierMap[key_code] || - !(pDev->kbdfeed->ctrl.autoRepeats[key_code >> 3] - & (1 << (key_code & 7)))) + !key_autorepeats(pDev, key_code) || + pDev->key->modifierMap[key_code]) return 0; #ifdef XKB @@ -511,12 +526,10 @@ GetPointerEvents(xEvent *events, DeviceIntPtr pDev, int type, int buttons, int num_events = 0, final_valuator = 0; CARD32 ms = 0; deviceKeyButtonPointer *kbp = NULL; - /* Thanks to a broken lib, we _always_ have to chase DeviceMotionNotifies - * with DeviceValuators. */ - Bool sendValuators = (type == MotionNotify || flags & POINTER_ABSOLUTE); DeviceIntPtr cp = inputInfo.pointer; int x = 0, y = 0; Bool coreOnly = (pDev == inputInfo.pointer); + ScreenPtr scr = miPointerGetScreen(pDev); /* Sanity checks. */ if (type != MotionNotify && type != ButtonPress && type != ButtonRelease) @@ -539,7 +552,7 @@ GetPointerEvents(xEvent *events, DeviceIntPtr pDev, int type, int buttons, return 0; /* Do we need to send a DeviceValuator event? */ - if (!coreOnly && sendValuators) { + if (!coreOnly && num_valuators) { if ((((num_valuators - 1) / 6) + 1) > MAX_VALUATOR_EVENTS) num_valuators = MAX_VALUATOR_EVENTS * 6; num_events += ((num_valuators - 1) / 6) + 1; @@ -560,21 +573,44 @@ GetPointerEvents(xEvent *events, DeviceIntPtr pDev, int type, int buttons, x = valuators[0]; } else { - if (pDev->coreEvents) - x = cp->valuator->lastx; - else - x = pDev->valuator->lastx; + /* If we're sending core events but didn't provide a value, + * translate the core value (but use the device coord if + * it translates to the same coord to preserve sub-pixel + * coord information). If we're not sending core events use + * whatever value we have */ + x = pDev->valuator->lastx; + if(pDev->coreEvents) { + int min = pDev->valuator->axes[0].min_value; + int max = pDev->valuator->axes[0].max_value; + if(min < max) { + if((int)((float)(x-min)*scr->width/(max-min+1)) != cp->valuator->lastx) + x = (int)((float)(cp->valuator->lastx)*(max-min+1)/scr->width)+min; + } + else + x = cp->valuator->lastx; + } } if (first_valuator <= 1 && num_valuators >= (2 - first_valuator)) { y = valuators[1 - first_valuator]; } else { - if (pDev->coreEvents) - y = cp->valuator->lasty; - else - y = pDev->valuator->lasty; + y = pDev->valuator->lasty; + if(pDev->coreEvents) { + int min = pDev->valuator->axes[1].min_value; + int max = pDev->valuator->axes[1].max_value; + if(min < max) { + if((int)((float)(y-min)*scr->height/(max-min+1)) != cp->valuator->lasty) + y = (int)((float)(cp->valuator->lasty)*(max-min+1)/scr->height)+min; + } + else + y = cp->valuator->lasty; + } } + + /* Clip both x and y to the defined limits (usually co-ord space limit). */ + clipAxis(pDev, 0, &x); + clipAxis(pDev, 1, &y); } else { if (flags & POINTER_ACCELERATE) @@ -582,54 +618,107 @@ GetPointerEvents(xEvent *events, DeviceIntPtr pDev, int type, int buttons, valuators); if (pDev->coreEvents) { - if (first_valuator == 0 && num_valuators >= 1) - x = cp->valuator->lastx + valuators[0]; + /* Get and convert the core pointer coordinate space into + * device coordinates. Use the device coords if it translates + * into the same position as the core to preserve relative sub- + * pixel movements from the device. */ + int min = pDev->valuator->axes[0].min_value; + int max = pDev->valuator->axes[0].max_value; + if(min < max) { + x = pDev->valuator->lastx; + if((int)((float)(x-min)*scr->width/(max-min+1)) != cp->valuator->lastx) + x = (int)((float)(cp->valuator->lastx)*(max-min+1)/scr->width)+min; + } else x = cp->valuator->lastx; - if (first_valuator <= 1 && num_valuators >= (2 - first_valuator)) - y = cp->valuator->lasty + valuators[1 - first_valuator]; + min = pDev->valuator->axes[1].min_value; + max = pDev->valuator->axes[1].max_value; + if(min < max) { + y = pDev->valuator->lasty; + if((int)((float)(y-min)*scr->height/(max-min+1)) != cp->valuator->lasty) + y = (int)((float)(cp->valuator->lasty)*(max-min+1)/scr->height)+min; + } else y = cp->valuator->lasty; + + /* Add relative movement */ + if (first_valuator == 0 && num_valuators >= 1) + x += valuators[0]; + if (first_valuator <= 1 && num_valuators >= (2 - first_valuator)) + y += valuators[1 - first_valuator]; } else { + x = pDev->valuator->lastx; + y = pDev->valuator->lasty; if (first_valuator == 0 && num_valuators >= 1) - x = pDev->valuator->lastx + valuators[0]; - else - x = pDev->valuator->lastx; - + x += valuators[0]; if (first_valuator <= 1 && num_valuators >= (2 - first_valuator)) - y = pDev->valuator->lasty + valuators[1 - first_valuator]; - else - y = pDev->valuator->lasty; + y += valuators[1 - first_valuator]; + + if(!coreOnly) { + /* Since we're not sending core-events we must clip both x and y + * to the defined limits so we don't run outside the box. */ + clipAxis(pDev, 0, &x); + clipAxis(pDev, 1, &y); + } } } - /* Clip both x and y to the defined limits (usually co-ord space limit). */ - clipAxis(pDev, 0, &x); - clipAxis(pDev, 1, &y); + pDev->valuator->lastx = x; + pDev->valuator->lasty = y; + /* Convert the dev coord back to screen coord if we're + * sending core events */ + if (pDev->coreEvents) { + int min = pDev->valuator->axes[0].min_value; + int max = pDev->valuator->axes[0].max_value; + if(min < max) + x = (int)((float)(x-min)*scr->width/(max-min+1)); + cp->valuator->lastx = x; + min = pDev->valuator->axes[1].min_value; + max = pDev->valuator->axes[1].max_value; + if(min < max) + y = (int)((float)(y-min)*scr->height/(max-min+1)); + cp->valuator->lasty = y; + } /* This takes care of crossing screens for us, as well as clipping * to the current screen. Right now, we only have one history buffer, * so we don't set this for both the device and core.*/ miPointerSetPosition(pDev, &x, &y, ms); + if (pDev->coreEvents) { + /* miPointerSetPosition may have changed screen */ + scr = miPointerGetScreen(pDev); + if(x != cp->valuator->lastx) { + int min = pDev->valuator->axes[0].min_value; + int max = pDev->valuator->axes[0].max_value; + cp->valuator->lastx = pDev->valuator->lastx = x; + if(min < max) + pDev->valuator->lastx = (int)((float)(x)*(max-min+1)/scr->width)+min; + } + if(y != cp->valuator->lasty) { + int min = pDev->valuator->axes[1].min_value; + int max = pDev->valuator->axes[1].max_value; + cp->valuator->lasty = pDev->valuator->lasty = y; + if(min < max) + pDev->valuator->lasty = (int)((float)(y)*(max-min+1)/scr->height)+min; + } + } + else if (coreOnly) { + cp->valuator->lastx = x; + cp->valuator->lasty = y; + } + /* Drop x and y back into the valuators list, if they were originally * present. */ if (first_valuator == 0 && num_valuators >= 1) - valuators[0] = x; + valuators[0] = pDev->valuator->lastx; if (first_valuator <= 1 && num_valuators >= (2 - first_valuator)) - valuators[1 - first_valuator] = y; + valuators[1 - first_valuator] = pDev->valuator->lasty; updateMotionHistory(pDev, ms, first_valuator, num_valuators, valuators); - if (pDev->coreEvents) { - cp->valuator->lastx = x; - cp->valuator->lasty = y; - } - pDev->valuator->lastx = x; - pDev->valuator->lasty = y; - /* for some reason inputInfo.pointer does not have coreEvents set */ if (coreOnly || pDev->coreEvents) { events->u.u.type = type; @@ -666,11 +755,11 @@ GetPointerEvents(xEvent *events, DeviceIntPtr pDev, int type, int buttons, kbp->detail = pDev->button->map[buttons]; } - kbp->root_x = x; - kbp->root_y = y; + kbp->root_x = pDev->valuator->lastx; + kbp->root_y = pDev->valuator->lasty; events++; - if (sendValuators) { + if (num_valuators) { kbp->deviceid |= MORE_EVENTS; clipValuators(pDev, first_valuator, num_valuators, valuators); events = getValuatorEvents(events, pDev, first_valuator, @@ -693,7 +782,7 @@ _X_EXPORT int GetProximityEvents(xEvent *events, DeviceIntPtr pDev, int type, int first_valuator, int num_valuators, int *valuators) { - int num_events = 0; + int num_events = 1; deviceKeyButtonPointer *kbp = (deviceKeyButtonPointer *) events; /* Sanity checks. */ diff --git a/xserver/exa/exa.c b/xserver/exa/exa.c index b49065303..b2faf2f1c 100644 --- a/xserver/exa/exa.c +++ b/xserver/exa/exa.c @@ -32,6 +32,10 @@ #include <dix-config.h> #endif +#ifdef MITSHM +#include "shmint.h" +#endif + #include <stdlib.h> #include "exa_priv.h" @@ -118,17 +122,54 @@ exaGetDrawablePixmap(DrawablePtr pDrawable) } /** - * exaDrawableDirty() marks a pixmap backing a drawable as dirty, allowing for + * Sets the offsets to add to coordinates to make them address the same bits in + * the backing drawable. These coordinates are nonzero only for redirected + * windows. + */ +void +exaGetDrawableDeltas (DrawablePtr pDrawable, PixmapPtr pPixmap, + int *xp, int *yp) +{ +#ifdef COMPOSITE + if (pDrawable->type == DRAWABLE_WINDOW) { + *xp = -pPixmap->screen_x; + *yp = -pPixmap->screen_y; + return; + } +#endif + + *xp = 0; + *yp = 0; +} + +/** + * exaPixmapDirty() marks a pixmap as dirty, allowing for * optimizations in pixmap migration when no changes have occurred. */ void -exaDrawableDirty (DrawablePtr pDrawable) +exaPixmapDirty (PixmapPtr pPix, int x1, int y1, int x2, int y2) { - ExaPixmapPrivPtr pExaPixmap; + ExaPixmapPriv(pPix); + BoxRec box; + RegionPtr pDamageReg; + RegionRec region; - pExaPixmap = ExaGetPixmapPriv(exaGetDrawablePixmap (pDrawable)); - if (pExaPixmap != NULL) - pExaPixmap->dirty = TRUE; + if (!pExaPixmap) + return; + + box.x1 = max(x1, 0); + box.y1 = max(y1, 0); + box.x2 = min(x2, pPix->drawable.width); + box.y2 = min(y2, pPix->drawable.height); + + if (box.x1 >= box.x2 || box.y1 >= box.y2) + return; + + pDamageReg = DamageRegion(pExaPixmap->pDamage); + + REGION_INIT(pScreen, ®ion, &box, 1); + REGION_UNION(pScreen, pDamageReg, pDamageReg, ®ion); + REGION_UNINIT(pScreen, ®ion); } static Bool @@ -149,6 +190,7 @@ exaDestroyPixmap (PixmapPtr pPixmap) pPixmap->devPrivate.ptr = pExaPixmap->sys_ptr; pPixmap->devKind = pExaPixmap->sys_pitch; } + REGION_UNINIT(pPixmap->drawable.pScreen, &pExaPixmap->validReg); } return fbDestroyPixmap (pPixmap); } @@ -211,12 +253,25 @@ exaCreatePixmap(ScreenPtr pScreen, int w, int h, int depth) pExaScr->info->pixmapPitchAlign); pExaPixmap->fb_size = pExaPixmap->fb_pitch * h; - if (pExaPixmap->fb_pitch > 32767) { + if (pExaPixmap->fb_pitch > 131071) { fbDestroyPixmap(pPixmap); return NULL; } - pExaPixmap->dirty = FALSE; + /* Set up damage tracking */ + pExaPixmap->pDamage = DamageCreate (NULL, NULL, DamageReportNone, TRUE, + pScreen, pPixmap); + + if (pExaPixmap->pDamage == NULL) { + fbDestroyPixmap (pPixmap); + return NULL; + } + + DamageRegister (&pPixmap->drawable, pExaPixmap->pDamage); + DamageSetReportAfterOp (pExaPixmap->pDamage, TRUE); + + /* None of the pixmap bits are valid initially */ + REGION_NULL(pScreen, &pExaPixmap->validReg); return pPixmap; } @@ -244,6 +299,9 @@ exaPixmapIsOffscreen(PixmapPtr p) if (p->devPrivate.ptr == NULL) return TRUE; + if (pExaScr->info->PixmapIsOffscreen) + return pExaScr->info->PixmapIsOffscreen(p); + return ((unsigned long) ((CARD8 *) p->devPrivate.ptr - (CARD8 *) pExaScr->info->memoryBase) < pExaScr->info->memorySize); @@ -261,32 +319,14 @@ exaDrawableIsOffscreen (DrawablePtr pDrawable) /** * Returns the pixmap which backs a drawable, and the offsets to add to * coordinates to make them address the same bits in the backing drawable. - * These coordinates are nonzero only for redirected windows. */ PixmapPtr exaGetOffscreenPixmap (DrawablePtr pDrawable, int *xp, int *yp) { - PixmapPtr pPixmap; - int x, y; + PixmapPtr pPixmap = exaGetDrawablePixmap (pDrawable); + + exaGetDrawableDeltas (pDrawable, pPixmap, xp, yp); - if (pDrawable->type == DRAWABLE_WINDOW) { - pPixmap = (*pDrawable->pScreen->GetWindowPixmap) ((WindowPtr) pDrawable); -#ifdef COMPOSITE - x = -pPixmap->screen_x; - y = -pPixmap->screen_y; -#else - x = 0; - y = 0; -#endif - } - else - { - pPixmap = (PixmapPtr) pDrawable; - x = 0; - y = 0; - } - *xp = x; - *yp = y; if (exaPixmapIsOffscreen (pPixmap)) return pPixmap; else @@ -334,8 +374,7 @@ exaPrepareAccess(DrawablePtr pDrawable, int index) /** * exaFinishAccess() is EXA's wrapper for the driver's FinishAccess() handler. * - * It deals with marking drawables as dirty, and calling the driver's - * FinishAccess() only if necessary. + * It deals with calling the driver's FinishAccess() only if necessary. */ void exaFinishAccess(DrawablePtr pDrawable, int index) @@ -345,9 +384,6 @@ exaFinishAccess(DrawablePtr pDrawable, int index) PixmapPtr pPixmap; ExaPixmapPrivPtr pExaPixmap; - if (index == EXA_PREPARE_DEST) - exaDrawableDirty (pDrawable); - pPixmap = exaGetDrawablePixmap (pDrawable); pExaPixmap = ExaGetPixmapPriv(pPixmap); @@ -373,7 +409,7 @@ exaFinishAccess(DrawablePtr pDrawable, int index) * accelerated or may sync the card and fall back to fb. */ static void -exaValidateGC (GCPtr pGC, Mask changes, DrawablePtr pDrawable) +exaValidateGC (GCPtr pGC, unsigned long changes, DrawablePtr pDrawable) { /* fbValidateGC will do direct access to pixmaps if the tiling has changed. * Preempt fbValidateGC by doing its work and masking the change out, so @@ -404,6 +440,7 @@ exaValidateGC (GCPtr pGC, Mask changes, DrawablePtr pDrawable) exaPrepareAccess(&pOldTile->drawable, EXA_PREPARE_SRC); pNewTile = fb24_32ReformatTile (pOldTile, pDrawable->bitsPerPixel); + exaPixmapDirty(pNewTile, 0, 0, pNewTile->drawable.width, pNewTile->drawable.height); exaFinishAccess(&pOldTile->drawable, EXA_PREPARE_SRC); } if (pNewTile) @@ -419,9 +456,14 @@ exaValidateGC (GCPtr pGC, Mask changes, DrawablePtr pDrawable) if (!pGC->tileIsPixel && FbEvenTile (pGC->tile.pixmap->drawable.width * pDrawable->bitsPerPixel)) { - exaPrepareAccess(&pGC->tile.pixmap->drawable, EXA_PREPARE_SRC); + /* XXX This fixes corruption with tiled pixmaps, but may just be a + * workaround for broken drivers + */ + exaMoveOutPixmap(pGC->tile.pixmap); fbPadPixmap (pGC->tile.pixmap); - exaFinishAccess(&pGC->tile.pixmap->drawable, EXA_PREPARE_SRC); + exaPixmapDirty(pGC->tile.pixmap, 0, 0, + pGC->tile.pixmap->drawable.width, + pGC->tile.pixmap->drawable.height); } /* Mask out the GCTile change notification, now that we've done FB's * job for it. @@ -484,6 +526,7 @@ exaCloseScreen(int i, ScreenPtr pScreen) if (ps) { ps->Composite = pExaScr->SavedComposite; ps->Glyphs = pExaScr->SavedGlyphs; + ps->Trapezoids = pExaScr->SavedTrapezoids; } #endif @@ -527,6 +570,45 @@ exaDriverInit (ScreenPtr pScreen, PictureScreenPtr ps; #endif + if (!pScreenInfo) + return FALSE; + + if (!pScreenInfo->memoryBase) { + LogMessage(X_ERROR, "EXA(%d): ExaDriverRec::memoryBase must be " + "non-zero\n", pScreen->myNum); + return FALSE; + } + + if (!pScreenInfo->memorySize) { + LogMessage(X_ERROR, "EXA(%d): ExaDriverRec::memorySize must be " + "non-zero\n", pScreen->myNum); + return FALSE; + } + + if (pScreenInfo->offScreenBase > pScreenInfo->memorySize) { + LogMessage(X_ERROR, "EXA(%d): ExaDriverRec::offScreenBase must be <= " + "ExaDriverRec::memorySize\n", pScreen->myNum); + return FALSE; + } + + if (!pScreenInfo->PrepareSolid) { + LogMessage(X_ERROR, "EXA(%d): ExaDriverRec::PrepareSolid must be " + "non-NULL\n", pScreen->myNum); + return FALSE; + } + + if (!pScreenInfo->PrepareCopy) { + LogMessage(X_ERROR, "EXA(%d): ExaDriverRec::PrepareCopy must be " + "non-NULL\n", pScreen->myNum); + return FALSE; + } + + if (!pScreenInfo->WaitMarker) { + LogMessage(X_ERROR, "EXA(%d): ExaDriverRec::WaitMarker must be " + "non-NULL\n", pScreen->myNum); + return FALSE; + } + if (pScreenInfo->exa_major != EXA_VERSION_MAJOR || pScreenInfo->exa_minor > EXA_VERSION_MINOR) { @@ -560,7 +642,7 @@ exaDriverInit (ScreenPtr pScreen, pScreen->devPrivates[exaScreenPrivateIndex].ptr = (pointer) pExaScr; - pExaScr->migration = ExaMigrationSmart; + pExaScr->migration = ExaMigrationAlways; exaDDXDriverInit(pScreen); @@ -603,13 +685,19 @@ exaDriverInit (ScreenPtr pScreen, pExaScr->SavedGlyphs = ps->Glyphs; ps->Glyphs = exaGlyphs; + + pExaScr->SavedTrapezoids = ps->Trapezoids; + ps->Trapezoids = exaTrapezoids; } #endif -#ifdef COMPOSITE - miDisableCompositeWrapper(pScreen); +#ifdef MITSHM + /* Re-register with the MI funcs, which don't allow shared pixmaps. + * Shared pixmaps are almost always a performance loss for us, but this + * still allows for SHM PutImage. + */ + ShmRegisterFuncs(pScreen, NULL); #endif - /* * Hookup offscreen pixmaps */ diff --git a/xserver/exa/exa_accel.c b/xserver/exa/exa_accel.c index bc77a4071..e8444c6a4 100644 --- a/xserver/exa/exa_accel.c +++ b/xserver/exa/exa_accel.c @@ -20,6 +20,11 @@ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR * PERFORMANCE OF THIS SOFTWARE. + * + * Authors: + * Eric Anholt <eric@anholt.net> + * Michel Dänzer <michel@tungstengraphics.com> + * */ #ifdef HAVE_DIX_CONFIG_H @@ -49,12 +54,12 @@ exaFillSpans(DrawablePtr pDrawable, GCPtr pGC, int n, pixmaps[0].as_dst = TRUE; pixmaps[0].as_src = FALSE; - pixmaps[0].pPix = exaGetDrawablePixmap (pDrawable); + pixmaps[0].pPix = pPixmap = exaGetDrawablePixmap (pDrawable); if (pExaScr->swappedOut || pGC->fillStyle != FillSolid || - pDrawable->width > pExaScr->info->maxX || - pDrawable->height > pExaScr->info->maxY) + pPixmap->drawable.width > pExaScr->info->maxX || + pPixmap->drawable.height > pExaScr->info->maxY) { exaDoMigration (pixmaps, 1, FALSE); ExaCheckFillSpans (pDrawable, pGC, n, ppt, pwidth, fSorted); @@ -69,6 +74,7 @@ exaFillSpans(DrawablePtr pDrawable, GCPtr pGC, int n, pGC->planemask, pGC->fgPixel)) { + exaDoMigration (pixmaps, 1, FALSE); ExaCheckFillSpans (pDrawable, pGC, n, ppt, pwidth, fSorted); return; } @@ -118,17 +124,17 @@ exaFillSpans(DrawablePtr pDrawable, GCPtr pGC, int n, partX2 = pbox->x2; if (partX2 > fullX2) partX2 = fullX2; - if (partX2 > partX1) + if (partX2 > partX1) { (*pExaScr->info->Solid) (pPixmap, partX1 + off_x, fullY1 + off_y, partX2 + off_x, fullY1 + 1 + off_y); + } } pbox++; } } } (*pExaScr->info->DoneSolid) (pPixmap); - exaDrawableDirty (pDrawable); exaMarkSync(pScreen); } @@ -145,8 +151,9 @@ exaPutImage (DrawablePtr pDrawable, GCPtr pGC, int depth, int x, int y, int xoff, yoff; int src_stride, bpp = pDrawable->bitsPerPixel; - if (pExaScr->swappedOut || pExaScr->info->UploadToScreen == NULL) - goto migrate_and_fallback; + pixmaps[0].as_dst = TRUE; + pixmaps[0].as_src = FALSE; + pixmaps[0].pPix = exaGetDrawablePixmap (pDrawable); /* Don't bother with under 8bpp, XYPixmaps. */ if (format != ZPixmap || bpp < 8) @@ -156,10 +163,14 @@ exaPutImage (DrawablePtr pDrawable, GCPtr pGC, int depth, int x, int y, if (!EXA_PM_IS_SOLID(pDrawable, pGC->planemask) || pGC->alu != GXcopy) goto migrate_and_fallback; - pixmaps[0].as_dst = TRUE; - pixmaps[0].as_src = FALSE; - pixmaps[0].pPix = exaGetDrawablePixmap (pDrawable); + if (pExaScr->swappedOut) + goto fallback; + exaDoMigration (pixmaps, 1, TRUE); + + if (pExaScr->info->UploadToScreen == NULL) + goto fallback; + pPix = exaGetOffscreenPixmap (pDrawable, &xoff, &yoff); if (pPix == NULL) @@ -212,25 +223,23 @@ exaPutImage (DrawablePtr pDrawable, GCPtr pGC, int depth, int x, int y, fbBltStip((FbStip *)bits + (y1 - y) * (src_stride / sizeof(FbStip)), src_stride / sizeof(FbStip), - (x1 - x) * bpp, - dst + (y1 + yoff) * dst_stride, + (x1 - x) * dstBpp, + dst + (y1 + dstYoff) * dst_stride, dst_stride, - (x1 + xoff) * bpp, - (x2 - x1) * bpp, + (x1 + dstXoff) * dstBpp, + (x2 - x1) * dstBpp, y2 - y1, - GXcopy, FB_ALLONES, bpp); + GXcopy, FB_ALLONES, dstBpp); exaFinishAccess(pDrawable, EXA_PREPARE_DEST); } + + exaPixmapDirty(pPix, x1 + xoff, y1 + yoff, x2 + xoff, y2 + yoff); } - exaDrawableDirty(pDrawable); return; migrate_and_fallback: - pixmaps[0].as_dst = TRUE; - pixmaps[0].as_src = FALSE; - pixmaps[0].pPix = exaGetDrawablePixmap (pDrawable); exaDoMigration (pixmaps, 1, FALSE); fallback: @@ -351,11 +360,12 @@ exaCopyNtoNTwoDir (DrawablePtr pSrcDrawable, DrawablePtr pDstDrawable, dst_off_y + pbox->y1 + i, pbox->x2 - pbox->x1, 1); } + exaPixmapDirty(pDstPixmap, dst_off_x + pbox->x1, dst_off_y + pbox->y1, + dst_off_x + pbox->x2, dst_off_y + pbox->y2); } if (dirsetup != 0) pExaScr->info->DoneCopy(pDstPixmap); exaMarkSync(pDstDrawable->pScreen); - exaDrawableDirty(pDstDrawable); return TRUE; } @@ -377,71 +387,82 @@ exaCopyNtoN (DrawablePtr pSrcDrawable, int src_off_x, src_off_y; int dst_off_x, dst_off_y; ExaMigrationRec pixmaps[2]; + Bool fallback = FALSE; pixmaps[0].as_dst = TRUE; pixmaps[0].as_src = FALSE; - pixmaps[0].pPix = exaGetDrawablePixmap (pDstDrawable); + pixmaps[0].pPix = pDstPixmap = exaGetDrawablePixmap (pDstDrawable); pixmaps[1].as_dst = FALSE; pixmaps[1].as_src = TRUE; - pixmaps[1].pPix = exaGetDrawablePixmap (pSrcDrawable); + pixmaps[1].pPix = pSrcPixmap = exaGetDrawablePixmap (pSrcDrawable); /* Respect maxX/maxY in a trivial way: don't set up drawing when we might * violate the limits. The proper solution would be a temporary pixmap * adjusted so that the drawing happened within limits. */ - if (pSrcDrawable->width > pExaScr->info->maxX || - pSrcDrawable->height > pExaScr->info->maxY || - pDstDrawable->width > pExaScr->info->maxX || - pDstDrawable->height > pExaScr->info->maxY) + if (pSrcPixmap->drawable.width > pExaScr->info->maxX || + pSrcPixmap->drawable.height > pExaScr->info->maxY || + pDstPixmap->drawable.width > pExaScr->info->maxX || + pDstPixmap->drawable.height > pExaScr->info->maxY) { - exaDoMigration (pixmaps, 2, FALSE); - goto fallback; + fallback = TRUE; } else { exaDoMigration (pixmaps, 2, TRUE); } /* Mixed directions must be handled specially if the card is lame */ - if (pExaScr->info->flags & EXA_TWO_BITBLT_DIRECTIONS && (dx*dy) < 0) { - if (!exaCopyNtoNTwoDir(pSrcDrawable, pDstDrawable, pGC, pbox, nbox, + if (!fallback && (pExaScr->info->flags & EXA_TWO_BITBLT_DIRECTIONS) && + reverse != upsidedown) { + if (exaCopyNtoNTwoDir(pSrcDrawable, pDstDrawable, pGC, pbox, nbox, dx, dy)) - goto fallback; - return; + return; + fallback = TRUE; + } + + pSrcPixmap = exaGetDrawablePixmap (pSrcDrawable); + pDstPixmap = exaGetDrawablePixmap (pDstDrawable); + + exaGetDrawableDeltas (pSrcDrawable, pSrcPixmap, &src_off_x, &src_off_y); + exaGetDrawableDeltas (pDstDrawable, pDstPixmap, &dst_off_x, &dst_off_y); + + if (fallback || !exaPixmapIsOffscreen(pSrcPixmap) || + !exaPixmapIsOffscreen(pDstPixmap) || + !(*pExaScr->info->PrepareCopy) (pSrcPixmap, pDstPixmap, reverse ? -1 : 1, + upsidedown ? -1 : 1, + pGC ? pGC->alu : GXcopy, + pGC ? pGC->planemask : FB_ALLONES)) { + fallback = TRUE; + EXA_FALLBACK(("from %p to %p (%c,%c)\n", pSrcDrawable, pDstDrawable, + exaDrawableLocation(pSrcDrawable), + exaDrawableLocation(pDstDrawable))); + exaDoMigration (pixmaps, 2, FALSE); + exaPrepareAccess (pDstDrawable, EXA_PREPARE_DEST); + exaPrepareAccess (pSrcDrawable, EXA_PREPARE_SRC); + fbCopyNtoN (pSrcDrawable, pDstDrawable, pGC, + pbox, nbox, dx, dy, reverse, upsidedown, + bitplane, closure); + exaFinishAccess (pSrcDrawable, EXA_PREPARE_SRC); + exaFinishAccess (pDstDrawable, EXA_PREPARE_DEST); } - if ((pSrcPixmap = exaGetOffscreenPixmap (pSrcDrawable, &src_off_x, &src_off_y)) && - (pDstPixmap = exaGetOffscreenPixmap (pDstDrawable, &dst_off_x, &dst_off_y)) && - (*pExaScr->info->PrepareCopy) (pSrcPixmap, pDstPixmap, - dx, dy, - pGC ? pGC->alu : GXcopy, - pGC ? pGC->planemask : FB_ALLONES)) + while (nbox--) { - while (nbox--) - { + if (!fallback) (*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); - exaDrawableDirty (pDstDrawable); - return; + pbox->x2 - pbox->x1, pbox->y2 - pbox->y1); + exaPixmapDirty (pDstPixmap, pbox->x1 + dst_off_x, pbox->y1 + dst_off_y, + pbox->x2 + dst_off_x, pbox->y2 + dst_off_y); + pbox++; } -fallback: - EXA_FALLBACK(("from %p to %p (%c,%c)\n", pSrcDrawable, pDstDrawable, - exaDrawableLocation(pSrcDrawable), - exaDrawableLocation(pDstDrawable))); - exaPrepareAccess (pDstDrawable, EXA_PREPARE_DEST); - exaPrepareAccess (pSrcDrawable, EXA_PREPARE_SRC); - fbCopyNtoN (pSrcDrawable, pDstDrawable, pGC, - pbox, nbox, dx, dy, reverse, upsidedown, - bitplane, closure); - exaFinishAccess (pSrcDrawable, EXA_PREPARE_SRC); - exaFinishAccess (pDstDrawable, EXA_PREPARE_DEST); + if (fallback) + return; + + (*pExaScr->info->DoneCopy) (pDstPixmap); + exaMarkSync (pDstDrawable->pScreen); } RegionPtr @@ -514,7 +535,7 @@ exaPolylines(DrawablePtr pDrawable, GCPtr pGC, int mode, int npt, x1 = ppt[0].x; y1 = ppt[0].y; /* If we have any non-horizontal/vertical, fall back. */ - for (i = 0; i < npt; i++) { + for (i = 0; i < npt - 1; i++) { if (mode == CoordModePrevious) { x2 = x1 + ppt[i + 1].x; y2 = y1 + ppt[i + 1].y; @@ -600,6 +621,9 @@ exaPolySegment (DrawablePtr pDrawable, GCPtr pGC, int nseg, DEALLOCATE_LOCAL(prect); } +static Bool exaFillRegionSolid (DrawablePtr pDrawable, RegionPtr pRegion, + Pixel pixel, CARD32 planemask, CARD32 alu); + static void exaPolyFillRect(DrawablePtr pDrawable, GCPtr pGC, @@ -608,7 +632,7 @@ exaPolyFillRect(DrawablePtr pDrawable, { ExaScreenPriv (pDrawable->pScreen); RegionPtr pClip = fbGetCompositeClip(pGC); - PixmapPtr pPixmap; + PixmapPtr pPixmap = exaGetDrawablePixmap(pDrawable); register BoxPtr pbox; BoxPtr pextent; int extentX1, extentX2, extentY1, extentY2; @@ -617,32 +641,73 @@ exaPolyFillRect(DrawablePtr pDrawable, int xoff, yoff; int xorg, yorg; int n; - ExaMigrationRec pixmaps[1]; + ExaMigrationRec pixmaps[2]; + RegionPtr pReg = RECTS_TO_REGION(pScreen, nrect, prect, CT_UNSORTED); + + /* Compute intersection of rects and clip region */ + REGION_TRANSLATE(pScreen, pReg, pDrawable->x, pDrawable->y); + REGION_INTERSECT(pScreen, pReg, pClip, pReg); + + if (!REGION_NUM_RECTS(pReg)) { + goto out; + } pixmaps[0].as_dst = TRUE; pixmaps[0].as_src = FALSE; - pixmaps[0].pPix = exaGetDrawablePixmap (pDrawable); + pixmaps[0].pPix = pPixmap; + exaGetDrawableDeltas(pDrawable, pPixmap, &xoff, &yoff); + if (pExaScr->swappedOut || - pGC->fillStyle != FillSolid || - pDrawable->width > pExaScr->info->maxX || - pDrawable->height > pExaScr->info->maxY) + pPixmap->drawable.width > pExaScr->info->maxX || + pPixmap->drawable.height > pExaScr->info->maxY) { - exaDoMigration (pixmaps, 1, FALSE); - ExaCheckPolyFillRect (pDrawable, pGC, nrect, prect); - return; - } else { - exaDoMigration (pixmaps, 1, TRUE); + goto fallback; } - if (!(pPixmap = exaGetOffscreenPixmap (pDrawable, &xoff, &yoff)) || + /* For ROPs where overlaps don't matter, convert rectangles to region and + * call exaFillRegion{Solid,Tiled}. + */ + if ((pGC->fillStyle == FillSolid || pGC->fillStyle == FillTiled) && + (pGC->alu == GXcopy || pGC->alu == GXclear || pGC->alu == GXnoop || + pGC->alu == GXcopyInverted || pGC->alu == GXset)) { + if (((pGC->fillStyle == FillSolid || pGC->tileIsPixel) && + exaFillRegionSolid(pDrawable, pReg, pGC->fillStyle == FillSolid ? + pGC->fgPixel : pGC->tile.pixel, pGC->planemask, + pGC->alu)) || + (pGC->fillStyle == FillTiled && !pGC->tileIsPixel && + exaFillRegionTiled(pDrawable, pReg, pGC->tile.pixmap, &pGC->patOrg, + pGC->planemask, pGC->alu))) { + goto out; + } + } + + if (pGC->fillStyle != FillSolid && + !(pGC->tileIsPixel && pGC->fillStyle == FillTiled)) + { + goto fallback; + } + + exaDoMigration (pixmaps, 1, TRUE); + + if (!exaPixmapIsOffscreen (pPixmap) || !(*pExaScr->info->PrepareSolid) (pPixmap, pGC->alu, pGC->planemask, pGC->fgPixel)) { +fallback: + if (pGC->fillStyle == FillTiled && !pGC->tileIsPixel) { + pixmaps[1].as_dst = FALSE; + pixmaps[1].as_src = TRUE; + pixmaps[1].pPix = pGC->tile.pixmap; + exaDoMigration (pixmaps, 2, FALSE); + } else { + exaDoMigration (pixmaps, 1, FALSE); + } + ExaCheckPolyFillRect (pDrawable, pGC, nrect, prect); - return; + goto out; } xorg = pDrawable->x; @@ -687,7 +752,8 @@ exaPolyFillRect(DrawablePtr pDrawable, pbox = REGION_RECTS(pClip); /* * clip the rectangle to each box in the clip region - * this is logically equivalent to calling Intersect() + * this is logically equivalent to calling Intersect(), + * but rectangles may overlap each other here. */ while(n--) { @@ -706,16 +772,19 @@ exaPolyFillRect(DrawablePtr pDrawable, pbox++; - if (partX1 < partX2 && partY1 < partY2) + if (partX1 < partX2 && partY1 < partY2) { (*pExaScr->info->Solid) (pPixmap, partX1 + xoff, partY1 + yoff, partX2 + xoff, partY2 + yoff); + } } } } (*pExaScr->info->DoneSolid) (pPixmap); - exaDrawableDirty (pDrawable); exaMarkSync(pDrawable->pScreen); + +out: + REGION_DESTROY(pScreen, pReg); } static void @@ -735,34 +804,36 @@ exaSolidBoxClipped (DrawablePtr pDrawable, int xoff, yoff; int partX1, partX2, partY1, partY2; ExaMigrationRec pixmaps[1]; + Bool fallback = FALSE; pixmaps[0].as_dst = TRUE; pixmaps[0].as_src = FALSE; - pixmaps[0].pPix = exaGetDrawablePixmap (pDrawable); - + pixmaps[0].pPix = pPixmap = exaGetDrawablePixmap (pDrawable); + if (pExaScr->swappedOut || - pDrawable->width > pExaScr->info->maxX || - pDrawable->height > pExaScr->info->maxY) + pPixmap->drawable.width > pExaScr->info->maxX || + pPixmap->drawable.height > pExaScr->info->maxY) { - exaDoMigration (pixmaps, 1, FALSE); - goto fallback; + fallback = TRUE; } else { exaDoMigration (pixmaps, 1, TRUE); } - if (!(pPixmap = exaGetOffscreenPixmap (pDrawable, &xoff, &yoff)) || + exaGetDrawableDeltas (pDrawable, pPixmap, &xoff, &yoff); + + if (fallback || !exaPixmapIsOffscreen(pPixmap) || !(*pExaScr->info->PrepareSolid) (pPixmap, GXcopy, pm, fg)) { -fallback: EXA_FALLBACK(("to %p (%c)\n", pDrawable, exaDrawableLocation(pDrawable))); + exaDoMigration (pixmaps, 1, FALSE); + fallback = TRUE; exaPrepareAccess (pDrawable, EXA_PREPARE_DEST); fg = fbReplicatePixel (fg, pDrawable->bitsPerPixel); fbSolidBoxClipped (pDrawable, pClip, x1, y1, x2, y2, fbAnd (GXcopy, fg, pm), fbXor (GXcopy, fg, pm)); exaFinishAccess (pDrawable, EXA_PREPARE_DEST); - return; } for (nbox = REGION_NUM_RECTS(pClip), pbox = REGION_RECTS(pClip); nbox--; @@ -790,12 +861,20 @@ fallback: if (partY2 <= partY1) continue; - (*pExaScr->info->Solid) (pPixmap, - partX1 + xoff, partY1 + yoff, - partX2 + xoff, partY2 + yoff); + if (!fallback) { + (*pExaScr->info->Solid) (pPixmap, + partX1 + xoff, partY1 + yoff, + partX2 + xoff, partY2 + yoff); + } + + exaPixmapDirty (pPixmap, partX1 + xoff, partY1 + yoff, partX2 + xoff, + partY2 + yoff); } + + if (fallback) + return; + (*pExaScr->info->DoneSolid) (pPixmap); - exaDrawableDirty (pDrawable); exaMarkSync(pDrawable->pScreen); } @@ -829,12 +908,36 @@ exaImageGlyphBlt (DrawablePtr pDrawable, int dstBpp; int dstXoff, dstYoff; FbBits depthMask; + PixmapPtr pPixmap = exaGetDrawablePixmap(pDrawable); + ExaMigrationRec pixmaps[1]; + int xBack, widthBack, yBack, heightBack; + + for (ppci = ppciInit, n = nglyph, widthBack = 0; n; n--) + widthBack += (*ppci++)->metrics.characterWidth; + + xBack = x; + if (widthBack < 0) + { + xBack += widthBack; + widthBack = -widthBack; + } + yBack = y - FONTASCENT(pGC->font); + heightBack = FONTASCENT(pGC->font) + FONTDESCENT(pGC->font); + + if (xBack >= pDrawable->width || yBack >= pDrawable->height || + (xBack + widthBack) <= 0 || (yBack + heightBack) <= 0) + return; + + pixmaps[0].as_dst = TRUE; + pixmaps[0].as_src = TRUE; + pixmaps[0].pPix = pPixmap; depthMask = FbFullMask(pDrawable->depth); if ((pGC->planemask & depthMask) != depthMask) { + exaDoMigration(pixmaps, 1, FALSE); ExaCheckImageGlyphBlt(pDrawable, pGC, x, y, nglyph, ppciInit, pglyphBase); - return; + goto damage; } glyph = NULL; switch (pDrawable->bitsPerPixel) { @@ -846,6 +949,8 @@ exaImageGlyphBlt (DrawablePtr pDrawable, x += pDrawable->x; y += pDrawable->y; + xBack += pDrawable->x; + yBack += pDrawable->y; if (TERMINALFONT (pGC->font) && !glyph) { @@ -853,23 +958,6 @@ exaImageGlyphBlt (DrawablePtr pDrawable, } else { - int xBack, widthBack; - int yBack, heightBack; - - ppci = ppciInit; - n = nglyph; - widthBack = 0; - while (n--) - widthBack += (*ppci++)->metrics.characterWidth; - - xBack = x; - if (widthBack < 0) - { - xBack += widthBack; - widthBack = -widthBack; - } - yBack = y - FONTASCENT(pGC->font); - heightBack = FONTASCENT(pGC->font) + FONTDESCENT(pGC->font); exaSolidBoxClipped (pDrawable, fbGetCompositeClip(pGC), pGC->planemask, @@ -882,57 +970,50 @@ exaImageGlyphBlt (DrawablePtr pDrawable, } EXA_FALLBACK(("to %p (%c)\n", pDrawable, exaDrawableLocation(pDrawable))); + exaDoMigration(pixmaps, 1, FALSE); exaPrepareAccess (pDrawable, EXA_PREPARE_DEST); exaPrepareAccessGC (pGC); fbGetDrawable (pDrawable, dst, dstStride, dstBpp, dstXoff, dstYoff); - ppci = ppciInit; - while (nglyph--) + for (ppci = ppciInit; nglyph; nglyph--, x += pci->metrics.characterWidth) { pci = *ppci++; - pglyph = FONTGLYPHBITS(pglyphBase, pci); gWidth = GLYPHWIDTHPIXELS(pci); gHeight = GLYPHHEIGHTPIXELS(pci); - if (gWidth && gHeight) + gx = x + pci->metrics.leftSideBearing; + gy = y - pci->metrics.ascent; + + if (!gWidth || !gHeight || (gx + gWidth) <= xBack || + (gy + gHeight) <= yBack || gx >= (xBack + widthBack) || + gy >= (yBack + heightBack)) + continue; + + pglyph = FONTGLYPHBITS(pglyphBase, pci); + + if (glyph && gWidth <= sizeof (FbStip) * 8 && + fbGlyphIn (fbGetCompositeClip(pGC), gx, gy, gWidth, gHeight)) { - gx = x + pci->metrics.leftSideBearing; - gy = y - pci->metrics.ascent; - if (glyph && gWidth <= sizeof (FbStip) * 8 && - fbGlyphIn (fbGetCompositeClip(pGC), gx, gy, gWidth, gHeight)) - { - (*glyph) (dst + (gy + dstYoff) * dstStride, - dstStride, - dstBpp, - (FbStip *) pglyph, - pPriv->fg, - gx + dstXoff, - gHeight); - } - else - { - gStride = GLYPHWIDTHBYTESPADDED(pci) / sizeof (FbStip); - fbPutXYImage (pDrawable, - fbGetCompositeClip(pGC), - pPriv->fg, - pPriv->bg, - pPriv->pm, - GXcopy, - opaque, - - gx, - gy, - gWidth, gHeight, - - (FbStip *) pglyph, - gStride, - 0); - } + (*glyph) (dst + (gy + dstYoff) * dstStride, dstStride, dstBpp, + (FbStip *) pglyph, pPriv->fg, gx + dstXoff, gHeight); + } + else + { + RegionPtr pClip = fbGetCompositeClip(pGC); + + gStride = GLYPHWIDTHBYTESPADDED(pci) / sizeof (FbStip); + fbPutXYImage (pDrawable, pClip, pPriv->fg, pPriv->bg, pPriv->pm, + GXcopy, opaque, gx, gy, gWidth, gHeight, + (FbStip *) pglyph, gStride, 0); } - x += pci->metrics.characterWidth; } exaFinishAccessGC (pGC); exaFinishAccess (pDrawable, EXA_PREPARE_DEST); + +damage: + exaGetDrawableDeltas(pDrawable, pPixmap, &dstXoff, &dstYoff); + exaPixmapDirty(pPixmap, xBack + dstXoff, yBack + dstYoff, + xBack + dstXoff + widthBack, yBack + dstYoff + heightBack); } const GCOps exaOps = { @@ -985,35 +1066,35 @@ exaCopyWindow(WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr prgnSrc) REGION_UNINIT(pWin->drawable.pScreen, &rgnDst); } -static void +static Bool exaFillRegionSolid (DrawablePtr pDrawable, RegionPtr pRegion, - Pixel pixel) + Pixel pixel, + CARD32 planemask, + CARD32 alu) { ExaScreenPriv(pDrawable->pScreen); PixmapPtr pPixmap; int xoff, yoff; ExaMigrationRec pixmaps[1]; + int nbox = REGION_NUM_RECTS (pRegion); + BoxPtr pBox = REGION_RECTS (pRegion); pixmaps[0].as_dst = TRUE; pixmaps[0].as_src = FALSE; - pixmaps[0].pPix = exaGetDrawablePixmap (pDrawable); + pixmaps[0].pPix = pPixmap = exaGetDrawablePixmap (pDrawable); - if (pDrawable->width > pExaScr->info->maxX || - pDrawable->height > pExaScr->info->maxY) + if (pPixmap->drawable.width > pExaScr->info->maxX || + pPixmap->drawable.height > pExaScr->info->maxY) { - exaDoMigration (pixmaps, 1, FALSE); goto fallback; } else { exaDoMigration (pixmaps, 1, TRUE); } if ((pPixmap = exaGetOffscreenPixmap (pDrawable, &xoff, &yoff)) && - (*pExaScr->info->PrepareSolid) (pPixmap, GXcopy, FB_ALLONES, pixel)) + (*pExaScr->info->PrepareSolid) (pPixmap, alu, planemask, pixel)) { - int nbox = REGION_NUM_RECTS (pRegion); - BoxPtr pBox = REGION_RECTS (pRegion); - while (nbox--) { (*pExaScr->info->Solid) (pPixmap, @@ -1023,33 +1104,42 @@ exaFillRegionSolid (DrawablePtr pDrawable, } (*pExaScr->info->DoneSolid) (pPixmap); exaMarkSync(pDrawable->pScreen); - exaDrawableDirty (pDrawable); } else { fallback: + if (alu != GXcopy || planemask != FB_ALLONES) + return FALSE; EXA_FALLBACK(("to %p (%c)\n", pDrawable, exaDrawableLocation(pDrawable))); + exaDoMigration (pixmaps, 1, FALSE); exaPrepareAccess (pDrawable, EXA_PREPARE_DEST); fbFillRegionSolid (pDrawable, pRegion, 0, fbReplicatePixel (pixel, pDrawable->bitsPerPixel)); exaFinishAccess (pDrawable, EXA_PREPARE_DEST); } + + return TRUE; } /* Try to do an accelerated tile of the pTile into pRegion of pDrawable. * Based on fbFillRegionTiled(), fbTile(). */ -static void +Bool exaFillRegionTiled (DrawablePtr pDrawable, RegionPtr pRegion, - PixmapPtr pTile) + PixmapPtr pTile, + DDXPointPtr pPatOrg, + CARD32 planemask, + CARD32 alu) { ExaScreenPriv(pDrawable->pScreen); PixmapPtr pPixmap; - int xoff, yoff; + int xoff, yoff, tileXoff, tileYoff; int tileWidth, tileHeight; ExaMigrationRec pixmaps[2]; + int nbox = REGION_NUM_RECTS (pRegion); + BoxPtr pBox = REGION_RECTS (pRegion); tileWidth = pTile->drawable.width; tileHeight = pTile->drawable.height; @@ -1057,49 +1147,48 @@ exaFillRegionTiled (DrawablePtr pDrawable, /* If we're filling with a solid color, grab it out and go to * FillRegionSolid, saving numerous copies. */ - if (tileWidth == 1 && tileHeight == 1) { - exaFillRegionSolid(pDrawable, pRegion, exaGetPixmapFirstPixel (pTile)); - return; - } + if (tileWidth == 1 && tileHeight == 1) + return exaFillRegionSolid(pDrawable, pRegion, + exaGetPixmapFirstPixel (pTile), planemask, + alu); pixmaps[0].as_dst = TRUE; pixmaps[0].as_src = FALSE; - pixmaps[0].pPix = exaGetDrawablePixmap (pDrawable); + pixmaps[0].pPix = pPixmap = exaGetDrawablePixmap (pDrawable); pixmaps[1].as_dst = FALSE; pixmaps[1].as_src = TRUE; pixmaps[1].pPix = pTile; - if (pDrawable->width > pExaScr->info->maxX || - pDrawable->height > pExaScr->info->maxY || + if (pPixmap->drawable.width > pExaScr->info->maxX || + pPixmap->drawable.height > pExaScr->info->maxY || tileWidth > pExaScr->info->maxX || tileHeight > pExaScr->info->maxY) { - exaDoMigration (pixmaps, 2, FALSE); goto fallback; } else { exaDoMigration (pixmaps, 2, TRUE); } pPixmap = exaGetOffscreenPixmap (pDrawable, &xoff, &yoff); + if (!pPixmap) goto fallback; if (!exaPixmapIsOffscreen(pTile)) goto fallback; - if ((*pExaScr->info->PrepareCopy) (pTile, pPixmap, 0, 0, GXcopy, - FB_ALLONES)) + if ((*pExaScr->info->PrepareCopy) (exaGetOffscreenPixmap((DrawablePtr)pTile, + &tileXoff, &tileYoff), + pPixmap, 0, 0, alu, planemask)) { - int nbox = REGION_NUM_RECTS (pRegion); - BoxPtr pBox = REGION_RECTS (pRegion); - while (nbox--) { int height = pBox->y2 - pBox->y1; int dstY = pBox->y1; int tileY; - tileY = (dstY - pDrawable->y) % tileHeight; + modulus(dstY - pDrawable->y - pPatOrg->y, tileHeight, tileY); + while (height > 0) { int width = pBox->x2 - pBox->x1; int dstX = pBox->x1; @@ -1110,7 +1199,8 @@ exaFillRegionTiled (DrawablePtr pDrawable, h = height; height -= h; - tileX = (dstX - pDrawable->x) % tileWidth; + modulus(dstX - pDrawable->x - pPatOrg->x, tileWidth, tileX); + while (width > 0) { int w = tileWidth - tileX; if (w > width) @@ -1118,7 +1208,7 @@ exaFillRegionTiled (DrawablePtr pDrawable, width -= w; (*pExaScr->info->Copy) (pPixmap, - tileX, tileY, + tileX + tileXoff, tileY + tileYoff, dstX + xoff, dstY + yoff, w, h); dstX += w; @@ -1131,28 +1221,41 @@ exaFillRegionTiled (DrawablePtr pDrawable, } (*pExaScr->info->DoneCopy) (pPixmap); exaMarkSync(pDrawable->pScreen); - exaDrawableDirty (pDrawable); - return; + return TRUE; } fallback: + if (alu != GXcopy || planemask != FB_ALLONES || pPatOrg->x != 0 || + pPatOrg->y != 0) + return FALSE; EXA_FALLBACK(("from %p to %p (%c,%c)\n", pTile, pDrawable, exaDrawableLocation(&pTile->drawable), exaDrawableLocation(pDrawable))); + exaDoMigration (pixmaps, 2, FALSE); exaPrepareAccess (pDrawable, EXA_PREPARE_DEST); exaPrepareAccess ((DrawablePtr)pTile, EXA_PREPARE_SRC); fbFillRegionTiled (pDrawable, pRegion, pTile); exaFinishAccess ((DrawablePtr)pTile, EXA_PREPARE_SRC); exaFinishAccess (pDrawable, EXA_PREPARE_DEST); + + return TRUE; } void exaPaintWindow(WindowPtr pWin, RegionPtr pRegion, int what) { ExaScreenPriv (pWin->drawable.pScreen); - if (!REGION_NUM_RECTS(pRegion)) + PixmapPtr pPixmap = exaGetDrawablePixmap((DrawablePtr)pWin); + int xoff, yoff; + BoxPtr pBox; + int nbox = REGION_NUM_RECTS(pRegion); + + if (!nbox) return; + if (!pExaScr->swappedOut) { + DDXPointRec zeros = { 0, 0 }; + switch (what) { case PW_BACKGROUND: switch (pWin->backgroundState) { @@ -1166,25 +1269,41 @@ exaPaintWindow(WindowPtr pWin, RegionPtr pRegion, int what) what); return; case BackgroundPixel: - exaFillRegionSolid((DrawablePtr)pWin, pRegion, pWin->background.pixel); - return; + exaFillRegionSolid((DrawablePtr)pWin, pRegion, pWin->background.pixel, + FB_ALLONES, GXcopy); + goto damage; case BackgroundPixmap: - exaFillRegionTiled((DrawablePtr)pWin, pRegion, pWin->background.pixmap); - return; + exaFillRegionTiled((DrawablePtr)pWin, pRegion, pWin->background.pixmap, + &zeros, FB_ALLONES, GXcopy); + goto damage; } break; case PW_BORDER: if (pWin->borderIsPixel) { - exaFillRegionSolid((DrawablePtr)pWin, pRegion, pWin->border.pixel); - return; + exaFillRegionSolid((DrawablePtr)pWin, pRegion, pWin->border.pixel, + FB_ALLONES, GXcopy); + goto damage; } else { - exaFillRegionTiled((DrawablePtr)pWin, pRegion, pWin->border.pixmap); - return; + exaFillRegionTiled((DrawablePtr)pWin, pRegion, pWin->border.pixmap, + &zeros, FB_ALLONES, GXcopy); + goto damage; } break; } } ExaCheckPaintWindow (pWin, pRegion, what); + +damage: + exaGetDrawableDeltas((DrawablePtr)pWin, pPixmap, &xoff, &yoff); + + pBox = REGION_RECTS(pRegion); + + while (nbox--) + { + exaPixmapDirty (pPixmap, pBox->x1 + xoff, pBox->y1 + yoff, + pBox->x2 + xoff, pBox->y2 + yoff); + pBox++; + } } /** @@ -1204,27 +1323,22 @@ exaGetImage (DrawablePtr pDrawable, int x, int y, int w, int h, int xoff, yoff; Bool ok; - if (pExaScr->swappedOut || pExaScr->info->DownloadFromScreen == NULL) + if (pExaScr->swappedOut || (w == 1 && h == 1)) goto fallback; + if (pExaScr->info->DownloadFromScreen == NULL) + goto migrate_and_fallback; + /* Only cover the ZPixmap, solid copy case. */ if (format != ZPixmap || !EXA_PM_IS_SOLID(pDrawable, planeMask)) - goto fallback; + goto migrate_and_fallback; /* Only try to handle the 8bpp and up cases, since we don't want to think * about <8bpp. */ if (pDrawable->bitsPerPixel < 8) - goto fallback; + goto migrate_and_fallback; - /* Migrate, but assume that we could accelerate the download. It is up to - * the migration scheme to ensure that this case doesn't result in bad - * moving of pixmaps. - */ - pixmaps[0].as_dst = FALSE; - pixmaps[0].as_src = TRUE; - pixmaps[0].pPix = exaGetDrawablePixmap (pDrawable); - exaDoMigration (pixmaps, 1, TRUE); pPix = exaGetOffscreenPixmap (pDrawable, &xoff, &yoff); if (pPix == NULL) goto fallback; @@ -1239,12 +1353,12 @@ exaGetImage (DrawablePtr pDrawable, int x, int y, int w, int h, return; } -fallback: +migrate_and_fallback: pixmaps[0].as_dst = FALSE; pixmaps[0].as_src = TRUE; pixmaps[0].pPix = exaGetDrawablePixmap (pDrawable); exaDoMigration (pixmaps, 1, FALSE); - +fallback: ExaCheckGetImage (pDrawable, x, y, w, h, format, planeMask, d); } diff --git a/xserver/exa/exa_render.c b/xserver/exa/exa_render.c index 9affb9f11..ad1c02b18 100644 --- a/xserver/exa/exa_render.c +++ b/xserver/exa/exa_render.c @@ -297,6 +297,7 @@ exaTryDriverSolidFill(PicturePtr pSrc, nbox = REGION_NUM_RECTS(®ion); pbox = REGION_RECTS(®ion); + while (nbox--) { (*pExaScr->info->Solid) (pDstPix, @@ -307,7 +308,6 @@ exaTryDriverSolidFill(PicturePtr pSrc, (*pExaScr->info->DoneSolid) (pDstPix); exaMarkSync(pDst->pDrawable->pScreen); - exaDrawableDirty (pDst->pDrawable); REGION_UNINIT(pDst->pDrawable->pScreen, ®ion); return 1; @@ -336,16 +336,21 @@ exaTryDriverComposite(CARD8 op, struct _Pixmap scratch; ExaMigrationRec pixmaps[3]; + pSrcPix = exaGetDrawablePixmap(pSrc->pDrawable); + pDstPix = exaGetDrawablePixmap(pDst->pDrawable); + if (pMask) + pMaskPix = exaGetDrawablePixmap(pMask->pDrawable); + /* Bail if we might exceed coord limits by rendering from/to these. We * should really be making some scratch pixmaps with offsets and coords * adjusted to deal with this, but it hasn't been done yet. */ - if (pSrc->pDrawable->width > pExaScr->info->maxX || - pSrc->pDrawable->height > pExaScr->info->maxY || - pDst->pDrawable->width > pExaScr->info->maxX || - pDst->pDrawable->height > pExaScr->info->maxY || - (pMask && (pMask->pDrawable->width > pExaScr->info->maxX || - pMask->pDrawable->height > pExaScr->info->maxY))) + if (pSrcPix->drawable.width > pExaScr->info->maxX || + pSrcPix->drawable.height > pExaScr->info->maxY || + pDstPix->drawable.width > pExaScr->info->maxX || + pDstPix->drawable.height > pExaScr->info->maxY || + (pMask && (pMaskPix->drawable.width > pExaScr->info->maxX || + pMaskPix->drawable.height > pExaScr->info->maxY))) { return -1; } @@ -443,10 +448,8 @@ exaTryDriverComposite(CARD8 op, pbox->y2 - pbox->y1); pbox++; } - (*pExaScr->info->DoneComposite) (pDstPix); exaMarkSync(pDst->pDrawable->pScreen); - exaDrawableDirty (pDst->pDrawable); REGION_UNINIT(pDst->pDrawable->pScreen, ®ion); return 1; @@ -516,6 +519,9 @@ exaTryMagicTwoPassCompositeHelper(CARD8 op, CARD16 height) { ExaScreenPriv (pDst->pDrawable->pScreen); + DrawablePtr pDstDraw = pDst->pDrawable; + PixmapPtr pDstPixmap = exaGetDrawablePixmap(pDstDraw); + int xoff, yoff; assert(op == PictOpOver); @@ -534,6 +540,12 @@ exaTryMagicTwoPassCompositeHelper(CARD8 op, exaComposite(PictOpOutReverse, pSrc, pMask, pDst, xSrc, ySrc, xMask, yMask, xDst, yDst, width, height); + exaGetDrawableDeltas(pDstDraw, pDstPixmap, &xoff, &yoff); + xoff += pDstDraw->x; + yoff += pDstDraw->y; + exaPixmapDirty(pDstPixmap, xDst + xoff, yDst + yoff, xDst + xoff + width, + yDst + yoff + height); + /* Then, add in the source value times the destination alpha factors (1.0). */ exaComposite(PictOpAdd, pSrc, pMask, pDst, xSrc, ySrc, xMask, yMask, @@ -560,6 +572,28 @@ exaComposite(CARD8 op, int ret = -1; Bool saveSrcRepeat = pSrc->repeat; Bool saveMaskRepeat = pMask ? pMask->repeat : 0; + ExaMigrationRec pixmaps[3]; + int npixmaps = 1; + PixmapPtr pSrcPixmap = NULL; + + pixmaps[0].as_dst = TRUE; + pixmaps[0].as_src = exaOpReadsDestination(op); + pixmaps[0].pPix = exaGetDrawablePixmap (pDst->pDrawable); + + if (pSrc->pDrawable) { + pSrcPixmap = exaGetDrawablePixmap (pSrc->pDrawable); + pixmaps[npixmaps].as_dst = FALSE; + pixmaps[npixmaps].as_src = TRUE; + pixmaps[npixmaps].pPix = pSrcPixmap; + npixmaps++; + } + + if (pMask && pMask->pDrawable) { + pixmaps[npixmaps].as_dst = FALSE; + pixmaps[npixmaps].as_src = TRUE; + pixmaps[npixmaps].pPix = exaGetDrawablePixmap (pMask->pDrawable); + npixmaps++; + } /* We currently don't support acceleration of gradients, or other pictures * with a NULL pDrawable. @@ -567,9 +601,7 @@ exaComposite(CARD8 op, if (pExaScr->swappedOut || pSrc->pDrawable == NULL || (pMask != NULL && pMask->pDrawable == NULL)) { - ExaCheckComposite (op, pSrc, pMask, pDst, xSrc, ySrc, - xMask, yMask, xDst, yDst, width, height); - return; + goto fallback; } /* Remove repeat in source if useless */ @@ -580,19 +612,24 @@ exaComposite(CARD8 op, if (!pMask) { - if (op == PictOpSrc) + if ((op == PictOpSrc && + ((pSrc->format == pDst->format) || + (pSrc->format==PICT_a8r8g8b8 && pDst->format==PICT_x8r8g8b8) || + (pSrc->format==PICT_a8b8g8r8 && pDst->format==PICT_x8b8g8r8))) || + (op == PictOpOver && !pSrc->alphaMap && !pDst->alphaMap && + pSrc->format == pDst->format && + (pSrc->format==PICT_x8r8g8b8 || pSrc->format==PICT_x8b8g8r8))) { if (pSrc->pDrawable->width == 1 && - pSrc->pDrawable->height == 1 && pSrc->repeat && - pSrc->repeatType == RepeatNormal) + pSrc->pDrawable->height == 1 && + pSrc->repeat) { ret = exaTryDriverSolidFill(pSrc, pDst, xSrc, ySrc, xDst, yDst, width, height); if (ret == 1) goto done; } - else if (!pSrc->repeat && !pSrc->transform && - pSrc->format == pDst->format) + else if (pSrcPixmap && !pSrc->repeat && !pSrc->transform) { RegionRec region; @@ -614,6 +651,45 @@ exaComposite(CARD8 op, REGION_UNINIT(pDst->pDrawable->pScreen, ®ion); goto done; } + else if (pSrcPixmap && !pSrc->transform && + pSrc->repeatType == RepeatNormal) + { + RegionRec region; + DDXPointRec srcOrg; + + /* Let's see if the driver can do the repeat in one go */ + if (pExaScr->info->PrepareComposite && !pSrc->alphaMap && + !pDst->alphaMap) + { + ret = exaTryDriverComposite(op, pSrc, pMask, pDst, xSrc, + ySrc, xMask, yMask, xDst, yDst, + width, height); + if (ret == 1) + goto done; + } + + /* Now see if we can use exaFillRegionTiled() */ + xDst += pDst->pDrawable->x; + yDst += pDst->pDrawable->y; + xSrc += pSrc->pDrawable->x; + ySrc += pSrc->pDrawable->y; + + if (!miComputeCompositeRegion (®ion, pSrc, pMask, pDst, xSrc, + ySrc, xMask, yMask, xDst, yDst, + width, height)) + goto done; + + srcOrg.x = (xSrc - xDst) % pSrcPixmap->drawable.width; + srcOrg.y = (ySrc - yDst) % pSrcPixmap->drawable.height; + + ret = exaFillRegionTiled(pDst->pDrawable, ®ion, pSrcPixmap, + &srcOrg, FB_ALLONES, GXcopy); + + REGION_UNINIT(pDst->pDrawable->pScreen, ®ion); + + if (ret) + goto done; + } } } @@ -624,8 +700,8 @@ exaComposite(CARD8 op, pMask->repeat = 0; if (pExaScr->info->PrepareComposite && - (!pSrc->repeat || pSrc->repeat == RepeatNormal) && - (!pMask || !pMask->repeat || pMask->repeat == RepeatNormal) && + (!pSrc->repeat || pSrc->repeatType == RepeatNormal) && + (!pMask || !pMask->repeat || pMask->repeatType == RepeatNormal) && !pSrc->alphaMap && (!pMask || !pMask->alphaMap) && !pDst->alphaMap) { Bool isSrcSolid; @@ -657,31 +733,12 @@ exaComposite(CARD8 op, } } - if (ret != 0) { - ExaMigrationRec pixmaps[3]; - /* failure to accelerate was not due to pixmaps being in the wrong - * locations. - */ - pixmaps[0].as_dst = TRUE; - pixmaps[0].as_src = exaOpReadsDestination(op); - pixmaps[0].pPix = exaGetDrawablePixmap (pDst->pDrawable); - pixmaps[1].as_dst = FALSE; - pixmaps[1].as_src = TRUE; - pixmaps[1].pPix = exaGetDrawablePixmap (pSrc->pDrawable); - if (pMask) { - pixmaps[2].as_dst = FALSE; - pixmaps[2].as_src = TRUE; - pixmaps[2].pPix = exaGetDrawablePixmap (pMask->pDrawable); - exaDoMigration(pixmaps, 3, FALSE); - } else { - exaDoMigration(pixmaps, 2, FALSE); - } - } - +fallback: #if DEBUG_TRACE_FALL exaPrintCompositeFallback (op, pSrc, pMask, pDst); #endif + exaDoMigration(pixmaps, npixmaps, FALSE); ExaCheckComposite (op, pSrc, pMask, pDst, xSrc, ySrc, xMask, yMask, xDst, yDst, width, height); @@ -692,6 +749,132 @@ done: } #endif +/** + * Same as miCreateAlphaPicture, except it uses ExaCheckPolyFillRect instead + * of PolyFillRect to initialize the pixmap after creating it, to prevent + * the pixmap from being migrated. + * + * See the comments about exaTrapezoids. + */ +static PicturePtr +exaCreateAlphaPicture (ScreenPtr pScreen, + PicturePtr pDst, + PictFormatPtr pPictFormat, + CARD16 width, + CARD16 height) +{ + PixmapPtr pPixmap; + PicturePtr pPicture; + GCPtr pGC; + int error; + xRectangle rect; + + if (width > 32767 || height > 32767) + return 0; + + if (!pPictFormat) + { + if (pDst->polyEdge == PolyEdgeSharp) + pPictFormat = PictureMatchFormat (pScreen, 1, PICT_a1); + else + pPictFormat = PictureMatchFormat (pScreen, 8, PICT_a8); + if (!pPictFormat) + return 0; + } + + pPixmap = (*pScreen->CreatePixmap) (pScreen, width, height, + pPictFormat->depth); + if (!pPixmap) + return 0; + pGC = GetScratchGC (pPixmap->drawable.depth, pScreen); + if (!pGC) + { + (*pScreen->DestroyPixmap) (pPixmap); + return 0; + } + ValidateGC (&pPixmap->drawable, pGC); + rect.x = 0; + rect.y = 0; + rect.width = width; + rect.height = height; + ExaCheckPolyFillRect (&pPixmap->drawable, pGC, 1, &rect); + exaPixmapDirty (pPixmap, 0, 0, width, height); + FreeScratchGC (pGC); + pPicture = CreatePicture (0, &pPixmap->drawable, pPictFormat, + 0, 0, serverClient, &error); + (*pScreen->DestroyPixmap) (pPixmap); + return pPicture; +} + +/** + * exaTrapezoids is essentially a copy of miTrapezoids that uses + * exaCreateAlphaPicture instead of miCreateAlphaPicture. + * + * The problem with miCreateAlphaPicture is that it calls PolyFillRect + * to initialize the contents after creating the pixmap, which + * causes the pixmap to be moved in for acceleration. The subsequent + * call to RasterizeTrapezoid won't be accelerated however, which + * forces the pixmap to be moved out again. + * + * exaCreateAlphaPicture avoids this roundtrip by using ExaCheckPolyFillRect + * to initialize the contents. + */ +void +exaTrapezoids (CARD8 op, PicturePtr pSrc, PicturePtr pDst, + PictFormatPtr maskFormat, INT16 xSrc, INT16 ySrc, + int ntrap, xTrapezoid *traps) +{ + ScreenPtr pScreen = pDst->pDrawable->pScreen; + PictureScreenPtr ps = GetPictureScreen(pScreen); + + /* + * Check for solid alpha add + */ + if (op == PictOpAdd && miIsSolidAlpha (pSrc)) + { + for (; ntrap; ntrap--, traps++) + (*ps->RasterizeTrapezoid) (pDst, traps, 0, 0); + } + else if (maskFormat) + { + PicturePtr pPicture; + BoxRec bounds; + INT16 xDst, yDst; + INT16 xRel, yRel; + + xDst = traps[0].left.p1.x >> 16; + yDst = traps[0].left.p1.y >> 16; + + miTrapezoidBounds (ntrap, traps, &bounds); + if (bounds.y1 >= bounds.y2 || bounds.x1 >= bounds.x2) + return; + pPicture = exaCreateAlphaPicture (pScreen, pDst, maskFormat, + bounds.x2 - bounds.x1, + bounds.y2 - bounds.y1); + if (!pPicture) + return; + for (; ntrap; ntrap--, traps++) + (*ps->RasterizeTrapezoid) (pPicture, traps, + -bounds.x1, -bounds.y1); + xRel = bounds.x1 + xSrc - xDst; + yRel = bounds.y1 + ySrc - yDst; + CompositePicture (op, pSrc, pPicture, pDst, + xRel, yRel, 0, 0, bounds.x1, bounds.y1, + bounds.x2 - bounds.x1, + bounds.y2 - bounds.y1); + FreePicture (pPicture, 0); + } + else + { + if (pDst->polyEdge == PolyEdgeSharp) + maskFormat = PictureMatchFormat (pScreen, 1, PICT_a1); + else + maskFormat = PictureMatchFormat (pScreen, 8, PICT_a8); + for (; ntrap; ntrap--, traps++) + exaTrapezoids (op, pSrc, pDst, maskFormat, xSrc, ySrc, 1, traps); + } +} + #define NeedsComponent(f) (PICT_FORMAT_A(f) != 0 && PICT_FORMAT_RGB(f) != 0) /** @@ -705,16 +888,22 @@ void exaRasterizeTrapezoid (PicturePtr pPicture, xTrapezoid *trap, int x_off, int y_off) { + DrawablePtr pDraw = pPicture->pDrawable; ExaMigrationRec pixmaps[1]; + int xoff, yoff; pixmaps[0].as_dst = TRUE; pixmaps[0].as_src = TRUE; - pixmaps[0].pPix = exaGetDrawablePixmap (pPicture->pDrawable); + pixmaps[0].pPix = exaGetDrawablePixmap (pDraw); exaDoMigration(pixmaps, 1, FALSE); - exaPrepareAccess(pPicture->pDrawable, EXA_PREPARE_DEST); + exaPrepareAccess(pDraw, EXA_PREPARE_DEST); fbRasterizeTrapezoid(pPicture, trap, x_off, y_off); - exaFinishAccess(pPicture->pDrawable, EXA_PREPARE_DEST); + exaGetDrawableDeltas(pDraw, pixmaps[0].pPix, &xoff, &yoff); + exaPixmapDirty(pixmaps[0].pPix, pDraw->x + xoff, pDraw->y + yoff, + pDraw->x + xoff + pDraw->width, + pDraw->y + yoff + pDraw->height); + exaFinishAccess(pDraw, EXA_PREPARE_DEST); } /** @@ -725,16 +914,22 @@ void exaAddTriangles (PicturePtr pPicture, INT16 x_off, INT16 y_off, int ntri, xTriangle *tris) { + DrawablePtr pDraw = pPicture->pDrawable; ExaMigrationRec pixmaps[1]; + int xoff, yoff; pixmaps[0].as_dst = TRUE; pixmaps[0].as_src = TRUE; - pixmaps[0].pPix = exaGetDrawablePixmap (pPicture->pDrawable); + pixmaps[0].pPix = exaGetDrawablePixmap (pDraw); exaDoMigration(pixmaps, 1, FALSE); - exaPrepareAccess(pPicture->pDrawable, EXA_PREPARE_DEST); + exaPrepareAccess(pDraw, EXA_PREPARE_DEST); fbAddTriangles(pPicture, x_off, y_off, ntri, tris); - exaFinishAccess(pPicture->pDrawable, EXA_PREPARE_DEST); + exaGetDrawableDeltas(pDraw, pixmaps[0].pPix, &xoff, &yoff); + exaPixmapDirty(pixmaps[0].pPix, pDraw->x + xoff, pDraw->y + yoff, + pDraw->x + xoff + pDraw->width, + pDraw->y + yoff + pDraw->height); + exaFinishAccess(pDraw, EXA_PREPARE_DEST); } /** @@ -830,10 +1025,11 @@ exaGlyphs (CARD8 op, PixmapPtr pPixmap = NULL; PicturePtr pPicture; PixmapPtr pMaskPixmap = NULL; + PixmapPtr pDstPixmap = exaGetDrawablePixmap(pDst->pDrawable); PicturePtr pMask; ScreenPtr pScreen = pDst->pDrawable->pScreen; int width = 0, height = 0; - int x, y; + int x, y, x1, y1, xoff, yoff; int xDst = list->xOff, yDst = list->yOff; int n; int error; @@ -877,7 +1073,12 @@ exaGlyphs (CARD8 op, xRectangle rect; miGlyphExtents (nlist, list, glyphs, &extents); - + + extents.x1 = max(extents.x1, 0); + extents.y1 = max(extents.y1, 0); + extents.x2 = min(extents.x2, pDst->pDrawable->width); + extents.y2 = min(extents.y2, pDst->pDrawable->height); + if (extents.x2 <= extents.x1 || extents.y2 <= extents.y1) return; width = extents.x2 - extents.x1; @@ -903,6 +1104,7 @@ exaGlyphs (CARD8 op, rect.width = width; rect.height = height; (*pGC->ops->PolyFillRect) (&pMaskPixmap->drawable, pGC, 1, &rect); + exaPixmapDirty(pMaskPixmap, 0, 0, width, height); FreeScratchGC (pGC); x = -extents.x1; y = -extents.y1; @@ -914,6 +1116,8 @@ exaGlyphs (CARD8 op, y = 0; } + exaGetDrawableDeltas(pDst->pDrawable, pDstPixmap, &xoff, &yoff); + while (nlist--) { GCPtr pGC = NULL; @@ -968,13 +1172,22 @@ exaGlyphs (CARD8 op, pixmaps[0].as_dst = TRUE; pixmaps[0].as_src = TRUE; pixmaps[0].pPix = pPixmap; - exaDoMigration (pixmaps, 1, TRUE); + exaDoMigration (pixmaps, 1, pExaScr->info->PrepareComposite != NULL); while (n--) { GlyphPtr glyph = *glyphs++; pointer glyphdata = (pointer) (glyph + 1); - + DrawablePtr pCmpDrw = (maskFormat ? pMask : pDst)->pDrawable; + + x1 = x - glyph->info.x; + y1 = y - glyph->info.y; + + if (x1 >= pCmpDrw->width || y1 >= pCmpDrw->height || + glyph->info.width == 0 || glyph->info.height == 0 || + (x1 + glyph->info.width) <= 0 || (y1 + glyph->info.height) <= 0) + goto nextglyph; + (*pScreen->ModifyPixmapHeader) (pScratchPixmap, glyph->info.width, glyph->info.height, @@ -984,15 +1197,17 @@ exaGlyphs (CARD8 op, * First we try to use UploadToScreen, if we can, then we fall back * to a plain exaCopyArea in case of failure. */ - if (!pExaScr->info->UploadToScreen || - !exaPixmapIsOffscreen(pPixmap) || - !(*pExaScr->info->UploadToScreen) (pPixmap, 0, 0, + if (pExaScr->info->UploadToScreen && + exaPixmapIsOffscreen(pPixmap) && + (*pExaScr->info->UploadToScreen) (pPixmap, 0, 0, glyph->info.width, glyph->info.height, glyphdata, PixmapBytePad(glyph->info.width, list->format->depth))) { + exaMarkSync (pScreen); + } else { /* Set up the scratch pixmap/GC for doing a CopyArea. */ if (pScratchPixmap == NULL) { /* Get a scratch pixmap to wrap the original glyph data */ @@ -1023,24 +1238,30 @@ exaGlyphs (CARD8 op, exaCopyArea (&pScratchPixmap->drawable, &pPixmap->drawable, pGC, 0, 0, glyph->info.width, glyph->info.height, 0, 0); - } else { - exaDrawableDirty (&pPixmap->drawable); } + exaPixmapDirty (pPixmap, 0, 0, + glyph->info.width, glyph->info.height); + if (maskFormat) { exaComposite (PictOpAdd, pPicture, NULL, pMask, 0, 0, 0, 0, - x - glyph->info.x, y - glyph->info.y, - glyph->info.width, glyph->info.height); + x1, y1, glyph->info.width, glyph->info.height); + exaPixmapDirty(pMaskPixmap, x1, y1, x1 + glyph->info.width, + y1 + glyph->info.height); } else { exaComposite (op, pSrc, pPicture, pDst, - xSrc + (x - glyph->info.x) - xDst, - ySrc + (y - glyph->info.y) - yDst, - 0, 0, x - glyph->info.x, y - glyph->info.y, - glyph->info.width, glyph->info.height); + xSrc + x1 - xDst, ySrc + y1 - yDst, + 0, 0, x1, y1, glyph->info.width, + glyph->info.height); + x1 += pDst->pDrawable->x + xoff; + y1 += pDst->pDrawable->y + yoff; + exaPixmapDirty(pDstPixmap, x1, y1, x1 + glyph->info.width, + y1 + glyph->info.height); } +nextglyph: x += glyph->info.xOff; y += glyph->info.yOff; } diff --git a/xserver/hw/dmx/Makefile.am b/xserver/hw/dmx/Makefile.am index 89136b904..15dc281cd 100644 --- a/xserver/hw/dmx/Makefile.am +++ b/xserver/hw/dmx/Makefile.am @@ -16,13 +16,18 @@ GLX_INCS = -I$(top_srcdir)/hw/xfree86/dixmods/extmod \ GLX_DEFS = @GL_CFLAGS@ endif -# It's essential that fbcmap.c be compiled with this flag for DMX to work!! -DMX_CFLAGS = -DXFree86Server=1 - if BUILDDOCS SUBDIRS += doc endif +AM_CFLAGS = \ + -DHAVE_DMX_CONFIG_H \ + $(DIX_CFLAGS) \ + $(GLX_INCS) \ + $(GLX_DEFS) \ + $(DMX_CFLAGS) \ + @DMXMODULES_CFLAGS@ + Xdmx_SOURCES = dmx.c \ dmxcb.c \ dmxcb.h \ @@ -67,8 +72,8 @@ Xdmx_SOURCES = dmx.c \ dmxvisual.h \ dmxwindow.c \ dmxwindow.h \ - $(top_srcdir)/fb/fbcmap.c \ $(top_srcdir)/mi/miinitext.c \ + $(top_srcdir)/fb/fbcmap_mi.c \ $(GLX_SRCS) @@ -82,16 +87,9 @@ Xdmx_LDADD = $(XORG_CORE_LIBS) \ $(GLX_LIBS) \ input/libdmxinput.a \ config/libdmxconfig.a \ + @XSERVER_LIBS@ \ @DMXMODULES_LIBS@ -Xdmx_CFLAGS = \ - -DHAVE_DMX_CONFIG_H \ - $(DIX_CFLAGS) \ - $(GLX_INCS) \ - $(GLX_DEFS) \ - $(DMX_CFLAGS) \ - @DMXMODULES_CFLAGS@ - # Man page appmandir = $(APP_MAN_DIR) diff --git a/xserver/hw/dmx/Makefile.in b/xserver/hw/dmx/Makefile.in index 1e25767af..f747986d3 100644 --- a/xserver/hw/dmx/Makefile.in +++ b/xserver/hw/dmx/Makefile.in @@ -721,6 +721,7 @@ Xdmx_LDADD = $(XORG_CORE_LIBS) \ $(GLX_LIBS) \ input/libdmxinput.a \ config/libdmxconfig.a \ + @XSERVER_LIBS@ \ @DMXMODULES_LIBS@ diff --git a/xserver/hw/dmx/dmxinput.c b/xserver/hw/dmx/dmxinput.c index 7c376dee4..83f8a4a90 100644 --- a/xserver/hw/dmx/dmxinput.c +++ b/xserver/hw/dmx/dmxinput.c @@ -1,4 +1,3 @@ -/* $XFree86$ */ /* * Copyright 2001,2002 Red Hat Inc., Durham, North Carolina. * @@ -49,11 +48,12 @@ #include "inputstr.h" #include "input.h" +#include "mi.h" /** Returns TRUE if the key is a valid modifier. For PC-class * keyboards, all keys can be used as modifiers, so return TRUE * always. */ -Bool LegalModifier(unsigned int key, DevicePtr pDev) +Bool LegalModifier(unsigned int key, DeviceIntPtr pDev) { return TRUE; } @@ -75,6 +75,8 @@ void InitInput(int argc, char **argv) dmxLog(dmxWarning, "Use keyboard/mouse pair with the first -input\n"); dmxLog(dmxFatal, "At least one core keyboard/mouse pair required\n"); } + + mieqInit(); } /** Called from dix/dispatch.c in Dispatch() whenever input events @@ -103,3 +105,14 @@ void dmxUpdateWindowInfo(DMXUpdateType type, WindowPtr pWindow) if (!dmxInput->detached && dmxInput->updateWindowInfo) dmxInput->updateWindowInfo(dmxInput, type, pWindow); } + +int +NewInputDeviceRequest (InputOption *options, DeviceIntPtr *pdev) +{ + return BadRequest; +} + +void +DeleteInputDeviceRequest(DeviceIntPtr pDev) +{ +} diff --git a/xserver/hw/kdrive/ephyr/Makefile.am b/xserver/hw/kdrive/ephyr/Makefile.am index 8f51bbe08..1738d0f95 100644 --- a/xserver/hw/kdrive/ephyr/Makefile.am +++ b/xserver/hw/kdrive/ephyr/Makefile.am @@ -28,9 +28,13 @@ Xephyr_LDADD = \ libxephyr-hostx.a \ ../../../exa/libexa.la \ @KDRIVE_LIBS@ \ - @KDRIVE_LIBS@ \ + @XSERVER_LIBS@ \ @XEPHYR_LIBS@ -Xephyr_DEPENDENCIES = \ +Xephyr_DEPENDENCIES = \ libxephyr.a \ - libxephyr-hostx.a + libxephyr-hostx.a \ + @KDRIVE_LOCAL_LIBS@ + +relink: + rm -f $(bin_PROGRAMS) && make $(bin_PROGRAMS) diff --git a/xserver/hw/kdrive/ephyr/Makefile.in b/xserver/hw/kdrive/ephyr/Makefile.in index 2bf3b471e..315f3322d 100644 --- a/xserver/hw/kdrive/ephyr/Makefile.in +++ b/xserver/hw/kdrive/ephyr/Makefile.in @@ -644,6 +644,7 @@ Xephyr_LDADD = \ libxephyr-hostx.a \ ../../../exa/libexa.la \ @KDRIVE_LIBS@ \ + @XSERVER_LIBS@ \ @XEPHYR_LIBS@ Xephyr_DEPENDENCIES = \ diff --git a/xserver/hw/kdrive/ephyr/ephyr.c b/xserver/hw/kdrive/ephyr/ephyr.c index fbb16a465..86e8f1f72 100644 --- a/xserver/hw/kdrive/ephyr/ephyr.c +++ b/xserver/hw/kdrive/ephyr/ephyr.c @@ -36,10 +36,16 @@ #include "inputstr.h" extern int KdTsPhyScreen; -extern DeviceIntPtr pKdKeyboard; +KdKeyboardInfo *ephyrKbd; +KdPointerInfo *ephyrMouse; +EphyrKeySyms ephyrKeySyms; static int mouseState = 0; +typedef struct _EphyrInputPrivate { + Bool enabled; +} EphyrKbdPrivate, EphyrPointerPrivate; + Bool EphyrWantGrayScale = 0; Bool @@ -75,7 +81,8 @@ Bool ephyrScreenInitialize (KdScreenInfo *screen, EphyrScrPriv *scrpriv) { int width = 640, height = 480; - + unsigned long redMask, greenMask, blueMask; + if (hostx_want_screen_size(&width, &height) || !screen->width || !screen->height) { @@ -127,30 +134,24 @@ ephyrScreenInitialize (KdScreenInfo *screen, EphyrScrPriv *scrpriv) { screen->fb[0].depth = 15; screen->fb[0].bitsPerPixel = 16; - - hostx_get_visual_masks (&screen->fb[0].redMask, - &screen->fb[0].greenMask, - &screen->fb[0].blueMask); - } else if (screen->fb[0].depth <= 16) { screen->fb[0].depth = 16; screen->fb[0].bitsPerPixel = 16; - - hostx_get_visual_masks (&screen->fb[0].redMask, - &screen->fb[0].greenMask, - &screen->fb[0].blueMask); } else { screen->fb[0].depth = 24; screen->fb[0].bitsPerPixel = 32; - - hostx_get_visual_masks (&screen->fb[0].redMask, - &screen->fb[0].greenMask, - &screen->fb[0].blueMask); } + + hostx_get_visual_masks (&redMask, &greenMask, &blueMask); + + screen->fb[0].redMask = (Pixel) redMask; + screen->fb[0].greenMask = (Pixel) greenMask; + screen->fb[0].blueMask = (Pixel) blueMask; + } scrpriv->randr = screen->randr; @@ -206,15 +207,14 @@ ephyrMapFramebuffer (KdScreenInfo *screen) { EphyrScrPriv *scrpriv = screen->driver; EphyrPriv *priv = screen->card->driver; - KdMouseMatrix m; + KdPointerMatrix m; int buffer_height; EPHYR_DBG(" screen->width: %d, screen->height: %d", screen->width, screen->height); - KdComputeMouseMatrix (&m, scrpriv->randr, screen->width, screen->height); - - KdSetMouseMatrix (&m); + KdComputePointerMatrix (&m, scrpriv->randr, screen->width, screen->height); + KdSetPointerMatrix (&m); priv->bytes_per_line = ((screen->width * screen->fb[0].bitsPerPixel + 31) >> 5) << 2; @@ -394,6 +394,7 @@ ephyrUnsetInternalDamage (ScreenPtr pScreen) pPixmap = (*pScreen->GetScreenPixmap) (pScreen); DamageUnregister (&pPixmap->drawable, scrpriv->pDamage); + DamageDestroy (scrpriv->pDamage); RemoveBlockAndWakeupHandlers (ephyrInternalDamageBlockHandler, ephyrInternalDamageWakeupHandler, @@ -675,6 +676,8 @@ ephyrRestore (KdCardInfo *card) void ephyrScreenFini (KdScreenInfo *screen) { + xfree(screen->driver); + screen->driver = NULL; } /* @@ -719,8 +722,9 @@ ephyrUpdateModifierState(unsigned int state) kptr = &keyc->down[key >> 3]; bit = 1 << (key & 7); - if (*kptr & bit) - KdEnqueueKeyboardEvent(key, TRUE); /* release */ + if (*kptr & bit && ephyrKbd && + ((EphyrKbdPrivate *)ephyrKbd->driverPrivate)->enabled) + KdEnqueueKeyboardEvent(ephyrKbd, key, TRUE); /* release */ if (--count == 0) break; @@ -732,7 +736,9 @@ ephyrUpdateModifierState(unsigned int state) for (key = 0; key < MAP_LENGTH; key++) if (keyc->modifierMap[key] & mask) { - KdEnqueueKeyboardEvent(key, FALSE); /* press */ + if (keyc->modifierMap[key] & mask && ephyrKbd && + ((EphyrKbdPrivate *)ephyrKbd->driverPrivate)->enabled) + KdEnqueueKeyboardEvent(ephyrKbd, key, FALSE); /* press */ break; } } @@ -748,31 +754,47 @@ ephyrPoll(void) switch (ev.type) { case EPHYR_EV_MOUSE_MOTION: - KdEnqueueMouseEvent(kdMouseInfo, mouseState, - ev.data.mouse_motion.x, - ev.data.mouse_motion.y); + if (!ephyrMouse || + !((EphyrPointerPrivate *)ephyrMouse->driverPrivate)->enabled) + continue; + KdEnqueuePointerEvent(ephyrMouse, mouseState, + ev.data.mouse_motion.x, + ev.data.mouse_motion.y, + 0); break; case EPHYR_EV_MOUSE_PRESS: + if (!ephyrMouse || + !((EphyrPointerPrivate *)ephyrMouse->driverPrivate)->enabled) + continue; ephyrUpdateModifierState(ev.key_state); mouseState |= ev.data.mouse_down.button_num; - KdEnqueueMouseEvent(kdMouseInfo, mouseState|KD_MOUSE_DELTA, 0, 0); + KdEnqueuePointerEvent(ephyrMouse, mouseState|KD_MOUSE_DELTA, 0, 0, 0); break; case EPHYR_EV_MOUSE_RELEASE: + if (!ephyrMouse || + !((EphyrPointerPrivate *)ephyrMouse->driverPrivate)->enabled) + continue; ephyrUpdateModifierState(ev.key_state); mouseState &= ~ev.data.mouse_up.button_num; - KdEnqueueMouseEvent(kdMouseInfo, mouseState|KD_MOUSE_DELTA, 0, 0); + KdEnqueuePointerEvent(ephyrMouse, mouseState|KD_MOUSE_DELTA, 0, 0, 0); break; case EPHYR_EV_KEY_PRESS: + if (!ephyrKbd || + !((EphyrKbdPrivate *)ephyrKbd->driverPrivate)->enabled) + continue; ephyrUpdateModifierState(ev.key_state); - KdEnqueueKeyboardEvent (ev.data.key_down.scancode, FALSE); + KdEnqueueKeyboardEvent (ephyrKbd, ev.data.key_down.scancode, FALSE); break; case EPHYR_EV_KEY_RELEASE: + if (!ephyrKbd || + !((EphyrKbdPrivate *)ephyrKbd->driverPrivate)->enabled) + continue; ephyrUpdateModifierState(ev.key_state); - KdEnqueueKeyboardEvent (ev.data.key_up.scancode, TRUE); + KdEnqueueKeyboardEvent (ephyrKbd, ev.data.key_up.scancode, TRUE); break; default: @@ -833,59 +855,113 @@ ephyrPutColors (ScreenPtr pScreen, int fb, int n, xColorItem *pdefs) /* Mouse calls */ -static Bool -MouseInit (void) +static Status +MouseInit (KdPointerInfo *pi) { - return TRUE; + pi->driverPrivate = (EphyrPointerPrivate *) + xcalloc(sizeof(EphyrPointerPrivate), 1); + ((EphyrPointerPrivate *)pi->driverPrivate)->enabled = FALSE; + pi->nAxes = 3; + pi->nButtons = 32; + pi->name = KdSaveString("Xephyr virtual mouse"); + ephyrMouse = pi; + return Success; +} + +static Status +MouseEnable (KdPointerInfo *pi) +{ + ((EphyrPointerPrivate *)pi->driverPrivate)->enabled = TRUE; + return Success; } static void -MouseFini (void) +MouseDisable (KdPointerInfo *pi) { - ; + ((EphyrPointerPrivate *)pi->driverPrivate)->enabled = FALSE; + return; } -KdMouseFuncs EphyrMouseFuncs = { +static void +MouseFini (KdPointerInfo *pi) +{ + ephyrMouse = NULL; + return; +} + +KdPointerDriver EphyrMouseDriver = { + "ephyr", MouseInit, + MouseEnable, + MouseDisable, MouseFini, + NULL, }; /* Keyboard */ -static void -EphyrKeyboardLoad (void) +static Status +EphyrKeyboardInit (KdKeyboardInfo *ki) { - EPHYR_DBG("mark"); - + ki->driverPrivate = (EphyrKbdPrivate *) + xcalloc(sizeof(EphyrKbdPrivate), 1); hostx_load_keymap(); + if (!ephyrKeySyms.map) { + ErrorF("Couldn't load keymap from host\n"); + return BadAlloc; + } + ki->keySyms.minKeyCode = ephyrKeySyms.minKeyCode; + ki->keySyms.maxKeyCode = ephyrKeySyms.maxKeyCode; + ki->minScanCode = ki->keySyms.minKeyCode; + ki->maxScanCode = ki->keySyms.maxKeyCode; + ki->keySyms.mapWidth = ephyrKeySyms.mapWidth; + xfree(ki->keySyms.map); + ki->keySyms.map = ephyrKeySyms.map; + ki->name = KdSaveString("Xephyr virtual keyboard"); + ephyrKbd = ki; + return Success; } -static int -EphyrKeyboardInit (void) +static Status +EphyrKeyboardEnable (KdKeyboardInfo *ki) { - return 0; + ((EphyrKbdPrivate *)ki->driverPrivate)->enabled = TRUE; + + return Success; } static void -EphyrKeyboardFini (void) +EphyrKeyboardDisable (KdKeyboardInfo *ki) { + ((EphyrKbdPrivate *)ki->driverPrivate)->enabled = FALSE; +} + +static void +EphyrKeyboardFini (KdKeyboardInfo *ki) +{ + /* not xfree: we call malloc from hostx.c. */ + free(ki->keySyms.map); + ephyrKbd = NULL; + return; } static void -EphyrKeyboardLeds (int leds) +EphyrKeyboardLeds (KdKeyboardInfo *ki, int leds) { } static void -EphyrKeyboardBell (int volume, int frequency, int duration) +EphyrKeyboardBell (KdKeyboardInfo *ki, int volume, int frequency, int duration) { } -KdKeyboardFuncs EphyrKeyboardFuncs = { - EphyrKeyboardLoad, +KdKeyboardDriver EphyrKeyboardDriver = { + "ephyr", EphyrKeyboardInit, + EphyrKeyboardEnable, EphyrKeyboardLeds, EphyrKeyboardBell, + EphyrKeyboardDisable, EphyrKeyboardFini, - 0, + NULL, }; diff --git a/xserver/hw/kdrive/src/kdrive.c b/xserver/hw/kdrive/src/kdrive.c index 52e56e90b..cd4ea7d32 100644 --- a/xserver/hw/kdrive/src/kdrive.c +++ b/xserver/hw/kdrive/src/kdrive.c @@ -1,6 +1,4 @@ /* - * $RCSId: xc/programs/Xserver/hw/kdrive/kdrive.c,v 1.29 2002/10/31 18:29:50 keithp Exp $ - * * Copyright © 1999 Keith Packard * * Permission to use, copy, modify, distribute, and sell this software and its @@ -43,6 +41,12 @@ #include "dpmsproc.h" #endif +#ifdef HAVE_EXECINFO_H +#include <execinfo.h> +#endif + +#include <signal.h> + typedef struct _kdDepths { CARD8 depth; CARD8 bpp; @@ -60,6 +64,8 @@ KdDepths kdDepths[] = { #define NUM_KD_DEPTHS (sizeof (kdDepths) / sizeof (kdDepths[0])) +#define KD_DEFAULT_BUTTONS 5 + int kdScreenPrivateIndex; unsigned long kdGeneration; @@ -75,6 +81,10 @@ int kdVirtualTerminal = -1; Bool kdSwitchPending; char *kdSwitchCmd; DDXPointRec kdOrigin; +Bool kdHasPointer = FALSE; +Bool kdHasKbd = FALSE; + +static Bool kdCaughtSignal = FALSE; /* * Carry arguments from InitOutput through driver initialization @@ -87,7 +97,6 @@ extern WindowPtr *WindowTable; void KdSetRootClip (ScreenPtr pScreen, BOOL enable) { -#ifndef FB_OLD_SCREEN WindowPtr pWin = WindowTable[pScreen->myNum]; WindowPtr pChild; Bool WasViewable; @@ -214,7 +223,6 @@ KdSetRootClip (ScreenPtr pScreen, BOOL enable) } if (pWin->realized) WindowsRestructured (); -#endif /* !FB_OLD_SCREEN */ } void @@ -271,7 +279,7 @@ KdSuspend (void) for (screen = card->screenList; screen; screen = screen->next) if (screen->mynum == card->selected && screen->pScreen) KdDisableScreen (screen->pScreen); - if (card->driver) + if (card->driver && card->cfuncs->restore) (*card->cfuncs->restore) (card); } KdDisableInput (); @@ -285,7 +293,8 @@ KdDisableScreens (void) KdSuspend (); if (kdEnabled) { - (*kdOsFuncs->Disable) (); + if (kdOsFuncs->Disable) + (*kdOsFuncs->Disable) (); kdEnabled = FALSE; } } @@ -343,7 +352,8 @@ KdEnableScreens (void) if (!kdEnabled) { kdEnabled = TRUE; - (*kdOsFuncs->Enable) (); + if (kdOsFuncs->Enable) + (*kdOsFuncs->Enable) (); } KdResume (); } @@ -363,11 +373,15 @@ AbortDDX(void) KdDisableScreens (); if (kdOsFuncs) { - if (kdEnabled) + if (kdEnabled && kdOsFuncs->Disable) (*kdOsFuncs->Disable) (); - (*kdOsFuncs->Fini) (); + if (kdOsFuncs->Fini) + (*kdOsFuncs->Fini) (); KdDoSwitchCmd ("stop"); } + + if (kdCaughtSignal) + abort(); } void @@ -379,7 +393,7 @@ ddxGiveUp () Bool kdDumbDriver; Bool kdSoftCursor; -static char * +char * KdParseFindNext (char *cur, char *delim, char *save, char *last) { while (*cur && !strchr (delim, *cur)) @@ -560,97 +574,6 @@ KdSaveString (char *str) return n; } -/* - * Parse mouse information. Syntax: - * - * <device>,<nbutton>,<protocol>{,<option>}... - * - * options: {nmo} pointer mapping (e.g. {321}) - * 2button emulate middle button - * 3button dont emulate middle button - */ - -void -KdParseMouse (char *arg) -{ - char save[1024]; - char delim; - KdMouseInfo *mi; - int i; - - mi = KdMouseInfoAdd (); - if (!mi) - return; - mi->name = 0; - mi->prot = 0; - mi->emulateMiddleButton = kdEmulateMiddleButton; - mi->transformCoordinates = !kdRawPointerCoordinates; - mi->nbutton = 3; - for (i = 0; i < KD_MAX_BUTTON; i++) - mi->map[i] = i + 1; - - if (!arg) - return; - if (strlen (arg) >= sizeof (save)) - return; - arg = KdParseFindNext (arg, ",", save, &delim); - if (!save[0]) - return; - mi->name = KdSaveString (save); - if (delim != ',') - return; - - arg = KdParseFindNext (arg, ",", save, &delim); - if (!save[0]) - return; - - if ('1' <= save[0] && save[0] <= '0' + KD_MAX_BUTTON && save[1] == '\0') - { - mi->nbutton = save[0] - '0'; - if (mi->nbutton > KD_MAX_BUTTON) - { - UseMsg (); - return; - } - } - - if (!delim != ',') - return; - - arg = KdParseFindNext (arg, ",", save, &delim); - - if (save[0]) - mi->prot = KdSaveString (save); - - while (delim == ',') - { - arg = KdParseFindNext (arg, ",", save, &delim); - if (save[0] == '{') - { - char *s = save + 1; - i = 0; - while (*s && *s != '}') - { - if ('1' <= *s && *s <= '0' + mi->nbutton) - mi->map[i] = *s - '0'; - else - UseMsg (); - s++; - } - } - else if (!strcmp (save, "2button")) - mi->emulateMiddleButton = TRUE; - else if (!strcmp (save, "3button")) - mi->emulateMiddleButton = FALSE; - else if (!strcmp (save, "rawcoord")) - mi->transformCoordinates = FALSE; - else if (!strcmp (save, "transform")) - mi->transformCoordinates = TRUE; - else - UseMsg (); - } -} - void KdParseRgba (char *rgba) { @@ -675,6 +598,8 @@ KdUseMsg (void) ErrorF("-card pcmcia Use PCMCIA card as additional screen\n"); ErrorF("-screen WIDTH[/WIDTHMM]xHEIGHT[/HEIGHTMM][@ROTATION][X][Y][xDEPTH/BPP{,DEPTH/BPP}[xFREQ]] Specify screen characteristics\n"); ErrorF("-rgba rgb/bgr/vrgb/vbgr/none Specify subpixel ordering for LCD panels\n"); + ErrorF("-mouse driver [,n,,options] Specify the pointer driver and its options (n is the number of buttons)\n"); + ErrorF("-keybd driver [,,options] Specify the keyboard driver and its options\n"); ErrorF("-zaphod Disable cursor screen switching\n"); ErrorF("-2button Emulate 3 button mouse\n"); ErrorF("-3button Disable 3 button mouse emulation\n"); @@ -683,7 +608,6 @@ KdUseMsg (void) ErrorF("-softCursor Force software cursor\n"); ErrorF("-videoTest Start the server, pause momentarily and exit\n"); ErrorF("-origin X,Y Locates the next screen in the the virtual screen (Xinerama)\n"); - ErrorF("-mouse path[,n] Filename of mouse device, n is number of buttons\n"); ErrorF("-switchCmd Command to execute on vt switch\n"); ErrorF("-nozap Don't terminate server on Ctrl+Alt+Backspace\n"); ErrorF("vtxx Use virtual terminal xx instead of the next available\n"); @@ -736,6 +660,11 @@ KdProcessArgument (int argc, char **argv, int i) kdDontZap = TRUE; return 1; } + if (!strcmp (argv[i], "-nozap")) + { + kdDontZap = TRUE; + return 1; + } if (!strcmp (argv[i], "-3button")) { kdEmulateMiddleButton = FALSE; @@ -785,14 +714,6 @@ KdProcessArgument (int argc, char **argv, int i) UseMsg (); return 2; } - if (!strcmp (argv[i], "-mouse")) - { - if ((i+1) < argc) - KdParseMouse (argv[i+1]); - else - UseMsg (); - return 2; - } if (!strcmp (argv[i], "-rgba")) { if ((i+1) < argc) @@ -814,6 +735,22 @@ KdProcessArgument (int argc, char **argv, int i) { return 1; } + if (!strcmp (argv[i], "-mouse") || + !strcmp (argv[i], "-pointer")) { + if (i + 1 >= argc) + UseMsg(); + KdAddConfigPointer(argv[i + 1]); + kdHasPointer = TRUE; + return 2; + } + if (!strcmp (argv[i], "-keybd")) { + if (i + 1 >= argc) + UseMsg(); + KdAddConfigKeyboard(argv[i + 1]); + kdHasKbd = TRUE; + return 2; + } + #ifdef PSEUDO8 return p8ProcessArgument (argc, argv, i); #else @@ -835,7 +772,8 @@ KdOsInit (KdOsFuncs *pOsFuncs) if (serverGeneration == 1) { KdDoSwitchCmd ("start"); - (*pOsFuncs->Init) (); + if (pOsFuncs->Init) + (*pOsFuncs->Init) (); } } } @@ -1130,14 +1068,6 @@ KdScreenInit(int index, ScreenPtr pScreen, int argc, char **argv) pScreen->SaveScreen = KdSaveScreen; pScreen->CreateWindow = KdCreateWindow; -#ifdef FB_OLD_SCREEN - pScreenPriv->BackingStoreFuncs.SaveAreas = fbSaveAreas; - pScreenPriv->BackingStoreFuncs.RestoreAreas = fbSaveAreas; - pScreenPriv->BackingStoreFuncs.SetClipmaskRgn = 0; - pScreenPriv->BackingStoreFuncs.GetImagePixmap = 0; - pScreenPriv->BackingStoreFuncs.GetSpansPixmap = 0; -#endif - #if KD_MAX_FB > 1 if (screen->fb[1].depth) { @@ -1219,12 +1149,8 @@ KdScreenInit(int index, ScreenPtr pScreen, int argc, char **argv) #if 0 pScreen->backingStoreSupport = Always; -#ifdef FB_OLD_SCREEN - miInitializeBackingStore (pScreen, &pScreenPriv->BackingStoreFuncs); -#else miInitializeBackingStore (pScreen); #endif -#endif /* @@ -1420,6 +1346,39 @@ 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) +{ + kdCaughtSignal = TRUE; + FatalError("Segmentation fault caught\n"); +} +#endif + void KdInitOutput (ScreenInfo *pScreenInfo, int argc, @@ -1427,7 +1386,7 @@ KdInitOutput (ScreenInfo *pScreenInfo, { KdCardInfo *card; KdScreenInfo *screen; - + if (!kdCardInfo) { InitCard (0); @@ -1464,6 +1423,8 @@ KdInitOutput (ScreenInfo *pScreenInfo, for (card = kdCardInfo; card; card = card->next) for (screen = card->screenList; screen; screen = screen->next) KdAddScreen (pScreenInfo, screen, argc, argv); + + signal(SIGSEGV, KdBacktrace); } #ifdef DPMSExtension diff --git a/xserver/hw/xfree86/common/xf86AutoConfig.c b/xserver/hw/xfree86/common/xf86AutoConfig.c index a2c9c5d0e..daf28d9d7 100644 --- a/xserver/hw/xfree86/common/xf86AutoConfig.c +++ b/xserver/hw/xfree86/common/xf86AutoConfig.c @@ -160,12 +160,17 @@ videoPtrToDriverName(pciVideoPtr info) { /* * things not handled yet: - * amd/cyrix/nsc - * xgi + * cyrix/nsc. should be merged into geode anyway. + * xgi. */ switch (info->vendor) { + case 0x1022: + if (info->chipType == 0x2081) + return "amd"; + else + return NULL; case 0x1142: return "apm"; case 0xedd8: return "ark"; case 0x1a03: return "ast"; diff --git a/xserver/hw/xfree86/common/xf86Priv.h b/xserver/hw/xfree86/common/xf86Priv.h index e7c0a9f67..5a3cba38f 100644 --- a/xserver/hw/xfree86/common/xf86Priv.h +++ b/xserver/hw/xfree86/common/xf86Priv.h @@ -100,7 +100,6 @@ extern int xf86NumModuleInfos; extern int xf86NumDrivers; extern Bool xf86Resetting; extern Bool xf86Initialising; -extern Bool xf86ProbeFailed; extern int xf86NumScreens; extern pciVideoPtr *xf86PciVideoInfo; extern xf86CurrentAccessRec xf86CurrentAccess; @@ -120,7 +119,7 @@ extern RootWinPropPtr *xf86RegisteredPropertiesTable; #define DEFAULT_LOG_VERBOSE 3 #endif #ifndef DEFAULT_DPI -#define DEFAULT_DPI 75 +#define DEFAULT_DPI 96 #endif #define DEFAULT_UNRESOLVED TRUE @@ -155,7 +154,6 @@ extern int pciTestMultiDeviceCard(int bus, int dev, int func, PCITAG** pTag); /* xf86Config.c */ -Bool xf86PathIsAbsolute(const char *path); Bool xf86PathIsSafe(const char *path); /* xf86DefaultModes */ @@ -176,9 +174,6 @@ void xf86PostKbdEvent(unsigned key); void xf86PostMseEvent(DeviceIntPtr device, int buttons, int dx, int dy); void xf86Wakeup(pointer blockData, int err, pointer pReadmask); void xf86SigHandler(int signo); -#ifdef MEMDEBUG -void xf86SigMemDebug(int signo); -#endif void xf86HandlePMEvents(int fd, pointer data); extern int (*xf86PMGetEventFromOs)(int fd,pmEvent *events,int num); extern pmWait (*xf86PMConfirmEventToOs)(int fd,pmEvent event); @@ -193,20 +188,6 @@ Bool xf86LoadModules(char **list, pointer *optlist); int xf86SetVerbosity(int verb); int xf86SetLogVerbosity(int verb); -/* xf86Io.c */ - -void xf86KbdBell(int percent, DeviceIntPtr pKeyboard, pointer ctrl, - int unused); -void xf86KbdLeds(void); -void xf86UpdateKbdLeds(void); -void xf86KbdCtrl(DevicePtr pKeyboard, KeybdCtrl *ctrl); -void xf86InitKBD(Bool init); -int xf86KbdProc(DeviceIntPtr pKeyboard, int what); - -/* xf86Kbd.c */ - -void xf86KbdGetMapping(KeySymsPtr pKeySyms, CARD8 *pModMap); - /* xf86Lock.c */ #ifdef USE_XF86_SERVERLOCK @@ -217,6 +198,9 @@ void xf86UnlockServer(void); void xf86InitXkb(void); +/* xf86Xinput.c */ +extern xEvent *xf86Events; + #endif /* _NO_XF86_PROTOTYPES */ diff --git a/xserver/hw/xfree86/common/xf86Xinput.c b/xserver/hw/xfree86/common/xf86Xinput.c index 9dd185f94..36a408e12 100644 --- a/xserver/hw/xfree86/common/xf86Xinput.c +++ b/xserver/hw/xfree86/common/xf86Xinput.c @@ -116,7 +116,7 @@ _X_EXPORT void xf86ProcessCommonOptions(LocalDevicePtr local, pointer list) { - if (xf86SetBoolOption(list, "AlwaysCore", 0) || + if (!xf86SetBoolOption(list, "AlwaysCore", 1) || !xf86SetBoolOption(list, "SendCoreEvents", 1) || !xf86SetBoolOption(list, "CorePointer", 1) || !xf86SetBoolOption(list, "CoreKeyboard", 1)) { diff --git a/xserver/hw/xfree86/loader/os.c b/xserver/hw/xfree86/loader/os.c index 83fd24787..12cf3d859 100644 --- a/xserver/hw/xfree86/loader/os.c +++ b/xserver/hw/xfree86/loader/os.c @@ -42,6 +42,8 @@ #define OSNAME "linux" #elif defined(__FreeBSD__) #define OSNAME "freebsd" +#elif defined(__DragonFly__) +#define OSNAME "dragonfly" #elif defined(__NetBSD__) #define OSNAME "netbsd" #elif defined(__OpenBSD__) @@ -62,8 +64,6 @@ #define OSNAME "svr5" #elif defined(SVR4) #define OSNAME "svr4" -#elif defined(__UNIXOS2__) -#define OSNAME "os2" #else #define OSNAME "unknown" #endif diff --git a/xserver/hw/xfree86/modes/xf86Cursors.c b/xserver/hw/xfree86/modes/xf86Cursors.c index b5101642b..a7616e0e5 100644 --- a/xserver/hw/xfree86/modes/xf86Cursors.c +++ b/xserver/hw/xfree86/modes/xf86Cursors.c @@ -137,7 +137,8 @@ cursor_bitpos (int flags, int x, Bool mask) mask = !mask; if (flags & HARDWARE_CURSOR_NIBBLE_SWAPPED) x = (x & ~3) | (3 - (x & 3)); - if (flags & HARDWARE_CURSOR_BIT_ORDER_MSBFIRST) + if (((flags & HARDWARE_CURSOR_BIT_ORDER_MSBFIRST) == 0) == + (X_BYTE_ORDER == X_BIG_ENDIAN)) x = (x & ~7) | (7 - (x & 7)); if (flags & HARDWARE_CURSOR_SOURCE_MASK_INTERLEAVE_1) x = (x << 1) + mask; diff --git a/xserver/hw/xfree86/modes/xf86EdidModes.c b/xserver/hw/xfree86/modes/xf86EdidModes.c index 8b5e69d9a..e2ae66567 100644 --- a/xserver/hw/xfree86/modes/xf86EdidModes.c +++ b/xserver/hw/xfree86/modes/xf86EdidModes.c @@ -239,6 +239,12 @@ DDCModeFromDetailedTiming(int scrnIndex, struct detailed_timings *timing, Mode->VSyncEnd = Mode->VSyncStart + timing->v_sync_width; Mode->VTotal = timing->v_active + timing->v_blanking; + /* perform basic check on the detail timing */ + if (Mode->HSyncEnd > Mode->HTotal || Mode->VSyncEnd > Mode->VTotal) { + xfree(Mode); + return NULL; + } + xf86SetModeDefaultName(Mode); /* We ignore h/v_size and h/v_border for now. */ diff --git a/xserver/hw/xfree86/modes/xf86Rotate.c b/xserver/hw/xfree86/modes/xf86Rotate.c index cbef1351d..f442d92dd 100644 --- a/xserver/hw/xfree86/modes/xf86Rotate.c +++ b/xserver/hw/xfree86/modes/xf86Rotate.c @@ -582,7 +582,7 @@ xf86CrtcRotate (xf86CrtcPtr crtc, DisplayModePtr mode, Rotation rotation) int width, height, old_width, old_height; void *shadowData; PixmapPtr shadow; - PictureTransformTranslate (&crtc_to_fb, &fb_to_crtc, crtc->x, crtc->y); + PictureTransformTranslate (&crtc_to_fb, &fb_to_crtc, F(crtc->x), F(crtc->y)); PictureTransformIsInverse ("offset", &crtc_to_fb, &fb_to_crtc); /* diff --git a/xserver/hw/xfree86/os-support/bus/Pci.h b/xserver/hw/xfree86/os-support/bus/Pci.h index c9098b1b5..a6655bf57 100644 --- a/xserver/hw/xfree86/os-support/bus/Pci.h +++ b/xserver/hw/xfree86/os-support/bus/Pci.h @@ -235,7 +235,7 @@ # if defined(linux) # define ARCH_PCI_INIT axpPciInit # define INCLUDE_XF86_MAP_PCI_MEM -# elif defined(__FreeBSD__) || defined(__OpenBSD__) +# elif defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__DragonFly__) # define ARCH_PCI_INIT freebsdPciInit # define INCLUDE_XF86_MAP_PCI_MEM # define INCLUDE_XF86_NO_DOMAIN diff --git a/xserver/hw/xfree86/os-support/bus/freebsdPci.c b/xserver/hw/xfree86/os-support/bus/freebsdPci.c index 97782f296..062f9b5a1 100644 --- a/xserver/hw/xfree86/os-support/bus/freebsdPci.c +++ b/xserver/hw/xfree86/os-support/bus/freebsdPci.c @@ -83,7 +83,7 @@ static pciBusInfo_t freebsdPci0 = { /* bridge */ NULL }; -#if !defined(__OpenBSD__) && !defined(__FreeBSD__) +#if !defined(__OpenBSD__) && !defined(__FreeBSD__) && !defined(__DragonFly__) #if X_BYTE_ORDER == X_BIG_ENDIAN #ifdef __sparc__ #ifndef ASI_PL diff --git a/xserver/hw/xfree86/xaa/xaaGC.c b/xserver/hw/xfree86/xaa/xaaGC.c index e22081103..b3dc83ada 100644 --- a/xserver/hw/xfree86/xaa/xaaGC.c +++ b/xserver/hw/xfree86/xaa/xaaGC.c @@ -38,7 +38,7 @@ Bool XAACreateGC(GCPtr pGC) { ScreenPtr pScreen = pGC->pScreen; - XAAGCPtr pGCPriv = (XAAGCPtr)(pGC->devPrivates[XAAGCIndex].ptr); + XAAGCPtr pGCPriv = (XAAGCPtr)(pGC->devPrivates[XAAGetGCIndex()].ptr); Bool ret; XAA_SCREEN_PROLOGUE(pScreen,CreateGC); @@ -80,10 +80,11 @@ XAAValidateGC( } if(pGC->depth != 32) { - if(pGC->bgPixel == -1) /* -1 is reserved for transparency */ - pGC->bgPixel = 0x7fffffff; - if(pGC->fgPixel == -1) /* -1 is reserved for transparency */ - pGC->fgPixel = 0x7fffffff; + /* 0xffffffff is reserved for transparency */ + if(pGC->bgPixel == 0xffffffff) + pGC->bgPixel = 0x7fffffff; + if(pGC->fgPixel == 0xffffffff) + pGC->fgPixel = 0x7fffffff; } if((pDraw->type == DRAWABLE_PIXMAP) && !IS_OFFSCREEN_PIXMAP(pDraw)){ diff --git a/xserver/hw/xprint/Makefile.am b/xserver/hw/xprint/Makefile.am index f2d41467f..b9a7de070 100644 --- a/xserver/hw/xprint/Makefile.am +++ b/xserver/hw/xprint/Makefile.am @@ -12,7 +12,7 @@ Xprt_LDFLAGS = -L$(top_srcdir) Xprt_LDADD = @XPRINT_LIBS@ ps/libps.la raster/libraster.la \ pcl/libpcl.la pcl-mono/libpcl.la $(top_builddir)/fb/libfb.la \ $(top_builddir)/render/librender.la $(top_builddir)/mi/libmi.la \ - $(top_builddir)/Xext/libXext.la @FREETYPE_LIBS@ + $(top_builddir)/Xext/libXext.la @FREETYPE_LIBS@ @XSERVER_LIBS@ miinitext-wrapper.c: echo "#include \"$(top_srcdir)/mi/miinitext.c\"" >> $@ @@ -41,3 +41,5 @@ Xprt_SOURCES = \ $(top_srcdir)/fb/fbcmap_mi.c EXTRA_DIST = ValTree.c + +CLEANFILES = miinitext-wrapper.c dpmsstubs-wrapper.c diff --git a/xserver/hw/xprint/Makefile.in b/xserver/hw/xprint/Makefile.in index b9d933009..163d36a01 100644 --- a/xserver/hw/xprint/Makefile.in +++ b/xserver/hw/xprint/Makefile.in @@ -631,7 +631,7 @@ Xprt_LDFLAGS = -L$(top_srcdir) Xprt_LDADD = @XPRINT_LIBS@ ps/libps.la raster/libraster.la \ pcl/libpcl.la pcl-mono/libpcl.la $(top_builddir)/fb/libfb.la \ $(top_builddir)/render/librender.la $(top_builddir)/mi/libmi.la \ - $(top_builddir)/Xext/libXext.la @FREETYPE_LIBS@ + $(top_builddir)/Xext/libXext.la @FREETYPE_LIBS@ @XSERVER_LIBS@ Xprt_SOURCES = \ attributes.c \ @@ -654,6 +654,7 @@ Xprt_SOURCES = \ $(top_srcdir)/fb/fbcmap_mi.c EXTRA_DIST = ValTree.c +CLEANFILES = miinitext-wrapper.c dpmsstubs-wrapper.c all: all-recursive .SUFFIXES: @@ -1121,6 +1122,7 @@ install-strip: mostlyclean-generic: clean-generic: + -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES) distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) diff --git a/xserver/hw/xprint/ddxInit.c b/xserver/hw/xprint/ddxInit.c index 6cd3cfd3c..1e7652e60 100644 --- a/xserver/hw/xprint/ddxInit.c +++ b/xserver/hw/xprint/ddxInit.c @@ -89,6 +89,12 @@ InitOutput( } +void +DDXRingBell(int volume, int pitch, int duration) +{ + /* dummy func; link fails without */ +} + static void BellProc( int volume, @@ -156,9 +162,9 @@ PointerProc( { map[0] = 0; InitPointerDeviceStruct(pPtr, map, NUM_BUTTONS, - miPointerGetMotionEvents, + GetMotionHistory, (PtrCtrlProcPtr)_XpVoidNoop, - miPointerGetMotionBufferSize()); + GetMotionHistorySize(), 2); break; } case DEVICE_ON: @@ -189,7 +195,7 @@ InitInput( Bool LegalModifier( unsigned int key, - DevicePtr dev) + DeviceIntPtr dev) { return TRUE; } @@ -304,6 +310,17 @@ ChangeDeviceControl ( return BadMatch; } +int +NewInputDeviceRequest(InputOption *options, DeviceIntPtr *pdev) +{ + return BadValue; +} + +void +DeleteInputDeviceRequest(DeviceIntPtr dev) +{ +} + void OpenInputDevice ( DeviceIntPtr dev, diff --git a/xserver/include/do-not-use-config.h.in b/xserver/include/do-not-use-config.h.in index b2e3ab4ce..5635f0fe6 100644 --- a/xserver/include/do-not-use-config.h.in +++ b/xserver/include/do-not-use-config.h.in @@ -262,6 +262,9 @@ /* Define to 1 if you have the <SDL/SDL.h> header file. */ #undef HAVE_SDL_SDL_H +/* Define to 1 if the system has the type `socklen_t'. */ +#undef HAVE_SOCKLEN_T + /* Define to 1 if you have the <stdint.h> header file. */ #undef HAVE_STDINT_H diff --git a/xserver/include/xkbsrv.h b/xserver/include/xkbsrv.h index 7846ad8ef..acf3bb0a3 100644 --- a/xserver/include/xkbsrv.h +++ b/xserver/include/xkbsrv.h @@ -241,6 +241,14 @@ typedef struct _XkbSrvLedInfo { typedef struct { ProcessInputProc processInputProc; + /* If processInputProc is set to something different than realInputProc, + * UNWRAP and COND_WRAP will not touch processInputProc and update only + * realInputProc. This ensures that + * processInputProc == (frozen ? EnqueueEvent : realInputProc) + * + * WRAP_PROCESS_INPUT_PROC should only be called during initialization, + * since it may destroy this invariant. + */ ProcessInputProc realInputProc; DeviceUnwrapProc unwrapProc; } xkbDeviceInfoRec, *xkbDeviceInfoPtr; @@ -258,14 +266,14 @@ typedef struct device->public.processInputProc = proc; \ oldprocs->processInputProc = \ oldprocs->realInputProc = device->public.realInputProc; \ - if (proc != device->public.enqueueInputProc) \ - device->public.realInputProc = proc; \ + device->public.realInputProc = proc; \ oldprocs->unwrapProc = device->unwrapProc; \ device->unwrapProc = unwrapproc; #define UNWRAP_PROCESS_INPUT_PROC(device, oldprocs, backupproc) \ - backupproc = device->public.processInputProc; \ - device->public.processInputProc = oldprocs->processInputProc; \ + backupproc = device->public.realInputProc; \ + if (device->public.processInputProc == device->public.realInputProc)\ + device->public.processInputProc = oldprocs->realInputProc; \ device->public.realInputProc = oldprocs->realInputProc; \ device->unwrapProc = oldprocs->unwrapProc; diff --git a/xserver/os/connection.c b/xserver/os/connection.c index d963bb184..ba723d308 100644 --- a/xserver/os/connection.c +++ b/xserver/os/connection.c @@ -353,7 +353,8 @@ InitConnectionLimits(void) #endif #if !defined(WIN32) - ConnectionTranslation = (int *)xnfalloc(sizeof(int)*(lastfdesc + 1)); + if (!ConnectionTranslation) + ConnectionTranslation = (int *)xnfalloc(sizeof(int)*(lastfdesc + 1)); #else InitConnectionTranslation(); #endif diff --git a/xserver/os/io.c b/xserver/os/io.c index f6c666c0f..a8b84fb82 100644 --- a/xserver/os/io.c +++ b/xserver/os/io.c @@ -70,7 +70,7 @@ SOFTWARE. #include <X11/Xtrans/Xtrans.h> #include <X11/Xmd.h> #include <errno.h> -#if !defined(__UNIXOS2__) && !defined(WIN32) +#if !defined(WIN32) #ifndef Lynx #include <sys/uio.h> #else @@ -90,10 +90,14 @@ SOFTWARE. _X_EXPORT CallbackListPtr ReplyCallback; _X_EXPORT CallbackListPtr FlushCallback; +static ConnectionInputPtr AllocateInputBuffer(void); +static ConnectionOutputPtr AllocateOutputBuffer(void); +static xReqPtr PeekNextRequest(xReqPtr req, ClientPtr client, Bool readmore); +static void SkipRequests(xReqPtr req, ClientPtr client, int numskipped); + /* check for both EAGAIN and EWOULDBLOCK, because some supposedly POSIX * systems are broken and return EWOULDBLOCK when they should return EAGAIN */ -#ifndef __UNIXOS2__ #ifndef WIN32 #if defined(EAGAIN) && defined(EWOULDBLOCK) #define ETEST(err) (err == EAGAIN || err == EWOULDBLOCK) @@ -107,15 +111,12 @@ _X_EXPORT CallbackListPtr FlushCallback; #else /* WIN32 The socket errorcodes differ from the normal errors*/ #define ETEST(err) (err == EAGAIN || err == WSAEWOULDBLOCK) #endif -#else /* __UNIXOS2__ Writing to full pipes may return ENOSPC */ -#define ETEST(err) (err == EAGAIN || err == EWOULDBLOCK || err == ENOSPC) -#endif -Bool CriticalOutputPending; -int timesThisConnection = 0; -ConnectionInputPtr FreeInputs = (ConnectionInputPtr)NULL; -ConnectionOutputPtr FreeOutputs = (ConnectionOutputPtr)NULL; -OsCommPtr AvailableInput = (OsCommPtr)NULL; +static Bool CriticalOutputPending; +static int timesThisConnection = 0; +static ConnectionInputPtr FreeInputs = (ConnectionInputPtr)NULL; +static ConnectionOutputPtr FreeOutputs = (ConnectionOutputPtr)NULL; +static OsCommPtr AvailableInput = (OsCommPtr)NULL; #define get_req_len(req,cli) ((cli)->swapped ? \ lswaps((req)->length) : (req)->length) @@ -303,12 +304,14 @@ ReadRequestFromClient(ClientPtr client) */ oci->lenLastReq = 0; - if (needed > MAXBUFSIZE) +#ifdef BIGREQS + if (needed > maxBigRequestSize << 2) { /* request is too big for us to handle */ YieldControlDeath(); return -1; } +#endif if ((gotnow == 0) || ((oci->bufptr - oci->buffer + needed) > oci->size)) { @@ -635,7 +638,7 @@ ResetCurrentRequest(ClientPtr client) * **********************/ -xReqPtr +static xReqPtr PeekNextRequest( xReqPtr req, /* request we're starting from */ ClientPtr client, /* client whose requests we're skipping */ @@ -697,7 +700,7 @@ PeekNextRequest( _X_EXPORT CallbackListPtr SkippedRequestsCallback = NULL; -void +static void SkipRequests( xReqPtr req, /* last request being skipped */ ClientPtr client, /* client whose requests we're skipping */ @@ -1165,7 +1168,7 @@ FlushClient(ClientPtr who, OsCommPtr oc, char *extraBuf, int extraCount) return extraCount; /* return only the amount explicitly requested */ } -ConnectionInputPtr +static ConnectionInputPtr AllocateInputBuffer(void) { ConnectionInputPtr oci; @@ -1186,7 +1189,7 @@ AllocateInputBuffer(void) return oci; } -ConnectionOutputPtr +static ConnectionOutputPtr AllocateOutputBuffer(void) { ConnectionOutputPtr oco; @@ -1194,7 +1197,7 @@ AllocateOutputBuffer(void) oco = (ConnectionOutputPtr)xalloc(sizeof(ConnectionOutput)); if (!oco) return (ConnectionOutputPtr)NULL; - oco->buf = (unsigned char *) xalloc(BUFSIZE); + oco->buf = (unsigned char *) xcalloc(1, BUFSIZE); if (!oco->buf) { xfree(oco); diff --git a/xserver/os/privsep.c b/xserver/os/privsep.c index 0d018616a..e8f617a2b 100644 --- a/xserver/os/privsep.c +++ b/xserver/os/privsep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: privsep.c,v 1.8 2008/06/14 21:37:13 mbalmer Exp $ */ +/* $OpenBSD: privsep.c,v 1.9 2008/06/15 00:17:33 matthieu Exp $ */ /* * Copyright 2001 Niels Provos <provos@citi.umich.edu> * All rights reserved. @@ -298,6 +298,7 @@ int priv_open_device(const char *path) { priv_cmd_t cmd; + struct okdev *dev; if (priv_fd != -1) { cmd.cmd = PRIV_OPEN_DEVICE; diff --git a/xserver/os/utils.c b/xserver/os/utils.c index d0f6d4f3b..4772be8cf 100644 --- a/xserver/os/utils.c +++ b/xserver/os/utils.c @@ -285,7 +285,8 @@ OsSignal(sig, handler) sigaddset(&act.sa_mask, sig); act.sa_flags = 0; act.sa_handler = handler; - sigaction(sig, &act, &oact); + if (sigaction(sig, &act, &oact)) + perror("sigaction"); return oact.sa_handler; #endif } @@ -1703,6 +1704,10 @@ System(char *command) #ifdef SIGCHLD csig = signal(SIGCHLD, SIG_DFL); + if (csig == SIG_ERR) { + perror("signal"); + return -1; + } #endif #ifdef DEBUG @@ -1727,7 +1732,10 @@ System(char *command) } #ifdef SIGCHLD - signal(SIGCHLD, csig); + if (signal(SIGCHLD, csig) == SIG_ERR) { + perror("signal"); + return -1; + } #endif return p == -1 ? -1 : status; @@ -1739,6 +1747,8 @@ static struct pid { int pid; } *pidlist; +void (*old_alarm)(int) = NULL; /* XXX horrible awful hack */ + pointer Popen(char *command, char *type) { @@ -1760,11 +1770,20 @@ Popen(char *command, char *type) return NULL; } + /* Ignore the smart scheduler while this is going on */ + old_alarm = signal(SIGALRM, SIG_IGN); + if (old_alarm == SIG_ERR) { + perror("signal"); + return NULL; + } + switch (pid = fork()) { case -1: /* error */ close(pdes[0]); close(pdes[1]); xfree(cur); + if (signal(SIGALRM, old_alarm) == SIG_ERR) + perror("signal"); return NULL; case 0: /* child */ if (setgid(getgid()) == -1) @@ -1940,6 +1959,11 @@ Pclose(pointer iop) /* allow EINTR again */ OsReleaseSignals (); + if (old_alarm && signal(SIGALRM, old_alarm) == SIG_ERR) { + perror("signal"); + return -1; + } + return pid == -1 ? -1 : pstat; } diff --git a/xserver/xkb/ddxLoad.c b/xserver/xkb/ddxLoad.c index 5795f8b0d..eb03cde93 100644 --- a/xserver/xkb/ddxLoad.c +++ b/xserver/xkb/ddxLoad.c @@ -44,7 +44,7 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE. #include "scrnintstr.h" #include "windowstr.h" #define XKBSRV_NEED_FILE_FUNCS -#include <X11/extensions/XKBsrv.h> +#include <xkbsrv.h> #include <X11/extensions/XI.h> #include "xkb.h" @@ -77,7 +77,7 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE. #define POST_ERROR_MSG1 "\"Errors from xkbcomp are not fatal to the X server\"" #define POST_ERROR_MSG2 "\"End of messages from xkbcomp\"" -#if defined(__UNIXOS2__) || defined(WIN32) +#if defined(WIN32) #define PATHSEPARATOR "\\" #else #define PATHSEPARATOR "/" @@ -211,7 +211,7 @@ OutputDirectory( } } -Bool +static Bool XkbDDXCompileNamedKeymap( XkbDescPtr xkb, XkbComponentNamesPtr names, char * nameRtrn, @@ -239,20 +239,8 @@ char *cmd = NULL,file[PATH_MAX],xkm_output_dir[PATH_MAX],*map,*outFile; OutputDirectory(xkm_output_dir, sizeof(xkm_output_dir)); if (XkbBaseDirectory!=NULL) { -#ifndef __UNIXOS2__ char *xkbbasedir = XkbBaseDirectory; char *xkbbindir = XkbBinDirectory; -#else - /* relocate the basedir and replace the slashes with backslashes */ - char *xkbbasedir = (char*)__XOS2RedirRoot(XkbBaseDirectory); - char *xkbbindir = (char*)__XOS2RedirRoot(XkbBinDirectory); - int i; - - for (i=0; i<strlen(xkbbasedir); i++) - if (xkbbasedir[i]=='/') xkbbasedir[i]='\\'; - for (i=0; i<strlen(xkbbindir); i++) - if (xkbbindir[i]=='/') xkbbindir[i]='\\'; -#endif cmd = Xprintf("\"%s" PATHSEPARATOR "xkbcomp\" -w %d \"-R%s\" -xkm %s%s -em1 %s -emp %s -eml %s keymap/%s \"%s%s.xkm\"", xkbbindir, @@ -298,7 +286,7 @@ char *cmd = NULL,file[PATH_MAX],xkm_output_dir[PATH_MAX],*map,*outFile; return False; } -Bool +static Bool XkbDDXCompileKeymapByNames( XkbDescPtr xkb, XkbComponentNamesPtr names, unsigned want, @@ -338,18 +326,8 @@ char tmpname[PATH_MAX]; for xkbcomp. xkbcomp does not read from stdin. */ char *xkmfile = tmpname; #endif -#ifndef __UNIXOS2__ char *xkbbasedir = XkbBaseDirectory; char *xkbbindir = XkbBinDirectory; -#else - int i; - char *xkbbasedir = (char*)__XOS2RedirRoot(XkbBaseDirectory); - char *xkbbindir = (char*)__XOS2RedirRoot(XkbBinDirectory); - for (i=0; i<strlen(xkbbasedir); i++) - if (xkbbasedir[i]=='/') xkbbasedir[i]='\\'; - for (i=0; i<strlen(xkbbindir); i++) - if (xkbbindir[i]=='/') xkbbindir[i]='\\'; -#endif buf = Xprintf( "\"%s" PATHSEPARATOR "xkbcomp\" -w %d \"-R%s\" -xkm \"%s\" -em1 %s -emp %s -eml %s \"%s%s.xkm\"", @@ -403,52 +381,24 @@ char tmpname[PATH_MAX]; strncpy(nameRtrn,keymap,nameRtrnLen); nameRtrn[nameRtrnLen-1]= '\0'; } -#if defined(Lynx) && defined(__i386__) && defined(NEED_POPEN_WORKAROUND) - /* somehow popen/pclose is broken on LynxOS AT 2.3.0/2.4.0! - * the problem usually shows up with XF86Setup - * this hack waits at max 5 seconds after pclose() returns - * for the output of the xkbcomp output file. - * I didn't manage to get a patch in time for the 3.2 release - */ - { - int i; - char name[PATH_MAX]; - if (XkbBaseDirectory!=NULL) - sprintf(name,"%s/%s%s.xkm", XkbBaseDirectory - ,xkm_output_dir, keymap); - else - sprintf(name,"%s%s.xkm", xkm_output_dir, keymap); - for (i = 0; i < 10; i++) { - if (access(name, 0) == 0) break; - usleep(500000); - } -#ifdef DEBUG - if (i) ErrorF(">>>> Waited %d times for %s\n", i, name); -#endif - } -#endif if (buf != NULL) xfree (buf); return True; } -#ifdef DEBUG else - ErrorF("Error compiling keymap (%s)\n",keymap); -#endif + LogMessage(X_ERROR, "Error compiling keymap (%s)\n", keymap); #ifdef WIN32 /* remove the temporary file */ unlink(tmpname); #endif } -#ifdef DEBUG else { #ifndef WIN32 - ErrorF("Could not invoke keymap compiler\n"); + LogMessage(X_ERROR, "XKB: Could not invoke xkbcomp\n"); #else - ErrorF("Could not open file %s\n", tmpname); + LogMessage(X_ERROR, "Could not open file %s\n", tmpname); #endif } -#endif if (nameRtrn) nameRtrn[0]= '\0'; if (buf != NULL) @@ -456,7 +406,7 @@ char tmpname[PATH_MAX]; return False; } -FILE * +static FILE * XkbDDXOpenConfigFile(char *mapName,char *fileNameRtrn,int fileNameRtrnLen) { char buf[PATH_MAX],xkm_output_dir[PATH_MAX]; @@ -523,17 +473,14 @@ unsigned missing; return 0; } else if (!XkbDDXCompileNamedKeymap(xkb,names,nameRtrn,nameRtrnLen)) { -#ifdef NOISY - ErrorF("Couldn't compile keymap file\n"); -#endif + LogMessage(X_ERROR, "Couldn't compile keymap file %s\n", + names->keymap); return 0; } } else if (!XkbDDXCompileKeymapByNames(xkb,names,want,need, - nameRtrn,nameRtrnLen)){ -#ifdef NOISY - ErrorF("Couldn't compile keymap file\n"); -#endif + nameRtrn,nameRtrnLen)){ + LogMessage(X_ERROR, "XKB: Couldn't compile keymap\n"); return 0; } file= XkbDDXOpenConfigFile(nameRtrn,fileName,PATH_MAX); @@ -548,11 +495,9 @@ unsigned missing; (void) unlink (fileName); return 0; } -#ifdef DEBUG - else if (xkbDebugFlags) { - ErrorF("Loaded %s, defined=0x%x\n",fileName,finfoRtrn->defined); + else { + DebugF("XKB: Loaded %s, defined=0x%x\n",fileName,finfoRtrn->defined); } -#endif fclose(file); (void) unlink (fileName); return (need|want)&(~missing); @@ -571,32 +516,40 @@ XkbRF_RulesPtr rules; if (!rules_name) return False; - if (XkbBaseDirectory==NULL) { - if (strlen(rules_name)+7 > PATH_MAX) - return False; - sprintf(buf,"rules/%s",rules_name); - } - else { - if (strlen(XkbBaseDirectory)+strlen(rules_name)+8 > PATH_MAX) - return False; - sprintf(buf,"%s/rules/%s",XkbBaseDirectory,rules_name); + + if (strlen(XkbBaseDirectory) + strlen(rules_name) + 8 > PATH_MAX) { + LogMessage(X_ERROR, "XKB: Rules name is too long\n"); + return False; } - if ((file= fopen(buf,"r"))==NULL) + sprintf(buf,"%s/rules/%s", XkbBaseDirectory, rules_name); + + file = fopen(buf, "r"); + if (!file) { + LogMessage(X_ERROR, "XKB: Couldn't open rules file %s\n", buf); return False; - if ((rules= XkbRF_Create(0,0))==NULL) { + } + + rules = XkbRF_Create(0, 0); + if (!rules) { + LogMessage(X_ERROR, "XKB: Couldn't create rules struct\n"); fclose(file); return False; } - if (!XkbRF_LoadRules(file,rules)) { + + if (!XkbRF_LoadRules(file, rules)) { + LogMessage(X_ERROR, "XKB: Couldn't parse rules file %s\n", rules_name); fclose(file); XkbRF_Free(rules,True); return False; } - bzero((char *)names,sizeof(XkbComponentNamesRec)); - complete= XkbRF_GetComponents(rules,defs,names); + + memset(names, 0, sizeof(*names)); + complete = XkbRF_GetComponents(rules,defs,names); fclose(file); - XkbRF_Free(rules,True); - return complete; -} + XkbRF_Free(rules, True); + if (!complete) + LogMessage(X_ERROR, "XKB: Rules returned no components\n"); + return complete; +} diff --git a/xserver/xkb/xkbActions.c b/xserver/xkb/xkbActions.c index 0cbf8d007..59d34c5fd 100644 --- a/xserver/xkb/xkbActions.c +++ b/xserver/xkb/xkbActions.c @@ -36,9 +36,11 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE. #include <X11/keysym.h> #include "misc.h" #include "inputstr.h" -#include <X11/extensions/XKBsrv.h> +#include "exevents.h" +#include <xkbsrv.h> #include "xkb.h" #include <ctype.h> +#define EXTENSION_EVENT_BASE 64 static unsigned int _xkbServerGeneration; int xkbDevicePrivateIndex = -1; @@ -48,14 +50,14 @@ xkbUnwrapProc(DeviceIntPtr device, DeviceHandleProc proc, pointer data) { xkbDeviceInfoPtr xkbPrivPtr = XKBDEVICEINFO(device); - ProcessInputProc tmp = device->public.processInputProc; + ProcessInputProc backupproc; if(xkbPrivPtr->unwrapProc) xkbPrivPtr->unwrapProc = NULL; - UNWRAP_PROCESS_INPUT_PROC(device,xkbPrivPtr); + UNWRAP_PROCESS_INPUT_PROC(device,xkbPrivPtr, backupproc); proc(device,data); - WRAP_PROCESS_INPUT_PROC(device,xkbPrivPtr, - tmp,xkbUnwrapProc); + COND_WRAP_PROCESS_INPUT_PROC(device,xkbPrivPtr, + backupproc,xkbUnwrapProc); } @@ -72,23 +74,20 @@ XkbSetExtension(DeviceIntPtr device, ProcessInputProc proc) if (!AllocateDevicePrivate(device, xkbDevicePrivateIndex)) return; - xkbPrivPtr = (xkbDeviceInfoPtr) xalloc(sizeof(xkbDeviceInfoRec)); + xkbPrivPtr = (xkbDeviceInfoPtr) xcalloc(1, sizeof(xkbDeviceInfoRec)); if (!xkbPrivPtr) return; xkbPrivPtr->unwrapProc = NULL; device->devPrivates[xkbDevicePrivateIndex].ptr = xkbPrivPtr; - WRAP_PROCESS_INPUT_PROC(device,xkbPrivPtr, - proc,xkbUnwrapProc); + WRAP_PROCESS_INPUT_PROC(device, xkbPrivPtr, proc, xkbUnwrapProc); } -#ifdef XINPUT extern void ProcessOtherEvent( xEvent * /* xE */, DeviceIntPtr /* dev */, int /* count */ ); -#endif /***====================================================================***/ @@ -216,7 +215,7 @@ static XkbAction fake; return fake; } -XkbAction +static XkbAction XkbGetButtonAction(DeviceIntPtr kbd,DeviceIntPtr dev,int button) { XkbAction fake; @@ -236,22 +235,6 @@ XkbAction fake; #define SYNTHETIC_KEYCODE 1 #define BTN_ACT_FLAG 0x100 -typedef struct _XkbFilter { - CARD16 keycode; - CARD8 what; - CARD8 active; - CARD8 filterOthers; - CARD32 priv; - XkbAction upAction; - int (*filter)( - XkbSrvInfoPtr /* xkbi */, - struct _XkbFilter * /* filter */, - unsigned /* keycode */, - XkbAction * /* action */ - ); - struct _XkbFilter *next; -} XkbFilterRec,*XkbFilterPtr; - static int _XkbFilterSetState( XkbSrvInfoPtr xkbi, XkbFilterPtr filter, @@ -416,7 +399,6 @@ _XkbFilterLockState( XkbSrvInfoPtr xkbi, unsigned keycode, XkbAction * pAction) { - if (pAction&&(pAction->type==XkbSA_LockGroup)) { if (pAction->group.flags&XkbSA_GroupAbsolute) xkbi->state.locked_group= XkbSAGroup(&pAction->group); @@ -578,6 +560,9 @@ _XkbFilterPointerMove( XkbSrvInfoPtr xkbi, int x,y; Bool accel; + if (xkbi->device == inputInfo.keyboard) + return 0; + if (filter->keycode==0) { /* initial press */ filter->keycode = keycode; filter->active = 1; @@ -618,6 +603,9 @@ _XkbFilterPointerBtn( XkbSrvInfoPtr xkbi, unsigned keycode, XkbAction * pAction) { + if (xkbi->device == inputInfo.keyboard) + return 0; + if (filter->keycode==0) { /* initial press */ int button= pAction->btn.button; @@ -688,6 +676,7 @@ _XkbFilterPointerBtn( XkbSrvInfoPtr xkbi, &old,xkbi->desc->ctrls, &cn,False)) { cn.keycode = keycode; + /* XXX: what about DeviceKeyPress? */ cn.eventType = KeyPress; cn.requestMajor = 0; cn.requestMinor = 0; @@ -752,6 +741,7 @@ XkbEventCauseRec cause; ctrls->enabled_ctrls|= change; if (XkbComputeControlsNotify(kbd,&old,ctrls,&cn,False)) { cn.keycode = keycode; + /* XXX: what about DeviceKeyPress? */ cn.eventType = KeyPress; cn.requestMajor = 0; cn.requestMinor = 0; @@ -867,6 +857,11 @@ int x,y; XkbStateRec old; unsigned mods,mask,oldCoreState = 0,oldCorePrevState = 0; xkbDeviceInfoPtr xkbPrivPtr = XKBDEVICEINFO(xkbi->device); +ProcessInputProc backupproc; + + /* never actually used uninitialised, but gcc isn't smart enough + * to work that out. */ + memset(&old, 0, sizeof(old)); if ((filter->keycode!=0)&&(filter->keycode!=keycode)) return 1; @@ -888,6 +883,7 @@ xkbDeviceInfoPtr xkbPrivPtr = XKBDEVICEINFO(xkbi->device); filter->filter = _XkbFilterRedirectKey; filter->upAction = *pAction; + /* XXX: what about DeviceKeyPress */ ev.u.u.type = KeyPress; ev.u.u.detail = pAction->redirect.new_key; @@ -915,10 +911,14 @@ xkbDeviceInfoPtr xkbPrivPtr = XKBDEVICEINFO(xkbi->device); realMods = xkbi->device->key->modifierMap[ev.u.u.detail]; xkbi->device->key->modifierMap[ev.u.u.detail] = 0; - UNWRAP_PROCESS_INPUT_PROC(xkbi->device,xkbPrivPtr); + /* XXX: Bad! Since the switch to XI devices xkbi->device will be the + * XI device. Sending a core event through ProcessOtherEvent will + * cause trouble. Somebody should fix this. + */ + UNWRAP_PROCESS_INPUT_PROC(xkbi->device,xkbPrivPtr, backupproc); xkbi->device->public.processInputProc(&ev,xkbi->device,1); COND_WRAP_PROCESS_INPUT_PROC(xkbi->device, xkbPrivPtr, - ProcessKeyboardEvent,xkbUnwrapProc); + backupproc,xkbUnwrapProc); xkbi->device->key->modifierMap[ev.u.u.detail] = realMods; if ( mask || mods ) { @@ -929,6 +929,7 @@ xkbDeviceInfoPtr xkbPrivPtr = XKBDEVICEINFO(xkbi->device); } else if (filter->keycode==keycode) { + /* XXX: what about DeviceKeyRelease */ ev.u.u.type = KeyRelease; ev.u.u.detail = filter->upAction.redirect.new_key; @@ -956,10 +957,14 @@ xkbDeviceInfoPtr xkbPrivPtr = XKBDEVICEINFO(xkbi->device); realMods = xkbi->device->key->modifierMap[ev.u.u.detail]; xkbi->device->key->modifierMap[ev.u.u.detail] = 0; - UNWRAP_PROCESS_INPUT_PROC(xkbi->device,xkbPrivPtr); + /* XXX: Bad! Since the switch to XI devices xkbi->device will be the + * XI device. Sending a core event through ProcessOtherEvent will + * cause trouble. Somebody should fix this. + */ + UNWRAP_PROCESS_INPUT_PROC(xkbi->device,xkbPrivPtr, backupproc); xkbi->device->public.processInputProc(&ev,xkbi->device,1); COND_WRAP_PROCESS_INPUT_PROC(xkbi->device, xkbPrivPtr, - ProcessKeyboardEvent,xkbUnwrapProc); + backupproc,xkbUnwrapProc); xkbi->device->key->modifierMap[ev.u.u.detail] = realMods; if ( mask || mods ) { @@ -980,8 +985,11 @@ _XkbFilterSwitchScreen( XkbSrvInfoPtr xkbi, unsigned keycode, XkbAction * pAction) { + DeviceIntPtr dev = xkbi->device; + if (dev == inputInfo.keyboard) + return 0; + if (filter->keycode==0) { /* initial press */ - DeviceIntPtr dev = xkbi->device; filter->keycode = keycode; filter->active = 1; filter->filterOthers = 0; @@ -1003,8 +1011,11 @@ _XkbFilterXF86Private( XkbSrvInfoPtr xkbi, unsigned keycode, XkbAction * pAction) { + DeviceIntPtr dev = xkbi->device; + if (dev == inputInfo.keyboard) + return 0; + if (filter->keycode==0) { /* initial press */ - DeviceIntPtr dev = xkbi->device; filter->keycode = keycode; filter->active = 1; filter->filterOthers = 0; @@ -1019,7 +1030,6 @@ _XkbFilterXF86Private( XkbSrvInfoPtr xkbi, return 1; } -#ifdef XINPUT static int _XkbFilterDeviceBtn( XkbSrvInfoPtr xkbi, @@ -1030,6 +1040,9 @@ _XkbFilterDeviceBtn( XkbSrvInfoPtr xkbi, DeviceIntPtr dev; int button; + if (dev == inputInfo.keyboard) + return 0; + if (filter->keycode==0) { /* initial press */ dev= _XkbLookupButtonDevice(pAction->devbtn.device,NULL); if ((!dev)||(!dev->public.on)||(&dev->public==LookupPointerDevice())) @@ -1091,34 +1104,33 @@ int button; } return 0; } -#endif - -static int szFilters = 0; -static XkbFilterPtr filters = NULL; static XkbFilterPtr _XkbNextFreeFilter( - void + XkbSrvInfoPtr xkbi ) { register int i; - if (szFilters==0) { - szFilters = 4; - filters = _XkbTypedCalloc(szFilters,XkbFilterRec); + if (xkbi->szFilters==0) { + xkbi->szFilters = 4; + xkbi->filters = _XkbTypedCalloc(xkbi->szFilters,XkbFilterRec); /* 6/21/93 (ef) -- XXX! deal with allocation failure */ } - for (i=0;i<szFilters;i++) { - if (!filters[i].active) { - filters[i].keycode = 0; - return &filters[i]; + for (i=0;i<xkbi->szFilters;i++) { + if (!xkbi->filters[i].active) { + xkbi->filters[i].keycode = 0; + return &xkbi->filters[i]; } } - szFilters*=2; - filters= _XkbTypedRealloc(filters,szFilters,XkbFilterRec); + xkbi->szFilters*=2; + xkbi->filters= _XkbTypedRealloc(xkbi->filters, + xkbi->szFilters, + XkbFilterRec); /* 6/21/93 (ef) -- XXX! deal with allocation failure */ - bzero(&filters[szFilters/2],(szFilters/2)*sizeof(XkbFilterRec)); - return &filters[szFilters/2]; + bzero(&xkbi->filters[xkbi->szFilters/2], + (xkbi->szFilters/2)*sizeof(XkbFilterRec)); + return &xkbi->filters[xkbi->szFilters/2]; } static int @@ -1127,9 +1139,10 @@ _XkbApplyFilters(XkbSrvInfoPtr xkbi,unsigned kc,XkbAction *pAction) register int i,send; send= 1; - for (i=0;i<szFilters;i++) { - if ((filters[i].active)&&(filters[i].filter)) - send= ((*filters[i].filter)(xkbi,&filters[i],kc,pAction)&&send); + for (i=0;i<xkbi->szFilters;i++) { + if ((xkbi->filters[i].active)&&(xkbi->filters[i].filter)) + send= ((*xkbi->filters[i].filter)(xkbi,&xkbi->filters[i],kc,pAction) + && send); } return send; } @@ -1148,15 +1161,15 @@ XkbAction act; XkbFilterPtr filter; Bool keyEvent; Bool pressEvent; -#ifdef XINPUT -Bool xiEvent; -#endif +ProcessInputProc backupproc; xkbDeviceInfoPtr xkbPrivPtr = XKBDEVICEINFO(dev); keyc= kbd->key; xkbi= keyc->xkbInfo; key= xE->u.u.detail; + /* The state may change, so if we're not in the middle of sending a state + * notify, prepare for it */ if ((xkbi->flags&_XkbStateNotifyInProgress)==0) { oldState= xkbi->state; xkbi->flags|= _XkbStateNotifyInProgress; @@ -1168,18 +1181,10 @@ xkbDeviceInfoPtr xkbPrivPtr = XKBDEVICEINFO(dev); xkbi->groupChange = 0; sendEvent = 1; -#ifdef XINPUT keyEvent= ((xE->u.u.type==KeyPress)||(xE->u.u.type==DeviceKeyPress)|| (xE->u.u.type==KeyRelease)||(xE->u.u.type==DeviceKeyRelease)); pressEvent= (xE->u.u.type==KeyPress)||(xE->u.u.type==DeviceKeyPress)|| (xE->u.u.type==ButtonPress)||(xE->u.u.type==DeviceButtonPress); - xiEvent= (xE->u.u.type==DeviceKeyPress)||(xE->u.u.type==DeviceKeyRelease)|| - (xE->u.u.type==DeviceButtonPress)|| - (xE->u.u.type==DeviceButtonRelease); -#else - keyEvent= (xE->u.u.type==KeyPress)||(xE->u.u.type==KeyRelease); - pressEvent= (xE->u.u.type==KeyPress)||(xE->u.u.type==ButtonPress); -#endif if (pressEvent) { if (keyEvent) @@ -1193,62 +1198,60 @@ xkbDeviceInfoPtr xkbPrivPtr = XKBDEVICEINFO(dev); switch (act.type) { case XkbSA_SetMods: case XkbSA_SetGroup: - filter = _XkbNextFreeFilter(); + filter = _XkbNextFreeFilter(xkbi); sendEvent = _XkbFilterSetState(xkbi,filter,key,&act); break; case XkbSA_LatchMods: case XkbSA_LatchGroup: - filter = _XkbNextFreeFilter(); + filter = _XkbNextFreeFilter(xkbi); sendEvent=_XkbFilterLatchState(xkbi,filter,key,&act); break; case XkbSA_LockMods: case XkbSA_LockGroup: - filter = _XkbNextFreeFilter(); + filter = _XkbNextFreeFilter(xkbi); sendEvent=_XkbFilterLockState(xkbi,filter,key,&act); break; case XkbSA_ISOLock: - filter = _XkbNextFreeFilter(); + filter = _XkbNextFreeFilter(xkbi); sendEvent=_XkbFilterISOLock(xkbi,filter,key,&act); break; case XkbSA_MovePtr: - filter = _XkbNextFreeFilter(); + filter = _XkbNextFreeFilter(xkbi); sendEvent= _XkbFilterPointerMove(xkbi,filter,key,&act); break; case XkbSA_PtrBtn: case XkbSA_LockPtrBtn: case XkbSA_SetPtrDflt: - filter = _XkbNextFreeFilter(); + filter = _XkbNextFreeFilter(xkbi); sendEvent= _XkbFilterPointerBtn(xkbi,filter,key,&act); break; case XkbSA_Terminate: sendEvent= XkbDDXTerminateServer(dev,key,&act); break; case XkbSA_SwitchScreen: - filter = _XkbNextFreeFilter(); + filter = _XkbNextFreeFilter(xkbi); sendEvent=_XkbFilterSwitchScreen(xkbi,filter,key,&act); break; case XkbSA_SetControls: case XkbSA_LockControls: - filter = _XkbNextFreeFilter(); + filter = _XkbNextFreeFilter(xkbi); sendEvent=_XkbFilterControls(xkbi,filter,key,&act); break; case XkbSA_ActionMessage: - filter = _XkbNextFreeFilter(); + filter = _XkbNextFreeFilter(xkbi); sendEvent=_XkbFilterActionMessage(xkbi,filter,key,&act); break; case XkbSA_RedirectKey: - filter = _XkbNextFreeFilter(); + filter = _XkbNextFreeFilter(xkbi); sendEvent= _XkbFilterRedirectKey(xkbi,filter,key,&act); break; -#ifdef XINPUT case XkbSA_DeviceBtn: case XkbSA_LockDeviceBtn: - filter = _XkbNextFreeFilter(); + filter = _XkbNextFreeFilter(xkbi); sendEvent= _XkbFilterDeviceBtn(xkbi,filter,key,&act); break; -#endif case XkbSA_XFree86Private: - filter = _XkbNextFreeFilter(); + filter = _XkbNextFreeFilter(xkbi); sendEvent= _XkbFilterXF86Private(xkbi,filter,key,&act); break; } @@ -1285,24 +1288,21 @@ xkbDeviceInfoPtr xkbPrivPtr = XKBDEVICEINFO(dev); } if (sendEvent) { -#ifdef XINPUT - if (xiEvent) - ProcessOtherEvent(xE,dev,count); - else -#endif if (keyEvent) { realMods = keyc->modifierMap[key]; keyc->modifierMap[key] = 0; - UNWRAP_PROCESS_INPUT_PROC(dev,xkbPrivPtr); - dev->public.processInputProc(xE,dev,count); - COND_WRAP_PROCESS_INPUT_PROC(dev, xkbPrivPtr, - ProcessKeyboardEvent,xkbUnwrapProc); + } + + UNWRAP_PROCESS_INPUT_PROC(dev,xkbPrivPtr, backupproc); + dev->public.processInputProc(xE,dev,count); + COND_WRAP_PROCESS_INPUT_PROC(dev, xkbPrivPtr, + backupproc,xkbUnwrapProc); + if (keyEvent) keyc->modifierMap[key] = realMods; - } - else CoreProcessPointerEvent(xE,dev,count); } - else if (keyEvent) + else if (keyEvent) { FixKeyState(xE,dev); + } xkbi->prev_state= oldState; XkbComputeDerivedState(xkbi); @@ -1324,7 +1324,7 @@ xkbDeviceInfoPtr xkbPrivPtr = XKBDEVICEINFO(dev); if (changed) { XkbEventCauseRec cause; XkbSetCauseKey(&cause,key,xE->u.u.type); - XkbUpdateIndicators(dev,changed,True,NULL,&cause); + XkbUpdateIndicators(dev,changed,False,NULL,&cause); } return; } @@ -1348,7 +1348,7 @@ unsigned clear; act.type = XkbSA_LatchMods; act.mods.flags = 0; act.mods.mask = mask&latches; - filter = _XkbNextFreeFilter(); + filter = _XkbNextFreeFilter(xkbi); _XkbFilterLatchState(xkbi,filter,SYNTHETIC_KEYCODE,&act); _XkbFilterLatchState(xkbi,filter,SYNTHETIC_KEYCODE,(XkbAction *)NULL); return Success; @@ -1368,7 +1368,7 @@ XkbAction act; act.type = XkbSA_LatchGroup; act.group.flags = 0; XkbSASetGroup(&act.group,group); - filter = _XkbNextFreeFilter(); + filter = _XkbNextFreeFilter(xkbi); _XkbFilterLatchState(xkbi,filter,SYNTHETIC_KEYCODE,&act); _XkbFilterLatchState(xkbi,filter,SYNTHETIC_KEYCODE,(XkbAction *)NULL); return Success; diff --git a/xserver/xkb/xkbUtils.c b/xserver/xkb/xkbUtils.c index 26ff35e89..ce4df4c30 100644 --- a/xserver/xkb/xkbUtils.c +++ b/xserver/xkb/xkbUtils.c @@ -28,6 +28,7 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE. #include <dix-config.h> #endif +#include "os.h" #include <stdio.h> #include <ctype.h> #include <math.h> @@ -40,28 +41,14 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE. #include "inputstr.h" #define XKBSRV_NEED_FILE_FUNCS -#include <X11/extensions/XKBsrv.h> +#include <xkbsrv.h> #include <X11/extensions/XKBgeom.h> #include "xkb.h" -#ifdef MODE_SWITCH -extern Bool noKME; /* defined in os/utils.c */ -#endif - int XkbDisableLockActions = 0; /***====================================================================***/ -#ifndef RETURN_SHOULD_REPEAT -#if (defined(__osf__) && defined(__alpha)) -#define RETURN_SHOULD_REPEAT 1 -#else -#define RETURN_SHOULD_REPEAT 0 -#endif -#endif - -/***====================================================================***/ - DeviceIntPtr _XkbLookupAnyDevice(int id,int *why_rtrn) { @@ -91,6 +78,8 @@ _XkbLookupKeyboard(int id,int *why_rtrn) { DeviceIntPtr dev = NULL; + if (id == XkbDfltXIId) + id = XkbUseCoreKbd; if ((dev= _XkbLookupAnyDevice(id,why_rtrn))==NULL) return NULL; else if ((!dev->key)||(!dev->key->xkbInfo)) { @@ -121,6 +110,8 @@ _XkbLookupLedDevice(int id,int *why_rtrn) { DeviceIntPtr dev = NULL; + if (id == XkbDfltXIId) + id = XkbUseCorePtr; if ((dev= _XkbLookupAnyDevice(id,why_rtrn))==NULL) return NULL; else if ((!dev->kbdfeed)&&(!dev->leds)) { @@ -181,44 +172,6 @@ register unsigned mask; return mask; } - -Bool -XkbApplyVModChanges( XkbSrvInfoPtr xkbi, - unsigned changed, - XkbChangesPtr changes, - unsigned * needChecksRtrn, - XkbEventCausePtr cause) -{ -XkbDescPtr xkb; -Bool check; - - xkb= xkbi->desc; -#ifdef DEBUG -{ -register unsigned i,bit; - for (i=0,bit=1;i<XkbNumVirtualMods;i++,bit<<=1) { - if ((changed&bit)==0) - continue; - if (xkbDebugFlags) - ErrorF("Should be applying: change vmod %d to 0x%x\n",i, - xkb->server->vmods[i]); - } -} -#endif - check= XkbApplyVirtualModChanges(xkb,changed,changes); - XkbApplyVModChangesToAllDevices(xkbi->device,xkb,changed,cause); - - if (needChecksRtrn!=NULL) { - if (check) - *needChecksRtrn= XkbStateNotifyMask|XkbIndicatorStateNotifyMask; - else *needChecksRtrn= 0; - } - else if (check) { - /* 7/12/95 (ef) -- XXX check compatibility and/or indicator state */ - } - return 1; -} - /***====================================================================***/ void @@ -241,7 +194,7 @@ XkbMapChangesPtr mc; xkb->min_key_code= first; /* 1/12/95 (ef) -- XXX! should zero out the new maps */ changes->map.changed|= XkbKeycodesMask; -generate a NewKeyboard notify here? +/* generate a NewKeyboard notify here? */ } } #endif @@ -559,12 +512,6 @@ CARD8 keysPerMod[XkbNumModifiers]; } } } -#ifdef MODE_SWITCH - /* Fix up any of the KME stuff if we changed the core description. - */ - if (!noKME) - HandleKeyBinding(keyc, &keyc->curKeySyms); -#endif return; } @@ -673,7 +620,7 @@ int changed; return changed; } -void +static void XkbComputeCompatState(XkbSrvInfoPtr xkbi) { CARD16 grp_mask; @@ -787,21 +734,6 @@ XkbCheckSecondaryEffects( XkbSrvInfoPtr xkbi, /***====================================================================***/ -void -XkbSetPhysicalLockingKey(DeviceIntPtr dev,unsigned key) -{ -XkbDescPtr xkb; - - xkb= dev->key->xkbInfo->desc; - if ((key>=xkb->min_key_code) && (key<=xkb->max_key_code)) { - xkb->server->behaviors[key].type= XkbKB_Lock|XkbKB_Permanent; - } - else ErrorF("Internal Error! Bad XKB info in SetPhysicalLockingKey\n"); - return; -} - -/***====================================================================***/ - Bool XkbEnableDisableControls( XkbSrvInfoPtr xkbi, unsigned long change, @@ -969,3 +901,1169 @@ XkbConvertCase(register KeySym sym, KeySym *lower, KeySym *upper) break; } } + + +/** + * Copy an XKB map from src to dst, reallocating when necessary: if some + * map components are present in one, but not in the other, the destination + * components will be allocated or freed as necessary. + * + * Basic map consistency is assumed on both sides, so maps with random + * uninitialised data (e.g. names->radio_grous == NULL, names->num_rg == 19) + * _will_ cause failures. You've been warned. + * + * Returns TRUE on success, or FALSE on failure. If this function fails, + * dst may be in an inconsistent state: all its pointers are guaranteed + * to remain valid, but part of the map may be from src and part from dst. + * + * FIXME: This function wants to be broken up into multiple functions. + */ +Bool +XkbCopyKeymap(XkbDescPtr src, XkbDescPtr dst, Bool sendNotifies) +{ + int i = 0, j = 0, k = 0; + void *tmp = NULL; + XkbColorPtr scolor = NULL, dcolor = NULL; + XkbDoodadPtr sdoodad = NULL, ddoodad = NULL; + XkbKeyTypePtr stype = NULL, dtype = NULL; + XkbOutlinePtr soutline = NULL, doutline = NULL; + XkbPropertyPtr sprop = NULL, dprop = NULL; + XkbRowPtr srow = NULL, drow = NULL; + XkbSectionPtr ssection = NULL, dsection = NULL; + XkbShapePtr sshape = NULL, dshape = NULL; + DeviceIntPtr pDev = NULL, tmpDev = NULL; + xkbMapNotify mn; + xkbNewKeyboardNotify nkn; + + if (!src || !dst || src == dst) + return FALSE; + + /* client map */ + if (src->map) { + if (!dst->map) { + tmp = xcalloc(1, sizeof(XkbClientMapRec)); + if (!tmp) + return FALSE; + dst->map = tmp; + } + + if (src->map->syms) { + if (src->map->size_syms != dst->map->size_syms) { + if (dst->map->syms) + tmp = xrealloc(dst->map->syms, + src->map->size_syms * sizeof(KeySym)); + else + tmp = xalloc(src->map->size_syms * sizeof(KeySym)); + if (!tmp) + return FALSE; + dst->map->syms = tmp; + + } + memcpy(dst->map->syms, src->map->syms, + src->map->size_syms * sizeof(KeySym)); + } + else { + if (dst->map->syms) { + xfree(dst->map->syms); + dst->map->syms = NULL; + } + } + dst->map->num_syms = src->map->num_syms; + dst->map->size_syms = src->map->size_syms; + + if (src->map->key_sym_map) { + if (src->max_key_code != dst->max_key_code) { + if (dst->map->key_sym_map) + tmp = xrealloc(dst->map->key_sym_map, + (src->max_key_code + 1) * + sizeof(XkbSymMapRec)); + else + tmp = xalloc((src->max_key_code + 1) * + sizeof(XkbSymMapRec)); + if (!tmp) + return FALSE; + dst->map->key_sym_map = tmp; + } + memcpy(dst->map->key_sym_map, src->map->key_sym_map, + (src->max_key_code + 1) * sizeof(XkbSymMapRec)); + } + else { + if (dst->map->key_sym_map) { + xfree(dst->map->key_sym_map); + dst->map->key_sym_map = NULL; + } + } + + if (src->map->types && src->map->num_types) { + if (src->map->num_types > dst->map->size_types || + !dst->map->types || !dst->map->size_types) { + if (dst->map->types && dst->map->size_types) { + tmp = xrealloc(dst->map->types, + src->map->num_types * sizeof(XkbKeyTypeRec)); + if (!tmp) + return FALSE; + dst->map->types = tmp; + bzero(dst->map->types + dst->map->num_types, + (src->map->num_types - dst->map->num_types) * + sizeof(XkbKeyTypeRec)); + } + else { + tmp = xcalloc(src->map->num_types, sizeof(XkbKeyTypeRec)); + if (!tmp) + return FALSE; + dst->map->types = tmp; + } + } + else if (src->map->num_types < dst->map->num_types && + dst->map->types) { + for (i = src->map->num_types, dtype = (dst->map->types + i); + i < dst->map->num_types; i++, dtype++) { + if (dtype->level_names) + xfree(dtype->level_names); + dtype->level_names = NULL; + dtype->num_levels = 0; + if (dtype->map_count) { + if (dtype->map) + xfree(dtype->map); + if (dtype->preserve) + xfree(dtype->preserve); + } + } + } + + stype = src->map->types; + dtype = dst->map->types; + for (i = 0; i < src->map->num_types; i++, dtype++, stype++) { + if (stype->num_levels && stype->level_names) { + if (stype->num_levels != dtype->num_levels && + dtype->num_levels && dtype->level_names && + i < dst->map->num_types) { + tmp = xrealloc(dtype->level_names, + stype->num_levels * sizeof(Atom)); + if (!tmp) + continue; + dtype->level_names = tmp; + } + else if (!dtype->num_levels || !dtype->level_names || + i >= dst->map->num_types) { + tmp = xalloc(stype->num_levels * sizeof(Atom)); + if (!tmp) + continue; + dtype->level_names = tmp; + } + dtype->num_levels = stype->num_levels; + memcpy(dtype->level_names, stype->level_names, + stype->num_levels * sizeof(Atom)); + } + else { + if (dtype->num_levels && dtype->level_names && + i < dst->map->num_types) + xfree(dtype->level_names); + dtype->num_levels = 0; + dtype->level_names = NULL; + } + + dtype->name = stype->name; + memcpy(&dtype->mods, &stype->mods, sizeof(XkbModsRec)); + + if (stype->map_count) { + if (stype->map) { + if (stype->map_count != dtype->map_count && + dtype->map_count && dtype->map && + i < dst->map->num_types) { + tmp = xrealloc(dtype->map, + stype->map_count * + sizeof(XkbKTMapEntryRec)); + if (!tmp) + return FALSE; + dtype->map = tmp; + } + else if (!dtype->map_count || !dtype->map || + i >= dst->map->num_types) { + tmp = xalloc(stype->map_count * + sizeof(XkbKTMapEntryRec)); + if (!tmp) + return FALSE; + dtype->map = tmp; + } + + memcpy(dtype->map, stype->map, + stype->map_count * sizeof(XkbKTMapEntryRec)); + } + else { + if (dtype->map && i < dst->map->num_types) + xfree(dtype->map); + dtype->map = NULL; + } + + if (stype->preserve) { + if (stype->map_count != dtype->map_count && + dtype->map_count && dtype->preserve && + i < dst->map->num_types) { + tmp = xrealloc(dtype->preserve, + stype->map_count * + sizeof(XkbModsRec)); + if (!tmp) + return FALSE; + dtype->preserve = tmp; + } + else if (!dtype->preserve || !dtype->map_count || + i >= dst->map->num_types) { + tmp = xalloc(stype->map_count * + sizeof(XkbModsRec)); + if (!tmp) + return FALSE; + dtype->preserve = tmp; + } + + memcpy(dtype->preserve, stype->preserve, + stype->map_count * sizeof(XkbModsRec)); + } + else { + if (dtype->preserve && i < dst->map->num_types) + xfree(dtype->preserve); + dtype->preserve = NULL; + } + + dtype->map_count = stype->map_count; + } + else { + if (dtype->map_count && i < dst->map->num_types) { + if (dtype->map) + xfree(dtype->map); + if (dtype->preserve) + xfree(dtype->preserve); + } + dtype->map_count = 0; + dtype->map = NULL; + dtype->preserve = NULL; + } + } + + dst->map->size_types = src->map->num_types; + dst->map->num_types = src->map->num_types; + } + else { + if (dst->map->types) { + for (i = 0, dtype = dst->map->types; i < dst->map->num_types; + i++, dtype++) { + if (dtype->level_names) + xfree(dtype->level_names); + if (dtype->map && dtype->map_count) + xfree(dtype->map); + if (dtype->preserve && dtype->map_count) + xfree(dtype->preserve); + } + xfree(dst->map->types); + dst->map->types = NULL; + } + dst->map->num_types = 0; + dst->map->size_types = 0; + } + + if (src->map->modmap) { + if (src->max_key_code != dst->max_key_code) { + if (dst->map->modmap) + tmp = xrealloc(dst->map->modmap, src->max_key_code + 1); + else + tmp = xalloc(src->max_key_code + 1); + if (!tmp) + return FALSE; + dst->map->modmap = tmp; + } + memcpy(dst->map->modmap, src->map->modmap, src->max_key_code + 1); + } + else { + if (dst->map->modmap) { + xfree(dst->map->modmap); + dst->map->modmap = NULL; + } + } + } + else { + if (dst->map) + XkbFreeClientMap(dst, XkbAllClientInfoMask, True); + } + + /* server map */ + if (src->server) { + if (!dst->server) { + tmp = xcalloc(1, sizeof(XkbServerMapRec)); + if (!tmp) + return FALSE; + dst->server = tmp; + } + + if (src->server->explicit) { + if (src->max_key_code != dst->max_key_code) { + if (dst->server->explicit) + tmp = xrealloc(dst->server->explicit, src->max_key_code + 1); + else + tmp = xalloc(src->max_key_code + 1); + if (!tmp) + return FALSE; + dst->server->explicit = tmp; + } + memcpy(dst->server->explicit, src->server->explicit, + src->max_key_code + 1); + } + else { + if (dst->server->explicit) { + xfree(dst->server->explicit); + dst->server->explicit = NULL; + } + } + + if (src->server->acts) { + if (src->server->size_acts != dst->server->size_acts) { + if (dst->server->acts) + tmp = xrealloc(dst->server->acts, + src->server->size_acts * sizeof(XkbAction)); + else + tmp = xalloc(src->server->size_acts * sizeof(XkbAction)); + if (!tmp) + return FALSE; + dst->server->acts = tmp; + } + memcpy(dst->server->acts, src->server->acts, + src->server->size_acts * sizeof(XkbAction)); + } + else { + if (dst->server->acts) { + xfree(dst->server->acts); + dst->server->acts = NULL; + } + } + dst->server->size_acts = src->server->size_acts; + dst->server->num_acts = src->server->num_acts; + + if (src->server->key_acts) { + if (src->max_key_code != dst->max_key_code) { + if (dst->server->key_acts) + tmp = xrealloc(dst->server->key_acts, + (src->max_key_code + 1) * + sizeof(unsigned short)); + else + tmp = xalloc((src->max_key_code + 1) * + sizeof(unsigned short)); + if (!tmp) + return FALSE; + dst->server->key_acts = tmp; + } + memcpy(dst->server->key_acts, src->server->key_acts, + (src->max_key_code + 1) * sizeof(unsigned short)); + } + else { + if (dst->server->key_acts) { + xfree(dst->server->key_acts); + dst->server->key_acts = NULL; + } + } + + if (src->server->behaviors) { + if (src->max_key_code != dst->max_key_code) { + if (dst->server->behaviors) + tmp = xrealloc(dst->server->behaviors, + (src->max_key_code + 1) * + sizeof(XkbBehavior)); + else + tmp = xalloc((src->max_key_code + 1) * + sizeof(XkbBehavior)); + if (!tmp) + return FALSE; + dst->server->behaviors = tmp; + } + memcpy(dst->server->behaviors, src->server->behaviors, + (src->max_key_code + 1) * sizeof(XkbBehavior)); + } + else { + if (dst->server->behaviors) { + xfree(dst->server->behaviors); + dst->server->behaviors = NULL; + } + } + + memcpy(dst->server->vmods, src->server->vmods, XkbNumVirtualMods); + + if (src->server->vmodmap) { + if (src->max_key_code != dst->max_key_code) { + if (dst->server->vmodmap) + tmp = xrealloc(dst->server->vmodmap, + (src->max_key_code + 1) * + sizeof(unsigned short)); + else + tmp = xalloc((src->max_key_code + 1) * + sizeof(unsigned short)); + if (!tmp) + return FALSE; + dst->server->vmodmap = tmp; + } + memcpy(dst->server->vmodmap, src->server->vmodmap, + (src->max_key_code + 1) * sizeof(unsigned short)); + } + else { + if (dst->server->vmodmap) { + xfree(dst->server->vmodmap); + dst->server->vmodmap = NULL; + } + } + } + else { + if (dst->server) + XkbFreeServerMap(dst, XkbAllServerInfoMask, True); + } + + /* indicators */ + if (src->indicators) { + if (!dst->indicators) { + dst->indicators = xalloc(sizeof(XkbIndicatorRec)); + if (!dst->indicators) + return FALSE; + } + memcpy(dst->indicators, src->indicators, sizeof(XkbIndicatorRec)); + } + else { + if (dst->indicators) { + xfree(dst->indicators); + dst->indicators = NULL; + } + } + + /* controls */ + if (src->ctrls) { + if (!dst->ctrls) { + dst->ctrls = xalloc(sizeof(XkbControlsRec)); + if (!dst->ctrls) + return FALSE; + } + memcpy(dst->ctrls, src->ctrls, sizeof(XkbControlsRec)); + } + else { + if (dst->ctrls) { + xfree(dst->ctrls); + dst->ctrls = NULL; + } + } + + /* names */ + if (src->names) { + if (!dst->names) { + dst->names = xcalloc(1, sizeof(XkbNamesRec)); + if (!dst->names) + return FALSE; + } + + if (src->names->keys) { + if (src->max_key_code != dst->max_key_code) { + if (dst->names->keys) + tmp = xrealloc(dst->names->keys, (src->max_key_code + 1) * + sizeof(XkbKeyNameRec)); + else + tmp = xalloc((src->max_key_code + 1) * + sizeof(XkbKeyNameRec)); + if (!tmp) + return FALSE; + dst->names->keys = tmp; + } + memcpy(dst->names->keys, src->names->keys, + (src->max_key_code + 1) * sizeof(XkbKeyNameRec)); + } + else { + if (dst->names->keys) { + xfree(dst->names->keys); + dst->names->keys = NULL; + } + } + + if (src->names->num_key_aliases) { + if (src->names->num_key_aliases != dst->names->num_key_aliases) { + if (dst->names->key_aliases) + tmp = xrealloc(dst->names->key_aliases, + src->names->num_key_aliases * + sizeof(XkbKeyAliasRec)); + else + tmp = xalloc(src->names->num_key_aliases * + sizeof(XkbKeyAliasRec)); + if (!tmp) + return FALSE; + dst->names->key_aliases = tmp; + } + memcpy(dst->names->key_aliases, src->names->key_aliases, + src->names->num_key_aliases * sizeof(XkbKeyAliasRec)); + } + else { + if (dst->names->key_aliases) { + xfree(dst->names->key_aliases); + dst->names->key_aliases = NULL; + } + } + dst->names->num_key_aliases = src->names->num_key_aliases; + + if (src->names->num_rg) { + if (src->names->num_rg != dst->names->num_rg) { + if (dst->names->radio_groups) + tmp = xrealloc(dst->names->radio_groups, + src->names->num_rg * sizeof(Atom)); + else + tmp = xalloc(src->names->num_rg * sizeof(Atom)); + if (!tmp) + return FALSE; + dst->names->radio_groups = tmp; + } + memcpy(dst->names->radio_groups, src->names->radio_groups, + src->names->num_rg * sizeof(Atom)); + } + else { + if (dst->names->radio_groups) + xfree(dst->names->radio_groups); + } + dst->names->num_rg = src->names->num_rg; + + dst->names->keycodes = src->names->keycodes; + dst->names->geometry = src->names->geometry; + dst->names->symbols = src->names->symbols; + dst->names->types = src->names->types; + dst->names->compat = src->names->compat; + dst->names->phys_symbols = src->names->phys_symbols; + + memcpy(dst->names->vmods, src->names->vmods, + XkbNumVirtualMods * sizeof(Atom)); + memcpy(dst->names->indicators, src->names->indicators, + XkbNumIndicators * sizeof(Atom)); + memcpy(dst->names->groups, src->names->groups, + XkbNumKbdGroups * sizeof(Atom)); + } + else { + if (dst->names) + XkbFreeNames(dst, XkbAllNamesMask, True); + } + + /* compat */ + if (src->compat) { + if (!dst->compat) { + dst->compat = xcalloc(1, sizeof(XkbCompatMapRec)); + if (!dst->compat) + return FALSE; + } + + if (src->compat->sym_interpret && src->compat->num_si) { + if (src->compat->num_si != dst->compat->size_si) { + if (dst->compat->sym_interpret) + tmp = xrealloc(dst->compat->sym_interpret, + src->compat->num_si * + sizeof(XkbSymInterpretRec)); + else + tmp = xalloc(src->compat->num_si * + sizeof(XkbSymInterpretRec)); + if (!tmp) + return FALSE; + dst->compat->sym_interpret = tmp; + } + memcpy(dst->compat->sym_interpret, src->compat->sym_interpret, + src->compat->num_si * sizeof(XkbSymInterpretRec)); + + dst->compat->num_si = src->compat->num_si; + dst->compat->size_si = src->compat->num_si; + } + else { + if (dst->compat->sym_interpret && dst->compat->size_si) + xfree(dst->compat->sym_interpret); + + dst->compat->sym_interpret = NULL; + dst->compat->num_si = 0; + dst->compat->size_si = 0; + } + + memcpy(dst->compat->groups, src->compat->groups, + XkbNumKbdGroups * sizeof(XkbModsRec)); + } + else { + if (dst->compat) + XkbFreeCompatMap(dst, XkbAllCompatMask, True); + } + + /* geometry */ + if (src->geom) { + if (!dst->geom) { + dst->geom = xcalloc(sizeof(XkbGeometryRec), 1); + if (!dst->geom) + return FALSE; + } + + /* properties */ + if (src->geom->num_properties) { + if (src->geom->num_properties != dst->geom->sz_properties) { + if (src->geom->num_properties < dst->geom->sz_properties) { + for (i = src->geom->num_properties, + dprop = dst->geom->properties + + src->geom->num_properties; + i < dst->geom->num_properties; + i++, dprop++) { + xfree(dprop->name); + xfree(dprop->value); + } + } + + if (dst->geom->sz_properties) + tmp = xrealloc(dst->geom->properties, + src->geom->num_properties * + sizeof(XkbPropertyRec)); + else + tmp = xalloc(src->geom->num_properties * + sizeof(XkbPropertyRec)); + if (!tmp) + return FALSE; + dst->geom->properties = tmp; + } + + dst->geom->sz_properties = src->geom->num_properties; + + if (dst->geom->sz_properties > dst->geom->num_properties) { + bzero(dst->geom->properties + dst->geom->num_properties, + (dst->geom->sz_properties - dst->geom->num_properties) * + sizeof(XkbPropertyRec)); + } + + for (i = 0, + sprop = src->geom->properties, + dprop = dst->geom->properties; + i < src->geom->num_properties; + i++, sprop++, dprop++) { + if (i < dst->geom->num_properties) { + if (strlen(sprop->name) != strlen(dprop->name)) { + tmp = xrealloc(dprop->name, strlen(sprop->name) + 1); + if (!tmp) + return FALSE; + dprop->name = tmp; + } + if (strlen(sprop->value) != strlen(dprop->value)) { + tmp = xrealloc(dprop->value, strlen(sprop->value) + 1); + if (!tmp) + return FALSE; + dprop->value = tmp; + } + strcpy(dprop->name, sprop->name); + strcpy(dprop->value, sprop->value); + } + else { + dprop->name = xstrdup(sprop->name); + dprop->value = xstrdup(sprop->value); + } + } + + dst->geom->num_properties = dst->geom->sz_properties; + } + else { + if (dst->geom->sz_properties) { + for (i = 0, dprop = dst->geom->properties; + i < dst->geom->num_properties; + i++, dprop++) { + xfree(dprop->name); + xfree(dprop->value); + } + xfree(dst->geom->properties); + dst->geom->properties = NULL; + } + + dst->geom->num_properties = 0; + dst->geom->sz_properties = 0; + } + + /* colors */ + if (src->geom->num_colors) { + if (src->geom->num_colors != dst->geom->sz_colors) { + if (src->geom->num_colors < dst->geom->sz_colors) { + for (i = src->geom->num_colors, + dcolor = dst->geom->colors + + src->geom->num_colors; + i < dst->geom->num_colors; + i++, dcolor++) { + xfree(dcolor->spec); + } + } + + if (dst->geom->sz_colors) + tmp = xrealloc(dst->geom->colors, + src->geom->num_colors * + sizeof(XkbColorRec)); + else + tmp = xalloc(src->geom->num_colors * + sizeof(XkbColorRec)); + if (!tmp) + return FALSE; + dst->geom->colors = tmp; + } + + dst->geom->sz_colors = src->geom->num_colors; + + if (dst->geom->sz_colors > dst->geom->num_colors) { + bzero(dst->geom->colors + dst->geom->num_colors, + (dst->geom->sz_colors - dst->geom->num_colors) * + sizeof(XkbColorRec)); + } + + for (i = 0, + scolor = src->geom->colors, + dcolor = dst->geom->colors; + i < src->geom->num_colors; + i++, scolor++, dcolor++) { + if (i < dst->geom->num_colors) { + if (strlen(scolor->spec) != strlen(dcolor->spec)) { + tmp = xrealloc(dcolor->spec, strlen(scolor->spec) + 1); + if (!tmp) + return FALSE; + dcolor->spec = tmp; + } + strcpy(dcolor->spec, scolor->spec); + } + else { + dcolor->spec = xstrdup(scolor->spec); + } + } + + dst->geom->num_colors = dst->geom->sz_colors; + } + else { + if (dst->geom->sz_colors) { + for (i = 0, dcolor = dst->geom->colors; + i < dst->geom->num_colors; + i++, dcolor++) { + xfree(dcolor->spec); + } + xfree(dst->geom->colors); + dst->geom->colors = NULL; + } + + dst->geom->num_colors = 0; + dst->geom->sz_colors = 0; + } + + /* shapes */ + /* shapes break down into outlines, which break down into points. */ + if (dst->geom->num_shapes) { + for (i = 0, dshape = dst->geom->shapes; + i < dst->geom->num_shapes; + i++, dshape++) { + for (j = 0, doutline = dshape->outlines; + j < dshape->num_outlines; + j++, doutline++) { + if (doutline->sz_points) + xfree(doutline->points); + } + + if (dshape->sz_outlines) { + xfree(dshape->outlines); + dshape->outlines = NULL; + } + + dshape->num_outlines = 0; + dshape->sz_outlines = 0; + } + } + + if (src->geom->num_shapes) { + tmp = xcalloc(src->geom->num_shapes, sizeof(XkbShapeRec)); + if (!tmp) + return FALSE; + dst->geom->shapes = tmp; + + for (i = 0, sshape = src->geom->shapes, dshape = dst->geom->shapes; + i < src->geom->num_shapes; + i++, sshape++, dshape++) { + if (sshape->num_outlines) { + tmp = xcalloc(sshape->num_outlines, sizeof(XkbOutlineRec)); + if (!tmp) + return FALSE; + dshape->outlines = tmp; + + for (j = 0, + soutline = sshape->outlines, + doutline = dshape->outlines; + j < sshape->num_outlines; + j++, soutline++, doutline++) { + if (soutline->num_points) { + tmp = xalloc(soutline->num_points * + sizeof(XkbPointRec)); + if (!tmp) + return FALSE; + doutline->points = tmp; + + memcpy(doutline->points, soutline->points, + soutline->num_points * sizeof(XkbPointRec)); + } + + doutline->num_points = soutline->num_points; + doutline->sz_points = soutline->sz_points; + } + } + + dshape->num_outlines = sshape->num_outlines; + dshape->sz_outlines = sshape->num_outlines; + } + + dst->geom->num_shapes = src->geom->num_shapes; + dst->geom->sz_shapes = src->geom->num_shapes; + } + else { + if (dst->geom->sz_shapes) { + xfree(dst->geom->shapes); + } + dst->geom->shapes = NULL; + dst->geom->num_shapes = 0; + dst->geom->sz_shapes = 0; + } + + /* sections */ + /* sections break down into doodads, and also into rows, which break + * down into keys. */ + if (dst->geom->num_sections) { + for (i = 0, dsection = dst->geom->sections; + i < dst->geom->num_sections; + i++, dsection++) { + for (j = 0, drow = dsection->rows; + j < dsection->num_rows; + j++, drow++) { + if (drow->num_keys) + xfree(drow->keys); + } + + if (dsection->num_rows) + xfree(dsection->rows); + + /* cut and waste from geom/doodad below. */ + for (j = 0, ddoodad = dsection->doodads; + j < dsection->num_doodads; + j++, ddoodad++) { + if (ddoodad->any.type == XkbTextDoodad) { + if (ddoodad->text.text) { + xfree(ddoodad->text.text); + ddoodad->text.text = NULL; + } + if (ddoodad->text.font) { + xfree(ddoodad->text.font); + ddoodad->text.font = NULL; + } + } + else if (ddoodad->any.type == XkbLogoDoodad) { + if (ddoodad->logo.logo_name) { + xfree(ddoodad->logo.logo_name); + ddoodad->logo.logo_name = NULL; + } + } + } + + if (dsection->num_doodads) + xfree(dsection->doodads); + } + + dst->geom->num_sections = 0; + dst->geom->sections = NULL; + } + + if (src->geom->num_sections) { + if (dst->geom->sz_sections) + tmp = xrealloc(dst->geom->sections, + src->geom->num_sections * + sizeof(XkbSectionRec)); + else + tmp = xalloc(src->geom->num_sections * sizeof(XkbSectionRec)); + if (!tmp) + return FALSE; + memset(tmp, 0, src->geom->num_sections * sizeof(XkbSectionRec)); + dst->geom->sections = tmp; + dst->geom->num_sections = src->geom->num_sections; + + for (i = 0, + ssection = src->geom->sections, + dsection = dst->geom->sections; + i < src->geom->num_sections; + i++, ssection++, dsection++) { + if (ssection->num_rows) { + tmp = xcalloc(ssection->num_rows, sizeof(XkbRowRec)); + if (!tmp) + return FALSE; + dsection->rows = tmp; + } + for (j = 0, srow = ssection->rows, drow = dsection->rows; + j < ssection->num_rows; + j++, srow++, drow++) { + if (srow->num_keys) { + tmp = xalloc(srow->num_keys * sizeof(XkbKeyRec)); + if (!tmp) + return FALSE; + drow->keys = tmp; + memcpy(drow->keys, srow->keys, + srow->num_keys * sizeof(XkbKeyRec)); + } + drow->num_keys = srow->num_keys; + drow->sz_keys = srow->num_keys; + } + + if (ssection->num_doodads) { + tmp = xcalloc(ssection->num_doodads, sizeof(XkbDoodadRec)); + if (!tmp) + return FALSE; + dsection->doodads = tmp; + } + else { + dsection->doodads = NULL; + } + + for (k = 0, + sdoodad = ssection->doodads, + ddoodad = dsection->doodads; + k < ssection->num_doodads; + k++, sdoodad++, ddoodad++) { + if (sdoodad->any.type == XkbTextDoodad) { + if (sdoodad->text.text) + ddoodad->text.text = + xstrdup(sdoodad->text.text); + if (sdoodad->text.font) + ddoodad->text.font = + xstrdup(sdoodad->text.font); + } + else if (sdoodad->any.type == XkbLogoDoodad) { + if (sdoodad->logo.logo_name) + ddoodad->logo.logo_name = + xstrdup(sdoodad->logo.logo_name); + } + ddoodad->any.type = sdoodad->any.type; + } + dsection->num_doodads = ssection->num_doodads; + dsection->sz_doodads = ssection->num_doodads; + } + } + else { + if (dst->geom->sz_sections) { + xfree(dst->geom->sections); + } + + dst->geom->sections = NULL; + dst->geom->num_sections = 0; + dst->geom->sz_sections = 0; + } + + /* doodads */ + if (dst->geom->num_doodads) { + for (i = src->geom->num_doodads, + ddoodad = dst->geom->doodads + + src->geom->num_doodads; + i < dst->geom->num_doodads; + i++, ddoodad++) { + if (ddoodad->any.type == XkbTextDoodad) { + if (ddoodad->text.text) { + xfree(ddoodad->text.text); + ddoodad->text.text = NULL; + } + if (ddoodad->text.font) { + xfree(ddoodad->text.font); + ddoodad->text.font = NULL; + } + } + else if (ddoodad->any.type == XkbLogoDoodad) { + if (ddoodad->logo.logo_name) { + xfree(ddoodad->logo.logo_name); + ddoodad->logo.logo_name = NULL; + } + } + } + dst->geom->num_doodads = 0; + dst->geom->doodads = NULL; + } + + if (src->geom->num_doodads) { + if (dst->geom->sz_doodads) + tmp = xrealloc(dst->geom->doodads, + src->geom->num_doodads * + sizeof(XkbDoodadRec)); + else + tmp = xalloc(src->geom->num_doodads * + sizeof(XkbDoodadRec)); + if (!tmp) + return FALSE; + memset(tmp, 0, src->geom->num_doodads * sizeof(XkbDoodadRec)); + dst->geom->doodads = tmp; + + dst->geom->sz_doodads = src->geom->num_doodads; + + for (i = 0, + sdoodad = src->geom->doodads, + ddoodad = dst->geom->doodads; + i < src->geom->num_doodads; + i++, sdoodad++, ddoodad++) { + ddoodad->any.type = sdoodad->any.type; + if (sdoodad->any.type == XkbTextDoodad) { + if (sdoodad->text.text) + ddoodad->text.text = xstrdup(sdoodad->text.text); + if (sdoodad->text.font) + ddoodad->text.font = xstrdup(sdoodad->text.font); + } + else if (sdoodad->any.type == XkbLogoDoodad) { + if (sdoodad->logo.logo_name) + ddoodad->logo.logo_name = + xstrdup(sdoodad->logo.logo_name); + } + } + + dst->geom->num_doodads = dst->geom->sz_doodads; + } + else { + if (dst->geom->sz_doodads) { + xfree(dst->geom->doodads); + } + + dst->geom->doodads = NULL; + dst->geom->num_doodads = 0; + dst->geom->sz_doodads = 0; + } + + /* key aliases */ + if (src->geom->num_key_aliases) { + if (src->geom->num_key_aliases != dst->geom->sz_key_aliases) { + if (dst->geom->sz_key_aliases) + tmp = xrealloc(dst->geom->key_aliases, + src->geom->num_key_aliases * + 2 * XkbKeyNameLength); + else + tmp = xalloc(src->geom->num_key_aliases * + 2 * XkbKeyNameLength); + if (!tmp) + return FALSE; + dst->geom->key_aliases = tmp; + + dst->geom->sz_key_aliases = src->geom->num_key_aliases; + } + + memcpy(dst->geom->key_aliases, src->geom->key_aliases, + src->geom->num_key_aliases * 2 * XkbKeyNameLength); + + dst->geom->num_key_aliases = dst->geom->sz_key_aliases; + } + else { + if (dst->geom->key_aliases) { + xfree(dst->geom->key_aliases); + } + dst->geom->key_aliases = NULL; + dst->geom->num_key_aliases = 0; + dst->geom->sz_key_aliases = 0; + } + + /* font */ + if (src->geom->label_font) { + if (!dst->geom->label_font) { + tmp = xalloc(strlen(src->geom->label_font)); + if (!tmp) + return FALSE; + dst->geom->label_font = tmp; + } + else if (strlen(src->geom->label_font) != + strlen(dst->geom->label_font)) { + tmp = xrealloc(dst->geom->label_font, + strlen(src->geom->label_font)); + if (!tmp) + return FALSE; + dst->geom->label_font = tmp; + } + + strcpy(dst->geom->label_font, src->geom->label_font); + i = XkbGeomColorIndex(src->geom, src->geom->label_color); + dst->geom->label_color = &(src->geom->colors[i]); + i = XkbGeomColorIndex(src->geom, src->geom->base_color); + dst->geom->base_color = &(src->geom->colors[i]); + } + else { + if (dst->geom->label_font) { + xfree(dst->geom->label_font); + } + dst->geom->label_font = NULL; + dst->geom->label_color = NULL; + dst->geom->base_color = NULL; + } + + dst->geom->name = src->geom->name; + dst->geom->width_mm = src->geom->width_mm; + dst->geom->height_mm = src->geom->height_mm; + } + else + { + if (dst->geom) { + /* I LOVE THE DIFFERENT CALL SIGNATURE. REALLY, I DO. */ + XkbFreeGeometry(dst->geom, XkbGeomAllMask, True); + dst->geom = NULL; + } + } + + if (inputInfo.keyboard->key->xkbInfo && + inputInfo.keyboard->key->xkbInfo->desc == dst) { + pDev = inputInfo.keyboard; + } + else { + for (tmpDev = inputInfo.devices; tmpDev && !pDev; + tmpDev = tmpDev->next) { + if (tmpDev->key && tmpDev->key->xkbInfo && + tmpDev->key->xkbInfo->desc == dst) { + pDev = tmpDev; + break; + } + } + for (tmpDev = inputInfo.off_devices; tmpDev && !pDev; + tmpDev = tmpDev->next) { + if (tmpDev->key && tmpDev->key->xkbInfo && + tmpDev->key->xkbInfo->desc == dst) { + pDev = tmpDev; + break; + } + } + } + + if (sendNotifies) { + if (!pDev) { + ErrorF("XkbCopyKeymap: asked for notifies, but can't find device!\n"); + } + else { + /* send NewKeyboardNotify if the keycode range changed, else + * just MapNotify. we also need to send NKN if the geometry + * changed (obviously ...). */ + if ((src->min_key_code != dst->min_key_code || + src->max_key_code != dst->max_key_code) && sendNotifies) { + nkn.oldMinKeyCode = dst->min_key_code; + nkn.oldMaxKeyCode = dst->max_key_code; + nkn.deviceID = nkn.oldDeviceID = pDev->id; + nkn.minKeyCode = src->min_key_code; + nkn.maxKeyCode = src->max_key_code; + nkn.requestMajor = XkbReqCode; + nkn.requestMinor = X_kbSetMap; /* XXX bare-faced lie */ + nkn.changed = XkbAllNewKeyboardEventsMask; + XkbSendNewKeyboardNotify(pDev, &nkn); + } + else if (sendNotifies) { + mn.deviceID = pDev->id; + mn.minKeyCode = src->min_key_code; + mn.maxKeyCode = src->max_key_code; + mn.firstType = 0; + mn.nTypes = src->map->num_types; + mn.firstKeySym = src->min_key_code; + mn.nKeySyms = XkbNumKeys(src); + mn.firstKeyAct = src->min_key_code; + mn.nKeyActs = XkbNumKeys(src); + /* Cargo-culted from ProcXkbGetMap. */ + mn.firstKeyBehavior = src->min_key_code; + mn.nKeyBehaviors = XkbNumKeys(src); + mn.firstKeyExplicit = src->min_key_code; + mn.nKeyExplicit = XkbNumKeys(src); + mn.firstModMapKey = src->min_key_code; + mn.nModMapKeys = XkbNumKeys(src); + mn.firstVModMapKey = src->min_key_code; + mn.nVModMapKeys = XkbNumKeys(src); + mn.virtualMods = ~0; /* ??? */ + mn.changed = XkbAllMapComponentsMask; + XkbSendMapNotify(pDev, &mn); + } + } + } + + dst->min_key_code = src->min_key_code; + dst->max_key_code = src->max_key_code; + + return TRUE; +} |