Re: [AD] Using system mouse cursor

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


Evert Glebbeek wrote:
Ok, revised patch attached (sans documentation).

Looks mostly okay. Though here are a few issues:

+   AL_METHOD(int,  select_os_cursor, (AL_CONST int cursor));
 } MOUSE_DRIVER;

Granted this is in the driver struct, and not API exposed, but do you plan on changing os to hardware here?

+static int use_os_cursor = FALSE;      /* Use native cursor? */

Again, it is internal, but I think we should maintain proper naming convention. IMO, this should be hardware, not os.

+static BITMAP *create_mouse_pointer(char data[][DEFAULT_SPRITE_W])

It might be safer to pass (char *data, int w), so you're not restricting the data to be a specific width.

+void set_mouse_cursor(AL_CONST int cursor, BITMAP *sprite)
+{
+   ASSERT(cursor < NUM_MOUSE_CURSORS);

You might want to change this to:
ASSERT((cursor < NUM_CURSORS) && (cursor >= 0))
for added safety.

+void select_mouse_cursor(AL_CONST int cursor)
+{
+   ASSERT(cursor < NUM_MOUSE_CURSORS);

Same here.

+   use_os_cursor = 0;
+   if (!cursors[cursor] || cursor != MOUSE_CURSOR_ALLEGRO) {
+      /* Use default system cursor */
+      if (mouse_driver && mouse_driver->select_os_cursor) {
+         use_os_cursor = mouse_driver->select_os_cursor(cursor);
+         if (use_os_cursor)
+            gfx_capabilities |= GFX_HW_CURSOR;
+      }
+   }

This also seems to indicate that you can't use custom hardware cursors. I'd like to be able to set MOUSE_CURSOR_ARROW/BUSY/etc to custom pointers so I can just select and use them as if they were the defaults (like for the GUI, and so I don't need to keep calling set_mouse_cursor to change it).

 void show_mouse(BITMAP *bmp)
 {
-   if (!mouse_driver)
+   if (!mouse_driver || use_os_cursor)
       return;

This means show_mouse won't have an effect if the hardware cursor is being used, right? IMO, showing the mouse on a memory bitmap should behave as if there is no hardware mouse (disable the hardware mouse, use software drawing on the specified bitmap), and show_mouse(NULL) should remove the mouse pointer from being displayed.

- Kitty Cat




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