Re: [AD] 4.1.17

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


> Yeah, I hope to get that done this weekend (ie, today).

Man, was I optimistic...
I have attached a new version of the mouse cursor patch. This just adds a 
new function select_mouse_cursor() to the API where you can specify if you 
want to use the Allegro cursor, or one of the system's native cursors 
(ARROW, BUSY...). Using show_mouse() should continue to work as it did 
previously. I haven't been able to test the code yet though, hopefully I 
can do that and do final cleanup (and documentation) when I get home.

> Agreed. I still have to hear back from spellcaster if my merging of his 
> detection code worked ok in Windows (but I see no reason it wouldn't).

Done.

> Yes, although several people (spellcaster, James Lohr) had patches for 
the 
> Windows mouse driver. In fact, I think I remember one patch that dealt 
> with smoothness of the mouse cursor in fullscreen mode.
> I have the thread bookmarked, so I can dig it up easily. I don't think I 
> applied it yet.

Ok, I cleaned up some problems with applying that patch and remade it 
manually. Attached.

> Off the top of my head: direct font loading functions (from datafile and 
> from bitmap) - these are in heavy demand and I don't really see a reason 
> to not have a load_font() function that can be extended a' la 
> load_bitmap() by registering a fonttype and loader function.

I still need to look into this.

> Extending the blender functions to use the new vtable entry that has been 
> in place since 4.1.16 but is currently unused.

Ditto.
As an aside, Bob, are there any other vtable entries that you think we 
should make? It'd be nice if we have as much as possible in 4.2 so that 
AllegroGL can work with the 4.2 stable branch normally and doesn't need a 
WIP release.

> There is a preliminary Direct 3D driver that was posted a whiel back. It 
> doesn't perform well though, from what I recall, so at the moment it's 
> really useless. If it works though, maybe we can just apply it and hope 
> that someone will pick it up and make it work faster? ;)

Any thoughts on this?

Evert
Index: include/allegro/mouse.h
===================================================================
RCS file: /cvsroot/alleg/allegro/include/allegro/mouse.h,v
retrieving revision 1.3
diff -u -r1.3 mouse.h
--- include/allegro/mouse.h	25 Sep 2004 08:17:01 -0000	1.3
+++ include/allegro/mouse.h	30 Nov 2004 10:15:52 -0000
@@ -44,7 +44,8 @@
    AL_METHOD(void, set_speed, (int xspeed, int yspeed));
    AL_METHOD(void, get_mickeys, (int *mickeyx, int *mickeyy));
    AL_METHOD(int,  analyse_data, (AL_CONST char *buffer, int size));
-   AL_METHOD(void,  enable_hardware_cursor, (AL_CONST int mode));
+   AL_METHOD(void, enable_hardware_cursor, (AL_CONST int mode));
+   AL_METHOD(int,  select_system_cursor, (AL_CONST int cursor));
 } MOUSE_DRIVER;
 
 
@@ -61,6 +62,15 @@
 AL_FUNC(void, enable_hardware_cursor, (void));
 AL_FUNC(void, disable_hardware_cursor, (void));
 
+/* Mouse cursors */
+#define MOUSE_CURSOR_NONE        0
+#define MOUSE_CURSOR_ALLEGRO     1
+#define MOUSE_CURSOR_ARROW       2
+#define MOUSE_CURSOR_BUSY        3
+#define MOUSE_CURSOR_QUESTION    4
+#define MOUSE_CURSOR_EDIT        5
+#define NUM_MOUSE_CURSORS        6
+
 AL_VAR(struct BITMAP *, mouse_sprite);
 AL_VAR(int, mouse_x_focus);
 AL_VAR(int, mouse_y_focus);
@@ -92,10 +102,10 @@
 AL_FUNC(void, position_mouse_z, (int z));
 AL_FUNC(void, set_mouse_range, (int x1, int y1, int x2, int y2));
 AL_FUNC(void, set_mouse_speed, (int xspeed, int yspeed));
-AL_FUNC(void, set_mouse_sprite, (struct BITMAP *sprite));
+AL_FUNC(void, select_mouse_cursor, (AL_CONST int cursor));
 AL_FUNC(void, set_mouse_sprite_focus, (int x, int y));
 AL_FUNC(void, get_mouse_mickeys, (int *mickeyx, int *mickeyy));
-
+AL_FUNC(void, set_mouse_sprite, (struct BITMAP *sprite));
 #ifdef __cplusplus
    }
 #endif
Index: src/mouse.c
===================================================================
RCS file: /cvsroot/alleg/allegro/src/mouse.c,v
retrieving revision 1.28
diff -u -r1.28 mouse.c
--- src/mouse.c	29 Nov 2004 21:22:03 -0000	1.28
+++ src/mouse.c	30 Nov 2004 10:15:53 -0000
@@ -71,27 +71,49 @@
 #define MOUSE_OFFSCREEN    -4096       /* somewhere to put unwanted cursors */
 
 
-#define DEFAULT_SPRITE_W   10          /* default arrow cursor */
+/* default mouse cursor sizes */
+#define DEFAULT_SPRITE_W   16
 #define DEFAULT_SPRITE_H   16
 
