Cursor confusion with themes



Hi,
  I've been trying to follow the startup of some gnome apps to
try and see if anything can be done to speed them up and am
trying to understand how cursors work and see if there is a way
to improve it.  Apologies for the long message, but I've been following
the cursor code through and am a bit confused.

If I ltrace the existing gnome-terminal process when I start
a second terminal I see about 110 sys_open's for files that appear to be
cursor related, most of them searching the themes to find left_ptr and
xterm cursors; given that this is the second terminal for the same
process I'd hope there is a way of optimsing this.

Gnome-terminal uses the vte terminal widget; during it's realise
it calls gdk_cursor_new_for_display for GDK_LEFT_PTR and GDK_XTERM.

gdk_cursor_new_for_display calls XCreateFontCursor that I'd assumed
was simple, but actually it calls back up into libXcursor into
XcursorTryShapeCursor

XcursorTryShapeCursor uses XcursorShapeLoadImages to search for
a file, loads it and then frees it.

There is no caching anywhere in this chain, and Xcursor's theme
searching is pretty simple - adding some to vte (checking for
it being on the same display) seems fairly simple but it would
seem better to add it somewhere to be shared, so some questions:

  1) Does the icon cache created by gtk-update-icon-cache contain
the cursors so would it help if Xcursor could use it? (But the
libXcursor stuff sohuld be more generic I assume?)

  2) Is there some generic theme code that Xcursor could pick up to
be more efficient? For example at the moment I'm using the Ubuntu
'Human' theme; it inherits from Tangerine and Gnome; Tangerine also
inherits from Gnome and the search looks at Gnome twice due to the
double inheritance.

  3) I thought perhaps the easiest place to add some caching would
be to gdk_cursor_new_for_display; I thought gdk already had a way
of knowing about all it's cursors since it updates them on a theme
change - but looking at the code I'm not sure; 
    gdk_x11_display_set_cursor_theme walks the xid_ht list
and from my reading updates the cursor on each window - but how
does xid_ht work? What about where a cursor isn't currently bound
to a window (for example in the vt case where the left cursor
is only used sometimes) - will it miss some cursors on a theme change?

I suppose I have a generic worry that XCreateFontCursor which was
probably very cheap in the pre-theme days is now very expensive;
when it was cheap it made no sense for things like vte to cache
anything themselves. I don't think anyone would expect requests
for the bultin cursors to be expensive.

(This is all on 2.24.1 in Ubuntu Intrepid).

Thanks for any advice,

Dave
-- 
 -----Open up your eyes, open up your mind, open up your code -------   
/ Dr. David Alan Gilbert    | Running GNU/Linux on Alpha,68K| Happy  \ 
\ gro.gilbert @ treblig.org | MIPS,x86,ARM,SPARC,PPC & HPPA | In Hex /
 \ _________________________|_____ http://www.treblig.org   |_______/


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