[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Fast mouse pointer



On Wednesday 19 February 2003 09:48, Francesco Orsenigo wrote:
> SDL_CreateCursor() is unfit to do this, another different function will be
> needed: either this function does not yet exists or is not documented.

That mail was a month ago, in case it's still relevant, here's how to do it 
(yeah, some real code on this list):

- check for Xcursor during configuration, e.g. in configure.ac
xcursor=0
AC_CHECK_LIB(Xcursor, XcursorLibraryLoadCursor,
    [AC_CHECK_HEADER(X11/Xcursor/Xcursor.h, [xcursor=1],
        [AC_MSG_WARN(*** Cannot find X11/Xcursor/Xcursor.h header)],
        [#include <X11/Xlib.h>])],
    [AC_MSG_WARN(*** Cannot find Xcursor library )],

- setup variables for Makefile.am accordingly, or whatever framework is used
if test "x$xcursor" = "x1"; then
    XCURSOR_LDFLAGS="-L /usr/X11R6/lib"
    LIB_XCURSOR="-lXcursor"
    AC_SUBST(XCURSOR_LDFLAGS)
    AC_SUBST(LIB_XCURSOR)
    AC_DEFINE_UNQUOTED(HAVE_XCURSOR, 1, [Xcursor support])
fi

- include the Xcursor library, and SDL's window manager stuff (which is 
somewhat undocumented...)
#ifdef HAVE_XCURSOR
#include <X11/Xlib.h>
#include <X11/Xcursor/Xcursor.h>
#include <SDL/SDL_syswm.h>
#endif

- Load a cursor theme of your choice
#ifdef HAVE_XCURSOR
Cursor cursor;
SDL_SysWMinfo info;
int ret;
...
info.version.major = 1;
ret = SDL_GetWMInfo(&info);
if(ret == 1)
{
info.info.x11.lock_func();
cursor = XcursorLibraryLoadCursor(info.info.x11.display, "redglass");
XDefineCursor(info.info.x11.display, info.info.x11.window, cursor);
info.info.x11.unlock_func();
}
#endif

Some notes:
Either the game must provide an own cursor, or a foreign one must be chosen 
according to freedesktop.org "standards".
(The issue with fonts is similar...)

A stock X11 pointer will be used in case Xcursor support has been compiled in 
but the Xserver doesn't provide this feature.

SDL 2.0 will appear one day, the first CVS checkins happened a few days ago. 
It should be possible to add this stuff without even changing the API for 
1.x, but things will be more difficult when it comes to animated cursors.
I'll try to write a patch for 1.2.x for the time being, if it's considered 
worthy...

Josef

-- 
Play for fun, win for freedom.