[PATCH 1/2] render/input: set anicursor hooks to control rendering

Peter Hutterer peter.hutterer at who-t.net
Tue Aug 25 18:16:46 PDT 2009


On Tue, Aug 25, 2009 at 05:03:15PM +0300, Tiago Vignatti wrote:
> Introduces AnimCursorStart and AnimCursorStop to put animated cursors out of
> the rendering. This is useful on invisible cursor environments like
> touchscreen user interfaces.
> 
> Signed-off-by: Tiago Vignatti <tiago.vignatti at nokia.com>
> ---
>  render/animcur.c    |   43 +++++++++++++++++++++++++++++++++++++++++++
>  render/picturestr.h |    6 ++++++
>  2 files changed, 49 insertions(+), 0 deletions(-)
> 
> diff --git a/render/animcur.c b/render/animcur.c
> index e7bc4e5..2590f73 100644
> --- a/render/animcur.c
> +++ b/render/animcur.c
> @@ -439,3 +439,46 @@ AnimCursorCreate (CursorPtr *cursors, CARD32 *deltas, int ncursor, CursorPtr *pp
>      *ppCursor = pCursor;
>      return Success;
>  }
> +
> +void
> +AnimCursorStop(ScreenPtr pScreen)
> +{
> +    AnimCurScreenPtr    as = GetAnimCurScreen(pScreen);
> +
> +    Unwrap(as, pScreen, CloseScreen);
> +    Unwrap(as, pScreen, BlockHandler);
> +    Unwrap(as, pScreen, CursorLimits);
> +    Unwrap(as, pScreen, DisplayCursor);
> +    Unwrap(as, pScreen, SetCursorPosition);
> +    Unwrap(as, pScreen, RealizeCursor);
> +    Unwrap(as, pScreen, UnrealizeCursor);
> +    Unwrap(as, pScreen, RecolorCursor);
> +    SetAnimCurScreen(pScreen,0);
> +    xfree(as);
> +}
> +
> +void
> +AnimCursorStart(ScreenPtr pScreen)
> +{
> +    AnimCurScreenPtr    as;
> +
> +    as = (AnimCurScreenPtr) xalloc (sizeof (AnimCurScreenRec));
> +    if (!as)
> +        FatalError("AnimCursor: failed to allocate memory\n");
> +
> +    /* AnimCursorStart can be stacked without problems. For this we do a
> +     * comparision on BlockHandler function, guaranteeing that such function
> +     * will not point to ifself. Address function comparision is not the best
> +     * way, but eh... */

any code that is "... not the best way, but eh..." usually guarantees that
sometime, someone will spend a significant portion of time hating you. at
least mark spots with a FIXME or XXX so they are immediately obvious.

> +    if (pScreen->BlockHandler != AnimCurScreenBlockHandler) {
> +        Wrap(as, pScreen, CloseScreen, AnimCurCloseScreen);
> +        Wrap(as, pScreen, BlockHandler, AnimCurScreenBlockHandler);
> +        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);
> +        SetAnimCurScreen(pScreen,as);
> +    }
> +}

This seems like overkill. The issue at hand are the Block- and
WakeupHandlers, the rest shouldn't have much impact. I see two simpler
solutions:
- just removing the block handler from the stack so it doesn't get called if
  the cursor is invisible.
- using Start/Stop to set a flag to skip the loop inside the block handler
  and basically make the block handler a noop. I think this would be much
  more readable, debuggable and has the same effect.

In both cases, the block handler would stop calling AdjustWaitForDelay and
thus not cause any explicit wakeups.

> diff --git a/render/picturestr.h b/render/picturestr.h
> index 6a1cc06..01d4100 100644
> --- a/render/picturestr.h
> +++ b/render/picturestr.h
> @@ -623,6 +623,12 @@ extern _X_EXPORT void RenderExtensionInit (void);
>  extern _X_EXPORT Bool
>  AnimCurInit (ScreenPtr pScreen);
>  
> +extern _X_EXPORT void
> +AnimCursorStart (ScreenPtr pScreen);
> +
> +extern _X_EXPORT void
> +AnimCursorStop (ScreenPtr pScreen);
> +

no _X_EXPORTS please. Init and CursorCreate shouldn't be _X_EXPORT either,
while we're at it.

>  extern _X_EXPORT int
>  AnimCursorCreate (CursorPtr *cursors, CARD32 *deltas, int ncursor, CursorPtr *ppCursor, ClientPtr client, XID cid);
 
Cheers,
  Peter


More information about the xorg-devel mailing list