aboutsummaryrefslogtreecommitdiff
path: root/xorg-server/xfixes/cursor.c
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2009-09-06 18:48:27 +0000
committermarha <marha@users.sourceforge.net>2009-09-06 18:48:27 +0000
commita915739887477b28d924ecc8417ee107d125bd6c (patch)
treec02f315476b61892d1fd89182e18943dce8d6277 /xorg-server/xfixes/cursor.c
parent6f25a23db1df27e992c34f6fd4c82e83c44fc2e2 (diff)
downloadvcxsrv-a915739887477b28d924ecc8417ee107d125bd6c.tar.gz
vcxsrv-a915739887477b28d924ecc8417ee107d125bd6c.tar.bz2
vcxsrv-a915739887477b28d924ecc8417ee107d125bd6c.zip
Switched to xorg-server-1.6.99.900.tar.gz
Diffstat (limited to 'xorg-server/xfixes/cursor.c')
-rw-r--r--xorg-server/xfixes/cursor.c140
1 files changed, 85 insertions, 55 deletions
diff --git a/xorg-server/xfixes/cursor.c b/xorg-server/xfixes/cursor.c
index 02ff1fd57..0c706600e 100644
--- a/xorg-server/xfixes/cursor.c
+++ b/xorg-server/xfixes/cursor.c
@@ -1,23 +1,30 @@
/*
- * Copyright © 2006 Sun Microsystems
+ * Copyright © 2006 Sun Microsystems, Inc. All rights reserved.
*
- * 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 Sun Microsystems not be used in
- * advertising or publicity pertaining to distribution of the software without
- * specific, written prior permission. Sun Microsystems makes no
- * representations about the suitability of this software for any purpose. It
- * is provided "as is" without express or implied warranty.
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, and/or sell copies of the Software, and to permit persons
+ * to whom the Software is furnished to do so, provided that the above
+ * copyright notice(s) and this permission notice appear in all copies of
+ * the Software and that both the above copyright notice(s) and this
+ * permission notice appear in supporting documentation.
*
- * SUN MICROSYSTEMS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- * EVENT SHALL SUN MICROSYSTEMS 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.
+ * 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
+ * OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR 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.
+ *
+ * Except as contained in this notice, the name of a copyright holder
+ * shall not be used in advertising or otherwise to promote the sale, use
+ * or other dealings in this Software without prior written authorization
+ * of the copyright holder.
*
* Copyright © 2002 Keith Packard
*
@@ -56,7 +63,7 @@
static RESTYPE CursorClientType;
static RESTYPE CursorHideCountType;
static RESTYPE CursorWindowType;
-static CursorPtr CursorCurrent;
+static CursorPtr CursorCurrent[MAXDEVICES];
static CursorPtr pInvisibleCursor = NULL;
static int CursorScreenPrivateKeyIndex;
@@ -64,14 +71,19 @@ static DevPrivateKey CursorScreenPrivateKey = &CursorScreenPrivateKeyIndex;
static void deleteCursorHideCountsForScreen (ScreenPtr pScreen);
-#define VERIFY_CURSOR(pCursor, cursor, client, access) { \
- pCursor = (CursorPtr)SecurityLookupIDByType((client), (cursor), \
- RT_CURSOR, (access)); \
- if (!pCursor) { \
- (client)->errorValue = (cursor); \
- return BadCursor; \
- } \
-}
+#define VERIFY_CURSOR(pCursor, cursor, client, access) \
+ do { \
+ int err; \
+ err = dixLookupResourceByType((pointer *) &pCursor, cursor, \
+ RT_CURSOR, client, access); \
+ if (err == BadValue) { \
+ client->errorValue = cursor; \
+ return BadCursor; \
+ } else if (err != Success) { \
+ client->errorValue = cursor; \
+ return err; \
+ } \
+ } while (0)
/*
* There is a global list of windows selecting for cursor events
@@ -119,11 +131,13 @@ typedef struct _CursorScreen {
#define GetCursorScreenIfSet(s) GetCursorScreen(s)
#define SetCursorScreen(s,p) dixSetPrivate(&(s)->devPrivates, CursorScreenPrivateKey, p)
#define Wrap(as,s,elt,func) (((as)->elt = (s)->elt), (s)->elt = func)
-#define Unwrap(as,s,elt) ((s)->elt = (as)->elt)
+#define Unwrap(as,s,elt,backup) (((backup) = (s)->elt), (s)->elt = (as)->elt)
/* The cursor doesn't show up until the first XDefineCursor() */
static Bool CursorVisible = FALSE;
+Bool EnableCursor = TRUE;
+
static Bool
CursorDisplayCursor (DeviceIntPtr pDev,
ScreenPtr pScreen,
@@ -131,15 +145,16 @@ CursorDisplayCursor (DeviceIntPtr pDev,
{
CursorScreenPtr cs = GetCursorScreen(pScreen);
Bool ret;
+ DisplayCursorProcPtr backupProc;
- Unwrap (cs, pScreen, DisplayCursor);
+ Unwrap (cs, pScreen, DisplayCursor, backupProc);
/*
* Have to check ConnectionInfo to distinguish client requests from
* initial root window setup. Not a great way to do it, I admit.
*/
if (ConnectionInfo)
- CursorVisible = TRUE;
+ CursorVisible = EnableCursor;
if (cs->pCursorHideCounts != NULL || !CursorVisible) {
ret = ((*pScreen->RealizeCursor)(pDev, pScreen, pInvisibleCursor) &&
@@ -148,11 +163,11 @@ CursorDisplayCursor (DeviceIntPtr pDev,
ret = (*pScreen->DisplayCursor) (pDev, pScreen, pCursor);
}
- if (pCursor != CursorCurrent)
+ if (pCursor != CursorCurrent[pDev->id])
{
CursorEventPtr e;
- CursorCurrent = pCursor;
+ CursorCurrent[pDev->id] = pCursor;
for (e = cursorEvents; e; e = e->next)
{
if ((e->eventMask & XFixesDisplayCursorNotifyMask) &&
@@ -170,7 +185,8 @@ CursorDisplayCursor (DeviceIntPtr pDev,
}
}
}
- Wrap (cs, pScreen, DisplayCursor, CursorDisplayCursor);
+ Wrap (cs, pScreen, DisplayCursor, backupProc);
+
return ret;
}
@@ -179,9 +195,11 @@ CursorCloseScreen (int index, ScreenPtr pScreen)
{
CursorScreenPtr cs = GetCursorScreen (pScreen);
Bool ret;
+ CloseScreenProcPtr close_proc;
+ DisplayCursorProcPtr display_proc;
- Unwrap (cs, pScreen, CloseScreen);
- Unwrap (cs, pScreen, DisplayCursor);
+ Unwrap (cs, pScreen, CloseScreen, close_proc);
+ Unwrap (cs, pScreen, DisplayCursor, display_proc);
deleteCursorHideCountsForScreen(pScreen);
ret = (*pScreen->CloseScreen) (index, pScreen);
xfree (cs);
@@ -196,6 +214,8 @@ XFixesSelectCursorInput (ClientPtr pClient,
CARD32 eventMask)
{
CursorEventPtr *prev, e;
+ pointer val;
+ int rc;
for (prev = &cursorEvents; (e = *prev); prev = &e->next)
{
@@ -228,7 +248,10 @@ XFixesSelectCursorInput (ClientPtr pClient,
* Add a resource hanging from the window to
* catch window destroy
*/
- if (!LookupIDByType(pWindow->drawable.id, CursorWindowType))
+ rc = dixLookupResourceByType( &val, pWindow->drawable.id,
+ CursorWindowType, serverClient,
+ DixGetAttrAccess);
+ if (rc != Success)
if (!AddResource (pWindow->drawable.id, CursorWindowType,
(pointer) pWindow))
{
@@ -361,7 +384,7 @@ ProcXFixesGetCursorImage (ClientPtr client)
int npixels, width, height, rc, x, y;
REQUEST_SIZE_MATCH(xXFixesGetCursorImageReq);
- pCursor = CursorCurrent;
+ pCursor = CursorCurrent[PickPointer(client)->id];
if (!pCursor)
return BadCursor;
rc = XaceHook(XACE_RESOURCE_ACCESS, client, pCursor->id, RT_CURSOR,
@@ -404,7 +427,7 @@ ProcXFixesGetCursorImage (ClientPtr client)
swapl (&rep->cursorSerial, n);
SwapLongs (image, npixels);
}
- (void) WriteToClient(client, sizeof (xXFixesGetCursorImageReply) +
+ WriteToClient(client, sizeof (xXFixesGetCursorImageReply) +
(npixels << 2), (char *) rep);
xfree (rep);
return client->noClientException;
@@ -457,7 +480,7 @@ ProcXFixesGetCursorName (ClientPtr client)
CursorPtr pCursor;
xXFixesGetCursorNameReply reply;
REQUEST(xXFixesGetCursorNameReq);
- char *str;
+ const char *str;
int len;
REQUEST_SIZE_MATCH(xXFixesGetCursorNameReq);
@@ -469,7 +492,7 @@ ProcXFixesGetCursorName (ClientPtr client)
len = strlen (str);
reply.type = X_Reply;
- reply.length = (len + 3) >> 2;
+ reply.length = bytes_to_int32(len);
reply.sequenceNumber = client->sequence;
reply.atom = pCursor->name;
reply.nbytes = len;
@@ -482,7 +505,7 @@ ProcXFixesGetCursorName (ClientPtr client)
swaps (&reply.nbytes, n);
}
WriteReplyToClient(client, sizeof(xXFixesGetCursorNameReply), &reply);
- (void)WriteToClient(client, len, str);
+ WriteToClient(client, len, str);
return(client->noClientException);
}
@@ -507,13 +530,13 @@ ProcXFixesGetCursorImageAndName (ClientPtr client)
CursorPtr pCursor;
CARD32 *image;
int npixels;
- char *name;
+ const char *name;
int nbytes, nbytesRound;
int width, height;
int rc, x, y;
REQUEST_SIZE_MATCH(xXFixesGetCursorImageAndNameReq);
- pCursor = CursorCurrent;
+ pCursor = CursorCurrent[PickPointer(client)->id];
if (!pCursor)
return BadCursor;
rc = XaceHook(XACE_RESOURCE_ACCESS, client, pCursor->id, RT_CURSOR,
@@ -526,7 +549,7 @@ ProcXFixesGetCursorImageAndName (ClientPtr client)
npixels = width * height;
name = pCursor->name ? NameForAtom (pCursor->name) : "";
nbytes = strlen (name);
- nbytesRound = (nbytes + 3) & ~3;
+ nbytesRound = pad_to_int32(nbytes);
rep = xalloc (sizeof (xXFixesGetCursorImageAndNameReply) +
npixels * sizeof (CARD32) + nbytesRound);
if (!rep)
@@ -534,7 +557,7 @@ ProcXFixesGetCursorImageAndName (ClientPtr client)
rep->type = X_Reply;
rep->sequenceNumber = client->sequence;
- rep->length = npixels + (nbytesRound >> 2);
+ rep->length = npixels + bytes_to_int32(nbytesRound);
rep->width = width;
rep->height = height;
rep->x = x;
@@ -564,7 +587,7 @@ ProcXFixesGetCursorImageAndName (ClientPtr client)
swaps (&rep->nbytes, n);
SwapLongs (image, npixels);
}
- (void) WriteToClient(client, sizeof (xXFixesGetCursorImageAndNameReply) +
+ WriteToClient(client, sizeof (xXFixesGetCursorImageAndNameReply) +
(npixels << 2) + nbytesRound, (char *) rep);
xfree (rep);
return client->noClientException;
@@ -893,7 +916,12 @@ ProcXFixesHideCursor (ClientPtr client)
ret = createCursorHideCount(client, pWin->drawable.pScreen);
if (ret == Success) {
- (void) CursorDisplayCursor(PickPointer(client), pWin->drawable.pScreen, CursorCurrent);
+ DeviceIntPtr dev;
+ for (dev = inputInfo.devices; dev; dev = dev->next)
+ {
+ if (IsMaster(dev) && IsPointerDevice(dev))
+ CursorDisplayCursor(dev, pWin->drawable.pScreen, CursorCurrent[dev->id]);
+ }
}
return ret;
@@ -985,9 +1013,14 @@ CursorFreeHideCount (pointer data, XID id)
{
CursorHideCountPtr pChc = (CursorHideCountPtr) data;
ScreenPtr pScreen = pChc->pScreen;
+ DeviceIntPtr dev;
deleteCursorHideCount(pChc, pChc->pScreen);
- (void) CursorDisplayCursor(inputInfo.pointer, pScreen, CursorCurrent);
+ for (dev = inputInfo.devices; dev; dev = dev->next)
+ {
+ if (IsMaster(dev) && IsPointerDevice(dev))
+ CursorDisplayCursor(dev, pScreen, CursorCurrent[dev->id]);
+ }
return 1;
}
@@ -1013,12 +1046,11 @@ static CursorPtr
createInvisibleCursor (void)
{
CursorPtr pCursor;
- static unsigned int *psrcbits, *pmaskbits;
+ unsigned char *psrcbits, *pmaskbits;
CursorMetricRec cm;
- int rc;
- psrcbits = (unsigned int *) xalloc(4);
- pmaskbits = (unsigned int *) xalloc(4);
+ psrcbits = (unsigned char *) xalloc(4);
+ pmaskbits = (unsigned char *) xalloc(4);
if (psrcbits == NULL || pmaskbits == NULL) {
return NULL;
}
@@ -1030,9 +1062,7 @@ createInvisibleCursor (void)
cm.xhot = 0;
cm.yhot = 0;
- rc = AllocARGBCursor(
- (unsigned char *)psrcbits,
- (unsigned char *)pmaskbits,
+ AllocARGBCursor(psrcbits, pmaskbits,
NULL, &cm,
0, 0, 0,
0, 0, 0,
@@ -1047,7 +1077,7 @@ XFixesCursorInit (void)
int i;
if (party_like_its_1989)
- CursorVisible = TRUE;
+ CursorVisible = EnableCursor;
for (i = 0; i < screenInfo.numScreens; i++)
{