-static char mouse_pointer_data[DEFAULT_SPRITE_H][DEFAULT_SPRITE_W] =
+
+static char mouse_arrow_data[DEFAULT_SPRITE_H * DEFAULT_SPRITE_W] =
 {
-   { 1, 1, 0, 0, 0, 0, 0, 0, 0, 0 },
-   { 1, 2, 1, 0, 0, 0, 0, 0, 0, 0 },
-   { 1, 2, 2, 1, 0, 0, 0, 0, 0, 0 },
-   { 1, 2, 2, 2, 1, 0, 0, 0, 0, 0 },
-   { 1, 2, 2, 2, 2, 1, 0, 0, 0, 0 },
-   { 1, 2, 2, 2, 2, 2, 1, 0, 0, 0 },
-   { 1, 2, 2, 2, 2, 2, 2, 1, 0, 0 },
-   { 1, 2, 2, 2, 2, 2, 2, 2, 1, 0 },
-   { 1, 2, 2, 2, 2, 2, 2, 2, 2, 1 },
-   { 1, 2, 2, 2, 2, 2, 1, 1, 1, 0 },
-   { 1, 2, 2, 1, 2, 2, 1, 0, 0, 0 },
-   { 1, 2, 1, 0, 1, 2, 2, 1, 0, 0 },
-   { 0, 1, 0, 0, 1, 2, 2, 1, 0, 0 },
-   { 0, 0, 0, 0, 0, 1, 2, 2, 1, 0 },
-   { 0, 0, 0, 0, 0, 1, 2, 2, 1, 0 },
-   { 0, 0, 0, 0, 0, 0, 1, 1, 0, 0 }
+   2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
+   2, 1, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
+   2, 1, 1, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
+   2, 1, 1, 1, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
+   2, 1, 1, 1, 1, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
+   2, 1, 1, 1, 1, 1, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
+   2, 1, 1, 1, 1, 1, 1, 2, 0, 0, 0, 0, 0, 0, 0, 0, 
+   2, 1, 1, 1, 1, 1, 1, 1, 2, 0, 0, 0, 0, 0, 0, 0, 
+   2, 1, 1, 1, 1, 1, 1, 1, 1, 2, 0, 0, 0, 0, 0, 0, 
+   2, 1, 1, 1, 1, 1, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 
+   2, 1, 1, 2, 1, 1, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
+   2, 1, 2, 0, 2, 1, 1, 2, 0, 0, 0, 0, 0, 0, 0, 0, 
+   0, 2, 0, 0, 2, 1, 1, 2, 0, 0, 0, 0, 0, 0, 0, 0, 
+   0, 0, 0, 0, 0, 2, 1, 1, 2, 0, 0, 0, 0, 0, 0, 0, 
+   0, 0, 0, 0, 0, 2, 1, 1, 2, 0, 0, 0, 0, 0, 0, 0, 
+   0, 0, 0, 0, 0, 0, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0
+};
+
+static char mouse_busy_data[DEFAULT_SPRITE_H * DEFAULT_SPRITE_W] =
+{
+   0, 0, 0, 0, 0, 0, 0, 2, 2, 0, 0, 0, 0, 0, 0, 0,
+   0, 0, 0, 0, 0, 2, 2, 1, 1, 2, 2, 0, 0, 0, 0, 0,
+   0, 0, 0, 0, 2, 1, 1, 1, 1, 1, 1, 2, 0, 0, 0, 0,
+   0, 0, 0, 2, 1, 1, 1, 0, 0, 1, 1, 1, 2, 0, 0, 0,
+   0, 0, 2, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 2, 0, 0,
+   0, 2, 1, 1, 0, 0, 0, 0, 0, 1, 1, 0, 1, 1, 2, 0,
+   0, 2, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0, 1, 1, 2, 0,
+   2, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 1, 1, 2,
+   2, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 1, 1, 2,
+   0, 2, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0, 1, 1, 2, 0,
+   0, 2, 1, 1, 0, 0, 0, 0, 0, 1, 1, 0, 1, 1, 2, 0,
+   0, 0, 2, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 2, 0, 0,
+   0, 0, 0, 2, 1, 1, 1, 0, 0, 1, 1, 1, 2, 0, 0, 0,
+   0, 0, 0, 0, 2, 1, 1, 1, 1, 1, 1, 2, 0, 0, 0, 0,
+   0, 0, 0, 0, 0, 2, 2, 1, 1, 2, 2, 0, 0, 0, 0, 0,
+   0, 0, 0, 0, 0, 0, 0, 2, 2, 0, 0, 0, 0, 0, 0, 0
 };
 
 
@@ -101,7 +123,11 @@
 
 BITMAP *_mouse_screen = NULL;          /* where to draw the pointer */
 
+static BITMAP *cursors[NUM_MOUSE_CURSORS];
+
+static int use_system_cursor = FALSE;  /* Use native cursor? */
 static int got_hw_cursor = FALSE;      /* hardware pointer available? */
+static int current_cursor = MOUSE_CURSOR_NONE;
 static int hw_cursor_dirty = FALSE;    /* need to set a new pointer? */
 
 static int mx, my;                     /* previous mouse pointer position */
@@ -368,7 +394,7 @@
  *  Creates the default arrow mouse sprite using the current color depth
  *  and palette.
  */
