[PATCH] xfixes: Remove the invisible cursor sprite, using NullCursor instead.

Oliver McFadden oliver.mcfadden at nokia.com
Mon May 24 19:45:57 PDT 2010


Hi Jamey,

I'll check this today on my hardware; I think there I might have had a
bug in the logic of my v2 patch. I'll let you know whether this one
works.

I don't care too much about Save/Restore during server reset or other
"special" cases, but during routine use.

I was testing by enabling SPRITE_DEBUG in misprite.c and looking at the
X log file. If the patch is working correctly, I should be able to drag
all over the touchscreen and not have the log fill up with SPRITE_DEBUG
messages.

P.S. Thanks for picking this up; I've been busy at work with some
upgrades.

-- Oliver.

On Mon, 2010-05-24 at 20:45 +0200, ext Jamey Sharp wrote:
> Oliver McFadden reports that the invisible cursor sprite caused damage
> events and thus unnecessary redrawing, so removing it improves
> performance when using software cursor sprites, especially on those
> devices where you do not want a visible cursor: touchscreen tablets,
> embedded devices, etc.
> 
> For the xfree86 DDX, if hardware cursors are used, the driver is
> required to provide a HideCursor function, which will be called instead
> of trying to set a null cursor. I think software cursors are already
> safe. The other DDXes also look safe.
> 
> As far as I can tell, there's no reason to realize a null cursor. I
> think everything that handles null cursors doesn't rely on any setup in
> RealizeCursor, and treats them as empty cursors.
> 
> Xnest assumes that if a cursor is created, it will be realized before it
> is freed, which didn't happen if the invisible cursor was never used in
> a server generation. So this fixes a segfault in Xnest as well.
> 
> Signed-off-by: Jamey Sharp <jamey at minilop.net>
> Cc: Oliver McFadden <oliver.mcfadden at nokia.com>
> ---
> I think this is working as intended. Oliver, those Save/Restore
> function calls you're seeing, are they perhaps only at server reset, and
> only after the first generation? How are you testing this?
> 
>  xfixes/cursor.c |   39 +--------------------------------------
>  1 files changed, 1 insertions(+), 38 deletions(-)
> 
> diff --git a/xfixes/cursor.c b/xfixes/cursor.c
> index 52bdb27..d3a207d 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;
> @@ -148,8 +147,7 @@ CursorDisplayCursor (DeviceIntPtr pDev,
>  	CursorVisible = EnableCursor;
>  
>      if (cs->pCursorHideCounts != NULL || !CursorVisible) {
> -        ret = ((*pScreen->RealizeCursor)(pDev, pScreen, pInvisibleCursor) &&
> -	       (*pScreen->DisplayCursor) (pDev, pScreen, pInvisibleCursor));
> +	ret = (*pScreen->DisplayCursor) (pDev, pScreen, NullCursor);
>      } else {
>  	ret = (*pScreen->DisplayCursor) (pDev, pScreen, pCursor);
>      }
> @@ -1031,37 +1029,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)
>  {
> @@ -1090,10 +1057,6 @@ XFixesCursorInit (void)
>      CursorWindowType = CreateNewResourceType(CursorFreeWindow,
>  					     "XFixesCursorWindow");
>  
> -    pInvisibleCursor = createInvisibleCursor();
> -    if (pInvisibleCursor == NULL)
> -	return BadAlloc;
> -
>      return CursorClientType && CursorHideCountType && CursorWindowType;
>  }
>  




More information about the xorg-devel mailing list