Re: [AD] show_os_cursor

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


> Speaking of hardware cursor clarifications - my local copy of Allegro
> has the attached additional function.

Sorry I didn't respond to this earlier. Anyway, I think the (at the time 
proposed) system_cursor API originally worked like that: you call a 
function to display the OS system cursor and it tells you if it succeeded 
or not and if it didn't you show your own.
I changed it because someone (I thought it was you, but I could easily 
remember wrongly) didn't like it and wanted it to use the show_mouse() 
API.

> The latter got annoying to me, after using the HW cursor a lot. Not only
> is it more (and un-intuitive) code,

I agree - obviously.
Please note that Allegro historically made a distinction between hardware 
and software cursors before it could use the native system cursor.
I think it would be best to keep the nomenclature distinct to make sure 
we're not talking about different things when talking about `hardware 
cursors' or reading the documentation: a hardware or software cursor, for 
Allegro, is a cursor made from a custom bitmap selected by the user of the 
library. A system cursor is a cursor Allegro (or the library user) has no 
control over: it is set by the OS (ok, so the user can change it there - 
but you get the point). The power of hardware cursors is in the fact that 
they share with system cursors that Allegro doesn't need to do teh drawing 
or buffering for them: the OS takes care of that.

> I'm even wondering if we shouldn't completely drop the software 
> cursor from 4.3.x - or at least find a way to draw it from the main
> thread. 

We can't drop it. DirectX doesn't support drawing a mouse pointer. We get 
around this in Windowed mode where we can just use the normal Windows API 
to draw it, but in fullscreen mode we can't do that. DGA2 also doesn't do 
mouse cursors.

> - I only tested it in X11, not sure if
> mouse_driver->select_system_cursor works the same in windows and OSX

It does (and if it doesn't it's a bug).

> - Allow MOUSE_CURSOR_ALLEGRO (to set a custom os cursor)
> 
> - Allow MOUSE_CURSOR_NONE (to hide it again)

Both make sense.

About the problem your code aims to solve though, you should just be able 
to call

enable_hardware_cursor();
set_mouse_cursor_bitmap(MOUSE_CURSOR_ARROW, custom_bitmap);
select_mouse_cursor(MOUSE_CURSOR_ARROW);
show_mouse(screen);

Allegro should now use the default system MOUSE_CURSOR_ARROW and fall back 
to your own custom_bitmap drawn in software if it can't do that. No need 
to check if you will get a system cursor after calling show_mouse() 
because you actually don't have to care except for calling 
scare_mouse_area() which should be safe to call because it does nothing if 
the OS draws the cursor.

Evert




Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/