-static BITMAP *create_mouse_pointer(void)
+static BITMAP *create_mouse_pointer(char *data)
 {
    BITMAP *bmp;
    int x, y;
@@ -378,7 +404,7 @@
 
    for (y=0; y<DEFAULT_SPRITE_H; y++) {
       for (x=0; x<DEFAULT_SPRITE_W; x++) {
-	 switch (mouse_pointer_data[y][x]) {
+	 switch (data[x+y*DEFAULT_SPRITE_W]) {
 	    case 1:  col = makecol(255, 255, 255);  break;
 	    case 2:  col = makecol(0, 0, 0);        break;
 	    default: col = bmp->vtable->mask_color; break;
@@ -392,18 +418,44 @@
 
 
 
+/* set_mouse_cursor:
+ *  Sets the default cursor shape. If this is NULL, the hardware cursor
+ *  will be used instead.
+ */
+static void set_mouse_cursor(AL_CONST int cursor, BITMAP *sprite)
+{
+   ASSERT(cursor < NUM_MOUSE_CURSORS);
+   
+   cursors[cursor] = sprite;
+}
+
+
+
+
 /* set_mouse_sprite:
  *  Sets the sprite to be used for the mouse pointer. If the sprite is
  *  NULL, restores the default arrow.
  */
 void set_mouse_sprite(struct BITMAP *sprite)
 {
+   set_mouse_cursor(MOUSE_CURSOR_ALLEGRO, sprite);
+   current_cursor = MOUSE_CURSOR_ALLEGRO;
+}
+
+
+
+/* _set_mouse_sprite:
+ *  Sets the sprite to be used for the mouse pointer. If the sprite is
+ *  NULL, restores the default arrow.
+ */
+static void _set_mouse_sprite(BITMAP *sprite, char *data)
+{
    BITMAP *old_mouse_screen = _mouse_screen;
 
    if (!mouse_driver)
       return;
 
-   if (_mouse_screen)
+   if (_mouse_screen && !(gfx_capabilities & GFX_HW_CURSOR))
       show_mouse(NULL);
 
    if (sprite)
@@ -411,7 +463,7 @@
    else {
       if (_mouse_pointer)
 	 destroy_bitmap(_mouse_pointer);
-      _mouse_pointer = create_mouse_pointer();
+      _mouse_pointer = create_mouse_pointer(data);
       mouse_sprite = _mouse_pointer;
    }
 
@@ -437,12 +489,25 @@
 
    hw_cursor_dirty = TRUE;
 
-   if (old_mouse_screen)
+   if (old_mouse_screen && !(gfx_capabilities & GFX_HW_CURSOR))
       show_mouse(old_mouse_screen);
 }
 
 
 
+/* select_mouse_cursor:
+ *  Selects the shape of the mouse cursor.
+ */
+void select_mouse_cursor(AL_CONST int cursor)
+{
+   ASSERT(cursor < NUM_MOUSE_CURSORS);
+
+   current_cursor = cursor;
+}
+
+
+
+
 /* set_mouse_sprite_focus:
  *  Sets co-ordinate (x, y) in the sprite to be the mouse location.
  *  Call after set_mouse_sprite(). Doesn't redraw the sprite.
@@ -465,9 +530,7 @@
  *  module is active. The mouse pointer will be drawn onto the bitmap bmp, 
  *  which should normally be the hardware screen. To turn off the mouse 
  *  pointer, which you must do before you draw anything onto the screen, call 
- *  show_mouse(NULL). If you forget to turn off the mouse pointer when 
- *  drawing something, the SVGA bank switching code will become confused and 
- *  will produce garbage all over the screen.
+ *  show_mouse(NULL).
  */
 void show_mouse(BITMAP *bmp)
 {
@@ -494,6 +557,32 @@
    if (bmp) {
       acquire_bitmap(_mouse_screen);
 
+
+      use_system_cursor = 0;
+      if (!cursors[current_cursor] || current_cursor != MOUSE_CURSOR_ALLEGRO) {
+         /* Use default system cursor */
+         if (mouse_driver && mouse_driver->select_system_cursor) {
+            use_system_cursor = mouse_driver->select_system_cursor(current_cursor);
+            if (use_system_cursor) {
+               gfx_capabilities |= GFX_HW_CURSOR;
+               hw_cursor_dirty = FALSE;
+            }
+         }
+      }
+   
+      if (!use_system_cursor) {
+         switch(current_cursor) {
+            case MOUSE_CURSOR_BUSY:
+               _set_mouse_sprite(cursors[current_cursor], mouse_busy_data);
+               break;
+            case MOUSE_CURSOR_ALLEGRO:
+               if (!cursors[current_cursor])
+                  _set_mouse_sprite(cursors[current_cursor], mouse_arrow_data);
+               break;
+            default:
+               _set_mouse_sprite(cursors[current_cursor], mouse_arrow_data);
+         }
+      }
       if (hw_cursor_dirty) {
 	 got_hw_cursor = FALSE;
 
@@ -873,7 +962,8 @@
    LOCK_VARIABLE(mouse_x_focus);
    LOCK_VARIABLE(mouse_y_focus);
    LOCK_VARIABLE(mouse_sprite);
-   LOCK_VARIABLE(mouse_pointer_data);
+   LOCK_VARIABLE(mouse_arrow_data);
+   LOCK_VARIABLE(mouse_busy_data);
    LOCK_VARIABLE(_mouse_pointer);
    LOCK_VARIABLE(_mouse_screen);
    LOCK_VARIABLE(mx);
@@ -882,6 +972,7 @@
    LOCK_VARIABLE(mtemp);
    LOCK_VARIABLE(mouse_polled);
    LOCK_VARIABLE(mouse_semaphore);
+   LOCK_VARIABLE(use_system_cursor);
    LOCK_FUNCTION(draw_mouse_doublebuffer);
    LOCK_FUNCTION(draw_mouse);
    LOCK_FUNCTION(update_mouse);
@@ -943,6 +1034,9 @@
    else {
       emulate_three = FALSE;
    }
+   
+   for (i=0; i<NUM_MOUSE_CURSORS; i++)
+      cursors[i] = NULL;
 
    mouse_polled = (mouse_driver->poll) ? TRUE : FALSE;
 
Index: src/beos/bmouse.c
===================================================================
RCS file: /cvsroot/alleg/allegro/src/beos/bmouse.c,v
retrieving revision 1.4
diff -u -r1.4 bmouse.c
--- src/beos/bmouse.c	25 Sep 2004 08:16:58 -0000	1.4
+++ src/beos/bmouse.c	30 Nov 2004 10:15:53 -0000
@@ -39,5 +39,6 @@
    be_mouse_set_speed,	// AL_METHOD(void, set_speed, (int xspeed, int yspeed));
    be_mouse_get_mickeys,// AL_METHOD(void, get_mickeys, (int *mickeyx, int *mickeyy));
    NULL,                // AL_METHOD(int,  analyse_data, (const char *buffer, int size));
-   NULL                 // AL_METHOD(void,  enable_hardware_cursor, (AL_CONST int mode));
+   NULL,                // AL_METHOD(void,  enable_hardware_cursor, (AL_CONST int mode));
+   NULL                 // AL_METHOD(int,  select_system_cursor, (AL_CONST int cursor));
 };
Index: src/dos/dmouse.c
===================================================================
RCS file: /cvsroot/alleg/allegro/src/dos/dmouse.c,v
retrieving revision 1.6
diff -u -r1.6 dmouse.c
--- src/dos/dmouse.c	25 Sep 2004 08:16:59 -0000	1.6
+++ src/dos/dmouse.c	30 Nov 2004 10:15:54 -0000
@@ -96,6 +96,7 @@
    mick_set_speed,
    mick_get_mickeys,
    NULL,
+   NULL,
    NULL
 };
 
Index: src/linux/lmseev.c
===================================================================
RCS file: /cvsroot/alleg/allegro/src/linux/lmseev.c,v
retrieving revision 1.7
diff -u -r1.7 lmseev.c
--- src/linux/lmseev.c	1 Oct 2004 14:16:13 -0000	1.7
+++ src/linux/lmseev.c	30 Nov 2004 10:15:54 -0000
@@ -682,7 +682,8 @@
    mouse_set_speed,
    mouse_get_mickeys,
    analyse_data,
-	NULL /* enable_hardware_cursor */
+   NULL, /* enable_hardware_cursor */
+   NULL
 };
 
 #endif
Index: src/linux/lmsegpmd.c
===================================================================
RCS file: /cvsroot/alleg/allegro/src/linux/lmsegpmd.c,v
retrieving revision 1.12
diff -u -r1.12 lmsegpmd.c
--- src/linux/lmsegpmd.c	1 Oct 2004 14:16:13 -0000	1.12
+++ src/linux/lmsegpmd.c	30 Nov 2004 10:15:55 -0000
@@ -141,6 +141,7 @@
 	__al_linux_mouse_set_speed,
 	__al_linux_mouse_get_mickeys,
 	NULL,  /* analyse_data */
-	NULL
+	NULL,
+       NULL
 };
 
Index: src/linux/lmsems.c
===================================================================
RCS file: /cvsroot/alleg/allegro/src/linux/lmsems.c,v
retrieving revision 1.13
diff -u -r1.13 lmsems.c
--- src/linux/lmsems.c	1 Oct 2004 14:16:13 -0000	1.13
+++ src/linux/lmsems.c	30 Nov 2004 10:15:55 -0000
@@ -224,7 +224,8 @@
 	__al_linux_mouse_set_speed,
 	__al_linux_mouse_get_mickeys,
 	analyse_data,
-	NULL /* enable_hardware_cursor */
+	NULL, /* enable_hardware_cursor */
+       NULL
 };
 
 MOUSE_DRIVER mousedrv_linux_ims =
Index: src/linux/lmseps2.c
===================================================================
RCS file: /cvsroot/alleg/allegro/src/linux/lmseps2.c,v
retrieving revision 1.16
diff -u -r1.16 lmseps2.c
--- src/linux/lmseps2.c	1 Oct 2004 14:16:13 -0000	1.16
+++ src/linux/lmseps2.c	30 Nov 2004 10:15:55 -0000
@@ -241,7 +241,8 @@
 	__al_linux_mouse_set_speed,
 	__al_linux_mouse_get_mickeys,
 	analyse_data,
-	NULL /* enable_hardware_cursor */
+	NULL, /* enable_hardware_cursor */
+       NULL
 };
 
 MOUSE_DRIVER mousedrv_linux_ips2 =
Index: src/mac/madb.c
===================================================================
RCS file: /cvsroot/alleg/allegro/src/mac/madb.c,v
retrieving revision 1.4
diff -u -r1.4 madb.c
--- src/mac/madb.c	6 Nov 2001 17:16:40 -0000	1.4
+++ src/mac/madb.c	30 Nov 2004 10:15:56 -0000
@@ -90,6 +90,7 @@
       mouse_adb_set_range,
       NULL,
       mouse_adb_get_mickeys,
+      NULL,
       NULL
 };
 
Index: src/mac/msys.c
===================================================================
RCS file: /cvsroot/alleg/allegro/src/mac/msys.c,v
retrieving revision 1.14
diff -u -r1.14 msys.c
--- src/mac/msys.c	2 Jul 2004 16:25:41 -0000	1.14
+++ src/mac/msys.c	30 Nov 2004 10:15:57 -0000
@@ -122,6 +122,7 @@
    NULL,
    NULL,
    NULL,
+   NULL,
    NULL
 };
 
