[PATCH] mi: removed the invisible cursor sprite; use NullCursor instead.
Oliver McFadden
oliver.mcfadden at nokia.com
Sun May 16 21:50:25 PDT 2010
Previously the cursor code would be called even with a "hidden" cursor.
This was because the X server used an invisible 1x1 cursor sprite,
rather than a NULL cursor.
This will help performance when XDefineCursor() is never called, and
also when the cursor is hidden via XFixesHideCursor() as there are no
damage events generated via the MI functions.
Note that this only applies for software cursors.
Signed-off-by: Oliver McFadden <oliver.mcfadden at nokia.com>
---
mi/mipointer.c | 16 ++++++++++++----
xfixes/cursor.c | 40 ++--------------------------------------
2 files changed, 14 insertions(+), 42 deletions(-)
diff --git a/mi/mipointer.c b/mi/mipointer.c
index 296c57f..fb52419 100644
--- a/mi/mipointer.c
+++ b/mi/mipointer.c
@@ -164,8 +164,12 @@ miPointerCloseScreen (int index, ScreenPtr pScreen)
static Bool
miPointerRealizeCursor (DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr pCursor)
{
- SetupScreen(pScreen);
- return (*pScreenPriv->spriteFuncs->RealizeCursor) (pDev, pScreen, pCursor);
+ if (pCursor)
+ {
+ SetupScreen(pScreen);
+ return (*pScreenPriv->spriteFuncs->RealizeCursor) (pDev, pScreen, pCursor);
+ }
+ return TRUE;
}
static Bool
@@ -173,8 +177,12 @@ miPointerUnrealizeCursor (DeviceIntPtr pDev,
ScreenPtr pScreen,
CursorPtr pCursor)
{
- SetupScreen(pScreen);
- return (*pScreenPriv->spriteFuncs->UnrealizeCursor) (pDev, pScreen, pCursor);
+ if (pCursor)
+ {
+ SetupScreen(pScreen);
+ return (*pScreenPriv->spriteFuncs->UnrealizeCursor) (pDev, pScreen, pCursor);
+ }
+ return TRUE;
}
static Bool
diff --git a/xfixes/cursor.c b/xfixes/cursor.c
index d5f8b29..083e54f 100644
--- a/xfixes/cursor.c
+++ b/xfixes/cursor.c
@@ -58,7 +58,6 @@ static RESTYPE CursorClientType;
static RESTYPE CursorHideCountType;
static RESTYPE CursorWindowType;
static CursorPtr CursorCurrent[MAXDEVICES];
-static CursorPtr pInvisibleCursor = NULL;
static int CursorScreenPrivateKeyIndex;
static DevPrivateKey CursorScreenPrivateKey = &CursorScreenPrivateKeyIndex;
@@ -151,8 +150,8 @@ CursorDisplayCursor (DeviceIntPtr pDev,
CursorVisible = EnableCursor;
if (cs->pCursorHideCounts != NULL || !CursorVisible) {
- ret = ((*pScreen->RealizeCursor)(pDev, pScreen, pInvisibleCursor) &&
- (*pScreen->DisplayCursor) (pDev, pScreen, pInvisibleCursor));
+ ret = ((*pScreen->RealizeCursor)(pDev, pScreen, NullCursor) &&
+ (*pScreen->DisplayCursor) (pDev, pScreen, NullCursor));
} else {
ret = (*pScreen->DisplayCursor) (pDev, pScreen, pCursor);
}
@@ -1036,37 +1035,6 @@ CursorFreeWindow (pointer data, XID id)
return 1;
}
-static CursorPtr
-createInvisibleCursor (void)
-{
- CursorPtr pCursor;
- unsigned char *psrcbits, *pmaskbits;
- CursorMetricRec cm;
-
- psrcbits = (unsigned char *) calloc(4, 1);
- pmaskbits = (unsigned char *) calloc(4, 1);
- if (psrcbits == NULL || pmaskbits == NULL) {
- return NULL;
- }
-
- cm.width = 1;
- cm.height = 1;
- cm.xhot = 0;
- cm.yhot = 0;
-
- if (AllocARGBCursor(psrcbits, pmaskbits,
- NULL, &cm,
- 0, 0, 0,
- 0, 0, 0,
- &pCursor, serverClient, (XID)0) != Success)
- return NullCursor;
-
- if (!AddResource(FakeClientID(0), RT_CURSOR, (pointer) pCursor))
- return NullCursor;
-
- return pCursor;
-}
-
Bool
XFixesCursorInit (void)
{
@@ -1095,10 +1063,6 @@ XFixesCursorInit (void)
CursorWindowType = CreateNewResourceType(CursorFreeWindow,
"XFixesCursorWindow");
- pInvisibleCursor = createInvisibleCursor();
- if (pInvisibleCursor == NULL)
- return BadAlloc;
-
return CursorClientType && CursorHideCountType && CursorWindowType;
}
--
1.6.1
More information about the xorg-devel
mailing list