Merge remote branch 'vignatti/animcursor-state-fix'
This commit is contained in:
commit
8bd8d81dc4
|
@ -477,6 +477,14 @@ typedef struct _SpriteInfoRec {
|
||||||
DeviceIntPtr paired; /* The paired device. Keyboard if
|
DeviceIntPtr paired; /* The paired device. Keyboard if
|
||||||
spriteOwner is TRUE, otherwise the
|
spriteOwner is TRUE, otherwise the
|
||||||
pointer that owns the sprite. */
|
pointer that owns the sprite. */
|
||||||
|
|
||||||
|
/* keep states for animated cursor */
|
||||||
|
struct {
|
||||||
|
CursorPtr pCursor;
|
||||||
|
ScreenPtr pScreen;
|
||||||
|
int elt;
|
||||||
|
CARD32 time;
|
||||||
|
} anim;
|
||||||
} SpriteInfoRec, *SpriteInfoPtr;
|
} SpriteInfoRec, *SpriteInfoPtr;
|
||||||
|
|
||||||
/* device types */
|
/* device types */
|
||||||
|
|
|
@ -58,10 +58,6 @@ typedef struct _AnimCur {
|
||||||
} AnimCurRec, *AnimCurPtr;
|
} AnimCurRec, *AnimCurPtr;
|
||||||
|
|
||||||
typedef struct _AnimScrPriv {
|
typedef struct _AnimScrPriv {
|
||||||
CursorPtr pCursor;
|
|
||||||
int elt;
|
|
||||||
CARD32 time;
|
|
||||||
|
|
||||||
CloseScreenProcPtr CloseScreen;
|
CloseScreenProcPtr CloseScreen;
|
||||||
|
|
||||||
ScreenBlockHandlerProcPtr BlockHandler;
|
ScreenBlockHandlerProcPtr BlockHandler;
|
||||||
|
@ -74,31 +70,18 @@ typedef struct _AnimScrPriv {
|
||||||
RecolorCursorProcPtr RecolorCursor;
|
RecolorCursorProcPtr RecolorCursor;
|
||||||
} AnimCurScreenRec, *AnimCurScreenPtr;
|
} AnimCurScreenRec, *AnimCurScreenPtr;
|
||||||
|
|
||||||
typedef struct _AnimCurState {
|
|
||||||
CursorPtr pCursor;
|
|
||||||
ScreenPtr pScreen;
|
|
||||||
int elt;
|
|
||||||
CARD32 time;
|
|
||||||
} AnimCurStateRec, *AnimCurStatePtr;
|
|
||||||
|
|
||||||
/* What a waste. But we need an API change to alloc it per device only. */
|
|
||||||
static AnimCurStateRec animCurState[MAXDEVICES];
|
|
||||||
|
|
||||||
static unsigned char empty[4];
|
static unsigned char empty[4];
|
||||||
|
|
||||||
static CursorBits animCursorBits = {
|
static CursorBits animCursorBits = {
|
||||||
empty, empty, 2, 1, 1, 0, 0, 1
|
empty, empty, 2, 1, 1, 0, 0, 1
|
||||||
};
|
};
|
||||||
|
|
||||||
static int AnimCurGeneration;
|
|
||||||
|
|
||||||
static int AnimCurScreenPrivateKeyIndex;
|
static int AnimCurScreenPrivateKeyIndex;
|
||||||
static DevPrivateKey AnimCurScreenPrivateKey = &AnimCurScreenPrivateKeyIndex;
|
static DevPrivateKey AnimCurScreenPrivateKey = &AnimCurScreenPrivateKeyIndex;
|
||||||
|
|
||||||
#define IsAnimCur(c) ((c) && ((c)->bits == &animCursorBits))
|
#define IsAnimCur(c) ((c) && ((c)->bits == &animCursorBits))
|
||||||
#define GetAnimCur(c) ((AnimCurPtr) ((c) + 1))
|
#define GetAnimCur(c) ((AnimCurPtr) ((c) + 1))
|
||||||
#define GetAnimCurScreen(s) ((AnimCurScreenPtr)dixLookupPrivate(&(s)->devPrivates, AnimCurScreenPrivateKey))
|
#define GetAnimCurScreen(s) ((AnimCurScreenPtr)dixLookupPrivate(&(s)->devPrivates, AnimCurScreenPrivateKey))
|
||||||
#define GetAnimCurScreenIfSet(s) GetAnimCurScreen(s)
|
|
||||||
#define SetAnimCurScreen(s,p) dixSetPrivate(&(s)->devPrivates, AnimCurScreenPrivateKey, p)
|
#define SetAnimCurScreen(s,p) dixSetPrivate(&(s)->devPrivates, AnimCurScreenPrivateKey, p)
|
||||||
|
|
||||||
#define Wrap(as,s,elt,func) (((as)->elt = (s)->elt), (s)->elt = func)
|
#define Wrap(as,s,elt,func) (((as)->elt = (s)->elt), (s)->elt = func)
|
||||||
|
@ -172,14 +155,14 @@ AnimCurScreenBlockHandler (int screenNum,
|
||||||
|
|
||||||
for (dev = inputInfo.devices; dev; dev = dev->next)
|
for (dev = inputInfo.devices; dev; dev = dev->next)
|
||||||
{
|
{
|
||||||
if (IsPointerDevice(dev) && pScreen == animCurState[dev->id].pScreen)
|
if (IsPointerDevice(dev) && pScreen == dev->spriteInfo->anim.pScreen)
|
||||||
{
|
{
|
||||||
if (!now) now = GetTimeInMillis ();
|
if (!now) now = GetTimeInMillis ();
|
||||||
|
|
||||||
if ((INT32) (now - animCurState[dev->id].time) >= 0)
|
if ((INT32) (now - dev->spriteInfo->anim.time) >= 0)
|
||||||
{
|
{
|
||||||
AnimCurPtr ac = GetAnimCur(animCurState[dev->id].pCursor);
|
AnimCurPtr ac = GetAnimCur(dev->spriteInfo->anim.pCursor);
|
||||||
int elt = (animCurState[dev->id].elt + 1) % ac->nelt;
|
int elt = (dev->spriteInfo->anim.elt + 1) % ac->nelt;
|
||||||
DisplayCursorProcPtr DisplayCursor;
|
DisplayCursorProcPtr DisplayCursor;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -195,12 +178,12 @@ AnimCurScreenBlockHandler (int screenNum,
|
||||||
as->DisplayCursor = pScreen->DisplayCursor;
|
as->DisplayCursor = pScreen->DisplayCursor;
|
||||||
pScreen->DisplayCursor = DisplayCursor;
|
pScreen->DisplayCursor = DisplayCursor;
|
||||||
|
|
||||||
animCurState[dev->id].elt = elt;
|
dev->spriteInfo->anim.elt = elt;
|
||||||
animCurState[dev->id].time = now + ac->elts[elt].delay;
|
dev->spriteInfo->anim.time = now + ac->elts[elt].delay;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (soonest > animCurState[dev->id].time)
|
if (soonest > dev->spriteInfo->anim.time)
|
||||||
soonest = animCurState[dev->id].time;
|
soonest = dev->spriteInfo->anim.time;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -223,7 +206,7 @@ AnimCurDisplayCursor (DeviceIntPtr pDev,
|
||||||
Unwrap (as, pScreen, DisplayCursor);
|
Unwrap (as, pScreen, DisplayCursor);
|
||||||
if (IsAnimCur(pCursor))
|
if (IsAnimCur(pCursor))
|
||||||
{
|
{
|
||||||
if (pCursor != animCurState[pDev->id].pCursor)
|
if (pCursor != pDev->spriteInfo->anim.pCursor)
|
||||||
{
|
{
|
||||||
AnimCurPtr ac = GetAnimCur(pCursor);
|
AnimCurPtr ac = GetAnimCur(pCursor);
|
||||||
|
|
||||||
|
@ -231,10 +214,10 @@ AnimCurDisplayCursor (DeviceIntPtr pDev,
|
||||||
(pDev, pScreen, ac->elts[0].pCursor);
|
(pDev, pScreen, ac->elts[0].pCursor);
|
||||||
if (ret)
|
if (ret)
|
||||||
{
|
{
|
||||||
animCurState[pDev->id].elt = 0;
|
pDev->spriteInfo->anim.elt = 0;
|
||||||
animCurState[pDev->id].time = GetTimeInMillis () + ac->elts[0].delay;
|
pDev->spriteInfo->anim.time = GetTimeInMillis () + ac->elts[0].delay;
|
||||||
animCurState[pDev->id].pCursor = pCursor;
|
pDev->spriteInfo->anim.pCursor = pCursor;
|
||||||
animCurState[pDev->id].pScreen = pScreen;
|
pDev->spriteInfo->anim.pScreen = pScreen;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -242,8 +225,8 @@ AnimCurDisplayCursor (DeviceIntPtr pDev,
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
animCurState[pDev->id].pCursor = 0;
|
pDev->spriteInfo->anim.pCursor = 0;
|
||||||
animCurState[pDev->id].pScreen = 0;
|
pDev->spriteInfo->anim.pScreen = 0;
|
||||||
ret = (*pScreen->DisplayCursor) (pDev, pScreen, pCursor);
|
ret = (*pScreen->DisplayCursor) (pDev, pScreen, pCursor);
|
||||||
}
|
}
|
||||||
Wrap (as, pScreen, DisplayCursor, AnimCurDisplayCursor);
|
Wrap (as, pScreen, DisplayCursor, AnimCurDisplayCursor);
|
||||||
|
@ -261,8 +244,8 @@ AnimCurSetCursorPosition (DeviceIntPtr pDev,
|
||||||
Bool ret;
|
Bool ret;
|
||||||
|
|
||||||
Unwrap (as, pScreen, SetCursorPosition);
|
Unwrap (as, pScreen, SetCursorPosition);
|
||||||
if (animCurState[pDev->id].pCursor)
|
if (pDev->spriteInfo->anim.pCursor)
|
||||||
animCurState[pDev->id].pScreen = pScreen;
|
pDev->spriteInfo->anim.pScreen = pScreen;
|
||||||
ret = (*pScreen->SetCursorPosition) (pDev, pScreen, x, y, generateEvent);
|
ret = (*pScreen->SetCursorPosition) (pDev, pScreen, x, y, generateEvent);
|
||||||
Wrap (as, pScreen, SetCursorPosition, AnimCurSetCursorPosition);
|
Wrap (as, pScreen, SetCursorPosition, AnimCurSetCursorPosition);
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -327,7 +310,7 @@ AnimCurRecolorCursor (DeviceIntPtr pDev,
|
||||||
for (i = 0; i < ac->nelt; i++)
|
for (i = 0; i < ac->nelt; i++)
|
||||||
(*pScreen->RecolorCursor) (pDev, pScreen, ac->elts[i].pCursor,
|
(*pScreen->RecolorCursor) (pDev, pScreen, ac->elts[i].pCursor,
|
||||||
displayed &&
|
displayed &&
|
||||||
animCurState[pDev->id].elt == i);
|
pDev->spriteInfo->anim.elt == i);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
(*pScreen->RecolorCursor) (pDev, pScreen, pCursor, displayed);
|
(*pScreen->RecolorCursor) (pDev, pScreen, pCursor, displayed);
|
||||||
|
@ -339,17 +322,6 @@ AnimCurInit (ScreenPtr pScreen)
|
||||||
{
|
{
|
||||||
AnimCurScreenPtr as;
|
AnimCurScreenPtr as;
|
||||||
|
|
||||||
if (AnimCurGeneration != serverGeneration)
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
AnimCurGeneration = serverGeneration;
|
|
||||||
for (i = 0; i < MAXDEVICES; i++) {
|
|
||||||
animCurState[i].pCursor = 0;
|
|
||||||
animCurState[i].pScreen = 0;
|
|
||||||
animCurState[i].elt = 0;
|
|
||||||
animCurState[i].time = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
as = (AnimCurScreenPtr) malloc(sizeof (AnimCurScreenRec));
|
as = (AnimCurScreenPtr) malloc(sizeof (AnimCurScreenRec));
|
||||||
if (!as)
|
if (!as)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
@ -375,7 +347,7 @@ AnimCursorCreate (CursorPtr *cursors, CARD32 *deltas, int ncursor, CursorPtr *pp
|
||||||
AnimCurPtr ac;
|
AnimCurPtr ac;
|
||||||
|
|
||||||
for (i = 0; i < screenInfo.numScreens; i++)
|
for (i = 0; i < screenInfo.numScreens; i++)
|
||||||
if (!GetAnimCurScreenIfSet (screenInfo.screens[i]))
|
if (!GetAnimCurScreen (screenInfo.screens[i]))
|
||||||
return BadImplementation;
|
return BadImplementation;
|
||||||
|
|
||||||
for (i = 0; i < ncursor; i++)
|
for (i = 0; i < ncursor; i++)
|
||||||
|
|
Loading…
Reference in New Issue