Index: src/macosx/qzmouse.m
===================================================================
RCS file: /cvsroot/alleg/allegro/src/macosx/qzmouse.m,v
retrieving revision 1.13
diff -u -r1.13 qzmouse.m
--- src/macosx/qzmouse.m	29 Nov 2004 21:22:06 -0000	1.13
+++ src/macosx/qzmouse.m	30 Nov 2004 10:15:57 -0000
@@ -47,7 +47,8 @@
    NULL,       // AL_METHOD(void, set_speed, (int xspeed, int yspeed));
    osx_mouse_get_mickeys,
    NULL,       // AL_METHOD(int,  analyse_data, (AL_CONST char *buffer, int size));
-   NULL        // AL_METHOD(void,  enable_hardware_cursor, (AL_CONST int mode));
+   NULL,       // AL_METHOD(void,  enable_hardware_cursor, (AL_CONST int mode));
+   NULL        // AL_METHOD(int,  select_system_cursor, (AL_CONST int cursor));
 };
 
 
Index: src/qnx/qmouse.c
===================================================================
RCS file: /cvsroot/alleg/allegro/src/qnx/qmouse.c,v
retrieving revision 1.11
diff -u -r1.11 qmouse.c
--- src/qnx/qmouse.c	25 Sep 2004 08:17:00 -0000	1.11
+++ src/qnx/qmouse.c	30 Nov 2004 10:15:58 -0000
@@ -49,7 +49,8 @@
    NULL,       // AL_METHOD(void, set_speed, (int xspeed, int yspeed));
    qnx_mouse_get_mickeys,
    NULL,       // AL_METHOD(int,  analyse_data, (AL_CONST char *buffer, int size));
