diff options
Diffstat (limited to 'mi/misprite.c')
-rw-r--r-- | mi/misprite.c | 763 |
1 files changed, 515 insertions, 248 deletions
diff --git a/mi/misprite.c b/mi/misprite.c index c0560a4bb..bb67f48da 100644 --- a/mi/misprite.c +++ b/mi/misprite.c @@ -29,6 +29,12 @@ Except as contained in this notice, the name of The Open Group shall not be used in advertising or otherwise to promote the sale, use or other dealings in this Software without prior written authorization from The Open Group. */ +/* + * MPX additions: + * Copyright © 2006 Peter Hutterer + * Author: Peter Hutterer <peter@cs.unisa.edu.au> + * + */ #ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> @@ -50,12 +56,15 @@ in this Software without prior written authorization from The Open Group. # include "mispritest.h" # include "dixfontstr.h" # include <X11/fonts/fontstruct.h> +# include "inputstr.h" #ifdef RENDER # include "mipict.h" #endif # include "damage.h" + + #define SPRITE_DEBUG_ENABLE 0 #if SPRITE_DEBUG_ENABLE #define SPRITE_DEBUG(x) ErrorF x @@ -92,7 +101,8 @@ static void miSpriteStoreColors(ColormapPtr pMap, int ndef, static void miSpriteSaveDoomedAreas(WindowPtr pWin, RegionPtr pObscured, int dx, int dy); -static void miSpriteComputeSaved(ScreenPtr pScreen); +static void miSpriteComputeSaved(DeviceIntPtr pDev, + ScreenPtr pScreen); #define SCREEN_PROLOGUE(pScreen, field)\ ((pScreen)->field = \ @@ -105,11 +115,14 @@ static void miSpriteComputeSaved(ScreenPtr pScreen); * pointer-sprite method table */ -static Bool miSpriteRealizeCursor(ScreenPtr pScreen, CursorPtr pCursor); -static Bool miSpriteUnrealizeCursor(ScreenPtr pScreen, CursorPtr pCursor); -static void miSpriteSetCursor(ScreenPtr pScreen, CursorPtr pCursor, - int x, int y); -static void miSpriteMoveCursor(ScreenPtr pScreen, int x, int y); +static Bool miSpriteRealizeCursor(DeviceIntPtr pDev, ScreenPtr pScreen, + CursorPtr pCursor); +static Bool miSpriteUnrealizeCursor(DeviceIntPtr pDev, ScreenPtr pScreen, + CursorPtr pCursor); +static void miSpriteSetCursor(DeviceIntPtr pDev, ScreenPtr pScreen, + CursorPtr pCursor, int x, int y); +static void miSpriteMoveCursor(DeviceIntPtr pDev, ScreenPtr pScreen, + int x, int y); _X_EXPORT miPointerSpriteFuncRec miSpritePointerFuncs = { miSpriteRealizeCursor, @@ -122,22 +135,37 @@ _X_EXPORT miPointerSpriteFuncRec miSpritePointerFuncs = { * other misc functions */ -static void miSpriteRemoveCursor(ScreenPtr pScreen); -static void miSpriteRestoreCursor(ScreenPtr pScreen); +static void miSpriteRemoveCursor(DeviceIntPtr pDev, + ScreenPtr pScreen); +static void miSpriteSaveUnderCursor(DeviceIntPtr pDev, + ScreenPtr pScreen); +static void miSpriteRestoreCursor(DeviceIntPtr pDev, + ScreenPtr pScreen); static void miSpriteReportDamage (DamagePtr pDamage, RegionPtr pRegion, void *closure) { ScreenPtr pScreen = closure; miSpriteScreenPtr pScreenPriv; + miCursorInfoPtr pCursorInfo; + DeviceIntPtr pDev; pScreenPriv = (miSpriteScreenPtr) pScreen->devPrivates[miSpriteScreenIndex].ptr; - - if (pScreenPriv->isUp && - RECT_IN_REGION (pScreen, pRegion, &pScreenPriv->saved) != rgnOUT) + + for (pDev = inputInfo.devices; pDev; pDev = pDev->next) { - SPRITE_DEBUG(("Damage remove\n")); - miSpriteRemoveCursor (pScreen); + if (DevHasCursor(pDev)) + { + pCursorInfo = &pScreenPriv->pDevCursors[pDev->id]; + + if (pCursorInfo->isUp && + RECT_IN_REGION (pScreen, pRegion, &pCursorInfo->saved) + != rgnOUT) + { + SPRITE_DEBUG(("Damage remove\n")); + miSpriteRemoveCursor (pDev, pScreen); + } + } } } @@ -155,6 +183,8 @@ miSpriteInitialize (pScreen, cursorFuncs, screenFuncs) { miSpriteScreenPtr pScreenPriv; VisualPtr pVisual; + miCursorInfoPtr pCursorInfo; + int cursorIdx; if (!DamageSetup (pScreen)) return FALSE; @@ -202,39 +232,61 @@ miSpriteInitialize (pScreen, cursorFuncs, screenFuncs) pScreenPriv->BlockHandler = pScreen->BlockHandler; - pScreenPriv->pCursor = NULL; - pScreenPriv->x = 0; - pScreenPriv->y = 0; - pScreenPriv->isUp = FALSE; - pScreenPriv->shouldBeUp = FALSE; - pScreenPriv->pCacheWin = NullWindow; - pScreenPriv->isInCacheWin = FALSE; - pScreenPriv->checkPixels = TRUE; - pScreenPriv->pInstalledMap = NULL; - pScreenPriv->pColormap = NULL; + /* alloc and zero memory for all cursors */ + pScreenPriv->pDevCursors = + (miCursorInfoPtr)xalloc(MAX_DEVICES * sizeof(miCursorInfoRec)); + + if (!pScreenPriv->pDevCursors) + { + xfree((pointer)pScreenPriv); + return FALSE; + } + /* virtual core pointer's ID is 1 */ + pScreenPriv->cp = &(pScreenPriv->pDevCursors[1]); + + cursorIdx = 0; + while (cursorIdx < MAX_DEVICES) + { + pCursorInfo = &(pScreenPriv->pDevCursors[cursorIdx]); + pCursorInfo->pCursor = NULL; + pCursorInfo->x = 0; + pCursorInfo->y = 0; + pCursorInfo->isUp = FALSE; + pCursorInfo->shouldBeUp = FALSE; + pCursorInfo->pCacheWin = NullWindow; + pCursorInfo->isInCacheWin = FALSE; + pCursorInfo->checkPixels = TRUE; + pCursorInfo->pInstalledMap = NULL; + pCursorInfo->pColormap = NULL; + pCursorInfo->colors[SOURCE_COLOR].red = 0; + pCursorInfo->colors[SOURCE_COLOR].green = 0; + pCursorInfo->colors[SOURCE_COLOR].blue = 0; + pCursorInfo->colors[MASK_COLOR].red = 0; + pCursorInfo->colors[MASK_COLOR].green = 0; + pCursorInfo->colors[MASK_COLOR].blue = 0; + + cursorIdx++; + } + pScreenPriv->funcs = cursorFuncs; - pScreenPriv->colors[SOURCE_COLOR].red = 0; - pScreenPriv->colors[SOURCE_COLOR].green = 0; - pScreenPriv->colors[SOURCE_COLOR].blue = 0; - pScreenPriv->colors[MASK_COLOR].red = 0; - pScreenPriv->colors[MASK_COLOR].green = 0; - pScreenPriv->colors[MASK_COLOR].blue = 0; pScreen->devPrivates[miSpriteScreenIndex].ptr = (pointer) pScreenPriv; - + pScreen->CloseScreen = miSpriteCloseScreen; pScreen->GetImage = miSpriteGetImage; pScreen->GetSpans = miSpriteGetSpans; pScreen->SourceValidate = miSpriteSourceValidate; - + pScreen->CopyWindow = miSpriteCopyWindow; - + pScreen->SaveDoomedAreas = miSpriteSaveDoomedAreas; - + pScreen->InstallColormap = miSpriteInstallColormap; pScreen->StoreColors = miSpriteStoreColors; pScreen->BlockHandler = miSpriteBlockHandler; - + + damageRegister = 0; + return TRUE; } @@ -253,6 +305,7 @@ miSpriteCloseScreen (i, pScreen) ScreenPtr pScreen; { miSpriteScreenPtr pScreenPriv; + DeviceIntPtr pDev; pScreenPriv = (miSpriteScreenPtr) pScreen->devPrivates[miSpriteScreenIndex].ptr; @@ -265,9 +318,18 @@ miSpriteCloseScreen (i, pScreen) pScreen->StoreColors = pScreenPriv->StoreColors; pScreen->SaveDoomedAreas = pScreenPriv->SaveDoomedAreas; - miSpriteIsUpFALSE (pScreen, pScreenPriv); + for (pDev = inputInfo.devices; pDev; pDev = pDev->next) + { + if (DevHasCursor(pDev)) + { + miCursorInfoPtr pCursor; + pCursor = &pScreenPriv->pDevCursors[pDev->id]; + miSpriteIsUpFALSE (pCursor, pScreen, pScreenPriv); + } + } DamageDestroy (pScreenPriv->pDamage); - + + xfree ((pointer)(pScreenPriv->pDevCursors)); xfree ((pointer) pScreenPriv); return (*pScreen->CloseScreen) (i, pScreen); @@ -283,17 +345,27 @@ miSpriteGetImage (pDrawable, sx, sy, w, h, format, planemask, pdstLine) { ScreenPtr pScreen = pDrawable->pScreen; miSpriteScreenPtr pScreenPriv; + DeviceIntPtr pDev = inputInfo.pointer; + miCursorInfoPtr pCursorInfo; SCREEN_PROLOGUE (pScreen, GetImage); pScreenPriv = (miSpriteScreenPtr) pScreen->devPrivates[miSpriteScreenIndex].ptr; - if (pDrawable->type == DRAWABLE_WINDOW && - pScreenPriv->isUp && - ORG_OVERLAP(&pScreenPriv->saved,pDrawable->x,pDrawable->y, sx, sy, w, h)) + for(pDev = inputInfo.devices; pDev; pDev = pDev->next) { - SPRITE_DEBUG (("GetImage remove\n")); - miSpriteRemoveCursor (pScreen); + if (DevHasCursor(pDev)) + { + pCursorInfo = &pScreenPriv->pDevCursors[pDev->id]; + if (pDrawable->type == DRAWABLE_WINDOW && + pCursorInfo->isUp && + ORG_OVERLAP(&pCursorInfo->saved,pDrawable->x,pDrawable->y, + sx, sy, w, h)) + { + SPRITE_DEBUG (("GetImage remove\n")); + miSpriteRemoveCursor (pDev, pScreen); + } + } } (*pScreen->GetImage) (pDrawable, sx, sy, w, h, @@ -313,34 +385,44 @@ miSpriteGetSpans (pDrawable, wMax, ppt, pwidth, nspans, pdstStart) { ScreenPtr pScreen = pDrawable->pScreen; miSpriteScreenPtr pScreenPriv; + DeviceIntPtr pDev = inputInfo.pointer; + miCursorInfoPtr pCursorInfo; SCREEN_PROLOGUE (pScreen, GetSpans); pScreenPriv = (miSpriteScreenPtr) pScreen->devPrivates[miSpriteScreenIndex].ptr; - if (pDrawable->type == DRAWABLE_WINDOW && pScreenPriv->isUp) + for(pDev = inputInfo.devices; pDev; pDev = pDev->next) { - DDXPointPtr pts; - int *widths; - int nPts; - int xorg, - yorg; - - xorg = pDrawable->x; - yorg = pDrawable->y; - - for (pts = ppt, widths = pwidth, nPts = nspans; - nPts--; - pts++, widths++) - { - if (SPN_OVERLAP(&pScreenPriv->saved,pts->y+yorg, - pts->x+xorg,*widths)) - { - SPRITE_DEBUG (("GetSpans remove\n")); - miSpriteRemoveCursor (pScreen); - break; - } - } + if (DevHasCursor(pDev)) + { + pCursorInfo = &pScreenPriv->pDevCursors[pDev->id]; + + if (pDrawable->type == DRAWABLE_WINDOW && pCursorInfo->isUp) + { + DDXPointPtr pts; + int *widths; + int nPts; + int xorg, + yorg; + + xorg = pDrawable->x; + yorg = pDrawable->y; + + for (pts = ppt, widths = pwidth, nPts = nspans; + nPts--; + pts++, widths++) + { + if (SPN_OVERLAP(&pCursorInfo->saved,pts->y+yorg, + pts->x+xorg,*widths)) + { + SPRITE_DEBUG (("GetSpans remove\n")); + miSpriteRemoveCursor (pDev, pScreen); + break; + } + } + } + } } (*pScreen->GetSpans) (pDrawable, wMax, ppt, pwidth, nspans, pdstStart); @@ -355,17 +437,26 @@ miSpriteSourceValidate (pDrawable, x, y, width, height) { ScreenPtr pScreen = pDrawable->pScreen; miSpriteScreenPtr pScreenPriv; + DeviceIntPtr pDev = inputInfo.pointer; + miCursorInfoPtr pCursorInfo; SCREEN_PROLOGUE (pScreen, SourceValidate); pScreenPriv = (miSpriteScreenPtr) pScreen->devPrivates[miSpriteScreenIndex].ptr; - if (pDrawable->type == DRAWABLE_WINDOW && pScreenPriv->isUp && - ORG_OVERLAP(&pScreenPriv->saved, pDrawable->x, pDrawable->y, - x, y, width, height)) + for(pDev = inputInfo.devices; pDev; pDev = pDev->next) { - SPRITE_DEBUG (("SourceValidate remove\n")); - miSpriteRemoveCursor (pScreen); + if (DevHasCursor(pDev)) + { + pCursorInfo = &pScreenPriv->pDevCursors[pDev->id]; + if (pDrawable->type == DRAWABLE_WINDOW && pCursorInfo->isUp && + ORG_OVERLAP(&pCursorInfo->saved, pDrawable->x, pDrawable->y, + x, y, width, height)) + { + SPRITE_DEBUG (("SourceValidate remove\n")); + miSpriteRemoveCursor (pDev, pScreen); + } + } } if (pScreen->SourceValidate) @@ -379,18 +470,28 @@ miSpriteCopyWindow (WindowPtr pWindow, DDXPointRec ptOldOrg, RegionPtr prgnSrc) { ScreenPtr pScreen = pWindow->drawable.pScreen; miSpriteScreenPtr pScreenPriv; + DeviceIntPtr pDev = inputInfo.pointer; + miCursorInfoPtr pCursorInfo; SCREEN_PROLOGUE (pScreen, CopyWindow); pScreenPriv = (miSpriteScreenPtr) pScreen->devPrivates[miSpriteScreenIndex].ptr; - /* - * Damage will take care of destination check - */ - if (pScreenPriv->isUp && - RECT_IN_REGION (pScreen, prgnSrc, &pScreenPriv->saved) != rgnOUT) + + for(pDev = inputInfo.devices; pDev; pDev = pDev->next) { - SPRITE_DEBUG (("CopyWindow remove\n")); - miSpriteRemoveCursor (pScreen); + if (DevHasCursor(pDev)) + { + pCursorInfo = &pScreenPriv->pDevCursors[pDev->id]; + /* + * Damage will take care of destination check + */ + if (pCursorInfo->isUp && + RECT_IN_REGION (pScreen, prgnSrc, &pCursorInfo->saved) != rgnOUT) + { + SPRITE_DEBUG (("CopyWindow remove\n")); + miSpriteRemoveCursor (pDev, pScreen); + } + } } (*pScreen->CopyWindow) (pWindow, ptOldOrg, prgnSrc); @@ -406,6 +507,8 @@ miSpriteBlockHandler (i, blockData, pTimeout, pReadmask) { ScreenPtr pScreen = screenInfo.screens[i]; miSpriteScreenPtr pPriv; + DeviceIntPtr pDev = inputInfo.pointer; + miCursorInfoPtr pCursorInfo; pPriv = (miSpriteScreenPtr) pScreen->devPrivates[miSpriteScreenIndex].ptr; @@ -415,10 +518,29 @@ miSpriteBlockHandler (i, blockData, pTimeout, pReadmask) SCREEN_EPILOGUE(pScreen, BlockHandler); - if (!pPriv->isUp && pPriv->shouldBeUp) + for(pDev = inputInfo.devices; pDev; pDev = pDev->next) { - SPRITE_DEBUG (("BlockHandler restore\n")); - miSpriteRestoreCursor (pScreen); + if (DevHasCursor(pDev)) + { + pCursorInfo = &pPriv->pDevCursors[pDev->id]; + if (!pCursorInfo->isUp && pCursorInfo->shouldBeUp) + { + SPRITE_DEBUG (("BlockHandler restore\n")); + miSpriteSaveUnderCursor (pDev, pScreen); + } + } + } + for(pDev = inputInfo.devices; pDev; pDev = pDev->next) + { + if (DevHasCursor(pDev)) + { + pCursorInfo = &pPriv->pDevCursors[pDev->id]; + if (!pCursorInfo->isUp && pCursorInfo->shouldBeUp) + { + SPRITE_DEBUG (("BlockHandler restore\n")); + miSpriteRestoreCursor (pDev, pScreen); + } + } } } @@ -428,6 +550,9 @@ miSpriteInstallColormap (pMap) { ScreenPtr pScreen = pMap->pScreen; miSpriteScreenPtr pPriv; + DeviceIntPtr pDev = inputInfo.pointer; + miCursorInfoPtr pCursorInfo; + int cursorIdx; pPriv = (miSpriteScreenPtr) pScreen->devPrivates[miSpriteScreenIndex].ptr; @@ -437,12 +562,29 @@ miSpriteInstallColormap (pMap) SCREEN_EPILOGUE(pScreen, InstallColormap); - pPriv->pInstalledMap = pMap; - if (pPriv->pColormap != pMap) + /* InstallColormap is called before devices are initialized. We cannot + * just run through the device list, we need to go through all possible + * sprite structs.*/ + for (cursorIdx = 0; cursorIdx < MAX_DEVICES; cursorIdx++) { - pPriv->checkPixels = TRUE; - if (pPriv->isUp) - miSpriteRemoveCursor (pScreen); + pCursorInfo = &pPriv->pDevCursors[cursorIdx]; + pCursorInfo->pInstalledMap = pMap; + if (pCursorInfo->pColormap != pMap) + { + pCursorInfo->checkPixels = TRUE; + if (pCursorInfo->isUp) + { + /* find matching device */ + for(pDev = inputInfo.devices; pDev; pDev = pDev->next) + { + if (pDev->id == cursorIdx) + { + miSpriteRemoveCursor(pDev, pScreen); + break; + } + } + } + } } } @@ -457,6 +599,8 @@ miSpriteStoreColors (pMap, ndef, pdef) int i; int updated; VisualPtr pVisual; + DeviceIntPtr pDev = inputInfo.pointer; + miCursorInfoPtr pCursorInfo; pPriv = (miSpriteScreenPtr) pScreen->devPrivates[miSpriteScreenIndex].ptr; @@ -466,74 +610,82 @@ miSpriteStoreColors (pMap, ndef, pdef) SCREEN_EPILOGUE(pScreen, StoreColors); - if (pPriv->pColormap == pMap) - { - updated = 0; - pVisual = pMap->pVisual; - if (pVisual->class == DirectColor) - { - /* Direct color - match on any of the subfields */ - #define MaskMatch(a,b,mask) (((a) & (pVisual->mask)) == ((b) & (pVisual->mask))) -#define UpdateDAC(plane,dac,mask) {\ - if (MaskMatch (pPriv->colors[plane].pixel,pdef[i].pixel,mask)) {\ - pPriv->colors[plane].dac = pdef[i].dac; \ +#define UpdateDAC(dev, plane,dac,mask) {\ + if (MaskMatch (dev->colors[plane].pixel,pdef[i].pixel,mask)) {\ + dev->colors[plane].dac = pdef[i].dac; \ updated = 1; \ } \ } -#define CheckDirect(plane) \ - UpdateDAC(plane,red,redMask) \ - UpdateDAC(plane,green,greenMask) \ - UpdateDAC(plane,blue,blueMask) +#define CheckDirect(dev, plane) \ + UpdateDAC(dev, plane,red,redMask) \ + UpdateDAC(dev, plane,green,greenMask) \ + UpdateDAC(dev, plane,blue,blueMask) - for (i = 0; i < ndef; i++) - { - CheckDirect (SOURCE_COLOR) - CheckDirect (MASK_COLOR) - } - } - else - { - /* PseudoColor/GrayScale - match on exact pixel */ - for (i = 0; i < ndef; i++) - { - if (pdef[i].pixel == pPriv->colors[SOURCE_COLOR].pixel) - { - pPriv->colors[SOURCE_COLOR] = pdef[i]; - if (++updated == 2) - break; - } - if (pdef[i].pixel == pPriv->colors[MASK_COLOR].pixel) - { - pPriv->colors[MASK_COLOR] = pdef[i]; - if (++updated == 2) - break; - } - } - } - if (updated) - { - pPriv->checkPixels = TRUE; - if (pPriv->isUp) - miSpriteRemoveCursor (pScreen); - } + for(pDev = inputInfo.devices; pDev; pDev = pDev->next) + { + if (DevHasCursor(pDev)) + { + pCursorInfo = &pPriv->pDevCursors[pDev->id]; + if (pCursorInfo->pColormap == pMap) + { + updated = 0; + pVisual = pMap->pVisual; + if (pVisual->class == DirectColor) + { + /* Direct color - match on any of the subfields */ + + for (i = 0; i < ndef; i++) + { + CheckDirect (pCursorInfo, SOURCE_COLOR) + CheckDirect (pCursorInfo, MASK_COLOR) + } + } + else + { + /* PseudoColor/GrayScale - match on exact pixel */ + for (i = 0; i < ndef; i++) + { + if (pdef[i].pixel == + pCursorInfo->colors[SOURCE_COLOR].pixel) + { + pCursorInfo->colors[SOURCE_COLOR] = pdef[i]; + if (++updated == 2) + break; + } + if (pdef[i].pixel == + pCursorInfo->colors[MASK_COLOR].pixel) + { + pCursorInfo->colors[MASK_COLOR] = pdef[i]; + if (++updated == 2) + break; + } + } + } + if (updated) + { + pCursorInfo->checkPixels = TRUE; + if (pCursorInfo->isUp) + miSpriteRemoveCursor (pDev, pScreen); + } + } + } } + } static void -miSpriteFindColors (ScreenPtr pScreen) +miSpriteFindColors (miCursorInfoPtr pDevCursor, ScreenPtr pScreen) { - miSpriteScreenPtr pScreenPriv = (miSpriteScreenPtr) - pScreen->devPrivates[miSpriteScreenIndex].ptr; CursorPtr pCursor; xColorItem *sourceColor, *maskColor; - pCursor = pScreenPriv->pCursor; - sourceColor = &pScreenPriv->colors[SOURCE_COLOR]; - maskColor = &pScreenPriv->colors[MASK_COLOR]; - if (pScreenPriv->pColormap != pScreenPriv->pInstalledMap || + pCursor = pDevCursor->pCursor; + sourceColor = &pDevCursor->colors[SOURCE_COLOR]; + maskColor = &pDevCursor->colors[MASK_COLOR]; + if (pDevCursor->pColormap != pDevCursor->pInstalledMap || !(pCursor->foreRed == sourceColor->red && pCursor->foreGreen == sourceColor->green && pCursor->foreBlue == sourceColor->blue && @@ -541,20 +693,22 @@ miSpriteFindColors (ScreenPtr pScreen) pCursor->backGreen == maskColor->green && pCursor->backBlue == maskColor->blue)) { - pScreenPriv->pColormap = pScreenPriv->pInstalledMap; + pDevCursor->pColormap = pDevCursor->pInstalledMap; sourceColor->red = pCursor->foreRed; sourceColor->green = pCursor->foreGreen; sourceColor->blue = pCursor->foreBlue; - FakeAllocColor (pScreenPriv->pColormap, sourceColor); + FakeAllocColor (pDevCursor->pColormap, sourceColor); maskColor->red = pCursor->backRed; maskColor->green = pCursor->backGreen; maskColor->blue = pCursor->backBlue; - FakeAllocColor (pScreenPriv->pColormap, maskColor); + FakeAllocColor (pDevCursor->pColormap, maskColor); /* "free" the pixels right away, don't let this confuse you */ - FakeFreeColor(pScreenPriv->pColormap, sourceColor->pixel); - FakeFreeColor(pScreenPriv->pColormap, maskColor->pixel); + FakeFreeColor(pDevCursor->pColormap, sourceColor->pixel); + FakeFreeColor(pDevCursor->pColormap, maskColor->pixel); } - pScreenPriv->checkPixels = FALSE; + + pDevCursor->checkPixels = FALSE; + } /* @@ -570,25 +724,36 @@ miSpriteSaveDoomedAreas (pWin, pObscured, dx, dy) ScreenPtr pScreen; miSpriteScreenPtr pScreenPriv; BoxRec cursorBox; + DeviceIntPtr pDev = inputInfo.pointer; + miCursorInfoPtr pCursorInfo; pScreen = pWin->drawable.pScreen; SCREEN_PROLOGUE (pScreen, SaveDoomedAreas); pScreenPriv = (miSpriteScreenPtr) pScreen->devPrivates[miSpriteScreenIndex].ptr; - if (pScreenPriv->isUp) + + for (pDev = inputInfo.devices; pDev; pDev = pDev->next) { - cursorBox = pScreenPriv->saved; - - if (dx || dy) - { - cursorBox.x1 += dx; - cursorBox.y1 += dy; - cursorBox.x2 += dx; - cursorBox.y2 += dy; - } - if (RECT_IN_REGION( pScreen, pObscured, &cursorBox) != rgnOUT) - miSpriteRemoveCursor (pScreen); + if(DevHasCursor(pDev)) + { + pCursorInfo = &pScreenPriv->pDevCursors[pDev->id]; + if (pCursorInfo->isUp) + { + cursorBox = pCursorInfo->saved; + + if (dx || dy) + { + cursorBox.x1 += dx; + cursorBox.y1 += dy; + cursorBox.x2 += dx; + cursorBox.y2 += dy; + } + if (RECT_IN_REGION( pScreen, pObscured, &cursorBox) != rgnOUT) + miSpriteRemoveCursor (pDev, pScreen); + } + + } } (*pScreen->SaveDoomedAreas) (pWin, pObscured, dx, dy); @@ -603,20 +768,29 @@ miSpriteSaveDoomedAreas (pWin, pObscured, dx, dy) #define SPRITE_PAD 8 static Bool -miSpriteRealizeCursor (pScreen, pCursor) +miSpriteRealizeCursor (pDev, pScreen, pCursor) + DeviceIntPtr pDev; ScreenPtr pScreen; CursorPtr pCursor; { miSpriteScreenPtr pScreenPriv; + miCursorInfoPtr pCursorInfo; pScreenPriv = (miSpriteScreenPtr) pScreen->devPrivates[miSpriteScreenIndex].ptr; - if (pCursor == pScreenPriv->pCursor) - pScreenPriv->checkPixels = TRUE; + pCursorInfo = pScreenPriv->cp; + + if (DevHasCursor(pDev)) + pCursorInfo = &pScreenPriv->pDevCursors[pDev->id]; + + if (pCursor == pCursorInfo->pCursor) + pCursorInfo->checkPixels = TRUE; + return (*pScreenPriv->funcs->RealizeCursor) (pScreen, pCursor); } static Bool -miSpriteUnrealizeCursor (pScreen, pCursor) +miSpriteUnrealizeCursor (pDev, pScreen, pCursor) + DeviceIntPtr pDev; ScreenPtr pScreen; CursorPtr pCursor; { @@ -627,7 +801,8 @@ miSpriteUnrealizeCursor (pScreen, pCursor) } static void -miSpriteSetCursor (pScreen, pCursor, x, y) +miSpriteSetCursor (pDev, pScreen, pCursor, x, y) + DeviceIntPtr pDev; ScreenPtr pScreen; CursorPtr pCursor; int x; @@ -636,107 +811,130 @@ miSpriteSetCursor (pScreen, pCursor, x, y) miSpriteScreenPtr pScreenPriv; pScreenPriv = (miSpriteScreenPtr) pScreen->devPrivates[miSpriteScreenIndex].ptr; + miCursorInfoPtr pPointer = pScreenPriv->cp; + + if (DevHasCursor(pDev)) + pPointer = &pScreenPriv->pDevCursors[pDev->id]; + if (!pCursor) { - pScreenPriv->shouldBeUp = FALSE; - if (pScreenPriv->isUp) - miSpriteRemoveCursor (pScreen); - pScreenPriv->pCursor = 0; + pPointer->shouldBeUp = FALSE; + if (pPointer->isUp) + miSpriteRemoveCursor (pDev, pScreen); + pPointer->pCursor = 0; return; } - pScreenPriv->shouldBeUp = TRUE; - if (pScreenPriv->x == x && - pScreenPriv->y == y && - pScreenPriv->pCursor == pCursor && - !pScreenPriv->checkPixels) + pPointer->shouldBeUp = TRUE; + if (pPointer->x == x && + pPointer->y == y && + pPointer->pCursor == pCursor && + !pPointer->checkPixels) { return; } - pScreenPriv->x = x; - pScreenPriv->y = y; - pScreenPriv->pCacheWin = NullWindow; - if (pScreenPriv->checkPixels || pScreenPriv->pCursor != pCursor) + pPointer->x = x; + pPointer->y = y; + pPointer->pCacheWin = NullWindow; + if (pPointer->checkPixels || pPointer->pCursor != pCursor) { - pScreenPriv->pCursor = pCursor; - miSpriteFindColors (pScreen); + pPointer->pCursor = pCursor; + miSpriteFindColors (pPointer, pScreen); } - if (pScreenPriv->isUp) { + if (pPointer->isUp) { +#if 0 + /* FIXME: Disabled for MPX, should be rewritten */ int sx, sy; /* * check to see if the old saved region * encloses the new sprite, in which case we use * the flicker-free MoveCursor primitive. */ - sx = pScreenPriv->x - (int)pCursor->bits->xhot; - sy = pScreenPriv->y - (int)pCursor->bits->yhot; - if (sx + (int) pCursor->bits->width >= pScreenPriv->saved.x1 && - sx < pScreenPriv->saved.x2 && - sy + (int) pCursor->bits->height >= pScreenPriv->saved.y1 && - sy < pScreenPriv->saved.y2 && + sx = pointer->x - (int)pCursor->bits->xhot; + sy = pointer->y - (int)pCursor->bits->yhot; + if (sx + (int) pCursor->bits->width >= pointer->saved.x1 && + sx < pointer->saved.x2 && + sy + (int) pCursor->bits->height >= pointer->saved.y1 && + sy < pointer->saved.y2 && (int) pCursor->bits->width + (2 * SPRITE_PAD) == - pScreenPriv->saved.x2 - pScreenPriv->saved.x1 && + pointer->saved.x2 - pointer->saved.x1 && (int) pCursor->bits->height + (2 * SPRITE_PAD) == - pScreenPriv->saved.y2 - pScreenPriv->saved.y1 + pointer->saved.y2 - pointer->saved.y1 ) { DamageDrawInternal (pScreen, TRUE); miSpriteIsUpFALSE (pScreen, pScreenPriv); - if (!(sx >= pScreenPriv->saved.x1 && - sx + (int)pCursor->bits->width < pScreenPriv->saved.x2 && - sy >= pScreenPriv->saved.y1 && - sy + (int)pCursor->bits->height < pScreenPriv->saved.y2)) - { + if (!(sx >= pointer->saved.x1 && + sx + (int)pCursor->bits->width < pointer->saved.x2 + && sy >= pointer->saved.y1 && + sy + (int)pCursor->bits->height < + pointer->saved.y2)) + { int oldx1, oldy1, dx, dy; - oldx1 = pScreenPriv->saved.x1; - oldy1 = pScreenPriv->saved.y1; + oldx1 = pointer->saved.x1; + oldy1 = pointer->saved.y1; dx = oldx1 - (sx - SPRITE_PAD); dy = oldy1 - (sy - SPRITE_PAD); - pScreenPriv->saved.x1 -= dx; - pScreenPriv->saved.y1 -= dy; - pScreenPriv->saved.x2 -= dx; - pScreenPriv->saved.y2 -= dy; + pointer->saved.x1 -= dx; + pointer->saved.y1 -= dy; + pointer->saved.x2 -= dx; + pointer->saved.y2 -= dy; (void) (*pScreenPriv->funcs->ChangeSave) (pScreen, - pScreenPriv->saved.x1, - pScreenPriv->saved.y1, - pScreenPriv->saved.x2 - pScreenPriv->saved.x1, - pScreenPriv->saved.y2 - pScreenPriv->saved.y1, + pointer->saved.x1, + pointer->saved.y1, + pointer->saved.x2 - + pointer->saved.x1, + pointer->saved.y2 - + pointer->saved.y1, dx, dy); } (void) (*pScreenPriv->funcs->MoveCursor) (pScreen, pCursor, - pScreenPriv->saved.x1, - pScreenPriv->saved.y1, - pScreenPriv->saved.x2 - pScreenPriv->saved.x1, - pScreenPriv->saved.y2 - pScreenPriv->saved.y1, - sx - pScreenPriv->saved.x1, - sy - pScreenPriv->saved.y1, - pScreenPriv->colors[SOURCE_COLOR].pixel, - pScreenPriv->colors[MASK_COLOR].pixel); + pointer->saved.x1, + pointer->saved.y1, + pointer->saved.x2 - + pointer->saved.x1, + pointer->saved.y2 - + pointer->saved.y1, + sx - pointer->saved.x1, + sy - pointer->saved.y1, + pointer->colors[SOURCE_COLOR].pixel, + pointer->colors[MASK_COLOR].pixel); miSpriteIsUpTRUE (pScreen, pScreenPriv); DamageDrawInternal (pScreen, FALSE); } else +#endif { - SPRITE_DEBUG (("SetCursor remove\n")); - miSpriteRemoveCursor (pScreen); + SPRITE_DEBUG (("SetCursor remove %d\n", pDev->id)); + miSpriteRemoveCursor (pDev, pScreen); } } - if (!pScreenPriv->isUp && pScreenPriv->pCursor) + + if (!pPointer->isUp && pPointer->pCursor) { - SPRITE_DEBUG (("SetCursor restore\n")); - miSpriteRestoreCursor (pScreen); + SPRITE_DEBUG (("SetCursor restore %d\n", pDev->id)); + miSpriteSaveUnderCursor(pDev, pScreen); + miSpriteRestoreCursor (pDev, pScreen); } + } static void -miSpriteMoveCursor (pScreen, x, y) +miSpriteMoveCursor (pDev, pScreen, x, y) + DeviceIntPtr pDev; ScreenPtr pScreen; int x, y; { miSpriteScreenPtr pScreenPriv; + CursorPtr pCursor; pScreenPriv = (miSpriteScreenPtr) pScreen->devPrivates[miSpriteScreenIndex].ptr; - miSpriteSetCursor (pScreen, pScreenPriv->pCursor, x, y); + pCursor = pScreenPriv->cp->pCursor; + + if (DevHasCursor(pDev)) + pCursor = pScreenPriv->pDevCursors[pDev->id].pCursor; + + miSpriteSetCursor (pDev, pScreen, pCursor, x, y); } /* @@ -744,60 +942,121 @@ miSpriteMoveCursor (pScreen, x, y) */ static void -miSpriteRemoveCursor (pScreen) +miSpriteRemoveCursor (pDev, pScreen) + DeviceIntPtr pDev; ScreenPtr pScreen; { miSpriteScreenPtr pScreenPriv; + miCursorInfoPtr pCursorInfo; + DamageDrawInternal (pScreen, TRUE); pScreenPriv = (miSpriteScreenPtr) pScreen->devPrivates[miSpriteScreenIndex].ptr; - miSpriteIsUpFALSE (pScreen, pScreenPriv); - pScreenPriv->pCacheWin = NullWindow; - if (!(*pScreenPriv->funcs->RestoreUnderCursor) (pScreen, - pScreenPriv->saved.x1, - pScreenPriv->saved.y1, - pScreenPriv->saved.x2 - pScreenPriv->saved.x1, - pScreenPriv->saved.y2 - pScreenPriv->saved.y1)) + pCursorInfo = pScreenPriv->cp; + + if (DevHasCursor(pDev)) + pCursorInfo = &pScreenPriv->pDevCursors[pDev->id]; + + miSpriteIsUpFALSE (pCursorInfo, pScreen, pScreenPriv); + pCursorInfo->pCacheWin = NullWindow; + miSpriteDisableDamage(pScreen, pScreenPriv); + if (!(*pScreenPriv->funcs->RestoreUnderCursor) (pDev, + pScreen, + pCursorInfo->saved.x1, + pCursorInfo->saved.y1, + pCursorInfo->saved.x2 - + pCursorInfo->saved.x1, + pCursorInfo->saved.y2 - + pCursorInfo->saved.y1)) { - miSpriteIsUpTRUE (pScreen, pScreenPriv); + miSpriteIsUpTRUE (pCursorInfo, pScreen, pScreenPriv); } + miSpriteEnableDamage(pScreen, pScreenPriv); + DamageDrawInternal (pScreen, FALSE); +} + +/* + * Called from the block handler, saves area under cursor + * before waiting for something to do. + */ + +static void +miSpriteSaveUnderCursor(pDev, pScreen) + DeviceIntPtr pDev; + ScreenPtr pScreen; +{ + miSpriteScreenPtr pScreenPriv; + int x, y; + CursorPtr pCursor; + miCursorInfoPtr pCursorInfo; + + DamageDrawInternal (pScreen, TRUE); + pScreenPriv = (miSpriteScreenPtr) pScreen->devPrivates[miSpriteScreenIndex].ptr; + pCursorInfo = pScreenPriv->cp; + + if (DevHasCursor(pDev)) + pCursorInfo = &pScreenPriv->pDevCursors[pDev->id]; + + miSpriteComputeSaved (pDev, pScreen); + pCursor = pCursorInfo->pCursor; + + x = pCursorInfo->x - (int)pCursor->bits->xhot; + y = pCursorInfo->y - (int)pCursor->bits->yhot; + miSpriteDisableDamage(pScreen, pScreenPriv); + + (*pScreenPriv->funcs->SaveUnderCursor) (pDev, + pScreen, + pCursorInfo->saved.x1, + pCursorInfo->saved.y1, + pCursorInfo->saved.x2 - + pCursorInfo->saved.x1, + pCursorInfo->saved.y2 - + pCursorInfo->saved.y1); + SPRITE_DEBUG(("SaveUnderCursor %d\n", pDev->id)); + miSpriteEnableDamage(pScreen, pScreenPriv); DamageDrawInternal (pScreen, FALSE); } + /* * Called from the block handler, restores the cursor * before waiting for something to do. */ static void -miSpriteRestoreCursor (pScreen) +miSpriteRestoreCursor (pDev, pScreen) + DeviceIntPtr pDev; ScreenPtr pScreen; { miSpriteScreenPtr pScreenPriv; int x, y; CursorPtr pCursor; + miCursorInfoPtr pCursorInfo; DamageDrawInternal (pScreen, TRUE); - miSpriteComputeSaved (pScreen); pScreenPriv = (miSpriteScreenPtr) pScreen->devPrivates[miSpriteScreenIndex].ptr; - pCursor = pScreenPriv->pCursor; - x = pScreenPriv->x - (int)pCursor->bits->xhot; - y = pScreenPriv->y - (int)pCursor->bits->yhot; - if ((*pScreenPriv->funcs->SaveUnderCursor) (pScreen, - pScreenPriv->saved.x1, - pScreenPriv->saved.y1, - pScreenPriv->saved.x2 - pScreenPriv->saved.x1, - pScreenPriv->saved.y2 - pScreenPriv->saved.y1)) + pCursorInfo = pScreenPriv->cp; + + if (DevHasCursor(pDev)) + pCursorInfo = &pScreenPriv->pDevCursors[pDev->id]; + + miSpriteComputeSaved (pDev, pScreen); + pCursor = pCursorInfo->pCursor; + + x = pCursorInfo->x - (int)pCursor->bits->xhot; + y = pCursorInfo->y - (int)pCursor->bits->yhot; + miSpriteDisableDamage(pScreen, pScreenPriv); + SPRITE_DEBUG(("RestoreCursor %d\n", pDev->id)); + if (pCursorInfo->checkPixels) + miSpriteFindColors (pCursorInfo, pScreen); + if ((*pScreenPriv->funcs->PutUpCursor) (pDev, pScreen, + pCursor, x, y, + pCursorInfo->colors[SOURCE_COLOR].pixel, + pCursorInfo->colors[MASK_COLOR].pixel)) { - if (pScreenPriv->checkPixels) - miSpriteFindColors (pScreen); - if ((*pScreenPriv->funcs->PutUpCursor) (pScreen, pCursor, x, y, - pScreenPriv->colors[SOURCE_COLOR].pixel, - pScreenPriv->colors[MASK_COLOR].pixel)) - { - miSpriteIsUpTRUE (pScreen, pScreenPriv); - } + miSpriteIsUpTRUE (pCursorInfo, pScreen, pScreenPriv); } + miSpriteEnableDamage(pScreen, pScreenPriv); DamageDrawInternal (pScreen, FALSE); } @@ -806,24 +1065,32 @@ miSpriteRestoreCursor (pScreen) */ static void -miSpriteComputeSaved (pScreen) +miSpriteComputeSaved (pDev, pScreen) + DeviceIntPtr pDev; ScreenPtr pScreen; { miSpriteScreenPtr pScreenPriv; int x, y, w, h; int wpad, hpad; CursorPtr pCursor; + miCursorInfoPtr pCursorInfo; pScreenPriv = (miSpriteScreenPtr) pScreen->devPrivates[miSpriteScreenIndex].ptr; - pCursor = pScreenPriv->pCursor; - x = pScreenPriv->x - (int)pCursor->bits->xhot; - y = pScreenPriv->y - (int)pCursor->bits->yhot; + pCursorInfo = pScreenPriv->cp; + + if (DevHasCursor(pDev)) + pCursorInfo = &pScreenPriv->pDevCursors[pDev->id]; + + pCursor = pCursorInfo->pCursor; + x = pCursorInfo->x - (int)pCursor->bits->xhot; + y = pCursorInfo->y - (int)pCursor->bits->yhot; w = pCursor->bits->width; h = pCursor->bits->height; wpad = SPRITE_PAD; hpad = SPRITE_PAD; - pScreenPriv->saved.x1 = x - wpad; - pScreenPriv->saved.y1 = y - hpad; - pScreenPriv->saved.x2 = pScreenPriv->saved.x1 + w + wpad * 2; - pScreenPriv->saved.y2 = pScreenPriv->saved.y1 + h + hpad * 2; + pCursorInfo->saved.x1 = x - wpad; + pCursorInfo->saved.y1 = y - hpad; + pCursorInfo->saved.x2 = pCursorInfo->saved.x1 + w + wpad * 2; + pCursorInfo->saved.y2 = pCursorInfo->saved.y1 + h + hpad * 2; } + |