problem with backwards compatibility hack in XCursors

Lubos Lunak l.lunak@suse.cz
Tue, 9 Mar 2004 11:58:11 +0100


 Hello,

 while creating all XCursors hash symlinks for cursors used by KDE I noticed 
that this mechanism sometimes fails, seemingly at random.

 While investigating the problem I realized that the mechanism watches for new 
bitmaps being created, being filled with data, and being used for cursor 
creation (if I understand the code correctly). The problem is that it 
remembers only last 8 bitmaps that look like possible candidates for cursor 
bitmaps, and the comment next to NUM_BITMAPS even says that 2 is likely 
sufficient :-/ . Unfortunately this is not guaranteed to be enough for Qt, as 
it creates the internal representations of many things like QCursor only 
on-demand.

 Specifically, I can reproduce this problem while doing DND in Konqueror 
(occassionally) or in KNode (very often) [1]. Qt first creates pixmaps for 
DND cursors, then creates QCursors for the various DND actions, and only when 
they're really needed, the X representation of the cursor is created. By this 
time the pixmaps may be already thrown out of the Xcursors cache. You may 
very easily check this by creating 10 bitmaps in a row and then creating 10 
cursors from them.

 I'll patch Qt to avoid on-demand creation for QCursor where possible, but 
with the API it cannot be guaranteed that the cursor creation will shortly 
follow creation of the bitmaps (the developer may pass their own bitmaps to 
QCursor). I understand that this code in Xcursors is just a hack, and that 
the proper solution would be Qt and Qt apps always using Xcursor directly, 
but this will need some time (e.g. the cursor names are currently a mess).

 So I'm wondering if there's possibly some way how to improve the chances that 
the backwards compatibility hack will find the bitmaps for cursor creation, 
other than making QCursor ctor docs say 'create the bitmap right before 
passing it to QCursor'.

 Thanks

[1] In case somebody want to try it with KDE, the hashes for DND cursors are:
4498f0e0c1937ffe01fd06f973665830 -> move cursor
6407b0e94181790501fd1e167b474872 -> copy cursor
640fb0e74195791501fd1ed57b41487f -> link cursor
03b6e0fcb3499374a867c041f52298f0 -> forbidden cursor

-- 
Lubos Lunak
KDE developer
---------------------------------------------------------------------
SuSE CR, s.r.o.  e-mail: l.lunak@suse.cz , l.lunak@kde.org
Drahobejlova 27  tel: +420 2 9654 2373
190 00 Praha 9   fax: +420 2 9654 2374
Czech Republic   http://www.suse.cz/