-   NULL        // AL_METHOD(void,  enable_hardware_cursor, (AL_CONST int mode));
+   NULL,       // AL_METHOD(void,  enable_hardware_cursor, (AL_CONST int mode));
+   NULL        // AL_METHOD(int,  select_system_cursor, (AL_CONST int cursor));
 };
 
 
Index: src/win/wddraw.c
===================================================================
RCS file: /cvsroot/alleg/allegro/src/win/wddraw.c,v
retrieving revision 1.33
diff -u -r1.33 wddraw.c
--- src/win/wddraw.c	25 Sep 2004 08:23:15 -0000	1.33
+++ src/win/wddraw.c	30 Nov 2004 10:15:59 -0000
@@ -384,6 +384,8 @@
    HBITMAP hOldXorMaskBitmap;
 
    if (hcursor) {
+      if (_win_hcursor == hcursor)
+         _win_hcursor = NULL;
       DestroyIcon(hcursor);
       hcursor = NULL;
    }
Index: src/win/wmouse.c
===================================================================
RCS file: /cvsroot/alleg/allegro/src/win/wmouse.c,v
retrieving revision 1.37
diff -u -r1.37 wmouse.c
--- src/win/wmouse.c	20 Oct 2004 20:03:31 -0000	1.37
+++ src/win/wmouse.c	30 Nov 2004 10:16:00 -0000
@@ -46,7 +46,7 @@
 static void mouse_directx_set_range(int x1, int y1, int x2, int y2);
 static void mouse_directx_set_speed(int xspeed, int yspeed);
 static void mouse_directx_get_mickeys(int *mickeyx, int *mickeyy);
-
+static int mouse_directx_select_system_cursor(AL_CONST int cursor);
 
 MOUSE_DRIVER mouse_directx =
 {
@@ -63,7 +63,8 @@
    mouse_directx_set_speed,
    mouse_directx_get_mickeys,
    NULL,                       // AL_METHOD(int, analyse_data, (AL_CONST char *buffer, int size));
-   NULL                        // AL_METHOD(void,  enable_hardware_cursor, (AL_CONST int mode));
+   NULL,                       // AL_METHOD(void,  enable_hardware_cursor, (AL_CONST int mode));
+   mouse_directx_select_system_cursor
 };
 
 
@@ -757,3 +758,36 @@
    *mickeyy = temp_y;
 }
 
