Re: [AD] Using system mouse cursor |
[ Thread Index |
Date Index
| More lists.liballeg.org/allegro-developers Archives
]
> > > Attached.
> >
> > Forgot? ;)
>
> Apparently so... I'll resubmit when I get home.
Really attached this time (I hope).
Evert
diff -ur allegro/include/allegro/mouse.h alleg_work/include/allegro/mouse.h
--- allegro/include/allegro/mouse.h 2002-10-31 13:56:24.000000000 +0100
+++ alleg_work/include/allegro/mouse.h 2004-09-06 19:37:36.000000000 +0200
@@ -44,6 +44,7 @@
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_mouse_mickeys, (AL_CONST int mode));
} MOUSE_DRIVER;
@@ -57,6 +58,8 @@
AL_FUNC(int, poll_mouse, (void));
AL_FUNC(int, mouse_needs_poll, (void));
+AL_FUNC(void, enable_mouse_mickeys, (AL_CONST int mode));
+
AL_VAR(struct BITMAP *, mouse_sprite);
AL_VAR(int, mouse_x_focus);
AL_VAR(int, mouse_y_focus);
diff -ur allegro/include/xalleg.h alleg_work/include/xalleg.h
--- allegro/include/xalleg.h 2004-09-03 11:30:15.000000000 +0200
+++ alleg_work/include/xalleg.h 2004-09-06 19:18:15.000000000 +0200
@@ -69,7 +69,6 @@
#endif
Cursor cursor;
int cursor_shape;
- int hw_cursor_ok;
void (*screen_to_buffer)(int sx, int sy, int sw, int sh);
void (*set_colors)(AL_CONST PALETTE p, int from, int to);
@@ -91,6 +90,8 @@
int virtual_width;
int virtual_height;
+
+ int fullscreen;
int mouse_warped;
int keycode_to_scancode[256];
diff -ur allegro/src/beos/bmouse.c alleg_work/src/beos/bmouse.c
--- allegro/src/beos/bmouse.c 2001-11-06 18:16:39.000000000 +0100
+++ alleg_work/src/beos/bmouse.c 2004-09-06 19:26:48.000000000 +0200
@@ -38,5 +38,6 @@
be_mouse_set_range, // AL_METHOD(void, set_range, (int x1, int y1, int x2, int y2));
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(int, analyse_data, (const char *buffer, int size));
+ NULL // AL_METHOD(void, enable_mouse_mickeys, (AL_CONST int mode));
};
diff -ur allegro/src/dos/dmouse.c alleg_work/src/dos/dmouse.c
--- allegro/src/dos/dmouse.c 2001-11-06 18:16:39.000000000 +0100
+++ alleg_work/src/dos/dmouse.c 2004-09-06 19:26:17.000000000 +0200
@@ -95,6 +95,7 @@
mick_set_range,
mick_set_speed,
mick_get_mickeys,
+ NULL,
NULL
};
@@ -123,6 +124,7 @@
int33_set_range,
int33_set_speed,
int33_get_mickeys,
+ NULL,
NULL
};
@@ -148,6 +150,7 @@
int33_set_range,
int33_set_speed,
int33_get_mickeys,
+ NULL,
NULL
};
@@ -171,6 +174,7 @@
int33_set_range,
int33_set_speed,
int33_get_mickeys,
+ NULL,
NULL
};
@@ -194,6 +198,7 @@
mick_set_range,
mick_set_speed,
mick_get_mickeys,
+ NULL,
NULL
};
diff -ur allegro/src/macosx/qzmouse.m alleg_work/src/macosx/qzmouse.m
--- allegro/src/macosx/qzmouse.m 2004-07-04 15:37:13.000000000 +0200
+++ alleg_work/src/macosx/qzmouse.m 2004-09-06 19:24:24.000000000 +0200
@@ -46,7 +46,8 @@
osx_mouse_set_range,
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(int, analyse_data, (AL_CONST char *buffer, int size));
+ NULL // AL_METHOD(void, enable_mouse_mickeys, (AL_CONST int mode));
};
diff -ur allegro/src/mouse.c alleg_work/src/mouse.c
--- allegro/src/mouse.c 2004-09-06 18:06:48.000000000 +0200
+++ alleg_work/src/mouse.c 2004-09-06 23:38:05.000000000 +0200
@@ -736,6 +736,22 @@
+/* enable_mouse_mickeys:
+ * Switches the mouse to warp-mode on platforms that need this
+ */
+void enable_mouse_mickeys(AL_CONST int mode)
+{
+ if ((mouse_driver) && (mouse_driver->enable_mouse_mickeys)) {
+ enable_mouse_mickeys(mode);
+ if (is_same_bitmap(_mouse_screen, screen)) {
+ show_mouse(NULL);
+ show_mouse(screen);
+ }
+ }
+}
+
+
+
/* poll_mouse:
* Polls the current mouse state, and updates the user-visible information
* accordingly. On some drivers this is actually required to get the
diff -ur allegro/src/qnx/qmouse.c alleg_work/src/qnx/qmouse.c
--- allegro/src/qnx/qmouse.c 2002-05-04 00:34:13.000000000 +0200
+++ alleg_work/src/qnx/qmouse.c 2004-09-06 19:24:43.000000000 +0200
@@ -48,7 +48,8 @@
qnx_mouse_set_range,
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(int, analyse_data, (AL_CONST char *buffer, int size));
+ NULL // AL_METHOD(void, enable_mouse_mickeys, (AL_CONST int mode));
};
diff -ur allegro/src/win/wmouse.c alleg_work/src/win/wmouse.c
--- allegro/src/win/wmouse.c 2004-07-04 15:37:13.000000000 +0200
+++ alleg_work/src/win/wmouse.c 2004-09-06 19:25:21.000000000 +0200
@@ -62,7 +62,8 @@
mouse_directx_set_range,
mouse_directx_set_speed,
mouse_directx_get_mickeys,
- NULL // AL_METHOD(int, analyse_data, (AL_CONST char *buffer, int size));
+ NULL, // AL_METHOD(int, analyse_data, (AL_CONST char *buffer, int size));
+ NULL // AL_METHOD(void, enable_mouse_mickeys, (AL_CONST int mode));
};
diff -ur allegro/src/x/xmouse.c alleg_work/src/x/xmouse.c
--- allegro/src/x/xmouse.c 2004-08-27 15:54:06.000000000 +0200
+++ alleg_work/src/x/xmouse.c 2004-09-06 19:30:09.000000000 +0200
@@ -64,7 +64,8 @@
_xwin_mousedrv_set_range,
_xwin_mousedrv_set_speed,
_xwin_mousedrv_get_mickeys,
- NULL
+ NULL,
+ _xwin_set_warped_mouse_mode
};
@@ -152,8 +153,6 @@
mymickey_x = mymickey_y = 0;
XUNLOCK();
-
- _xwin_set_warped_mouse_mode(FALSE);
}
@@ -206,7 +205,5 @@
*mickeyx = temp_x;
*mickeyy = temp_y;
-
- _xwin_set_warped_mouse_mode(TRUE);
}
diff -ur allegro/src/x/xwin.c alleg_work/src/x/xwin.c
--- allegro/src/x/xwin.c 2004-09-03 11:30:45.000000000 +0200
+++ alleg_work/src/x/xwin.c 2004-09-06 19:18:07.000000000 +0200
@@ -73,7 +73,6 @@
#endif
None, /* cursor */
XC_heart, /* cursor_shape */
- 1, /* hw_cursor_ok */
0, /* screen_to_buffer */
0, /* set_colors */
@@ -95,6 +94,8 @@
320, /* virtual width */
200, /* virtual_height */
+
+ 0, /* fullscreen */
0, /* mouse_warped */
{ 0 }, /* keycode_to_scancode */
@@ -422,9 +423,6 @@
#ifdef ALLEGRO_XWINDOWS_WITH_XCURSOR
/* Detect if ARGB cursors are supported */
_xwin.support_argb_cursor = XcursorSupportsARGB(_xwin.display);
- _xwin.hw_cursor_ok = 1;
-#else
- _xwin.hw_cursor_ok = 0;
#endif
return 0;
@@ -705,6 +703,14 @@
_xwin.screen_depth = depth;
_xwin.virtual_width = vw;
_xwin.virtual_height = vh;
+ _xwin.fullscreen = fullscreen;
+ if (fullscreen) {
+ /* Mouse warp mode is the default in fullscreen mode */
+ _xwin.mouse_warped = 1;
+ }
+ else {
+ _xwin.mouse_warped = 0;
+ }
#ifdef ALLEGRO_XWINDOWS_WITH_XF86VIDMODE
if (fullscreen) {
@@ -1616,8 +1622,8 @@
return -1;
}
- /* Hardware cursor is disabled (mickey mode) */
- if (!_xwin.hw_cursor_ok) {
+ /* Hardware cursor is disabled (mickey mode) */
+ if (_xwin.mouse_warped) {
return -1;
}
@@ -2364,24 +2370,6 @@
if (_xwin.display == 0)
return;
- /* Switch mouse to non-warped mode if mickeys were not used recently (~2 seconds). */
- if (_xwin.mouse_warped && (_xwin.mouse_warped++ > MOUSE_WARP_DELAY)) {
- _xwin.mouse_warped = 0;
- /* Move X-cursor to Allegro cursor. */
- XWarpPointer(_xwin.display, _xwin.window, _xwin.window,
- 0, 0, _xwin.window_width, _xwin.window_height,
- _mouse_x - (_xwin_mouse_extended_range ? _xwin.scroll_x : 0),
- _mouse_y - (_xwin_mouse_extended_range ? _xwin.scroll_y : 0));
- /* Re-enable hardware cursor */
- _xwin.hw_cursor_ok = 1;
-#ifdef ALLEGRO_XWINDOWS_WITH_XCURSOR
- if (_xwin.support_argb_cursor && (_xwin.xcursor_image != None) && is_same_bitmap(_mouse_screen, screen)) {
- show_mouse(_mouse_screen);
- }
-#endif
-
- }
-
/* Flush X-buffers. */
_xwin_private_flush_buffers();
@@ -2451,15 +2439,16 @@
*/
static void _xwin_private_set_warped_mouse_mode(int permanent)
{
- _xwin.mouse_warped = ((permanent) ? 1 : (MOUSE_WARP_DELAY*7/8));
+ _xwin.mouse_warped = permanent;
+
+ if (!permanent) {
+ /* Move X-cursor to Allegro cursor. */
+ XWarpPointer(_xwin.display, _xwin.window, _xwin.window,
+ 0, 0, _xwin.window_width, _xwin.window_height,
+ _mouse_x - (_xwin_mouse_extended_range ? _xwin.scroll_x : 0),
+ _mouse_y - (_xwin_mouse_extended_range ? _xwin.scroll_y : 0));
- /* Disable hardware cursor in warp mode */
-#ifdef ALLEGRO_XWINDOWS_WITH_XCURSOR
- if (_xwin.hw_cursor_ok && permanent && _xwin.support_argb_cursor && (_xwin.xcursor_image != None) && is_same_bitmap(_mouse_screen, screen)) {
- show_mouse(_mouse_screen);
}
-#endif
- _xwin.hw_cursor_ok = !permanent;
}
void _xwin_set_warped_mouse_mode(int permanent)