aboutsummaryrefslogtreecommitdiff
path: root/xorg-server/hw/xquartz/xpr/xprCursor.c
diff options
context:
space:
mode:
Diffstat (limited to 'xorg-server/hw/xquartz/xpr/xprCursor.c')
-rw-r--r--xorg-server/hw/xquartz/xpr/xprCursor.c101
1 files changed, 44 insertions, 57 deletions
diff --git a/xorg-server/hw/xquartz/xpr/xprCursor.c b/xorg-server/hw/xquartz/xpr/xprCursor.c
index 2b31865a5..b0afa8c0e 100644
--- a/xorg-server/hw/xquartz/xpr/xprCursor.c
+++ b/xorg-server/hw/xquartz/xpr/xprCursor.c
@@ -51,12 +51,13 @@
#include "x-hash.h"
typedef struct {
- int cursorVisible;
- QueryBestSizeProcPtr QueryBestSize;
- miPointerSpriteFuncPtr spriteFuncs;
+ int cursorVisible;
+ QueryBestSizeProcPtr QueryBestSize;
+ miPointerSpriteFuncPtr spriteFuncs;
} QuartzCursorScreenRec, *QuartzCursorScreenPtr;
static DevPrivateKeyRec darwinCursorScreenKeyRec;
+
#define darwinCursorScreenKey (&darwinCursorScreenKeyRec)
#define CURSOR_PRIV(pScreen) ((QuartzCursorScreenPtr) \
@@ -85,22 +86,22 @@ load_cursor(CursorPtr src, int screen)
hot_y = src->bits->yhot;
#ifdef ARGB_CURSOR
- if (src->bits->argb != NULL)
- {
+ if (src->bits->argb != NULL) {
#if BITMAP_BIT_ORDER == MSBFirst
- rowbytes = src->bits->width * sizeof (CARD32);
+ rowbytes = src->bits->width * sizeof(CARD32);
data = (uint32_t *) src->bits->argb;
#else
- const uint32_t *be_data=(uint32_t *) src->bits->argb;
+ const uint32_t *be_data = (uint32_t *) src->bits->argb;
unsigned i;
- rowbytes = src->bits->width * sizeof (CARD32);
+
+ rowbytes = src->bits->width * sizeof(CARD32);
data = malloc(rowbytes * src->bits->height);
free_data = TRUE;
- if(!data) {
+ if (!data) {
FatalError("Failed to allocate memory in %s\n", __func__);
}
- for(i=0;i<(src->bits->width*src->bits->height);i++)
- data[i]=ntohl(be_data[i]);
+ for (i = 0; i < (src->bits->width * src->bits->height); i++)
+ data[i] = ntohl(be_data[i]);
#endif
}
else
@@ -123,42 +124,43 @@ load_cursor(CursorPtr src, int screen)
rowbytes = ((src->bits->width * 4) + 31) & ~31;
data = malloc(rowbytes * src->bits->height);
free_data = TRUE;
- if(!data) {
+ if (!data) {
FatalError("Failed to allocate memory in %s\n", __func__);
}
-
- if (!src->bits->emptyMask)
- {
+
+ if (!src->bits->emptyMask) {
ycount = src->bits->height;
- srow = src->bits->source; mrow = src->bits->mask;
+ srow = src->bits->source;
+ mrow = src->bits->mask;
drow = data;
- while (ycount-- > 0)
- {
+ while (ycount-- > 0) {
xcount = bits_to_bytes(src->bits->width);
- sptr = srow; mptr = mrow;
+ sptr = srow;
+ mptr = mrow;
dptr = drow;
- while (xcount-- > 0)
- {
+ while (xcount-- > 0) {
uint8_t s, m;
int i;
- s = *sptr++; m = *mptr++;
- for (i = 0; i < 8; i++)
- {
+ s = *sptr++;
+ m = *mptr++;
+ for (i = 0; i < 8; i++) {
#if BITMAP_BIT_ORDER == MSBFirst
if (m & 128)
*dptr++ = (s & 128) ? fg_color : bg_color;
else
*dptr++ = 0;
- s <<= 1; m <<= 1;
+ s <<= 1;
+ m <<= 1;
#else
if (m & 1)
*dptr++ = (s & 1) ? fg_color : bg_color;
else
*dptr++ = 0;
- s >>= 1; m >>= 1;
+ s >>= 1;
+ m >>= 1;
#endif
}
}
@@ -168,19 +170,17 @@ load_cursor(CursorPtr src, int screen)
drow = (uint32_t *) ((char *) drow + rowbytes);
}
}
- else
- {
+ else {
memset(data, 0, src->bits->height * rowbytes);
}
}
err = xp_set_cursor(width, height, hot_x, hot_y, data, rowbytes);
- if(free_data)
+ if (free_data)
free(data);
return err == Success;
}
-
/*
===========================================================================
@@ -196,7 +196,7 @@ load_cursor(CursorPtr src, int screen)
static Bool
QuartzRealizeCursor(DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr pCursor)
{
- if(pCursor == NULL || pCursor->bits == NULL)
+ if (pCursor == NULL || pCursor->bits == NULL)
return FALSE;
/* FIXME: cache ARGB8888 representation? */
@@ -204,7 +204,6 @@ QuartzRealizeCursor(DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr pCursor)
return TRUE;
}
-
/*
* QuartzUnrealizeCursor
* Free the storage space associated with a realized cursor.
@@ -215,33 +214,29 @@ QuartzUnrealizeCursor(DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr pCursor)
return TRUE;
}
-
/*
* QuartzSetCursor
* Set the cursor sprite and position.
*/
static void
-QuartzSetCursor(DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr pCursor, int x, int y)
+QuartzSetCursor(DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr pCursor, int x,
+ int y)
{
QuartzCursorScreenPtr ScreenPriv = CURSOR_PRIV(pScreen);
if (!XQuartzServerVisible)
return;
- if (pCursor == NULL)
- {
- if (ScreenPriv->cursorVisible)
- {
+ if (pCursor == NULL) {
+ if (ScreenPriv->cursorVisible) {
xp_hide_cursor();
ScreenPriv->cursorVisible = FALSE;
}
}
- else
- {
+ else {
load_cursor(pCursor, pScreen->myNum);
- if (!ScreenPriv->cursorVisible)
- {
+ if (!ScreenPriv->cursorVisible) {
xp_show_cursor();
ScreenPriv->cursorVisible = TRUE;
}
@@ -274,7 +269,6 @@ QuartzCursorOffScreen(ScreenPtr *pScreen, int *x, int *y)
return FALSE;
}
-
/*
* QuartzCrossScreen
*/
@@ -284,7 +278,6 @@ QuartzCrossScreen(ScreenPtr pScreen, Bool entering)
return;
}
-
/*
* QuartzWarpCursor
* Change the cursor position without generating an event or motion history.
@@ -294,8 +287,7 @@ QuartzCrossScreen(ScreenPtr pScreen, Bool entering)
static void
QuartzWarpCursor(DeviceIntPtr pDev, ScreenPtr pScreen, int x, int y)
{
- if (XQuartzServerVisible)
- {
+ if (XQuartzServerVisible) {
int sx, sy;
sx = pScreen->x + darwinMainScreenX;
@@ -308,7 +300,6 @@ QuartzWarpCursor(DeviceIntPtr pDev, ScreenPtr pScreen, int x, int y)
miPointerUpdateSprite(pDev);
}
-
static miPointerScreenFuncRec quartzScreenFuncsRec = {
QuartzCursorOffScreen,
QuartzCrossScreen,
@@ -317,7 +308,6 @@ static miPointerScreenFuncRec quartzScreenFuncsRec = {
NULL
};
-
/*
===========================================================================
@@ -336,15 +326,13 @@ QuartzCursorQueryBestSize(int class, unsigned short *width,
{
QuartzCursorScreenPtr ScreenPriv = CURSOR_PRIV(pScreen);
- if (class == CursorShape)
- {
+ if (class == CursorShape) {
/* FIXME: query window server? */
*width = 32;
*height = 32;
}
- else
- {
- (*ScreenPriv->QueryBestSize)(class, width, height, pScreen);
+ else {
+ (*ScreenPriv->QueryBestSize) (class, width, height, pScreen);
}
}
@@ -363,7 +351,7 @@ QuartzInitCursor(ScreenPtr pScreen)
return FALSE;
if (!dixRegisterPrivateKey(&darwinCursorScreenKeyRec, PRIVATE_SCREEN, 0))
- return FALSE;
+ return FALSE;
ScreenPriv = calloc(1, sizeof(QuartzCursorScreenRec));
if (ScreenPriv == NULL)
@@ -384,7 +372,7 @@ QuartzInitCursor(ScreenPtr pScreen)
PointPriv->spriteFuncs->UnrealizeCursor = QuartzUnrealizeCursor;
PointPriv->spriteFuncs->SetCursor = QuartzSetCursor;
PointPriv->spriteFuncs->MoveCursor = QuartzMoveCursor;
-
+
ScreenPriv->cursorVisible = TRUE;
return TRUE;
}
@@ -398,7 +386,6 @@ QuartzSuspendXCursor(ScreenPtr pScreen)
{
}
-
/*
* QuartzResumeXCursor
* X server is showing. Restore the X cursor.
@@ -410,7 +397,7 @@ QuartzResumeXCursor(ScreenPtr pScreen)
CursorPtr pCursor;
/* TODO: Tablet? */
-
+
pWin = GetSpriteWindow(darwinPointer);
if (pWin->drawable.pScreen != pScreen)
return;