From fd439afdfe7ba451aff19b62d1764e4dfd0b782f Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Wed, 11 Aug 2004 22:40:14 +0000 Subject: Add COMPOSITE change to fbCopyWindow (not needed yet) Xnest was half-using midispcur and doing a bad job of it. Replace all of that code with mipointer which does a lot of the work. Support DDXen which don't provide GetWindowPixmap, or which return NULL for the root pixmap. --- fb/fbwindow.c | 11 ++++++- hw/xnest/Cursor.c | 73 +++++++------------------------------------ hw/xnest/Events.c | 10 ++++++ hw/xnest/GCOps.c | 13 +++++++- hw/xnest/Screen.c | 65 ++++++++++++++++++++------------------- hw/xnest/XNCursor.h | 9 ++---- miext/damage/damage.c | 80 ++++++++++++++++++++++++++++++------------------ miext/damage/damagestr.h | 6 ++++ 8 files changed, 134 insertions(+), 133 deletions(-) diff --git a/fb/fbwindow.c b/fb/fbwindow.c index dd775cc0c..1666dfe16 100644 --- a/fb/fbwindow.c +++ b/fb/fbwindow.c @@ -1,4 +1,4 @@ -/* $XdotOrg$ */ +/* $XdotOrg: xc/programs/Xserver/fb/fbwindow.c,v 1.2 2004/04/23 19:05:14 eich Exp $ */ /* * Id: fbwindow.c,v 1.1 1999/11/02 03:54:45 keithp Exp $ * @@ -123,6 +123,9 @@ fbCopyWindow(WindowPtr pWin, RegionRec rgnDst; int dx, dy; WindowPtr pwinRoot; +#ifdef COMPOSITE + PixmapPtr pPixmap = fbGetWindowPixmap (pWin); +#endif pwinRoot = WindowTable[pWin->drawable.pScreen->myNum]; @@ -134,6 +137,12 @@ fbCopyWindow(WindowPtr pWin, REGION_INTERSECT(pWin->drawable.pScreen, &rgnDst, &pWin->borderClip, prgnSrc); +#ifdef COMPOSITE + if (pPixmap->screen_x || pPixmap->screen_y) + REGION_TRANSLATE (pWin->drawable.pScreen, &rgnDst, + -pPixmap->screen_x, -pPixmap->screen_y); +#endif + fbCopyRegion ((DrawablePtr)pwinRoot, (DrawablePtr)pwinRoot, 0, &rgnDst, dx, dy, fbCopyWindowProc, 0, 0); diff --git a/hw/xnest/Cursor.c b/hw/xnest/Cursor.c index 146e7ebd0..aaab62c23 100644 --- a/hw/xnest/Cursor.c +++ b/hw/xnest/Cursor.c @@ -33,59 +33,6 @@ is" without express or implied warranty. #include "Keyboard.h" #include "Args.h" -void -xnestConstrainCursor(ScreenPtr pScreen, BoxPtr pBox) -{ -#ifdef _XSERVER64 - Window64 wroot; -#else - Window wroot; -#endif - - int wx, wy; - unsigned int wwidth, wheight; - unsigned int wborderwidth; - unsigned int wdepth; - - XGetGeometry(xnestDisplay, xnestDefaultWindows[pScreen->myNum], &wroot, - &wx, &wy, &wwidth, &wheight, &wborderwidth, &wdepth); - - if (pBox->x1 <= 0 && pBox->y1 <= 0 && - pBox->x2 >= wwidth && pBox->y2 >= wheight) - XUngrabPointer(xnestDisplay, CurrentTime); - else { - XReparentWindow(xnestDisplay, xnestConfineWindow, - xnestDefaultWindows[pScreen->myNum], - pBox->x1, pBox->y1); - XResizeWindow(xnestDisplay, xnestConfineWindow, - pBox->x2 - pBox->x1, pBox->y2 - pBox->y1); - - XGrabPointer(xnestDisplay, - xnestDefaultWindows[pScreen->myNum], - True, - xnestEventMask & (~XNEST_KEYBOARD_EVENT_MASK|KeymapStateMask), - GrabModeAsync, GrabModeAsync, - xnestConfineWindow, - None, CurrentTime); - } -} - -void -xnestCursorLimits(ScreenPtr pScreen, CursorPtr pCursor, BoxPtr pHotBox, - BoxPtr pTopLeftBox) -{ - *pTopLeftBox = *pHotBox; -} - -Bool -xnestDisplayCursor(ScreenPtr pScreen, CursorPtr pCursor) -{ - XDefineCursor(xnestDisplay, - xnestDefaultWindows[pScreen->myNum], - xnestCursor(pCursor, pScreen)); - return True; -} - Bool xnestRealizeCursor(ScreenPtr pScreen, CursorPtr pCursor) { @@ -192,15 +139,17 @@ xnestRecolorCursor(ScreenPtr pScreen, CursorPtr pCursor, Bool displayed) &fg_color, &bg_color); } -Bool -xnestSetCursorPosition(ScreenPtr pScreen, int x, int y, Bool generateEvent) +void xnestSetCursor (ScreenPtr pScreen, CursorPtr pCursor, int x, int y) { - int i; + if (pCursor) + { + XDefineCursor(xnestDisplay, + xnestDefaultWindows[pScreen->myNum], + xnestCursor(pCursor, pScreen)); + } +} - for (i = 0; i < xnestNumScreens; i++) - XWarpPointer(xnestDisplay, xnestDefaultWindows[i], - xnestDefaultWindows[pScreen->myNum], - 0, 0, 0, 0, x, y); - - return True; +void +xnestMoveCursor (ScreenPtr pScreen, int x, int y) +{ } diff --git a/hw/xnest/Events.c b/hw/xnest/Events.c index a36e0d8e8..69a3c208f 100644 --- a/hw/xnest/Events.c +++ b/hw/xnest/Events.c @@ -34,6 +34,7 @@ is" without express or implied warranty. #include "Screen.h" #include "XNWindow.h" #include "Events.h" +#include "mipointer.h" CARD32 lastEventTime = 0; @@ -41,6 +42,7 @@ void ProcessInputEvents() { mieqProcessInputEvents(); + miPointerUpdate(); } int @@ -131,11 +133,15 @@ xnestCollectEvents() break; case MotionNotify: +#if 0 x.u.u.type = MotionNotify; x.u.keyButtonPointer.rootX = X.xmotion.x; x.u.keyButtonPointer.rootY = X.xmotion.y; x.u.keyButtonPointer.time = lastEventTime = GetTimeInMillis(); mieqEnqueue(&x); +#endif + miPointerAbsoluteCursor (X.xmotion.x, X.xmotion.y, + lastEventTime = GetTimeInMillis()); break; case FocusIn: @@ -162,11 +168,15 @@ xnestCollectEvents() pScreen = xnestScreen(X.xcrossing.window); if (pScreen) { NewCurrentScreen(pScreen, X.xcrossing.x, X.xcrossing.y); +#if 0 x.u.u.type = MotionNotify; x.u.keyButtonPointer.rootX = X.xcrossing.x; x.u.keyButtonPointer.rootY = X.xcrossing.y; x.u.keyButtonPointer.time = lastEventTime = GetTimeInMillis(); mieqEnqueue(&x); +#endif + miPointerAbsoluteCursor (X.xcrossing.x, X.xcrossing.y, + lastEventTime = GetTimeInMillis()); xnestDirectInstallColormaps(pScreen); } } diff --git a/hw/xnest/GCOps.c b/hw/xnest/GCOps.c index 042a29f6e..4ccc0b916 100644 --- a/hw/xnest/GCOps.c +++ b/hw/xnest/GCOps.c @@ -310,5 +310,16 @@ void xnestPushPixels(GCPtr pGC, PixmapPtr pBitmap, DrawablePtr pDst, int width, int height, int x, int y) { - ErrorF("xnest warning: function xnestPushPixels not implemented\n"); + /* only works for solid bitmaps */ + if (pGC->fillStyle == FillSolid) + { + XSetStipple (xnestDisplay, xnestGC(pGC), xnestPixmap(pBitmap)); + XSetTSOrigin (xnestDisplay, xnestGC(pGC), x, y); + XSetFillStyle (xnestDisplay, xnestGC(pGC), FillStippled); + XFillRectangle (xnestDisplay, xnestDrawable(pDst), + xnestGC(pGC), x, y, width, height); + XSetFillStyle (xnestDisplay, xnestGC(pGC), FillSolid); + } + else + ErrorF("xnest warning: function xnestPushPixels not implemented\n"); } diff --git a/hw/xnest/Screen.c b/hw/xnest/Screen.c index 3412edfb8..8490a7995 100644 --- a/hw/xnest/Screen.c +++ b/hw/xnest/Screen.c @@ -124,6 +124,14 @@ static miPointerScreenFuncRec xnestPointerCursorFuncs = miPointerWarpCursor }; +static miPointerSpriteFuncRec xnestPointerSpriteFuncs = +{ + xnestRealizeCursor, + xnestUnrealizeCursor, + xnestSetCursor, + xnestMoveCursor, +}; + Bool xnestOpenScreen(int index, ScreenPtr pScreen, int argc, char *argv[]) { @@ -241,27 +249,6 @@ xnestOpenScreen(int index, ScreenPtr pScreen, int argc, char *argv[]) xnestHeight = gattributes.height; } - /* myNum */ - /* id */ - miScreenInit(pScreen, NULL, xnestWidth, xnestHeight, 1, 1, xnestWidth, - rootDepth, - numDepths, depths, - defaultVisual, /* root visual */ - numVisuals, visuals); - - miInitializeBackingStore(pScreen); - - miDCInitialize(pScreen, &xnestPointerCursorFuncs); - - pScreen->mmWidth = xnestWidth * DisplayWidthMM(xnestDisplay, - DefaultScreen(xnestDisplay)) / - DisplayWidth(xnestDisplay, - DefaultScreen(xnestDisplay)); - pScreen->mmHeight = xnestHeight * DisplayHeightMM(xnestDisplay, - DefaultScreen(xnestDisplay)) / - DisplayHeight(xnestDisplay, - DefaultScreen(xnestDisplay)); - pScreen->defColormap = (Colormap) FakeClientID(0); pScreen->minInstalledCmaps = MINCMAPS; pScreen->maxInstalledCmaps = MAXCMAPS; @@ -282,7 +269,6 @@ xnestOpenScreen(int index, ScreenPtr pScreen, int argc, char *argv[]) /* Random screen procedures */ - pScreen->CloseScreen = xnestCloseScreen; pScreen->QueryBestSize = xnestQueryBestSize; pScreen->SaveScreen = xnestSaveScreen; pScreen->GetImage = xnestGetImage; @@ -324,16 +310,6 @@ xnestOpenScreen(int index, ScreenPtr pScreen, int argc, char *argv[]) pScreen->RealizeFont = xnestRealizeFont; pScreen->UnrealizeFont = xnestUnrealizeFont; - /* Cursor Procedures */ - - pScreen->ConstrainCursor = xnestConstrainCursor; - pScreen->CursorLimits = xnestCursorLimits; - pScreen->DisplayCursor = xnestDisplayCursor; - pScreen->RealizeCursor = xnestRealizeCursor; - pScreen->UnrealizeCursor = xnestUnrealizeCursor; - pScreen->RecolorCursor = xnestRecolorCursor; - pScreen->SetCursorPosition = xnestSetCursorPosition; - /* GC procedures */ pScreen->CreateGC = xnestCreateGC; @@ -356,6 +332,31 @@ xnestOpenScreen(int index, ScreenPtr pScreen, int argc, char *argv[]) pScreen->WakeupHandler = (ScreenWakeupHandlerProcPtr)NoopDDA; pScreen->blockData = NULL; pScreen->wakeupData = NULL; + /* myNum */ + /* id */ + miScreenInit(pScreen, NULL, xnestWidth, xnestHeight, 1, 1, xnestWidth, + rootDepth, + numDepths, depths, + defaultVisual, /* root visual */ + numVisuals, visuals); + +/* miInitializeBackingStore(pScreen); */ + + miPointerInitialize (pScreen, &xnestPointerSpriteFuncs, + &xnestPointerCursorFuncs, True); + + pScreen->mmWidth = xnestWidth * DisplayWidthMM(xnestDisplay, + DefaultScreen(xnestDisplay)) / + DisplayWidth(xnestDisplay, + DefaultScreen(xnestDisplay)); + pScreen->mmHeight = xnestHeight * DisplayHeightMM(xnestDisplay, + DefaultScreen(xnestDisplay)) / + DisplayHeight(xnestDisplay, + DefaultScreen(xnestDisplay)); + + /* overwrite miCloseScreen with our own */ + pScreen->CloseScreen = xnestCloseScreen; + if (!miScreenDevPrivateInit(pScreen, xnestWidth, NULL)) return FALSE; diff --git a/hw/xnest/XNCursor.h b/hw/xnest/XNCursor.h index b396c80b5..8684a5e7f 100644 --- a/hw/xnest/XNCursor.h +++ b/hw/xnest/XNCursor.h @@ -27,14 +27,9 @@ typedef struct { #define xnestCursor(pCursor, pScreen) \ (xnestCursorPriv(pCursor, pScreen)->cursor) -void xnestConstrainCursor(ScreenPtr pScreen, BoxPtr pBox); -void xnestCursorLimits(ScreenPtr pScreen, CursorPtr pCursor, BoxPtr pHotBox, - BoxPtr pTopLeftBox); -Bool xnestDisplayCursor(ScreenPtr pScreen, CursorPtr pCursor); Bool xnestRealizeCursor(ScreenPtr pScreen, CursorPtr pCursor); Bool xnestUnrealizeCursor(ScreenPtr pScreen, CursorPtr pCursor); -void xnestRecolorCursor(ScreenPtr pScreen, CursorPtr pCursor, Bool displayed); -Bool xnestSetCursorPosition(ScreenPtr pScreen, int x, int y, - Bool generateEvent); +void xnestSetCursor (ScreenPtr pScreen, CursorPtr pCursor, int x, int y); +void xnestMoveCursor (ScreenPtr pScreen, int x, int y); #endif /* XNESTCURSOR_H */ diff --git a/miext/damage/damage.c b/miext/damage/damage.c index 4284cacf7..3d1681dc9 100755 --- a/miext/damage/damage.c +++ b/miext/damage/damage.c @@ -61,30 +61,44 @@ #define DAMAGE_DEBUG(x) #endif -static PixmapPtr -GetDrawablePixmap (DrawablePtr pDrawable) +#define getPixmapDamageRef(pPixmap) \ + ((DamagePtr *) &(pPixmap->devPrivates[damagePixPrivateIndex].ptr)) + +#define pixmapDamage(pPixmap) damagePixPriv(pPixmap) + +static DamagePtr * +getDrawableDamageRef (DrawablePtr pDrawable) { - ScreenPtr pScreen = pDrawable->pScreen; - PixmapPtr pPixmap; + PixmapPtr pPixmap; + if (pDrawable->type == DRAWABLE_WINDOW) { - pPixmap = (*pScreen->GetWindowPixmap) ((WindowPtr) pDrawable); + ScreenPtr pScreen = pDrawable->pScreen; + + pPixmap = 0; + if (pScreen->GetWindowPixmap) + pPixmap = (*pScreen->GetWindowPixmap) ((WindowPtr)pDrawable); + if (!pPixmap) - pPixmap = (*pScreen->GetScreenPixmap) (pDrawable->pScreen); + { + damageScrPriv(pScreen); + + return &pScrPriv->pScreenDamage; + } } else pPixmap = (PixmapPtr) pDrawable; - return pPixmap; + return getPixmapDamageRef (pPixmap); } -#define pixmapDamage(pPixmap) damagePixPriv(pPixmap) -#define drawableDamage(pDrawable) damagePixPriv(GetDrawablePixmap(pDrawable)) -#define windowDamage(pWin) drawableDamage(&(pWin)->drawable) -#define getDrawableDamage(pDrawable) damageGetPixPriv(GetDrawablePixmap(pDrawable)) -#define getWindowDamage(pWin) getDrawableDamage(&(pWin)->drawable) -#define pixDamageRef(pPixmap) \ - DamagePtr *pPrev = (DamagePtr *) \ - &(pPixmap->devPrivates[damagePixPrivateIndex].ptr) +#define getDrawableDamage(pDrawable) (*getDrawableDamageRef (pDrawable)) +#define getWindowDamage(pWin) getDrawableDamage(&(pWin)->drawable) + +#define drawableDamage(pDrawable) \ + DamagePtr pDamage = getDrawableDamage(pDrawable) + +#define windowDamage(pWin) drawableDamage(&(pWin)->drawable) + #define winDamageRef(pWindow) \ DamagePtr *pPrev = (DamagePtr *) \ &(pWindow->devPrivates[damageWinPrivateIndex].ptr) @@ -299,6 +313,7 @@ damageCreateGC(GCPtr pGC) damageGCPriv(pGC); Bool ret; + pGC->pCompositeClip = 0; unwrap (pScrPriv, pScreen, CreateGC); if((ret = (*pScreen->CreateGC) (pGC))) { pGCPriv->ops = NULL; @@ -416,7 +431,7 @@ damageDestroyClip(GCPtr pGC) DAMAGE_GC_FUNC_EPILOGUE (pGC); } -#define TRIM_BOX(box, pGC) { \ +#define TRIM_BOX(box, pGC) if (pGC->pCompositeClip) { \ BoxPtr extents = &pGC->pCompositeClip->extents;\ if(box.x1 < extents->x1) box.x1 = extents->x1; \ if(box.x2 > extents->x2) box.x2 = extents->x2; \ @@ -440,7 +455,9 @@ damageDestroyClip(GCPtr pGC) (((box.x2 - box.x1) > 0) && ((box.y2 - box.y1) > 0)) #define checkGCDamage(d,g) (getDrawableDamage(d) && \ - REGION_NOTEMPTY(d->pScreen, g->pCompositeClip)) + (!g->pCompositeClip ||\ + REGION_NOTEMPTY(d->pScreen, \ + g->pCompositeClip))) #ifdef RENDER @@ -1442,10 +1459,8 @@ damagePushPixels(GCPtr pGC, } static void -damageRemoveDamage (PixmapPtr pPixmap, DamagePtr pDamage) +damageRemoveDamage (DamagePtr *pPrev, DamagePtr pDamage) { - pixDamageRef (pPixmap); - while (*pPrev) { if (*pPrev == pDamage) @@ -1462,10 +1477,8 @@ damageRemoveDamage (PixmapPtr pPixmap, DamagePtr pDamage) } static void -damageInsertDamage (PixmapPtr pPixmap, DamagePtr pDamage) +damageInsertDamage (DamagePtr *pPrev, DamagePtr pDamage) { - pixDamageRef (pPixmap); - #if DAMAGE_VALIDATE_ENABLE DamagePtr pOld; @@ -1484,13 +1497,15 @@ damageDestroyPixmap (PixmapPtr pPixmap) { ScreenPtr pScreen = pPixmap->drawable.pScreen; damageScrPriv(pScreen); - DamagePtr pDamage; if (pPixmap->refcnt == 1) { - while ((pDamage = damageGetPixPriv(pPixmap))) + DamagePtr *pPrev = getPixmapDamageRef (pPixmap); + DamagePtr pDamage; + + while ((pDamage = *pPrev)) { - damageRemoveDamage (pPixmap, pDamage); + damageRemoveDamage (pPrev, pDamage); if (!pDamage->isWindow) DamageDestroy (pDamage); } @@ -1599,9 +1614,11 @@ damageSetWindowPixmap (WindowPtr pWindow, PixmapPtr pPixmap) if ((pDamage = damageGetWinPriv(pWindow))) { PixmapPtr pOldPixmap = (*pScreen->GetWindowPixmap) (pWindow); + DamagePtr *pPrev = getPixmapDamageRef(pOldPixmap); + while (pDamage) { - damageRemoveDamage (pOldPixmap, pDamage); + damageRemoveDamage (pPrev, pDamage); pDamage = pDamage->pNextWin; } } @@ -1610,9 +1627,11 @@ damageSetWindowPixmap (WindowPtr pWindow, PixmapPtr pPixmap) wrap (pScrPriv, pScreen, SetWindowPixmap, damageSetWindowPixmap); if ((pDamage = damageGetWinPriv(pWindow))) { + DamagePtr *pPrev = getPixmapDamageRef(pPixmap); + while (pDamage) { - damageInsertDamage (pPixmap, pDamage); + damageInsertDamage (pPrev, pDamage); pDamage = pDamage->pNextWin; } } @@ -1698,6 +1717,7 @@ DamageSetup (ScreenPtr pScreen) return FALSE; pScrPriv->internalLevel = 0; + pScrPriv->pScreenDamage = 0; wrap (pScrPriv, pScreen, DestroyPixmap, damageDestroyPixmap); wrap (pScrPriv, pScreen, CreateGC, damageCreateGC); @@ -1773,7 +1793,7 @@ DamageRegister (DrawablePtr pDrawable, else pDamage->isWindow = FALSE; pDamage->pDrawable = pDrawable; - damageInsertDamage (GetDrawablePixmap (pDrawable), pDamage); + damageInsertDamage (getDrawableDamageRef (pDrawable), pDamage); } void @@ -1816,7 +1836,7 @@ DamageUnregister (DrawablePtr pDrawable, #endif } pDamage->pDrawable = 0; - damageRemoveDamage (GetDrawablePixmap (pDrawable), pDamage); + damageRemoveDamage (getDrawableDamageRef (pDrawable), pDamage); } void diff --git a/miext/damage/damagestr.h b/miext/damage/damagestr.h index 5cb565084..d975ee23b 100755 --- a/miext/damage/damagestr.h +++ b/miext/damage/damagestr.h @@ -46,6 +46,12 @@ typedef struct _damage { typedef struct _damageScrPriv { int internalLevel; + /* + * For DDXen which don't provide GetScreenPixmap, this provides + * a place to hook damage for windows on the screen + */ + DamagePtr pScreenDamage; + PaintWindowBackgroundProcPtr PaintWindowBackground; PaintWindowBorderProcPtr PaintWindowBorder; CopyWindowProcPtr CopyWindow; -- cgit v1.2.3