2003-11-14 16:48:57 +00:00
|
|
|
/*
|
|
|
|
|
*
|
2004-12-04 00:43:13 +00:00
|
|
|
* Copyright © 2002 Keith Packard, member of The XFree86 Project, Inc.
|
2003-11-14 16:48:57 +00:00
|
|
|
*
|
|
|
|
|
* 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, and that the name of Keith Packard not be used in
|
|
|
|
|
* advertising or publicity pertaining to distribution of the software without
|
|
|
|
|
* specific, written prior permission. Keith Packard makes no
|
|
|
|
|
* representations about the suitability of this software for any purpose. It
|
|
|
|
|
* is provided "as is" without express or implied warranty.
|
|
|
|
|
*
|
|
|
|
|
* KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
|
|
|
|
|
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
|
|
|
|
|
* EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
|
|
|
|
|
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
|
|
|
|
|
* DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
|
|
|
|
|
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
|
|
|
* PERFORMANCE OF THIS SOFTWARE.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Animated cursors for X. Not specific to Render in any way, but
|
|
|
|
|
* stuck there because Render has the other cool cursor extension.
|
|
|
|
|
* Besides, everyone has Render.
|
|
|
|
|
*
|
|
|
|
|
* Implemented as a simple layer over the core cursor code; it
|
|
|
|
|
* creates composite cursors out of a set of static cursors and
|
|
|
|
|
* delta times between each image.
|
|
|
|
|
*/
|
|
|
|
|
|
2005-07-03 07:02:09 +00:00
|
|
|
#include <dix-config.h>
|
|
|
|
|
|
2005-04-20 12:25:48 +00:00
|
|
|
#include <X11/X.h>
|
|
|
|
|
#include <X11/Xmd.h>
|
2024-02-29 12:14:47 +01:00
|
|
|
|
|
|
|
|
#include "dix/cursor_priv.h"
|
2025-05-23 19:23:34 +02:00
|
|
|
#include "dix/input_priv.h"
|
2024-10-04 21:58:57 +02:00
|
|
|
#include "dix/screen_hooks_priv.h"
|
2024-02-29 12:14:47 +01:00
|
|
|
|
2003-11-14 16:48:57 +00:00
|
|
|
#include "servermd.h"
|
|
|
|
|
#include "scrnintstr.h"
|
|
|
|
|
#include "dixstruct.h"
|
|
|
|
|
#include "cursorstr.h"
|
|
|
|
|
#include "dixfontstr.h"
|
|
|
|
|
#include "opaque.h"
|
2024-02-12 11:42:39 +01:00
|
|
|
#include "picturestr_priv.h"
|
2006-11-23 17:15:14 +10:30
|
|
|
#include "inputstr.h"
|
2007-08-31 09:55:27 -04:00
|
|
|
#include "xace.h"
|
2003-11-14 16:48:57 +00:00
|
|
|
|
|
|
|
|
typedef struct _AnimCurElt {
|
|
|
|
|
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 */
|
2017-10-26 15:24:39 -04:00
|
|
|
OsTimerPtr timer;
|
2003-11-14 16:48:57 +00:00
|
|
|
} AnimCurRec, *AnimCurPtr;
|
|
|
|
|
|
|
|
|
|
typedef struct _AnimScrPriv {
|
|
|
|
|
CursorLimitsProcPtr CursorLimits;
|
|
|
|
|
DisplayCursorProcPtr DisplayCursor;
|
|
|
|
|
SetCursorPositionProcPtr SetCursorPosition;
|
|
|
|
|
RealizeCursorProcPtr RealizeCursor;
|
|
|
|
|
UnrealizeCursorProcPtr UnrealizeCursor;
|
|
|
|
|
RecolorCursorProcPtr RecolorCursor;
|
|
|
|
|
} AnimCurScreenRec, *AnimCurScreenPtr;
|
|
|
|
|
|
|
|
|
|
static unsigned char empty[4];
|
|
|
|
|
|
|
|
|
|
static CursorBits animCursorBits = {
|
|
|
|
|
empty, empty, 2, 1, 1, 0, 0, 1
|
|
|
|
|
};
|
|
|
|
|
|
2010-04-26 17:22:21 -07:00
|
|
|
static DevPrivateKeyRec AnimCurScreenPrivateKeyRec;
|
2012-03-21 12:55:09 -07:00
|
|
|
|
2008-05-12 20:05:21 +09:30
|
|
|
#define IsAnimCur(c) ((c) && ((c)->bits == &animCursorBits))
|
2010-04-26 17:22:21 -07:00
|
|
|
#define GetAnimCur(c) ((AnimCurPtr) ((((char *)(c) + CURSOR_REC_SIZE))))
|
2017-10-26 13:40:57 -04:00
|
|
|
#define GetAnimCurScreen(s) ((AnimCurScreenPtr)dixLookupPrivate(&(s)->devPrivates, &AnimCurScreenPrivateKeyRec))
|
2003-11-14 16:48:57 +00:00
|
|
|
|
|
|
|
|
#define Wrap(as,s,elt,func) (((as)->elt = (s)->elt), (s)->elt = func)
|
|
|
|
|
#define Unwrap(as,s,elt) ((s)->elt = (as)->elt)
|
|
|
|
|
|
2024-10-04 21:58:57 +02:00
|
|
|
static void AnimCurScreenClose(CallbackListPtr *pcbl, ScreenPtr pScreen, void *unused)
|
2003-11-14 16:48:57 +00:00
|
|
|
{
|
|
|
|
|
AnimCurScreenPtr as = GetAnimCurScreen(pScreen);
|
|
|
|
|
|
2024-10-04 21:58:57 +02:00
|
|
|
dixScreenUnhookClose(pScreen, AnimCurScreenClose);
|
2003-11-14 16:48:57 +00:00
|
|
|
|
|
|
|
|
Unwrap(as, pScreen, CursorLimits);
|
|
|
|
|
Unwrap(as, pScreen, DisplayCursor);
|
|
|
|
|
Unwrap(as, pScreen, SetCursorPosition);
|
|
|
|
|
Unwrap(as, pScreen, RealizeCursor);
|
|
|
|
|
Unwrap(as, pScreen, UnrealizeCursor);
|
|
|
|
|
Unwrap(as, pScreen, RecolorCursor);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2006-11-23 17:15:14 +10:30
|
|
|
AnimCurCursorLimits(DeviceIntPtr pDev,
|
|
|
|
|
ScreenPtr pScreen,
|
2003-11-14 16:48:57 +00:00
|
|
|
CursorPtr pCursor, BoxPtr pHotBox, BoxPtr pTopLeftBox)
|
|
|
|
|
{
|
|
|
|
|
AnimCurScreenPtr as = GetAnimCurScreen(pScreen);
|
|
|
|
|
|
|
|
|
|
Unwrap(as, pScreen, CursorLimits);
|
|
|
|
|
if (IsAnimCur(pCursor)) {
|
|
|
|
|
AnimCurPtr ac = GetAnimCur(pCursor);
|
|
|
|
|
|
2006-11-23 17:15:14 +10:30
|
|
|
(*pScreen->CursorLimits) (pDev, pScreen, ac->elts[0].pCursor,
|
|
|
|
|
pHotBox, pTopLeftBox);
|
2003-11-14 16:48:57 +00:00
|
|
|
}
|
|
|
|
|
else {
|
2009-03-13 15:57:27 +10:00
|
|
|
(*pScreen->CursorLimits) (pDev, pScreen, pCursor, pHotBox, pTopLeftBox);
|
2003-11-14 16:48:57 +00:00
|
|
|
}
|
|
|
|
|
Wrap(as, pScreen, CursorLimits, AnimCurCursorLimits);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
2015-11-11 22:02:15 -08:00
|
|
|
* The cursor animation timer has expired, go display any relevant cursor changes
|
|
|
|
|
* and compute a new timeout value
|
2003-11-14 16:48:57 +00:00
|
|
|
*/
|
|
|
|
|
|
2015-11-11 22:02:15 -08:00
|
|
|
static CARD32
|
|
|
|
|
AnimCurTimerNotify(OsTimerPtr timer, CARD32 now, void *arg)
|
2003-11-14 16:48:57 +00:00
|
|
|
{
|
2017-10-26 15:24:39 -04:00
|
|
|
DeviceIntPtr dev = arg;
|
|
|
|
|
ScreenPtr pScreen = dev->spriteInfo->anim.pScreen;
|
2003-11-14 16:48:57 +00:00
|
|
|
AnimCurScreenPtr as = GetAnimCurScreen(pScreen);
|
2012-03-21 12:55:09 -07:00
|
|
|
|
2018-02-12 15:35:04 -05:00
|
|
|
AnimCurPtr ac = GetAnimCur(dev->spriteInfo->sprite->current);
|
2017-10-26 15:24:39 -04:00
|
|
|
int elt = (dev->spriteInfo->anim.elt + 1) % ac->nelt;
|
|
|
|
|
DisplayCursorProcPtr DisplayCursor = pScreen->DisplayCursor;
|
2007-04-04 17:38:10 +09:30
|
|
|
|
2017-10-26 15:24:39 -04:00
|
|
|
/*
|
|
|
|
|
* Not a simple Unwrap/Wrap as this isn't called along the DisplayCursor
|
|
|
|
|
* wrapper chain.
|
|
|
|
|
*/
|
|
|
|
|
pScreen->DisplayCursor = as->DisplayCursor;
|
|
|
|
|
(void) (*pScreen->DisplayCursor) (dev, pScreen, ac->elts[elt].pCursor);
|
|
|
|
|
as->DisplayCursor = pScreen->DisplayCursor;
|
|
|
|
|
pScreen->DisplayCursor = DisplayCursor;
|
2015-11-11 22:02:15 -08:00
|
|
|
|
2017-10-26 15:24:39 -04:00
|
|
|
dev->spriteInfo->anim.elt = elt;
|
2018-02-12 15:35:04 -05:00
|
|
|
dev->spriteInfo->anim.pCursor = ac->elts[elt].pCursor;
|
2017-10-26 15:24:39 -04:00
|
|
|
|
|
|
|
|
return ac->elts[elt].delay;
|
2003-11-14 16:48:57 +00:00
|
|
|
}
|
|
|
|
|
|
2018-01-09 10:54:05 -05:00
|
|
|
static void
|
|
|
|
|
AnimCurCancelTimer(DeviceIntPtr pDev)
|
|
|
|
|
{
|
2018-04-23 15:21:14 -04:00
|
|
|
CursorPtr cur = pDev->spriteInfo->sprite ?
|
|
|
|
|
pDev->spriteInfo->sprite->current : NULL;
|
2018-01-09 10:54:05 -05:00
|
|
|
|
|
|
|
|
if (IsAnimCur(cur))
|
|
|
|
|
TimerCancel(GetAnimCur(cur)->timer);
|
|
|
|
|
}
|
|
|
|
|
|
2003-11-14 16:48:57 +00:00
|
|
|
static Bool
|
2006-11-23 17:15:14 +10:30
|
|
|
AnimCurDisplayCursor(DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr pCursor)
|
2003-11-14 16:48:57 +00:00
|
|
|
{
|
|
|
|
|
AnimCurScreenPtr as = GetAnimCurScreen(pScreen);
|
2018-01-09 10:54:05 -05:00
|
|
|
Bool ret = TRUE;
|
2003-11-14 16:48:57 +00:00
|
|
|
|
2025-05-23 19:33:05 +02:00
|
|
|
if (InputDevIsFloating(pDev))
|
2012-01-06 13:20:45 +10:00
|
|
|
return FALSE;
|
|
|
|
|
|
2003-11-14 16:48:57 +00:00
|
|
|
Unwrap(as, pScreen, DisplayCursor);
|
|
|
|
|
if (IsAnimCur(pCursor)) {
|
2018-02-12 15:35:04 -05:00
|
|
|
if (pCursor != pDev->spriteInfo->sprite->current) {
|
2003-11-14 16:48:57 +00:00
|
|
|
AnimCurPtr ac = GetAnimCur(pCursor);
|
|
|
|
|
|
2018-01-09 10:54:05 -05:00
|
|
|
AnimCurCancelTimer(pDev);
|
|
|
|
|
ret = (*pScreen->DisplayCursor) (pDev, pScreen,
|
|
|
|
|
ac->elts[0].pCursor);
|
|
|
|
|
|
2003-11-14 16:48:57 +00:00
|
|
|
if (ret) {
|
2010-05-18 13:53:29 +03:00
|
|
|
pDev->spriteInfo->anim.elt = 0;
|
|
|
|
|
pDev->spriteInfo->anim.pCursor = pCursor;
|
|
|
|
|
pDev->spriteInfo->anim.pScreen = pScreen;
|
2012-03-21 12:55:09 -07:00
|
|
|
|
2017-10-26 15:24:39 -04:00
|
|
|
ac->timer = TimerSet(ac->timer, 0, ac->elts[0].delay,
|
|
|
|
|
AnimCurTimerNotify, pDev);
|
2003-11-14 16:48:57 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
2018-01-09 10:54:05 -05:00
|
|
|
AnimCurCancelTimer(pDev);
|
2010-05-18 13:53:29 +03:00
|
|
|
pDev->spriteInfo->anim.pCursor = 0;
|
|
|
|
|
pDev->spriteInfo->anim.pScreen = 0;
|
2006-11-23 17:15:14 +10:30
|
|
|
ret = (*pScreen->DisplayCursor) (pDev, pScreen, pCursor);
|
2003-11-14 16:48:57 +00:00
|
|
|
}
|
|
|
|
|
Wrap(as, pScreen, DisplayCursor, AnimCurDisplayCursor);
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static Bool
|
2006-11-23 17:15:14 +10:30
|
|
|
AnimCurSetCursorPosition(DeviceIntPtr pDev,
|
2003-11-14 16:48:57 +00:00
|
|
|
ScreenPtr pScreen, int x, int y, Bool generateEvent)
|
|
|
|
|
{
|
|
|
|
|
AnimCurScreenPtr as = GetAnimCurScreen(pScreen);
|
|
|
|
|
Bool ret;
|
2012-03-21 12:55:09 -07:00
|
|
|
|
2003-11-14 16:48:57 +00:00
|
|
|
Unwrap(as, pScreen, SetCursorPosition);
|
2010-12-30 19:19:33 +02:00
|
|
|
if (pDev->spriteInfo->anim.pCursor) {
|
2010-05-18 13:53:29 +03:00
|
|
|
pDev->spriteInfo->anim.pScreen = pScreen;
|
2010-12-30 19:19:33 +02:00
|
|
|
}
|
2006-11-23 17:15:14 +10:30
|
|
|
ret = (*pScreen->SetCursorPosition) (pDev, pScreen, x, y, generateEvent);
|
2003-11-14 16:48:57 +00:00
|
|
|
Wrap(as, pScreen, SetCursorPosition, AnimCurSetCursorPosition);
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static Bool
|
2006-11-23 17:15:14 +10:30
|
|
|
AnimCurRealizeCursor(DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr pCursor)
|
2003-11-14 16:48:57 +00:00
|
|
|
{
|
|
|
|
|
AnimCurScreenPtr as = GetAnimCurScreen(pScreen);
|
|
|
|
|
Bool ret;
|
2012-03-21 12:55:09 -07:00
|
|
|
|
2003-11-14 16:48:57 +00:00
|
|
|
Unwrap(as, pScreen, RealizeCursor);
|
|
|
|
|
if (IsAnimCur(pCursor))
|
|
|
|
|
ret = TRUE;
|
|
|
|
|
else
|
2006-11-23 17:15:14 +10:30
|
|
|
ret = (*pScreen->RealizeCursor) (pDev, pScreen, pCursor);
|
2003-11-14 16:48:57 +00:00
|
|
|
Wrap(as, pScreen, RealizeCursor, AnimCurRealizeCursor);
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static Bool
|
2006-11-23 17:15:14 +10:30
|
|
|
AnimCurUnrealizeCursor(DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr pCursor)
|
2003-11-14 16:48:57 +00:00
|
|
|
{
|
|
|
|
|
AnimCurScreenPtr as = GetAnimCurScreen(pScreen);
|
|
|
|
|
Bool ret;
|
2012-03-21 12:55:09 -07:00
|
|
|
|
2003-11-14 16:48:57 +00:00
|
|
|
Unwrap(as, pScreen, UnrealizeCursor);
|
|
|
|
|
if (IsAnimCur(pCursor)) {
|
|
|
|
|
AnimCurPtr ac = GetAnimCur(pCursor);
|
|
|
|
|
int i;
|
2012-03-21 12:55:09 -07:00
|
|
|
|
2003-11-14 16:48:57 +00:00
|
|
|
if (pScreen->myNum == 0)
|
|
|
|
|
for (i = 0; i < ac->nelt; i++)
|
|
|
|
|
FreeCursor(ac->elts[i].pCursor, 0);
|
|
|
|
|
ret = TRUE;
|
|
|
|
|
}
|
|
|
|
|
else
|
2006-11-23 17:15:14 +10:30
|
|
|
ret = (*pScreen->UnrealizeCursor) (pDev, pScreen, pCursor);
|
2003-11-14 16:48:57 +00:00
|
|
|
Wrap(as, pScreen, UnrealizeCursor, AnimCurUnrealizeCursor);
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2006-11-23 17:15:14 +10:30
|
|
|
AnimCurRecolorCursor(DeviceIntPtr pDev,
|
2003-11-14 16:48:57 +00:00
|
|
|
ScreenPtr pScreen, CursorPtr pCursor, Bool displayed)
|
|
|
|
|
{
|
|
|
|
|
AnimCurScreenPtr as = GetAnimCurScreen(pScreen);
|
2012-03-21 12:55:09 -07:00
|
|
|
|
2003-11-14 16:48:57 +00:00
|
|
|
Unwrap(as, pScreen, RecolorCursor);
|
|
|
|
|
if (IsAnimCur(pCursor)) {
|
|
|
|
|
AnimCurPtr ac = GetAnimCur(pCursor);
|
|
|
|
|
int i;
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < ac->nelt; i++)
|
2006-11-23 17:15:14 +10:30
|
|
|
(*pScreen->RecolorCursor) (pDev, pScreen, ac->elts[i].pCursor,
|
2003-11-14 16:48:57 +00:00
|
|
|
displayed &&
|
2010-05-18 13:53:29 +03:00
|
|
|
pDev->spriteInfo->anim.elt == i);
|
2003-11-14 16:48:57 +00:00
|
|
|
}
|
|
|
|
|
else
|
2006-11-23 17:15:14 +10:30
|
|
|
(*pScreen->RecolorCursor) (pDev, pScreen, pCursor, displayed);
|
2003-11-14 16:48:57 +00:00
|
|
|
Wrap(as, pScreen, RecolorCursor, AnimCurRecolorCursor);
|
|
|
|
|
}
|
|
|
|
|
|
Rework symbol visibility for easier maintenance
Save in a few special cases, _X_EXPORT should not be used in C source
files. Instead, it should be used in headers, and the proper C source
include that header. Some special cases are symbols that need to be
shared between modules, but not expected to be used by external drivers,
and symbols that are accessible via LoaderSymbol/dlopen.
This patch also adds conditionally some new sdk header files, depending
on extensions enabled. These files were added to match pattern for
other extensions/modules, that is, have the headers "deciding" symbol
visibility in the sdk. These headers are:
o Xext/panoramiXsrv.h, Xext/panoramiX.h
o fbpict.h (unconditionally)
o vidmodeproc.h
o mioverlay.h (unconditionally, used only by xaa)
o xfixes.h (unconditionally, symbols required by dri2)
LoaderSymbol and similar functions now don't have different prototypes,
in loaderProcs.h and xf86Module.h, so that both headers can be included,
without the need of defining IN_LOADER.
xf86NewInputDevice() device prototype readded to xf86Xinput.h, but
not exported (and with a comment about it).
2008-12-03 05:43:34 -02:00
|
|
|
Bool
|
2003-11-14 16:48:57 +00:00
|
|
|
AnimCurInit(ScreenPtr pScreen)
|
|
|
|
|
{
|
|
|
|
|
AnimCurScreenPtr as;
|
|
|
|
|
|
2017-10-26 13:40:57 -04:00
|
|
|
if (!dixRegisterPrivateKey(&AnimCurScreenPrivateKeyRec, PRIVATE_SCREEN,
|
|
|
|
|
sizeof(AnimCurScreenRec)))
|
2010-04-26 17:22:21 -07:00
|
|
|
return FALSE;
|
|
|
|
|
|
2017-10-26 13:40:57 -04:00
|
|
|
as = GetAnimCurScreen(pScreen);
|
2003-11-14 16:48:57 +00:00
|
|
|
|
2024-10-04 21:58:57 +02:00
|
|
|
dixScreenHookClose(pScreen, AnimCurScreenClose);
|
2003-11-14 16:48:57 +00:00
|
|
|
|
|
|
|
|
Wrap(as, pScreen, CursorLimits, AnimCurCursorLimits);
|
|
|
|
|
Wrap(as, pScreen, DisplayCursor, AnimCurDisplayCursor);
|
|
|
|
|
Wrap(as, pScreen, SetCursorPosition, AnimCurSetCursorPosition);
|
|
|
|
|
Wrap(as, pScreen, RealizeCursor, AnimCurRealizeCursor);
|
|
|
|
|
Wrap(as, pScreen, UnrealizeCursor, AnimCurUnrealizeCursor);
|
|
|
|
|
Wrap(as, pScreen, RecolorCursor, AnimCurRecolorCursor);
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
Rework symbol visibility for easier maintenance
Save in a few special cases, _X_EXPORT should not be used in C source
files. Instead, it should be used in headers, and the proper C source
include that header. Some special cases are symbols that need to be
shared between modules, but not expected to be used by external drivers,
and symbols that are accessible via LoaderSymbol/dlopen.
This patch also adds conditionally some new sdk header files, depending
on extensions enabled. These files were added to match pattern for
other extensions/modules, that is, have the headers "deciding" symbol
visibility in the sdk. These headers are:
o Xext/panoramiXsrv.h, Xext/panoramiX.h
o fbpict.h (unconditionally)
o vidmodeproc.h
o mioverlay.h (unconditionally, used only by xaa)
o xfixes.h (unconditionally, symbols required by dri2)
LoaderSymbol and similar functions now don't have different prototypes,
in loaderProcs.h and xf86Module.h, so that both headers can be included,
without the need of defining IN_LOADER.
xf86NewInputDevice() device prototype readded to xf86Xinput.h, but
not exported (and with a comment about it).
2008-12-03 05:43:34 -02:00
|
|
|
int
|
2007-08-31 09:55:27 -04:00
|
|
|
AnimCursorCreate(CursorPtr *cursors, CARD32 *deltas, int ncursor,
|
|
|
|
|
CursorPtr *ppCursor, ClientPtr client, XID cid)
|
2003-11-14 16:48:57 +00:00
|
|
|
{
|
2025-06-17 16:22:53 +02:00
|
|
|
if (ncursor <= 0)
|
|
|
|
|
return BadValue;
|
|
|
|
|
|
2003-11-14 16:48:57 +00:00
|
|
|
CursorPtr pCursor;
|
2018-01-09 11:48:10 -05:00
|
|
|
int rc = BadAlloc, i;
|
2003-11-14 16:48:57 +00:00
|
|
|
AnimCurPtr ac;
|
|
|
|
|
|
2025-08-11 09:53:01 +02:00
|
|
|
DIX_FOR_EACH_SCREEN({
|
2025-08-12 18:51:31 +02:00
|
|
|
if (!GetAnimCurScreen(walkScreen))
|
2003-11-14 16:48:57 +00:00
|
|
|
return BadImplementation;
|
2025-08-11 09:53:01 +02:00
|
|
|
});
|
2003-11-14 16:48:57 +00:00
|
|
|
|
|
|
|
|
for (i = 0; i < ncursor; i++)
|
|
|
|
|
if (IsAnimCur(cursors[i]))
|
|
|
|
|
return BadMatch;
|
2012-03-21 12:55:09 -07:00
|
|
|
|
2010-04-26 17:22:21 -07:00
|
|
|
pCursor = (CursorPtr) calloc(CURSOR_REC_SIZE +
|
|
|
|
|
sizeof(AnimCurRec) +
|
|
|
|
|
ncursor * sizeof(AnimCurElt), 1);
|
2003-11-14 16:48:57 +00:00
|
|
|
if (!pCursor)
|
2018-01-09 11:48:10 -05:00
|
|
|
return rc;
|
2010-04-26 17:22:21 -07:00
|
|
|
dixInitPrivates(pCursor, pCursor + 1, PRIVATE_CURSOR);
|
2003-11-14 16:48:57 +00:00
|
|
|
pCursor->bits = &animCursorBits;
|
|
|
|
|
pCursor->refcnt = 1;
|
2012-03-21 12:55:09 -07:00
|
|
|
|
2003-11-14 16:48:57 +00:00
|
|
|
pCursor->foreRed = cursors[0]->foreRed;
|
|
|
|
|
pCursor->foreGreen = cursors[0]->foreGreen;
|
|
|
|
|
pCursor->foreBlue = cursors[0]->foreBlue;
|
2012-03-21 12:55:09 -07:00
|
|
|
|
2003-11-14 16:48:57 +00:00
|
|
|
pCursor->backRed = cursors[0]->backRed;
|
|
|
|
|
pCursor->backGreen = cursors[0]->backGreen;
|
|
|
|
|
pCursor->backBlue = cursors[0]->backBlue;
|
|
|
|
|
|
2007-08-31 09:55:27 -04:00
|
|
|
pCursor->id = cid;
|
|
|
|
|
|
2017-10-26 15:24:39 -04:00
|
|
|
ac = GetAnimCur(pCursor);
|
|
|
|
|
ac->timer = TimerSet(NULL, 0, 0, AnimCurTimerNotify, NULL);
|
|
|
|
|
|
2007-08-31 09:55:27 -04:00
|
|
|
/* security creation/labeling check */
|
2018-01-09 11:48:10 -05:00
|
|
|
if (ac->timer)
|
2024-05-16 17:49:33 +02:00
|
|
|
rc = XaceHookResourceAccess(client, cid, X11_RESTYPE_CURSOR, pCursor,
|
2024-03-04 15:08:32 +01:00
|
|
|
X11_RESTYPE_NONE, NULL, DixCreateAccess);
|
2018-01-09 11:48:10 -05:00
|
|
|
|
2007-08-31 09:55:27 -04:00
|
|
|
if (rc != Success) {
|
2017-10-26 15:24:39 -04:00
|
|
|
TimerFree(ac->timer);
|
2010-04-26 17:22:21 -07:00
|
|
|
dixFiniPrivates(pCursor, PRIVATE_CURSOR);
|
2010-05-06 01:44:06 +07:00
|
|
|
free(pCursor);
|
2007-08-31 09:55:27 -04:00
|
|
|
return rc;
|
|
|
|
|
}
|
2012-03-21 12:55:09 -07:00
|
|
|
|
2003-11-14 16:48:57 +00:00
|
|
|
/*
|
|
|
|
|
* Fill in the AnimCurRec
|
|
|
|
|
*/
|
2007-08-31 09:55:27 -04:00
|
|
|
animCursorBits.refcnt++;
|
2003-11-14 16:48:57 +00:00
|
|
|
ac->nelt = ncursor;
|
|
|
|
|
ac->elts = (AnimCurElt *) (ac + 1);
|
2012-03-21 12:55:09 -07:00
|
|
|
|
2003-11-14 16:48:57 +00:00
|
|
|
for (i = 0; i < ncursor; i++) {
|
2013-05-15 19:01:11 +10:00
|
|
|
ac->elts[i].pCursor = RefCursor(cursors[i]);
|
2003-11-14 16:48:57 +00:00
|
|
|
ac->elts[i].delay = deltas[i];
|
|
|
|
|
}
|
2012-03-21 12:55:09 -07:00
|
|
|
|
2003-11-14 16:48:57 +00:00
|
|
|
*ppCursor = pCursor;
|
|
|
|
|
return Success;
|
|
|
|
|
}
|