[RFC] [PATCH 0/3] libwayland-cursor

Kristian Høgsberg hoegsberg at gmail.com
Wed May 23 07:25:13 PDT 2012


On Wed, May 23, 2012 at 04:19:34PM +0300, Ander Conselvan de Oliveira wrote:
> On 05/22/2012 06:25 PM, Kristian Høgsberg wrote:
> >On Tue, May 22, 2012 at 03:39:39PM +0300, Ander Conselvan de Oliveira wrote:
> >>Hi,
> >>
> >>In order to get rid of the X11 dependency that libXcursor brings,
> >>Kristian suggested that a libwayland-cursor be created. This library
> >>handles the X cursor theme format, loading the image content straight
> >>into an shm pool so that the users need just one function call for
> >>getting a buffer for a cursor image.
> >>
> >>The code for handling the cursor theme is just a stripped down version
> >>of libXcursor, that is contained on the files cursor/xcursor.[ch].
> >>
> >>The library API is quite similar to the cursor code in libtoytoolkit.
> >
> >Looks great Ander.  It's a good start, and I want to start using it so
> >I've committed it all now.  There are a couple of things that we need
> >to tweak thoguh: I'm not sure we can do enum wl_cursor_type, I think
> >we should just stick to only loading by name.
> 
> My thinking when I added enum wl_cursor_type was to make lookup
> faster, but I guess we can just cache the struct wl_cursor for each
> type on toytoolkit.

Yeah, I agree, I just don't think there's a nice list of "all cursors"
that we can put in the header file.  If you look at X11/cursorfont.h,
there's a lot of cursors there that we should support and then there's
a cursor like "grabbing" which libXcursor will load, but that's not in
that list.  So I think we should just stick to loading cursors by name
and leave the convenient enum to toolkits.

> >Also, in the shm resize code we should use mremap.
> 
> I sent a patch for that. I looked for a way to do a remap but for
> some reason I didn't see mremap existed.

It's Linux specific, so it's a little harder to find.
 
> >I'd also like to see the wl_cursor_theme
> >object cache a bit more of the theme and patch lookup libXcursor does
> >over and over again.
> 
> Could you be more specific on what to cache on wl_cursor_theme?

All of the work we do in XcursorScanTheme was what I had in mind.  If
we load cursors one by one by the filename, we would need to build up
some index up front, mapping cursor name to filename.  If we go for
the "load everything" approach below, we'll have to cut that code up
anyway and traverse the cursor theme and inherited themes and just
load everything.

> >Finally, I was wondering if we should just scan
> >the cursor dir and load all cursors into a shm object instead of
> >preloading just that small subset.
> 
> I'm working on that. This actually makes it easier to avoid the
> unnecessary lookups. My idea is to make XcursorScanTheme open all
> the cursors and callback the wl_cursor_theme with all the
> XcursorImages objects. This adds an extra loop between the parts,
> but I don't want to fiddle too much with the Xcursor code.

Yeah, a callback could work... though I think we do need to get our
hands a little dirty with the Xcursor code, since we need to add a
directory walking loop to load all images in a directory.

Kristian


More information about the wayland-devel mailing list