+
+
+/* mouse_directx_select_system_cursor:
+ *  Select an OS native cursor 
+ */
+static int mouse_directx_select_system_cursor (AL_CONST int cursor)
+{
+   HCURSOR wc;
+   
+   wc = NULL;
+   switch(cursor) {
+      case MOUSE_CURSOR_ARROW:
+         wc = LoadCursor(NULL, IDC_ARROW);
+         break;
+      case MOUSE_CURSOR_BUSY:
+         wc = LoadCursor(NULL, IDC_WAIT);
+         break;
+      case MOUSE_CURSOR_QUESTION:
+         wc = LoadCursor(NULL, IDC_HELP);
+         break;
+      case MOUSE_CURSOR_EDIT:
+         wc = LoadCursor(NULL, IDC_IBEAM);
+         break;
+      default:
+         return 0;
+   }
+
+   _win_hcursor = wc;
+   SetCursor(_win_hcursor);
+   PostMessage(allegro_wnd, WM_MOUSEMOVE, 0, 0);
+   
+   return cursor;
+}
Index: src/x/xmouse.c
===================================================================
RCS file: /cvsroot/alleg/allegro/src/x/xmouse.c,v
retrieving revision 1.7
diff -u -r1.7 xmouse.c
--- src/x/xmouse.c	25 Sep 2004 08:33:31 -0000	1.7
+++ src/x/xmouse.c	30 Nov 2004 10:16:01 -0000
@@ -20,7 +20,7 @@
 #include "allegro/internal/aintern.h"
 #include "allegro/platform/aintunix.h"
 #include "xwin.h"
