2006-11-26 11:13:41 -07:00
|
|
|
/*
|
|
|
|
* misprite.c
|
|
|
|
*
|
|
|
|
* machine independent software sprite routines
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
|
|
Copyright 1989, 1998 The Open Group
|
|
|
|
|
|
|
|
Permission to use, copy, modify, distribute, and sell this software and its
|
|
|
|
documentation for any purpose is hereby granted without fee, provided that
|
|
|
|
the above copyright notice appear in all copies and that both that
|
|
|
|
copyright notice and this permission notice appear in supporting
|
|
|
|
documentation.
|
|
|
|
|
|
|
|
The above copyright notice and this permission notice shall be included in
|
|
|
|
all copies or substantial portions of the Software.
|
|
|
|
|
|
|
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
|
|
|
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
|
|
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
|
|
|
|
|
|
Except as contained in this notice, the name of 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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef HAVE_DIX_CONFIG_H
|
|
|
|
#include <dix-config.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
# include <X11/X.h>
|
|
|
|
# include <X11/Xproto.h>
|
|
|
|
# include "misc.h"
|
|
|
|
# include "pixmapstr.h"
|
|
|
|
# include "input.h"
|
|
|
|
# include "mi.h"
|
|
|
|
# include "cursorstr.h"
|
|
|
|
# include <X11/fonts/font.h>
|
|
|
|
# include "scrnintstr.h"
|
|
|
|
# include "colormapst.h"
|
|
|
|
# include "windowstr.h"
|
|
|
|
# include "gcstruct.h"
|
|
|
|
# include "mipointer.h"
|
|
|
|
# include "mispritest.h"
|
|
|
|
# include "dixfontstr.h"
|
|
|
|
# include <X11/fonts/fontstruct.h>
|
2009-09-06 13:44:18 -06:00
|
|
|
# include "inputstr.h"
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
#ifdef RENDER
|
|
|
|
# include "mipict.h"
|
|
|
|
#endif
|
|
|
|
# include "damage.h"
|
|
|
|
|
2009-09-06 13:44:18 -06:00
|
|
|
|
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
#define SPRITE_DEBUG_ENABLE 0
|
|
|
|
#if SPRITE_DEBUG_ENABLE
|
|
|
|
#define SPRITE_DEBUG(x) ErrorF x
|
|
|
|
#else
|
|
|
|
#define SPRITE_DEBUG(x)
|
|
|
|
#endif
|
|
|
|
|
2009-09-06 13:44:18 -06:00
|
|
|
|
|
|
|
#define MISPRITE(dev) \
|
|
|
|
((DevHasCursor(dev)) ? \
|
|
|
|
(miCursorInfoPtr)dixLookupPrivate(&dev->devPrivates, miSpriteDevPrivatesKey) : \
|
|
|
|
(miCursorInfoPtr)dixLookupPrivate(&dev->u.master->devPrivates, miSpriteDevPrivatesKey))
|
|
|
|
|
|
|
|
static int damageRegister = 0;
|
|
|
|
|
|
|
|
static void
|
|
|
|
miSpriteDisableDamage(ScreenPtr pScreen, miSpriteScreenPtr pScreenPriv)
|
|
|
|
{
|
|
|
|
if (damageRegister) {
|
|
|
|
DamageUnregister (&(pScreen->GetScreenPixmap(pScreen)->drawable),
|
|
|
|
pScreenPriv->pDamage);
|
|
|
|
damageRegister = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
miSpriteEnableDamage(ScreenPtr pScreen, miSpriteScreenPtr pScreenPriv)
|
|
|
|
{
|
|
|
|
if (!damageRegister) {
|
|
|
|
damageRegister = 1;
|
|
|
|
DamageRegister (&(pScreen->GetScreenPixmap(pScreen)->drawable),
|
|
|
|
pScreenPriv->pDamage);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
miSpriteIsUp(miCursorInfoPtr pDevCursor)
|
|
|
|
{
|
|
|
|
pDevCursor->isUp = TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
miSpriteIsDown(miCursorInfoPtr pDevCursor)
|
|
|
|
{
|
|
|
|
pDevCursor->isUp = FALSE;
|
|
|
|
}
|
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
/*
|
|
|
|
* screen wrappers
|
|
|
|
*/
|
|
|
|
|
2009-09-06 13:44:18 -06:00
|
|
|
static int miSpriteScreenKeyIndex;
|
|
|
|
static DevPrivateKey miSpriteScreenKey = &miSpriteScreenKeyIndex;
|
|
|
|
static int mmiSpriteDevPrivatesKeyIndex;
|
|
|
|
static DevPrivateKey miSpriteDevPrivatesKey = &mmiSpriteDevPrivatesKeyIndex;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
static Bool miSpriteCloseScreen(int i, ScreenPtr pScreen);
|
|
|
|
static void miSpriteGetImage(DrawablePtr pDrawable, int sx, int sy,
|
|
|
|
int w, int h, unsigned int format,
|
|
|
|
unsigned long planemask, char *pdstLine);
|
|
|
|
static void miSpriteGetSpans(DrawablePtr pDrawable, int wMax,
|
|
|
|
DDXPointPtr ppt, int *pwidth, int nspans,
|
|
|
|
char *pdstStart);
|
|
|
|
static void miSpriteSourceValidate(DrawablePtr pDrawable, int x, int y,
|
|
|
|
int width, int height);
|
|
|
|
static void miSpriteCopyWindow (WindowPtr pWindow,
|
|
|
|
DDXPointRec ptOldOrg,
|
|
|
|
RegionPtr prgnSrc);
|
|
|
|
static void miSpriteBlockHandler(int i, pointer blockData,
|
|
|
|
pointer pTimeout,
|
|
|
|
pointer pReadMask);
|
|
|
|
static void miSpriteInstallColormap(ColormapPtr pMap);
|
|
|
|
static void miSpriteStoreColors(ColormapPtr pMap, int ndef,
|
|
|
|
xColorItem *pdef);
|
|
|
|
|
2009-09-06 13:44:18 -06:00
|
|
|
static void miSpriteComputeSaved(DeviceIntPtr pDev,
|
|
|
|
ScreenPtr pScreen);
|
|
|
|
|
|
|
|
static Bool miSpriteDeviceCursorInitialize(DeviceIntPtr pDev,
|
|
|
|
ScreenPtr pScreen);
|
|
|
|
static void miSpriteDeviceCursorCleanup(DeviceIntPtr pDev,
|
|
|
|
ScreenPtr pScreen);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2008-11-02 08:26:08 -07:00
|
|
|
#define SCREEN_PROLOGUE(pScreen, field) ((pScreen)->field = \
|
|
|
|
((miSpriteScreenPtr)dixLookupPrivate(&(pScreen)->devPrivates, \
|
|
|
|
miSpriteScreenKey))->field)
|
2006-11-26 11:13:41 -07:00
|
|
|
#define SCREEN_EPILOGUE(pScreen, field)\
|
|
|
|
((pScreen)->field = miSprite##field)
|
|
|
|
|
|
|
|
/*
|
|
|
|
* pointer-sprite method table
|
|
|
|
*/
|
|
|
|
|
2009-09-06 13:44:18 -06:00
|
|
|
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);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
_X_EXPORT miPointerSpriteFuncRec miSpritePointerFuncs = {
|
|
|
|
miSpriteRealizeCursor,
|
|
|
|
miSpriteUnrealizeCursor,
|
|
|
|
miSpriteSetCursor,
|
|
|
|
miSpriteMoveCursor,
|
2009-09-06 13:44:18 -06:00
|
|
|
miSpriteDeviceCursorInitialize,
|
|
|
|
miSpriteDeviceCursorCleanup,
|
2006-11-26 11:13:41 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* other misc functions
|
|
|
|
*/
|
|
|
|
|
2009-09-06 13:44:18 -06:00
|
|
|
static void miSpriteRemoveCursor(DeviceIntPtr pDev,
|
|
|
|
ScreenPtr pScreen);
|
|
|
|
static void miSpriteSaveUnderCursor(DeviceIntPtr pDev,
|
|
|
|
ScreenPtr pScreen);
|
|
|
|
static void miSpriteRestoreCursor(DeviceIntPtr pDev,
|
|
|
|
ScreenPtr pScreen);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
static void
|
|
|
|
miSpriteReportDamage (DamagePtr pDamage, RegionPtr pRegion, void *closure)
|
|
|
|
{
|
|
|
|
ScreenPtr pScreen = closure;
|
|
|
|
miSpriteScreenPtr pScreenPriv;
|
2009-09-06 13:44:18 -06:00
|
|
|
miCursorInfoPtr pCursorInfo;
|
|
|
|
DeviceIntPtr pDev;
|
|
|
|
|
2008-11-02 08:26:08 -07:00
|
|
|
pScreenPriv = (miSpriteScreenPtr)dixLookupPrivate(&pScreen->devPrivates,
|
|
|
|
miSpriteScreenKey);
|
2009-09-06 13:44:18 -06:00
|
|
|
|
|
|
|
for (pDev = inputInfo.devices; pDev; pDev = pDev->next)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2009-09-06 13:44:18 -06:00
|
|
|
if (DevHasCursor(pDev))
|
|
|
|
{
|
|
|
|
pCursorInfo = MISPRITE(pDev);
|
|
|
|
|
|
|
|
if (pCursorInfo->isUp &&
|
|
|
|
pCursorInfo->pScreen == pScreen &&
|
|
|
|
RECT_IN_REGION (pScreen, pRegion, &pCursorInfo->saved)
|
|
|
|
!= rgnOUT)
|
|
|
|
{
|
|
|
|
SPRITE_DEBUG(("Damage remove\n"));
|
|
|
|
miSpriteRemoveCursor (pDev, pScreen);
|
|
|
|
}
|
|
|
|
}
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* miSpriteInitialize -- called from device-dependent screen
|
|
|
|
* initialization proc after all of the function pointers have
|
|
|
|
* been stored in the screen structure.
|
|
|
|
*/
|
|
|
|
|
|
|
|
Bool
|
2009-09-06 13:44:18 -06:00
|
|
|
miSpriteInitialize (ScreenPtr pScreen,
|
|
|
|
miSpriteCursorFuncPtr cursorFuncs,
|
|
|
|
miPointerScreenFuncPtr screenFuncs)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
miSpriteScreenPtr pScreenPriv;
|
|
|
|
VisualPtr pVisual;
|
2009-09-06 13:44:18 -06:00
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
if (!DamageSetup (pScreen))
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
pScreenPriv = (miSpriteScreenPtr) xalloc (sizeof (miSpriteScreenRec));
|
|
|
|
if (!pScreenPriv)
|
|
|
|
return FALSE;
|
2009-09-06 13:44:18 -06:00
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
pScreenPriv->pDamage = DamageCreate (miSpriteReportDamage,
|
|
|
|
(DamageDestroyFunc) 0,
|
|
|
|
DamageReportRawRegion,
|
|
|
|
TRUE,
|
|
|
|
pScreen,
|
|
|
|
(void *) pScreen);
|
|
|
|
|
|
|
|
if (!miPointerInitialize (pScreen, &miSpritePointerFuncs, screenFuncs,TRUE))
|
|
|
|
{
|
|
|
|
xfree ((pointer) pScreenPriv);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
for (pVisual = pScreen->visuals;
|
|
|
|
pVisual->vid != pScreen->rootVisual;
|
|
|
|
pVisual++)
|
|
|
|
;
|
|
|
|
pScreenPriv->pVisual = pVisual;
|
|
|
|
pScreenPriv->CloseScreen = pScreen->CloseScreen;
|
|
|
|
pScreenPriv->GetImage = pScreen->GetImage;
|
|
|
|
pScreenPriv->GetSpans = pScreen->GetSpans;
|
|
|
|
pScreenPriv->SourceValidate = pScreen->SourceValidate;
|
|
|
|
|
|
|
|
pScreenPriv->CopyWindow = pScreen->CopyWindow;
|
2009-09-06 13:44:18 -06:00
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
pScreenPriv->InstallColormap = pScreen->InstallColormap;
|
|
|
|
pScreenPriv->StoreColors = pScreen->StoreColors;
|
2009-09-06 13:44:18 -06:00
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
pScreenPriv->BlockHandler = pScreen->BlockHandler;
|
2009-09-06 13:44:18 -06:00
|
|
|
|
|
|
|
pScreenPriv->DeviceCursorInitialize = pScreen->DeviceCursorInitialize;
|
|
|
|
pScreenPriv->DeviceCursorCleanup = pScreen->DeviceCursorCleanup;
|
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
pScreenPriv->pInstalledMap = NULL;
|
|
|
|
pScreenPriv->pColormap = NULL;
|
|
|
|
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;
|
2008-11-02 08:26:08 -07:00
|
|
|
dixSetPrivate(&pScreen->devPrivates, miSpriteScreenKey, pScreenPriv);
|
2009-09-06 13:44:18 -06:00
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
pScreen->CloseScreen = miSpriteCloseScreen;
|
|
|
|
pScreen->GetImage = miSpriteGetImage;
|
|
|
|
pScreen->GetSpans = miSpriteGetSpans;
|
|
|
|
pScreen->SourceValidate = miSpriteSourceValidate;
|
2009-09-06 13:44:18 -06:00
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
pScreen->CopyWindow = miSpriteCopyWindow;
|
|
|
|
pScreen->InstallColormap = miSpriteInstallColormap;
|
|
|
|
pScreen->StoreColors = miSpriteStoreColors;
|
|
|
|
|
|
|
|
pScreen->BlockHandler = miSpriteBlockHandler;
|
2009-09-06 13:44:18 -06:00
|
|
|
|
|
|
|
damageRegister = 0;
|
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Screen wrappers
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* CloseScreen wrapper -- unwrap everything, free the private data
|
|
|
|
* and call the wrapped function
|
|
|
|
*/
|
|
|
|
|
|
|
|
static Bool
|
2009-09-06 13:44:18 -06:00
|
|
|
miSpriteCloseScreen (int i, ScreenPtr pScreen)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
miSpriteScreenPtr pScreenPriv;
|
|
|
|
|
2008-11-02 08:26:08 -07:00
|
|
|
pScreenPriv = (miSpriteScreenPtr)dixLookupPrivate(&pScreen->devPrivates,
|
|
|
|
miSpriteScreenKey);
|
2006-11-26 11:13:41 -07:00
|
|
|
pScreen->CloseScreen = pScreenPriv->CloseScreen;
|
|
|
|
pScreen->GetImage = pScreenPriv->GetImage;
|
|
|
|
pScreen->GetSpans = pScreenPriv->GetSpans;
|
|
|
|
pScreen->SourceValidate = pScreenPriv->SourceValidate;
|
|
|
|
pScreen->BlockHandler = pScreenPriv->BlockHandler;
|
|
|
|
pScreen->InstallColormap = pScreenPriv->InstallColormap;
|
|
|
|
pScreen->StoreColors = pScreenPriv->StoreColors;
|
|
|
|
|
|
|
|
DamageDestroy (pScreenPriv->pDamage);
|
2009-09-06 13:44:18 -06:00
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
xfree ((pointer) pScreenPriv);
|
|
|
|
|
|
|
|
return (*pScreen->CloseScreen) (i, pScreen);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2009-09-06 13:44:18 -06:00
|
|
|
miSpriteGetImage (DrawablePtr pDrawable, int sx, int sy, int w, int h,
|
|
|
|
unsigned int format, unsigned long planemask,
|
|
|
|
char *pdstLine)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
ScreenPtr pScreen = pDrawable->pScreen;
|
|
|
|
miSpriteScreenPtr pScreenPriv;
|
2009-09-06 13:44:18 -06:00
|
|
|
DeviceIntPtr pDev = inputInfo.pointer;
|
|
|
|
miCursorInfoPtr pCursorInfo;
|
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
SCREEN_PROLOGUE (pScreen, GetImage);
|
|
|
|
|
2008-11-02 08:26:08 -07:00
|
|
|
pScreenPriv = (miSpriteScreenPtr)dixLookupPrivate(&pScreen->devPrivates,
|
|
|
|
miSpriteScreenKey);
|
2009-09-06 13:44:18 -06:00
|
|
|
for(pDev = inputInfo.devices; pDev; pDev = pDev->next)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2009-09-06 13:44:18 -06:00
|
|
|
if (DevHasCursor(pDev))
|
|
|
|
{
|
|
|
|
pCursorInfo = MISPRITE(pDev);
|
|
|
|
if (pDrawable->type == DRAWABLE_WINDOW &&
|
|
|
|
pCursorInfo->isUp &&
|
|
|
|
pCursorInfo->pScreen == pScreen &&
|
|
|
|
ORG_OVERLAP(&pCursorInfo->saved,pDrawable->x,pDrawable->y,
|
|
|
|
sx, sy, w, h))
|
|
|
|
{
|
|
|
|
SPRITE_DEBUG (("GetImage remove\n"));
|
|
|
|
miSpriteRemoveCursor (pDev, pScreen);
|
|
|
|
}
|
|
|
|
}
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
(*pScreen->GetImage) (pDrawable, sx, sy, w, h,
|
|
|
|
format, planemask, pdstLine);
|
|
|
|
|
|
|
|
SCREEN_EPILOGUE (pScreen, GetImage);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2009-09-06 13:44:18 -06:00
|
|
|
miSpriteGetSpans (DrawablePtr pDrawable, int wMax, DDXPointPtr ppt,
|
|
|
|
int *pwidth, int nspans, char *pdstStart)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
ScreenPtr pScreen = pDrawable->pScreen;
|
|
|
|
miSpriteScreenPtr pScreenPriv;
|
2009-09-06 13:44:18 -06:00
|
|
|
DeviceIntPtr pDev = inputInfo.pointer;
|
|
|
|
miCursorInfoPtr pCursorInfo;
|
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
SCREEN_PROLOGUE (pScreen, GetSpans);
|
|
|
|
|
2008-11-02 08:26:08 -07:00
|
|
|
pScreenPriv = (miSpriteScreenPtr)dixLookupPrivate(&pScreen->devPrivates,
|
|
|
|
miSpriteScreenKey);
|
2009-09-06 13:44:18 -06:00
|
|
|
|
|
|
|
for(pDev = inputInfo.devices; pDev; pDev = pDev->next)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2009-09-06 13:44:18 -06:00
|
|
|
if (DevHasCursor(pDev))
|
|
|
|
{
|
|
|
|
pCursorInfo = MISPRITE(pDev);
|
|
|
|
|
|
|
|
if (pDrawable->type == DRAWABLE_WINDOW &&
|
|
|
|
pCursorInfo->isUp &&
|
|
|
|
pCursorInfo->pScreen == pScreen)
|
|
|
|
{
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
(*pScreen->GetSpans) (pDrawable, wMax, ppt, pwidth, nspans, pdstStart);
|
|
|
|
|
|
|
|
SCREEN_EPILOGUE (pScreen, GetSpans);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2009-09-06 13:44:18 -06:00
|
|
|
miSpriteSourceValidate (DrawablePtr pDrawable, int x, int y, int width,
|
|
|
|
int height)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
ScreenPtr pScreen = pDrawable->pScreen;
|
|
|
|
miSpriteScreenPtr pScreenPriv;
|
2009-09-06 13:44:18 -06:00
|
|
|
DeviceIntPtr pDev = inputInfo.pointer;
|
|
|
|
miCursorInfoPtr pCursorInfo;
|
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
SCREEN_PROLOGUE (pScreen, SourceValidate);
|
|
|
|
|
2008-11-02 08:26:08 -07:00
|
|
|
pScreenPriv = (miSpriteScreenPtr)dixLookupPrivate(&pScreen->devPrivates,
|
|
|
|
miSpriteScreenKey);
|
2009-09-06 13:44:18 -06:00
|
|
|
|
|
|
|
for(pDev = inputInfo.devices; pDev; pDev = pDev->next)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2009-09-06 13:44:18 -06:00
|
|
|
if (DevHasCursor(pDev))
|
|
|
|
{
|
|
|
|
pCursorInfo = MISPRITE(pDev);
|
|
|
|
if (pDrawable->type == DRAWABLE_WINDOW && pCursorInfo->isUp &&
|
|
|
|
pCursorInfo->pScreen == pScreen &&
|
|
|
|
ORG_OVERLAP(&pCursorInfo->saved, pDrawable->x, pDrawable->y,
|
|
|
|
x, y, width, height))
|
|
|
|
{
|
|
|
|
SPRITE_DEBUG (("SourceValidate remove\n"));
|
|
|
|
miSpriteRemoveCursor (pDev, pScreen);
|
|
|
|
}
|
|
|
|
}
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
if (pScreen->SourceValidate)
|
|
|
|
(*pScreen->SourceValidate) (pDrawable, x, y, width, height);
|
|
|
|
|
|
|
|
SCREEN_EPILOGUE (pScreen, SourceValidate);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
miSpriteCopyWindow (WindowPtr pWindow, DDXPointRec ptOldOrg, RegionPtr prgnSrc)
|
|
|
|
{
|
|
|
|
ScreenPtr pScreen = pWindow->drawable.pScreen;
|
|
|
|
miSpriteScreenPtr pScreenPriv;
|
2009-09-06 13:44:18 -06:00
|
|
|
DeviceIntPtr pDev = inputInfo.pointer;
|
|
|
|
miCursorInfoPtr pCursorInfo;
|
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
SCREEN_PROLOGUE (pScreen, CopyWindow);
|
|
|
|
|
2008-11-02 08:26:08 -07:00
|
|
|
pScreenPriv = (miSpriteScreenPtr)dixLookupPrivate(&pScreen->devPrivates,
|
|
|
|
miSpriteScreenKey);
|
2009-09-06 13:44:18 -06:00
|
|
|
|
|
|
|
for(pDev = inputInfo.devices; pDev; pDev = pDev->next)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2009-09-06 13:44:18 -06:00
|
|
|
if (DevHasCursor(pDev))
|
|
|
|
{
|
|
|
|
pCursorInfo = MISPRITE(pDev);
|
|
|
|
/*
|
|
|
|
* Damage will take care of destination check
|
|
|
|
*/
|
|
|
|
if (pCursorInfo->isUp && pCursorInfo->pScreen == pScreen &&
|
|
|
|
RECT_IN_REGION (pScreen, prgnSrc, &pCursorInfo->saved) != rgnOUT)
|
|
|
|
{
|
|
|
|
SPRITE_DEBUG (("CopyWindow remove\n"));
|
|
|
|
miSpriteRemoveCursor (pDev, pScreen);
|
|
|
|
}
|
|
|
|
}
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
(*pScreen->CopyWindow) (pWindow, ptOldOrg, prgnSrc);
|
|
|
|
SCREEN_EPILOGUE (pScreen, CopyWindow);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2009-09-06 13:44:18 -06:00
|
|
|
miSpriteBlockHandler (int i, pointer blockData, pointer pTimeout,
|
|
|
|
pointer pReadmask)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
ScreenPtr pScreen = screenInfo.screens[i];
|
|
|
|
miSpriteScreenPtr pPriv;
|
2009-09-06 13:44:18 -06:00
|
|
|
DeviceIntPtr pDev = inputInfo.pointer;
|
|
|
|
miCursorInfoPtr pCursorInfo;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2008-11-02 08:26:08 -07:00
|
|
|
pPriv = (miSpriteScreenPtr)dixLookupPrivate(&pScreen->devPrivates,
|
|
|
|
miSpriteScreenKey);
|
2006-11-26 11:13:41 -07:00
|
|
|
SCREEN_PROLOGUE(pScreen, BlockHandler);
|
2009-09-06 13:44:18 -06:00
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
(*pScreen->BlockHandler) (i, blockData, pTimeout, pReadmask);
|
|
|
|
|
|
|
|
SCREEN_EPILOGUE(pScreen, BlockHandler);
|
|
|
|
|
2009-09-06 13:44:18 -06:00
|
|
|
for(pDev = inputInfo.devices; pDev; pDev = pDev->next)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2009-09-06 13:44:18 -06:00
|
|
|
if (DevHasCursor(pDev))
|
|
|
|
{
|
|
|
|
pCursorInfo = MISPRITE(pDev);
|
|
|
|
if (pCursorInfo && !pCursorInfo->isUp
|
|
|
|
&& pCursorInfo->pScreen == pScreen
|
|
|
|
&& pCursorInfo->shouldBeUp)
|
|
|
|
{
|
|
|
|
SPRITE_DEBUG (("BlockHandler restore\n"));
|
|
|
|
miSpriteSaveUnderCursor (pDev, pScreen);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for(pDev = inputInfo.devices; pDev; pDev = pDev->next)
|
|
|
|
{
|
|
|
|
if (DevHasCursor(pDev))
|
|
|
|
{
|
|
|
|
pCursorInfo = MISPRITE(pDev);
|
|
|
|
if (pCursorInfo && !pCursorInfo->isUp &&
|
|
|
|
pCursorInfo->pScreen == pScreen &&
|
|
|
|
pCursorInfo->shouldBeUp)
|
|
|
|
{
|
|
|
|
SPRITE_DEBUG (("BlockHandler restore\n"));
|
|
|
|
miSpriteRestoreCursor (pDev, pScreen);
|
|
|
|
}
|
|
|
|
}
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2009-09-06 13:44:18 -06:00
|
|
|
miSpriteInstallColormap (ColormapPtr pMap)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
ScreenPtr pScreen = pMap->pScreen;
|
|
|
|
miSpriteScreenPtr pPriv;
|
|
|
|
|
2008-11-02 08:26:08 -07:00
|
|
|
pPriv = (miSpriteScreenPtr)dixLookupPrivate(&pScreen->devPrivates,
|
|
|
|
miSpriteScreenKey);
|
2006-11-26 11:13:41 -07:00
|
|
|
SCREEN_PROLOGUE(pScreen, InstallColormap);
|
2009-09-06 13:44:18 -06:00
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
(*pScreen->InstallColormap) (pMap);
|
|
|
|
|
|
|
|
SCREEN_EPILOGUE(pScreen, InstallColormap);
|
|
|
|
|
2009-09-06 13:44:18 -06:00
|
|
|
/* InstallColormap can be called before devices are initialized. */
|
2006-11-26 11:13:41 -07:00
|
|
|
pPriv->pInstalledMap = pMap;
|
|
|
|
if (pPriv->pColormap != pMap)
|
|
|
|
{
|
2009-09-06 13:44:18 -06:00
|
|
|
DeviceIntPtr pDev;
|
|
|
|
miCursorInfoPtr pCursorInfo;
|
|
|
|
for (pDev = inputInfo.devices; pDev; pDev = pDev->next)
|
|
|
|
{
|
|
|
|
if (DevHasCursor(pDev))
|
|
|
|
{
|
|
|
|
pCursorInfo = MISPRITE(pDev);
|
|
|
|
pCursorInfo->checkPixels = TRUE;
|
|
|
|
if (pCursorInfo->isUp && pCursorInfo->pScreen == pScreen)
|
|
|
|
miSpriteRemoveCursor(pDev, pScreen);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2009-09-06 13:44:18 -06:00
|
|
|
miSpriteStoreColors (ColormapPtr pMap, int ndef, xColorItem *pdef)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
ScreenPtr pScreen = pMap->pScreen;
|
|
|
|
miSpriteScreenPtr pPriv;
|
|
|
|
int i;
|
|
|
|
int updated;
|
|
|
|
VisualPtr pVisual;
|
2009-09-06 13:44:18 -06:00
|
|
|
DeviceIntPtr pDev = inputInfo.pointer;
|
|
|
|
miCursorInfoPtr pCursorInfo;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2008-11-02 08:26:08 -07:00
|
|
|
pPriv = (miSpriteScreenPtr)dixLookupPrivate(&pScreen->devPrivates,
|
|
|
|
miSpriteScreenKey);
|
2006-11-26 11:13:41 -07:00
|
|
|
SCREEN_PROLOGUE(pScreen, StoreColors);
|
2009-09-06 13:44:18 -06:00
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
(*pScreen->StoreColors) (pMap, ndef, pdef);
|
|
|
|
|
|
|
|
SCREEN_EPILOGUE(pScreen, StoreColors);
|
|
|
|
|
|
|
|
if (pPriv->pColormap == pMap)
|
|
|
|
{
|
2009-09-06 13:44:18 -06:00
|
|
|
updated = 0;
|
|
|
|
pVisual = pMap->pVisual;
|
|
|
|
if (pVisual->class == DirectColor)
|
|
|
|
{
|
|
|
|
/* Direct color - match on any of the subfields */
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
#define MaskMatch(a,b,mask) (((a) & (pVisual->mask)) == ((b) & (pVisual->mask)))
|
|
|
|
|
2009-09-06 13:44:18 -06:00
|
|
|
#define UpdateDAC(dev, plane,dac,mask) {\
|
|
|
|
if (MaskMatch (dev->colors[plane].pixel,pdef[i].pixel,mask)) {\
|
|
|
|
dev->colors[plane].dac = pdef[i].dac; \
|
2006-11-26 11:13:41 -07:00
|
|
|
updated = 1; \
|
|
|
|
} \
|
|
|
|
}
|
|
|
|
|
2009-09-06 13:44:18 -06:00
|
|
|
#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 (pPriv, SOURCE_COLOR)
|
|
|
|
CheckDirect (pPriv, 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)
|
|
|
|
{
|
|
|
|
for(pDev = inputInfo.devices; pDev; pDev = pDev->next)
|
|
|
|
{
|
|
|
|
if (DevHasCursor(pDev))
|
|
|
|
{
|
|
|
|
pCursorInfo = MISPRITE(pDev);
|
|
|
|
pCursorInfo->checkPixels = TRUE;
|
|
|
|
if (pCursorInfo->isUp && pCursorInfo->pScreen == pScreen)
|
|
|
|
miSpriteRemoveCursor (pDev, pScreen);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2009-09-06 13:44:18 -06:00
|
|
|
miSpriteFindColors (miCursorInfoPtr pDevCursor, ScreenPtr pScreen)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2009-09-06 13:44:18 -06:00
|
|
|
miSpriteScreenPtr pScreenPriv = (miSpriteScreenPtr)
|
2008-11-02 08:26:08 -07:00
|
|
|
dixLookupPrivate(&pScreen->devPrivates, miSpriteScreenKey);
|
2006-11-26 11:13:41 -07:00
|
|
|
CursorPtr pCursor;
|
|
|
|
xColorItem *sourceColor, *maskColor;
|
|
|
|
|
2009-09-06 13:44:18 -06:00
|
|
|
pCursor = pDevCursor->pCursor;
|
2006-11-26 11:13:41 -07:00
|
|
|
sourceColor = &pScreenPriv->colors[SOURCE_COLOR];
|
|
|
|
maskColor = &pScreenPriv->colors[MASK_COLOR];
|
|
|
|
if (pScreenPriv->pColormap != pScreenPriv->pInstalledMap ||
|
|
|
|
!(pCursor->foreRed == sourceColor->red &&
|
|
|
|
pCursor->foreGreen == sourceColor->green &&
|
|
|
|
pCursor->foreBlue == sourceColor->blue &&
|
|
|
|
pCursor->backRed == maskColor->red &&
|
|
|
|
pCursor->backGreen == maskColor->green &&
|
|
|
|
pCursor->backBlue == maskColor->blue))
|
|
|
|
{
|
|
|
|
pScreenPriv->pColormap = pScreenPriv->pInstalledMap;
|
|
|
|
sourceColor->red = pCursor->foreRed;
|
|
|
|
sourceColor->green = pCursor->foreGreen;
|
|
|
|
sourceColor->blue = pCursor->foreBlue;
|
|
|
|
FakeAllocColor (pScreenPriv->pColormap, sourceColor);
|
|
|
|
maskColor->red = pCursor->backRed;
|
|
|
|
maskColor->green = pCursor->backGreen;
|
|
|
|
maskColor->blue = pCursor->backBlue;
|
|
|
|
FakeAllocColor (pScreenPriv->pColormap, maskColor);
|
|
|
|
/* "free" the pixels right away, don't let this confuse you */
|
|
|
|
FakeFreeColor(pScreenPriv->pColormap, sourceColor->pixel);
|
|
|
|
FakeFreeColor(pScreenPriv->pColormap, maskColor->pixel);
|
|
|
|
}
|
2009-09-06 13:44:18 -06:00
|
|
|
|
|
|
|
pDevCursor->checkPixels = FALSE;
|
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* miPointer interface routines
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define SPRITE_PAD 8
|
|
|
|
|
|
|
|
static Bool
|
2009-09-06 13:44:18 -06:00
|
|
|
miSpriteRealizeCursor (DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr pCursor)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
miSpriteScreenPtr pScreenPriv;
|
2009-09-06 13:44:18 -06:00
|
|
|
miCursorInfoPtr pCursorInfo;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2008-11-02 08:26:08 -07:00
|
|
|
pScreenPriv = (miSpriteScreenPtr)dixLookupPrivate(&pScreen->devPrivates,
|
|
|
|
miSpriteScreenKey);
|
2009-09-06 13:44:18 -06:00
|
|
|
if (!pDev->isMaster && !pDev->u.master)
|
|
|
|
{
|
|
|
|
ErrorF("[mi] miSpriteRealizeCursor called for floating device.\n");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
pCursorInfo = MISPRITE(pDev);
|
|
|
|
|
|
|
|
if (pCursor == pCursorInfo->pCursor)
|
|
|
|
pCursorInfo->checkPixels = TRUE;
|
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
return (*pScreenPriv->funcs->RealizeCursor) (pScreen, pCursor);
|
|
|
|
}
|
|
|
|
|
|
|
|
static Bool
|
2009-09-06 13:44:18 -06:00
|
|
|
miSpriteUnrealizeCursor(DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr pCursor)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
miSpriteScreenPtr pScreenPriv;
|
|
|
|
|
2008-11-02 08:26:08 -07:00
|
|
|
pScreenPriv = (miSpriteScreenPtr)dixLookupPrivate(&pScreen->devPrivates,
|
|
|
|
miSpriteScreenKey);
|
2006-11-26 11:13:41 -07:00
|
|
|
return (*pScreenPriv->funcs->UnrealizeCursor) (pScreen, pCursor);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2009-09-06 13:44:18 -06:00
|
|
|
miSpriteSetCursor (DeviceIntPtr pDev, ScreenPtr pScreen,
|
|
|
|
CursorPtr pCursor, int x, int y)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
miSpriteScreenPtr pScreenPriv;
|
2009-09-06 13:44:18 -06:00
|
|
|
miCursorInfoPtr pPointer;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2008-11-02 08:26:08 -07:00
|
|
|
pScreenPriv = (miSpriteScreenPtr)dixLookupPrivate(&pScreen->devPrivates,
|
|
|
|
miSpriteScreenKey);
|
2009-09-06 13:44:18 -06:00
|
|
|
|
|
|
|
if (!pDev->isMaster && !pDev->u.master)
|
|
|
|
{
|
|
|
|
ErrorF("[mi] miSpriteSetCursor called for floating device.\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
pPointer = MISPRITE(pDev);
|
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
if (!pCursor)
|
|
|
|
{
|
2009-09-06 13:44:18 -06:00
|
|
|
pPointer->shouldBeUp = FALSE;
|
|
|
|
if (pPointer->isUp)
|
|
|
|
miSpriteRemoveCursor (pDev, pScreen);
|
|
|
|
pPointer->pCursor = 0;
|
2006-11-26 11:13:41 -07:00
|
|
|
return;
|
|
|
|
}
|
2009-09-06 13:44:18 -06:00
|
|
|
pPointer->shouldBeUp = TRUE;
|
|
|
|
if (pPointer->x == x &&
|
|
|
|
pPointer->y == y &&
|
|
|
|
pPointer->pCursor == pCursor &&
|
|
|
|
!pPointer->checkPixels)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
2009-09-06 13:44:18 -06:00
|
|
|
pPointer->x = x;
|
|
|
|
pPointer->y = y;
|
|
|
|
pPointer->pCacheWin = NullWindow;
|
|
|
|
if (pPointer->checkPixels || pPointer->pCursor != pCursor)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2009-09-06 13:44:18 -06:00
|
|
|
pPointer->pCursor = pCursor;
|
|
|
|
miSpriteFindColors (pPointer, pScreen);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
2009-09-06 13:44:18 -06:00
|
|
|
if (pPointer->isUp) {
|
|
|
|
#if 0
|
|
|
|
/* FIXME: Disabled for MPX, should be rewritten */
|
2006-11-26 11:13:41 -07:00
|
|
|
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.
|
|
|
|
*/
|
2009-09-06 13:44:18 -06:00
|
|
|
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 &&
|
2006-11-26 11:13:41 -07:00
|
|
|
(int) pCursor->bits->width + (2 * SPRITE_PAD) ==
|
2009-09-06 13:44:18 -06:00
|
|
|
pointer->saved.x2 - pointer->saved.x1 &&
|
2006-11-26 11:13:41 -07:00
|
|
|
(int) pCursor->bits->height + (2 * SPRITE_PAD) ==
|
2009-09-06 13:44:18 -06:00
|
|
|
pointer->saved.y2 - pointer->saved.y1
|
2006-11-26 11:13:41 -07:00
|
|
|
)
|
|
|
|
{
|
|
|
|
DamageDrawInternal (pScreen, TRUE);
|
2009-09-06 13:44:18 -06:00
|
|
|
miSpriteIsDown(pCursorInfo);
|
|
|
|
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))
|
|
|
|
{
|
2006-11-26 11:13:41 -07:00
|
|
|
int oldx1, oldy1, dx, dy;
|
|
|
|
|
2009-09-06 13:44:18 -06:00
|
|
|
oldx1 = pointer->saved.x1;
|
|
|
|
oldy1 = pointer->saved.y1;
|
2006-11-26 11:13:41 -07:00
|
|
|
dx = oldx1 - (sx - SPRITE_PAD);
|
|
|
|
dy = oldy1 - (sy - SPRITE_PAD);
|
2009-09-06 13:44:18 -06:00
|
|
|
pointer->saved.x1 -= dx;
|
|
|
|
pointer->saved.y1 -= dy;
|
|
|
|
pointer->saved.x2 -= dx;
|
|
|
|
pointer->saved.y2 -= dy;
|
2006-11-26 11:13:41 -07:00
|
|
|
(void) (*pScreenPriv->funcs->ChangeSave) (pScreen,
|
2009-09-06 13:44:18 -06:00
|
|
|
pointer->saved.x1,
|
|
|
|
pointer->saved.y1,
|
|
|
|
pointer->saved.x2 -
|
|
|
|
pointer->saved.x1,
|
|
|
|
pointer->saved.y2 -
|
|
|
|
pointer->saved.y1,
|
2006-11-26 11:13:41 -07:00
|
|
|
dx, dy);
|
|
|
|
}
|
|
|
|
(void) (*pScreenPriv->funcs->MoveCursor) (pScreen, pCursor,
|
2009-09-06 13:44:18 -06:00
|
|
|
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);
|
|
|
|
miSpriteIsUp(pCursorInfo);
|
2006-11-26 11:13:41 -07:00
|
|
|
DamageDrawInternal (pScreen, FALSE);
|
|
|
|
}
|
|
|
|
else
|
2009-09-06 13:44:18 -06:00
|
|
|
#endif
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2009-09-06 13:44:18 -06:00
|
|
|
SPRITE_DEBUG (("SetCursor remove %d\n", pDev->id));
|
|
|
|
miSpriteRemoveCursor (pDev, pScreen);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
}
|
2009-09-06 13:44:18 -06:00
|
|
|
|
|
|
|
if (!pPointer->isUp && pPointer->pCursor)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2009-09-06 13:44:18 -06:00
|
|
|
SPRITE_DEBUG (("SetCursor restore %d\n", pDev->id));
|
|
|
|
miSpriteSaveUnderCursor(pDev, pScreen);
|
|
|
|
miSpriteRestoreCursor (pDev, pScreen);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
2009-09-06 13:44:18 -06:00
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2009-09-06 13:44:18 -06:00
|
|
|
miSpriteMoveCursor (DeviceIntPtr pDev, ScreenPtr pScreen, int x, int y)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
miSpriteScreenPtr pScreenPriv;
|
2009-09-06 13:44:18 -06:00
|
|
|
CursorPtr pCursor;
|
|
|
|
|
|
|
|
pScreenPriv = (miSpriteScreenPtr)dixLookupPrivate(&pScreen->devPrivates,
|
|
|
|
miSpriteScreenKey);
|
|
|
|
if (!pDev->isMaster && !pDev->u.master)
|
|
|
|
{
|
|
|
|
ErrorF("[mi] miSpriteMoveCursor called for floating device.\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
pCursor = MISPRITE(pDev)->pCursor;
|
|
|
|
|
|
|
|
miSpriteSetCursor (pDev, pScreen, pCursor, x, y);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static Bool
|
|
|
|
miSpriteDeviceCursorInitialize(DeviceIntPtr pDev, ScreenPtr pScreen)
|
|
|
|
{
|
|
|
|
miSpriteScreenPtr pScreenPriv;
|
|
|
|
miCursorInfoPtr pCursorInfo;
|
|
|
|
int ret = FALSE;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2008-11-02 08:26:08 -07:00
|
|
|
pScreenPriv = (miSpriteScreenPtr)dixLookupPrivate(&pScreen->devPrivates,
|
|
|
|
miSpriteScreenKey);
|
2009-09-06 13:44:18 -06:00
|
|
|
|
|
|
|
pCursorInfo = xalloc(sizeof(miCursorInfoRec));
|
|
|
|
if (!pCursorInfo)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
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->pScreen = FALSE;
|
|
|
|
|
|
|
|
ret = (*pScreenPriv->funcs->DeviceCursorInitialize)(pDev, pScreen);
|
|
|
|
if (!ret)
|
|
|
|
{
|
|
|
|
xfree(pCursorInfo);
|
|
|
|
pCursorInfo = NULL;
|
|
|
|
}
|
|
|
|
dixSetPrivate(&pDev->devPrivates, miSpriteDevPrivatesKey, pCursorInfo);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
miSpriteDeviceCursorCleanup(DeviceIntPtr pDev, ScreenPtr pScreen)
|
|
|
|
{
|
|
|
|
if (DevHasCursor(pDev))
|
|
|
|
{
|
|
|
|
miSpriteScreenPtr pScreenPriv;
|
|
|
|
pScreenPriv = (miSpriteScreenPtr)
|
|
|
|
dixLookupPrivate(&pScreen->devPrivates, miSpriteScreenKey);
|
|
|
|
|
|
|
|
(*pScreenPriv->funcs->DeviceCursorCleanup)(pDev, pScreen);
|
|
|
|
}
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* undraw/draw cursor
|
|
|
|
*/
|
|
|
|
|
|
|
|
static void
|
2009-09-06 13:44:18 -06:00
|
|
|
miSpriteRemoveCursor (DeviceIntPtr pDev, ScreenPtr pScreen)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
miSpriteScreenPtr pScreenPriv;
|
2009-09-06 13:44:18 -06:00
|
|
|
miCursorInfoPtr pCursorInfo;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2009-09-06 13:44:18 -06:00
|
|
|
|
|
|
|
if (!pDev->isMaster && !pDev->u.master)
|
|
|
|
{
|
|
|
|
ErrorF("[mi] miSpriteRemoveCursor called for floating device.\n");
|
|
|
|
return;
|
|
|
|
}
|
2006-11-26 11:13:41 -07:00
|
|
|
DamageDrawInternal (pScreen, TRUE);
|
2008-11-02 08:26:08 -07:00
|
|
|
pScreenPriv = (miSpriteScreenPtr)dixLookupPrivate(&pScreen->devPrivates,
|
|
|
|
miSpriteScreenKey);
|
2009-09-06 13:44:18 -06:00
|
|
|
pCursorInfo = MISPRITE(pDev);
|
|
|
|
|
|
|
|
miSpriteIsDown(pCursorInfo);
|
|
|
|
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))
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2009-09-06 13:44:18 -06:00
|
|
|
miSpriteIsUp(pCursorInfo);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
2009-09-06 13:44:18 -06:00
|
|
|
miSpriteEnableDamage(pScreen, pScreenPriv);
|
2006-11-26 11:13:41 -07:00
|
|
|
DamageDrawInternal (pScreen, FALSE);
|
|
|
|
}
|
|
|
|
|
2009-09-06 13:44:18 -06:00
|
|
|
/*
|
|
|
|
* Called from the block handler, saves area under cursor
|
|
|
|
* before waiting for something to do.
|
|
|
|
*/
|
|
|
|
|
|
|
|
static void
|
|
|
|
miSpriteSaveUnderCursor(DeviceIntPtr pDev, ScreenPtr pScreen)
|
|
|
|
{
|
|
|
|
miSpriteScreenPtr pScreenPriv;
|
|
|
|
int x, y;
|
|
|
|
CursorPtr pCursor;
|
|
|
|
miCursorInfoPtr pCursorInfo;
|
|
|
|
|
|
|
|
if (!pDev->isMaster && !pDev->u.master)
|
|
|
|
{
|
|
|
|
ErrorF("[mi] miSpriteSaveUnderCursor called for floating device.\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
DamageDrawInternal (pScreen, TRUE);
|
|
|
|
pScreenPriv = (miSpriteScreenPtr)dixLookupPrivate(&pScreen->devPrivates,
|
|
|
|
miSpriteScreenKey);
|
|
|
|
pCursorInfo = MISPRITE(pDev);
|
|
|
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
/*
|
|
|
|
* Called from the block handler, restores the cursor
|
|
|
|
* before waiting for something to do.
|
|
|
|
*/
|
|
|
|
|
|
|
|
static void
|
2009-09-06 13:44:18 -06:00
|
|
|
miSpriteRestoreCursor (DeviceIntPtr pDev, ScreenPtr pScreen)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
miSpriteScreenPtr pScreenPriv;
|
|
|
|
int x, y;
|
|
|
|
CursorPtr pCursor;
|
2009-09-06 13:44:18 -06:00
|
|
|
miCursorInfoPtr pCursorInfo;
|
|
|
|
|
|
|
|
if (!pDev->isMaster && !pDev->u.master)
|
|
|
|
{
|
|
|
|
ErrorF("[mi] miSpriteRestoreCursor called for floating device.\n");
|
|
|
|
return;
|
|
|
|
}
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
DamageDrawInternal (pScreen, TRUE);
|
2008-11-02 08:26:08 -07:00
|
|
|
pScreenPriv = (miSpriteScreenPtr)dixLookupPrivate(&pScreen->devPrivates,
|
|
|
|
miSpriteScreenKey);
|
2009-09-06 13:44:18 -06:00
|
|
|
pCursorInfo = MISPRITE(pDev);
|
|
|
|
|
|
|
|
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,
|
|
|
|
pScreenPriv->colors[SOURCE_COLOR].pixel,
|
|
|
|
pScreenPriv->colors[MASK_COLOR].pixel))
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2009-09-06 13:44:18 -06:00
|
|
|
miSpriteIsUp(pCursorInfo);
|
|
|
|
pCursorInfo->pScreen = pScreen;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
2009-09-06 13:44:18 -06:00
|
|
|
miSpriteEnableDamage(pScreen, pScreenPriv);
|
2006-11-26 11:13:41 -07:00
|
|
|
DamageDrawInternal (pScreen, FALSE);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* compute the desired area of the screen to save
|
|
|
|
*/
|
|
|
|
|
|
|
|
static void
|
2009-09-06 13:44:18 -06:00
|
|
|
miSpriteComputeSaved (DeviceIntPtr pDev, ScreenPtr pScreen)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
miSpriteScreenPtr pScreenPriv;
|
|
|
|
int x, y, w, h;
|
|
|
|
int wpad, hpad;
|
|
|
|
CursorPtr pCursor;
|
2009-09-06 13:44:18 -06:00
|
|
|
miCursorInfoPtr pCursorInfo;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2009-09-06 13:44:18 -06:00
|
|
|
if (!pDev->isMaster && !pDev->u.master)
|
|
|
|
{
|
|
|
|
ErrorF("[mi] miSpriteComputeSaved called for floating device.\n");
|
|
|
|
return;
|
|
|
|
}
|
2008-11-02 08:26:08 -07:00
|
|
|
pScreenPriv = (miSpriteScreenPtr)dixLookupPrivate(&pScreen->devPrivates,
|
|
|
|
miSpriteScreenKey);
|
2009-09-06 13:44:18 -06:00
|
|
|
pCursorInfo = MISPRITE(pDev);
|
|
|
|
|
|
|
|
pCursor = pCursorInfo->pCursor;
|
|
|
|
x = pCursorInfo->x - (int)pCursor->bits->xhot;
|
|
|
|
y = pCursorInfo->y - (int)pCursor->bits->yhot;
|
2006-11-26 11:13:41 -07:00
|
|
|
w = pCursor->bits->width;
|
|
|
|
h = pCursor->bits->height;
|
|
|
|
wpad = SPRITE_PAD;
|
|
|
|
hpad = SPRITE_PAD;
|
2009-09-06 13:44:18 -06:00
|
|
|
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;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
2009-09-06 13:44:18 -06:00
|
|
|
|