aboutsummaryrefslogtreecommitdiff
path: root/xorg-server/render/animcur.c
diff options
context:
space:
mode:
Diffstat (limited to 'xorg-server/render/animcur.c')
-rw-r--r--xorg-server/render/animcur.c386
1 files changed, 180 insertions, 206 deletions
diff --git a/xorg-server/render/animcur.c b/xorg-server/render/animcur.c
index 8d4a9c2ef..485c068fe 100644
--- a/xorg-server/render/animcur.c
+++ b/xorg-server/render/animcur.c
@@ -48,35 +48,36 @@
#include "xace.h"
typedef struct _AnimCurElt {
- CursorPtr pCursor; /* cursor to show */
- CARD32 delay; /* in ms */
+ CursorPtr pCursor; /* cursor to show */
+ CARD32 delay; /* in ms */
} AnimCurElt;
typedef struct _AnimCur {
- int nelt; /* number of elements in the elts array */
- AnimCurElt *elts; /* actually allocated right after the structure */
+ int nelt; /* number of elements in the elts array */
+ AnimCurElt *elts; /* actually allocated right after the structure */
} AnimCurRec, *AnimCurPtr;
typedef struct _AnimScrPriv {
- CloseScreenProcPtr CloseScreen;
+ CloseScreenProcPtr CloseScreen;
- ScreenBlockHandlerProcPtr BlockHandler;
+ ScreenBlockHandlerProcPtr BlockHandler;
- CursorLimitsProcPtr CursorLimits;
- DisplayCursorProcPtr DisplayCursor;
- SetCursorPositionProcPtr SetCursorPosition;
- RealizeCursorProcPtr RealizeCursor;
- UnrealizeCursorProcPtr UnrealizeCursor;
- RecolorCursorProcPtr RecolorCursor;
+ CursorLimitsProcPtr CursorLimits;
+ DisplayCursorProcPtr DisplayCursor;
+ SetCursorPositionProcPtr SetCursorPosition;
+ RealizeCursorProcPtr RealizeCursor;
+ UnrealizeCursorProcPtr UnrealizeCursor;
+ RecolorCursorProcPtr RecolorCursor;
} AnimCurScreenRec, *AnimCurScreenPtr;
static unsigned char empty[4];
-static CursorBits animCursorBits = {
+static CursorBits animCursorBits = {
empty, empty, 2, 1, 1, 0, 0, 1
};
static DevPrivateKeyRec AnimCurScreenPrivateKeyRec;
+
#define AnimCurScreenPrivateKey (&AnimCurScreenPrivateKeyRec)
#define IsAnimCur(c) ((c) && ((c)->bits == &animCursorBits))
@@ -87,12 +88,11 @@ static DevPrivateKeyRec AnimCurScreenPrivateKeyRec;
#define Wrap(as,s,elt,func) (((as)->elt = (s)->elt), (s)->elt = func)
#define Unwrap(as,s,elt) ((s)->elt = (as)->elt)
-
static Bool
-AnimCurCloseScreen (int index, ScreenPtr pScreen)
+AnimCurCloseScreen(int index, ScreenPtr pScreen)
{
- AnimCurScreenPtr as = GetAnimCurScreen(pScreen);
- Bool ret;
+ AnimCurScreenPtr as = GetAnimCurScreen(pScreen);
+ Bool ret;
Unwrap(as, pScreen, CloseScreen);
@@ -102,35 +102,30 @@ AnimCurCloseScreen (int index, ScreenPtr pScreen)
Unwrap(as, pScreen, RealizeCursor);
Unwrap(as, pScreen, UnrealizeCursor);
Unwrap(as, pScreen, RecolorCursor);
- SetAnimCurScreen(pScreen,0);
+ SetAnimCurScreen(pScreen, 0);
ret = (*pScreen->CloseScreen) (index, pScreen);
free(as);
return ret;
}
-static void
-AnimCurCursorLimits (DeviceIntPtr pDev,
- ScreenPtr pScreen,
- CursorPtr pCursor,
- BoxPtr pHotBox,
- BoxPtr pTopLeftBox)
+static void
+AnimCurCursorLimits(DeviceIntPtr pDev,
+ ScreenPtr pScreen,
+ CursorPtr pCursor, BoxPtr pHotBox, BoxPtr pTopLeftBox)
{
- AnimCurScreenPtr as = GetAnimCurScreen(pScreen);
+ AnimCurScreenPtr as = GetAnimCurScreen(pScreen);
- Unwrap (as, pScreen, CursorLimits);
- if (IsAnimCur(pCursor))
- {
- AnimCurPtr ac = GetAnimCur(pCursor);
+ Unwrap(as, pScreen, CursorLimits);
+ if (IsAnimCur(pCursor)) {
+ AnimCurPtr ac = GetAnimCur(pCursor);
- (*pScreen->CursorLimits) (pDev, pScreen, ac->elts[0].pCursor,
- pHotBox, pTopLeftBox);
+ (*pScreen->CursorLimits) (pDev, pScreen, ac->elts[0].pCursor,
+ pHotBox, pTopLeftBox);
}
- else
- {
- (*pScreen->CursorLimits) (pDev, pScreen, pCursor,
- pHotBox, pTopLeftBox);
+ else {
+ (*pScreen->CursorLimits) (pDev, pScreen, pCursor, pHotBox, pTopLeftBox);
}
- Wrap (as, pScreen, CursorLimits, AnimCurCursorLimits);
+ Wrap(as, pScreen, CursorLimits, AnimCurCursorLimits);
}
/*
@@ -140,209 +135,188 @@ AnimCurCursorLimits (DeviceIntPtr pDev,
*/
static void
-AnimCurScreenBlockHandler (int screenNum,
- pointer blockData,
- pointer pTimeout,
- pointer pReadmask)
+AnimCurScreenBlockHandler(int screenNum,
+ pointer blockData,
+ pointer pTimeout, pointer pReadmask)
{
- ScreenPtr pScreen = screenInfo.screens[screenNum];
- AnimCurScreenPtr as = GetAnimCurScreen(pScreen);
- DeviceIntPtr dev;
- Bool activeDevice = FALSE;
- CARD32 now = 0,
- soonest = ~0; /* earliest time to wakeup again */
-
- for (dev = inputInfo.devices; dev; dev = dev->next)
- {
- if (IsPointerDevice(dev) && pScreen == dev->spriteInfo->anim.pScreen)
- {
- if (!activeDevice) {
- now = GetTimeInMillis ();
+ ScreenPtr pScreen = screenInfo.screens[screenNum];
+ AnimCurScreenPtr as = GetAnimCurScreen(pScreen);
+ DeviceIntPtr dev;
+ Bool activeDevice = FALSE;
+ CARD32 now = 0, soonest = ~0; /* earliest time to wakeup again */
+
+ for (dev = inputInfo.devices; dev; dev = dev->next) {
+ if (IsPointerDevice(dev) && pScreen == dev->spriteInfo->anim.pScreen) {
+ if (!activeDevice) {
+ now = GetTimeInMillis();
activeDevice = TRUE;
}
- if ((INT32) (now - dev->spriteInfo->anim.time) >= 0)
- {
- AnimCurPtr ac = GetAnimCur(dev->spriteInfo->anim.pCursor);
- int elt = (dev->spriteInfo->anim.elt + 1) % ac->nelt;
- DisplayCursorProcPtr DisplayCursor;
-
- /*
- * Not a simple Unwrap/Wrap as this
- * isn't called along the DisplayCursor
- * wrapper chain.
- */
- DisplayCursor = pScreen->DisplayCursor;
- pScreen->DisplayCursor = as->DisplayCursor;
- (void) (*pScreen->DisplayCursor) (dev,
- pScreen,
- ac->elts[elt].pCursor);
- as->DisplayCursor = pScreen->DisplayCursor;
- pScreen->DisplayCursor = DisplayCursor;
-
- dev->spriteInfo->anim.elt = elt;
- dev->spriteInfo->anim.time = now + ac->elts[elt].delay;
- }
-
- if (soonest > dev->spriteInfo->anim.time)
- soonest = dev->spriteInfo->anim.time;
- }
+ if ((INT32) (now - dev->spriteInfo->anim.time) >= 0) {
+ AnimCurPtr ac = GetAnimCur(dev->spriteInfo->anim.pCursor);
+ int elt = (dev->spriteInfo->anim.elt + 1) % ac->nelt;
+ DisplayCursorProcPtr DisplayCursor;
+
+ /*
+ * Not a simple Unwrap/Wrap as this
+ * isn't called along the DisplayCursor
+ * wrapper chain.
+ */
+ DisplayCursor = pScreen->DisplayCursor;
+ pScreen->DisplayCursor = as->DisplayCursor;
+ (void) (*pScreen->DisplayCursor) (dev,
+ pScreen,
+ ac->elts[elt].pCursor);
+ as->DisplayCursor = pScreen->DisplayCursor;
+ pScreen->DisplayCursor = DisplayCursor;
+
+ dev->spriteInfo->anim.elt = elt;
+ dev->spriteInfo->anim.time = now + ac->elts[elt].delay;
+ }
+
+ if (soonest > dev->spriteInfo->anim.time)
+ soonest = dev->spriteInfo->anim.time;
+ }
}
if (activeDevice)
- AdjustWaitForDelay (pTimeout, soonest - now);
+ AdjustWaitForDelay(pTimeout, soonest - now);
- Unwrap (as, pScreen, BlockHandler);
+ Unwrap(as, pScreen, BlockHandler);
(*pScreen->BlockHandler) (screenNum, blockData, pTimeout, pReadmask);
if (activeDevice)
- Wrap (as, pScreen, BlockHandler, AnimCurScreenBlockHandler);
+ Wrap(as, pScreen, BlockHandler, AnimCurScreenBlockHandler);
else
as->BlockHandler = NULL;
}
static Bool
-AnimCurDisplayCursor (DeviceIntPtr pDev,
- ScreenPtr pScreen,
- CursorPtr pCursor)
+AnimCurDisplayCursor(DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr pCursor)
{
- AnimCurScreenPtr as = GetAnimCurScreen(pScreen);
- Bool ret;
+ AnimCurScreenPtr as = GetAnimCurScreen(pScreen);
+ Bool ret;
if (IsFloating(pDev))
- return FALSE;
+ return FALSE;
- Unwrap (as, pScreen, DisplayCursor);
- if (IsAnimCur(pCursor))
- {
- if (pCursor != pDev->spriteInfo->anim.pCursor)
- {
- AnimCurPtr ac = GetAnimCur(pCursor);
+ Unwrap(as, pScreen, DisplayCursor);
+ if (IsAnimCur(pCursor)) {
+ if (pCursor != pDev->spriteInfo->anim.pCursor) {
+ AnimCurPtr ac = GetAnimCur(pCursor);
- ret = (*pScreen->DisplayCursor)
+ ret = (*pScreen->DisplayCursor)
(pDev, pScreen, ac->elts[0].pCursor);
- if (ret)
- {
- pDev->spriteInfo->anim.elt = 0;
- pDev->spriteInfo->anim.time = GetTimeInMillis () + ac->elts[0].delay;
- pDev->spriteInfo->anim.pCursor = pCursor;
- pDev->spriteInfo->anim.pScreen = pScreen;
-
- if (!as->BlockHandler)
- Wrap(as, pScreen, BlockHandler, AnimCurScreenBlockHandler);
- }
- }
- else
- ret = TRUE;
+ if (ret) {
+ pDev->spriteInfo->anim.elt = 0;
+ pDev->spriteInfo->anim.time =
+ GetTimeInMillis() + ac->elts[0].delay;
+ pDev->spriteInfo->anim.pCursor = pCursor;
+ pDev->spriteInfo->anim.pScreen = pScreen;
+
+ if (!as->BlockHandler)
+ Wrap(as, pScreen, BlockHandler, AnimCurScreenBlockHandler);
+ }
+ }
+ else
+ ret = TRUE;
}
- else
- {
- pDev->spriteInfo->anim.pCursor = 0;
- pDev->spriteInfo->anim.pScreen = 0;
- ret = (*pScreen->DisplayCursor) (pDev, pScreen, pCursor);
+ else {
+ pDev->spriteInfo->anim.pCursor = 0;
+ pDev->spriteInfo->anim.pScreen = 0;
+ ret = (*pScreen->DisplayCursor) (pDev, pScreen, pCursor);
}
- Wrap (as, pScreen, DisplayCursor, AnimCurDisplayCursor);
+ Wrap(as, pScreen, DisplayCursor, AnimCurDisplayCursor);
return ret;
}
static Bool
-AnimCurSetCursorPosition (DeviceIntPtr pDev,
- ScreenPtr pScreen,
- int x,
- int y,
- Bool generateEvent)
+AnimCurSetCursorPosition(DeviceIntPtr pDev,
+ ScreenPtr pScreen, int x, int y, Bool generateEvent)
{
- AnimCurScreenPtr as = GetAnimCurScreen(pScreen);
- Bool ret;
-
- Unwrap (as, pScreen, SetCursorPosition);
+ AnimCurScreenPtr as = GetAnimCurScreen(pScreen);
+ Bool ret;
+
+ Unwrap(as, pScreen, SetCursorPosition);
if (pDev->spriteInfo->anim.pCursor) {
- pDev->spriteInfo->anim.pScreen = pScreen;
+ pDev->spriteInfo->anim.pScreen = pScreen;
- if (!as->BlockHandler)
- Wrap(as, pScreen, BlockHandler, AnimCurScreenBlockHandler);
+ if (!as->BlockHandler)
+ Wrap(as, pScreen, BlockHandler, AnimCurScreenBlockHandler);
}
ret = (*pScreen->SetCursorPosition) (pDev, pScreen, x, y, generateEvent);
- Wrap (as, pScreen, SetCursorPosition, AnimCurSetCursorPosition);
+ Wrap(as, pScreen, SetCursorPosition, AnimCurSetCursorPosition);
return ret;
}
-static Bool
-AnimCurRealizeCursor (DeviceIntPtr pDev,
- ScreenPtr pScreen,
- CursorPtr pCursor)
+static Bool
+AnimCurRealizeCursor(DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr pCursor)
{
- AnimCurScreenPtr as = GetAnimCurScreen(pScreen);
- Bool ret;
-
- Unwrap (as, pScreen, RealizeCursor);
+ AnimCurScreenPtr as = GetAnimCurScreen(pScreen);
+ Bool ret;
+
+ Unwrap(as, pScreen, RealizeCursor);
if (IsAnimCur(pCursor))
- ret = TRUE;
+ ret = TRUE;
else
- ret = (*pScreen->RealizeCursor) (pDev, pScreen, pCursor);
- Wrap (as, pScreen, RealizeCursor, AnimCurRealizeCursor);
+ ret = (*pScreen->RealizeCursor) (pDev, pScreen, pCursor);
+ Wrap(as, pScreen, RealizeCursor, AnimCurRealizeCursor);
return ret;
}
-static Bool
-AnimCurUnrealizeCursor (DeviceIntPtr pDev,
- ScreenPtr pScreen,
- CursorPtr pCursor)
+static Bool
+AnimCurUnrealizeCursor(DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr pCursor)
{
- AnimCurScreenPtr as = GetAnimCurScreen(pScreen);
- Bool ret;
-
- Unwrap (as, pScreen, UnrealizeCursor);
- if (IsAnimCur(pCursor))
- {
- AnimCurPtr ac = GetAnimCur(pCursor);
- int i;
-
- if (pScreen->myNum == 0)
- for (i = 0; i < ac->nelt; i++)
- FreeCursor (ac->elts[i].pCursor, 0);
- ret = TRUE;
+ AnimCurScreenPtr as = GetAnimCurScreen(pScreen);
+ Bool ret;
+
+ Unwrap(as, pScreen, UnrealizeCursor);
+ if (IsAnimCur(pCursor)) {
+ AnimCurPtr ac = GetAnimCur(pCursor);
+ int i;
+
+ if (pScreen->myNum == 0)
+ for (i = 0; i < ac->nelt; i++)
+ FreeCursor(ac->elts[i].pCursor, 0);
+ ret = TRUE;
}
else
- ret = (*pScreen->UnrealizeCursor) (pDev, pScreen, pCursor);
- Wrap (as, pScreen, UnrealizeCursor, AnimCurUnrealizeCursor);
+ ret = (*pScreen->UnrealizeCursor) (pDev, pScreen, pCursor);
+ Wrap(as, pScreen, UnrealizeCursor, AnimCurUnrealizeCursor);
return ret;
}
static void
-AnimCurRecolorCursor (DeviceIntPtr pDev,
- ScreenPtr pScreen,
- CursorPtr pCursor,
- Bool displayed)
+AnimCurRecolorCursor(DeviceIntPtr pDev,
+ ScreenPtr pScreen, CursorPtr pCursor, Bool displayed)
{
- AnimCurScreenPtr as = GetAnimCurScreen(pScreen);
-
- Unwrap (as, pScreen, RecolorCursor);
- if (IsAnimCur(pCursor))
- {
- AnimCurPtr ac = GetAnimCur(pCursor);
- int i;
+ AnimCurScreenPtr as = GetAnimCurScreen(pScreen);
+
+ Unwrap(as, pScreen, RecolorCursor);
+ if (IsAnimCur(pCursor)) {
+ AnimCurPtr ac = GetAnimCur(pCursor);
+ int i;
for (i = 0; i < ac->nelt; i++)
- (*pScreen->RecolorCursor) (pDev, pScreen, ac->elts[i].pCursor,
- displayed &&
- pDev->spriteInfo->anim.elt == i);
+ (*pScreen->RecolorCursor) (pDev, pScreen, ac->elts[i].pCursor,
+ displayed &&
+ pDev->spriteInfo->anim.elt == i);
}
else
- (*pScreen->RecolorCursor) (pDev, pScreen, pCursor, displayed);
- Wrap (as, pScreen, RecolorCursor, AnimCurRecolorCursor);
+ (*pScreen->RecolorCursor) (pDev, pScreen, pCursor, displayed);
+ Wrap(as, pScreen, RecolorCursor, AnimCurRecolorCursor);
}
Bool
-AnimCurInit (ScreenPtr pScreen)
+AnimCurInit(ScreenPtr pScreen)
{
- AnimCurScreenPtr as;
+ AnimCurScreenPtr as;
if (!dixRegisterPrivateKey(&AnimCurScreenPrivateKeyRec, PRIVATE_SCREEN, 0))
- return FALSE;
+ return FALSE;
- as = (AnimCurScreenPtr) malloc(sizeof (AnimCurScreenRec));
+ as = (AnimCurScreenPtr) malloc(sizeof(AnimCurScreenRec));
if (!as)
- return FALSE;
+ return FALSE;
Wrap(as, pScreen, CloseScreen, AnimCurCloseScreen);
as->BlockHandler = NULL;
@@ -353,38 +327,39 @@ AnimCurInit (ScreenPtr pScreen)
Wrap(as, pScreen, RealizeCursor, AnimCurRealizeCursor);
Wrap(as, pScreen, UnrealizeCursor, AnimCurUnrealizeCursor);
Wrap(as, pScreen, RecolorCursor, AnimCurRecolorCursor);
- SetAnimCurScreen(pScreen,as);
+ SetAnimCurScreen(pScreen, as);
return TRUE;
}
int
-AnimCursorCreate (CursorPtr *cursors, CARD32 *deltas, int ncursor, CursorPtr *ppCursor, ClientPtr client, XID cid)
+AnimCursorCreate(CursorPtr *cursors, CARD32 *deltas, int ncursor,
+ CursorPtr *ppCursor, ClientPtr client, XID cid)
{
- CursorPtr pCursor;
- int rc, i;
- AnimCurPtr ac;
+ CursorPtr pCursor;
+ int rc, i;
+ AnimCurPtr ac;
for (i = 0; i < screenInfo.numScreens; i++)
- if (!GetAnimCurScreen (screenInfo.screens[i]))
- return BadImplementation;
+ if (!GetAnimCurScreen(screenInfo.screens[i]))
+ return BadImplementation;
for (i = 0; i < ncursor; i++)
- if (IsAnimCur (cursors[i]))
- return BadMatch;
-
+ if (IsAnimCur(cursors[i]))
+ return BadMatch;
+
pCursor = (CursorPtr) calloc(CURSOR_REC_SIZE +
- sizeof (AnimCurRec) +
- ncursor * sizeof (AnimCurElt), 1);
+ sizeof(AnimCurRec) +
+ ncursor * sizeof(AnimCurElt), 1);
if (!pCursor)
- return BadAlloc;
+ return BadAlloc;
dixInitPrivates(pCursor, pCursor + 1, PRIVATE_CURSOR);
pCursor->bits = &animCursorBits;
pCursor->refcnt = 1;
-
+
pCursor->foreRed = cursors[0]->foreRed;
pCursor->foreGreen = cursors[0]->foreGreen;
pCursor->foreBlue = cursors[0]->foreBlue;
-
+
pCursor->backRed = cursors[0]->backRed;
pCursor->backGreen = cursors[0]->backGreen;
pCursor->backBlue = cursors[0]->backBlue;
@@ -393,28 +368,27 @@ AnimCursorCreate (CursorPtr *cursors, CARD32 *deltas, int ncursor, CursorPtr *pp
/* security creation/labeling check */
rc = XaceHook(XACE_RESOURCE_ACCESS, client, cid, RT_CURSOR, pCursor,
- RT_NONE, NULL, DixCreateAccess);
+ RT_NONE, NULL, DixCreateAccess);
if (rc != Success) {
- dixFiniPrivates(pCursor, PRIVATE_CURSOR);
- free(pCursor);
- return rc;
+ dixFiniPrivates(pCursor, PRIVATE_CURSOR);
+ free(pCursor);
+ return rc;
}
-
+
/*
* Fill in the AnimCurRec
*/
animCursorBits.refcnt++;
- ac = GetAnimCur (pCursor);
+ ac = GetAnimCur(pCursor);
ac->nelt = ncursor;
ac->elts = (AnimCurElt *) (ac + 1);
-
- for (i = 0; i < ncursor; i++)
- {
- cursors[i]->refcnt++;
- ac->elts[i].pCursor = cursors[i];
- ac->elts[i].delay = deltas[i];
+
+ for (i = 0; i < ncursor; i++) {
+ cursors[i]->refcnt++;
+ ac->elts[i].pCursor = cursors[i];
+ ac->elts[i].delay = deltas[i];
}
-
+
*ppCursor = pCursor;
return Success;
}