-
+#include <X11/cursorfont.h>
 
 /* TRUE if the requested mouse range extends beyond the regular
  * (0, 0, SCREEN_W-1, SCREEN_H-1) range. This is aimed at detecting
@@ -48,7 +48,7 @@
 static void _xwin_mousedrv_set_range(int x1, int y1, int x2, int y2);
 static void _xwin_mousedrv_set_speed(int xspeed, int yspeed);
 static void _xwin_mousedrv_get_mickeys(int *mickeyx, int *mickeyy);
-
+static int _xwin_select_system_cursor(AL_CONST int cursor);
 
 static MOUSE_DRIVER mouse_xwin =
 {
@@ -65,7 +65,8 @@
    _xwin_mousedrv_set_speed,
    _xwin_mousedrv_get_mickeys,
    NULL,
-   _xwin_enable_hardware_cursor
+   _xwin_enable_hardware_cursor,
+   _xwin_select_system_cursor
 };
 
 
@@ -214,3 +215,37 @@
    _xwin_set_warped_mouse_mode(TRUE);
 }
 
+
+
+/* _xwin_select_system_cursor:
+ *  Select an OS native cursor 
+ */
+static int _xwin_select_system_cursor(AL_CONST int cursor)
+{
+   switch(cursor) {
+      case MOUSE_CURSOR_ARROW:
+         _xwin.cursor_shape = XC_left_ptr;
+         break;
+      case MOUSE_CURSOR_BUSY:
+         _xwin.cursor_shape = XC_watch;
+         break;
+      case MOUSE_CURSOR_QUESTION:
+         _xwin.cursor_shape = XC_question_arrow;
+         break;
+      case MOUSE_CURSOR_EDIT:
+         _xwin.cursor_shape = XC_xterm;
+         break;
+      default:
+         return 0;
+   }
+   
+   if (_xwin.cursor != None) {
+      XUndefineCursor(_xwin.display, _xwin.window);
+      XFreeCursor(_xwin.display, _xwin.cursor);
+   }   
+
+   _xwin.cursor = XCreateFontCursor(_xwin.display, _xwin.cursor_shape);
+   XDefineCursor(_xwin.display, _xwin.window, _xwin.cursor);
+   
+   return cursor;
+}
Index: tools/grabber.c
===================================================================
RCS file: /cvsroot/alleg/allegro/tools/grabber.c,v
retrieving revision 1.72
diff -u -r1.72 grabber.c
--- tools/grabber.c	2 Jul 2004 09:46:28 -0000	1.72
+++ tools/grabber.c	30 Nov 2004 10:16:04 -0000
@@ -376,14 +376,14 @@
 /* starts outputting a progress message */
 static void box_start(void)
 {
-   show_mouse(NULL);
+   scare_mouse();
 
    rectfill(screen, BOX_L, BOX_T, BOX_R, BOX_B, gui_bg_color);
    rect(screen, BOX_L-1, BOX_T-1, BOX_R+1, BOX_B+1, gui_fg_color);
    hline(screen, BOX_L, BOX_B+2, BOX_R+1, gui_fg_color);
    vline(screen, BOX_R+2, BOX_T, BOX_B+2, gui_fg_color);
 
-   show_mouse(screen);
+   unscare_mouse();
 
    box_x = box_y = 0;
    box_active = TRUE;
@@ -397,8 +397,7 @@
    BITMAP *mouse_screen = _mouse_screen;
 
    if (box_active) {
-      if (mouse_screen)
-	 show_mouse(NULL);
+      scare_mouse();
 
       set_clip_rect(screen, BOX_L+8, BOX_T+1, BOX_R-8, BOX_B-1);
 
@@ -406,8 +405,7 @@
 
       set_clip_rect(screen, 0, 0, SCREEN_W-1, SCREEN_H-1);
 
-      if (mouse_screen)
-	 show_mouse(mouse_screen);
+      unscare_mouse();
 
       box_x += strlen(msg);
    }
@@ -425,14 +423,12 @@
       box_y++;
 
       if ((box_y+2)*8 >= BOX_H) {
-	 if (mouse_screen)
-	    show_mouse(NULL);
+         scare_mouse();
 
 	 blit(screen, screen, BOX_L+8, BOX_T+16, BOX_L+8, BOX_T+8, BOX_W-16, BOX_H-24);
 	 rectfill(screen, BOX_L+8, BOX_T+BOX_H-16, BOX_L+BOX_W-8, BOX_T+BOX_H-8, gui_bg_color);
 
-	 if (mouse_screen)
-	    show_mouse(mouse_screen);
+	 unscare_mouse();
 
 	 box_y--;
       }
@@ -828,64 +824,15 @@
 
 
 
-static char my_mouse_pointer_data[256] =
-{
-   2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
-   2, 1, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
-   2, 1, 1, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
-   2, 1, 1, 1, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
-   2, 1, 1, 1, 1, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
-   2, 1, 1, 1, 1, 1, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
-   2, 1, 1, 1, 1, 1, 1, 2, 0, 0, 0, 0, 0, 0, 0, 0, 
-   2, 1, 1, 1, 1, 1, 1, 1, 2, 0, 0, 0, 0, 0, 0, 0, 
-   2, 1, 1, 1, 1, 1, 1, 1, 1, 2, 0, 0, 0, 0, 0, 0, 
-   2, 1, 1, 1, 1, 1, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 
-   2, 1, 1, 2, 1, 1, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
-   2, 1, 2, 0, 2, 1, 1, 2, 0, 0, 0, 0, 0, 0, 0, 0, 
-   0, 2, 0, 0, 2, 1, 1, 2, 0, 0, 0, 0, 0, 0, 0, 0, 
-   0, 0, 0, 0, 0, 2, 1, 1, 2, 0, 0, 0, 0, 0, 0, 0, 
-   0, 0, 0, 0, 0, 2, 1, 1, 2, 0, 0, 0, 0, 0, 0, 0, 
-   0, 0, 0, 0, 0, 0, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0
-};
-
-
-
-static char my_busy_pointer_data[256] =
-{
-   0, 0, 0, 0, 0, 0, 0, 2, 2, 0, 0, 0, 0, 0, 0, 0,
-   0, 0, 0, 0, 0, 2, 2, 1, 1, 2, 2, 0, 0, 0, 0, 0,
-   0, 0, 0, 0, 2, 1, 1, 1, 1, 1, 1, 2, 0, 0, 0, 0,
-   0, 0, 0, 2, 1, 1, 1, 0, 0, 1, 1, 1, 2, 0, 0, 0,
-   0, 0, 2, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 2, 0, 0,
-   0, 2, 1, 1, 0, 0, 0, 0, 0, 1, 1, 0, 1, 1, 2, 0,
-   0, 2, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0, 1, 1, 2, 0,
-   2, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 1, 1, 2,
-   2, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 1, 1, 2,
-   0, 2, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0, 1, 1, 2, 0,
-   0, 2, 1, 1, 0, 0, 0, 0, 0, 1, 1, 0, 1, 1, 2, 0,
-   0, 0, 2, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 2, 0, 0,
-   0, 0, 0, 2, 1, 1, 1, 0, 0, 1, 1, 1, 2, 0, 0, 0,
-   0, 0, 0, 0, 2, 1, 1, 1, 1, 1, 1, 2, 0, 0, 0, 0,
-   0, 0, 0, 0, 0, 2, 2, 1, 1, 2, 2, 0, 0, 0, 0, 0,
-   0, 0, 0, 0, 0, 0, 0, 2, 2, 0, 0, 0, 0, 0, 0, 0
-};
-
-
-
-static BITMAP *my_mouse_pointer = NULL;
-static BITMAP *my_busy_pointer = NULL;
-
-
-
 /* changes the mouse pointer */
 static void set_busy_mouse(int busy)
 {
    if (busy) {
-      set_mouse_sprite(my_busy_pointer);
+      select_mouse_cursor(MOUSE_CURSOR_BUSY);
       busy_mouse = TRUE;
    }
    else {
-      set_mouse_sprite(my_mouse_pointer);
+      select_mouse_cursor(MOUSE_CURSOR_ARROW);
       busy_mouse = FALSE;
    }
 }
@@ -912,29 +859,8 @@
    main_dlg[DLG_FIRSTWHITE].proc = proc;
    set_dialog_color(main_dlg+DLG_FIRSTWHITE, gui_fg_color, gui_bg_color);
 
-   if (!my_mouse_pointer)
-      my_mouse_pointer = create_bitmap(16, 16);
-
-   if (!my_busy_pointer)
-      my_busy_pointer = create_bitmap(16, 16);
-
-   for (y=0; y<16; y++) {
-      for (x=0; x<16; x++) {
-	 switch (my_mouse_pointer_data[x+y*16]) {
-	    case 1:  c = gui_fg_color; break;
-	    case 2:  c = gui_bg_color; break;
-	    default: c = screen->vtable->mask_color; break;
-	 }
-	 putpixel(my_mouse_pointer, x, y, c);
-
-	 switch (my_busy_pointer_data[x+y*16]) {
-	    case 1:  c = gui_fg_color; break;
-	    case 2:  c = gui_bg_color; break;
-	    default: c = screen->vtable->mask_color; break;
-	 }
-	 putpixel(my_busy_pointer, x, y, c);
-      }
-   }
+   set_mouse_cursor(MOUSE_CURSOR_BUSY, NULL);
+   set_mouse_cursor(MOUSE_CURSOR_ARROW, NULL);
 
    set_busy_mouse(FALSE);
 }
@@ -3361,10 +3287,6 @@
    install_timer();
 
    if (set_gfx_mode(autodetect_card, oldw, oldh, 0, 0) != 0) {
-      destroy_bitmap(my_mouse_pointer);
-      my_mouse_pointer = NULL;
-      destroy_bitmap(my_busy_pointer);
-      my_busy_pointer = NULL;
       set_gfx_mode(GFX_SAFE, 320, 200, 0, 0);
       sel_palette(datedit_current_palette);
       alert("bad, Bad, BAD error!", "Unable to restore the graphics mode...", NULL, "Shit", NULL, 13, 0);
@@ -3429,14 +3351,14 @@
    vsprintf(buf, fmt, args);
    va_end(args);
 
-   show_mouse(NULL);
+   scare_mouse();
    acquire_screen();
 
    box_out(buf);
    box_eol();
 
    release_screen();
-   show_mouse(screen);
+   unscare_mouse();
 }
 
 
@@ -3466,14 +3388,14 @@
    vsprintf(buf, fmt, args);
    va_end(args);
 
-   show_mouse(NULL);
+   scare_mouse();
    acquire_screen();
 
    box_out(buf);
    box_eol();
 
    release_screen();
-   show_mouse(screen);
+   unscare_mouse();
 }
 
 
@@ -3488,12 +3410,12 @@
    vsprintf(buf, fmt, args);
    va_end(args);
 
-   set_mouse_sprite(my_mouse_pointer);
+   select_mouse_cursor(MOUSE_CURSOR_ARROW);
 
    alert(buf, NULL, NULL, "Oh dear", NULL, 13, 0);
 
    if (busy_mouse)
-      set_mouse_sprite(my_busy_pointer);
+      select_mouse_cursor(MOUSE_CURSOR_BUSY);
 }
 
 
@@ -3511,12 +3433,12 @@
 
    strcat(buf, "?");
 
-   set_mouse_sprite(my_mouse_pointer);
+   select_mouse_cursor(MOUSE_CURSOR_ARROW);
 
    ret = alert(buf, NULL, NULL, "Yes", "Cancel", 'y', 27);
 
    if (busy_mouse)
-      set_mouse_sprite(my_busy_pointer);
+      select_mouse_cursor(MOUSE_CURSOR_BUSY);
 
    if (ret == 1)
       return 'y';
Index: src/win/wmouse.c
===================================================================
RCS file: /cvsroot/alleg/allegro/src/win/wmouse.c,v
retrieving revision 1.37
diff -u -r1.37 wmouse.c
--- src/win/wmouse.c	20 Oct 2004 20:03:31 -0000	1.37
+++ src/win/wmouse.c	28 Nov 2004 22:22:02 -0000
@@ -92,8 +92,8 @@
 #define MAF_DEFAULT 1                 /* mouse acceleration parameters */
 static int mouse_accel_fact = MAF_DEFAULT;
 static int mouse_accel_mult = MAF_DEFAULT;
-static int mouse_accel_thr1 = 5;
-static int mouse_accel_thr2 = 16;
+static int mouse_accel_thr1 = 50;     /* 50 = 5^2 *2 */
+static int mouse_accel_thr2 = 512;    /* 512 = 16^2 *2 */
 
 static int mouse_minx = 0;            /* mouse range */
 static int mouse_miny = 0;
@@ -208,31 +208,39 @@
  */
 static void mouse_dinput_handle_event(int ofs, int data)
 {
+   static int last_mickeyx = 0;
+   static int last_mickeyy = 0;
+   int mag;
+   
    switch (ofs) {
 
       case DIMOFS_X:
          if (!gfx_driver || !gfx_driver->windowed) {
             if (mouse_accel_mult) {
-               if (ABS(data) >= mouse_accel_thr2)
+               mag = last_mickeyx*last_mickeyx + last_mickeyy*last_mickeyy;
+               if (mag >= mouse_accel_thr2)
                   data *= (mouse_accel_mult<<1);
-               else if (ABS(data) >= mouse_accel_thr1) 
+               else if (mag >= mouse_accel_thr1) 
                   data *= mouse_accel_mult;
             }
 
             dinput_x += data;
+            last_mickeyx = data;
          }
          break;
 
       case DIMOFS_Y:
          if (!gfx_driver || !gfx_driver->windowed) {
             if (mouse_accel_mult) {
-               if (ABS(data) >= mouse_accel_thr2)
+               mag = last_mickeyx*last_mickeyx + last_mickeyy*last_mickeyy;
+               if (mag >= mouse_accel_thr2)
                   data *= (mouse_accel_mult<<1);
-               else if (ABS(data) >= mouse_accel_thr1) 
+               else if (mag >= mouse_accel_thr1) 
                   data *= mouse_accel_mult;
             }
 
             dinput_y += data;
+            last_mickeyy = data;
          }
          break;
 


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