Removed unneccesary code lines. Fixed mousename bug. Added lacking code in mousebutton
1.1 --- a/include/SDL_mouse.h Mon Aug 25 17:34:58 2008 +0000
1.2 +++ b/include/SDL_mouse.h Mon Aug 25 18:02:14 2008 +0000
1.3 @@ -55,6 +55,17 @@
1.4 extern DECLSPEC int SDLCALL SDL_GetNumMice(void);
1.5
1.6 /**
1.7 + * \fn char* SDL_GetMouseName(int index)
1.8 + *
1.9 + * \brief Gets the name of a mouse with the given index.
1.10 + *
1.11 + * \param index is the index of the mouse, which name is to be returned.
1.12 + *
1.13 + * \return the name of the mouse with the specified index
1.14 + */
1.15 +extern DECLSPEC char *SDLCALL SDL_GetMouseName(int index);
1.16 +
1.17 +/**
1.18 * \fn int SDL_SelectMouse(int index)
1.19 *
1.20 * \brief Set the index of the currently selected mouse.
1.21 @@ -206,13 +217,35 @@
1.22 Button 3: Right mouse button
1.23 */
1.24
1.25 -/* FIXME: Where do these functions go in this header?
1.26 - Also, add doxygen documentation for these...
1.27 -*/
1.28 -extern DECLSPEC char *SDLCALL SDL_GetMouseName(int index);
1.29 -
1.30 +/**
1.31 + * \fn int SDL_GetCursorsNumber(int index)
1.32 + *
1.33 + * \brief Gets the number of cursors a pointing device supports.
1.34 + * Useful for tablet users. Useful only under Windows.
1.35 + *
1.36 + * \param index is the index of the pointing device, which number of cursors we
1.37 + * want to receive.
1.38 + *
1.39 + * \return the number of cursors supported by the pointing device. On Windows
1.40 + * if a device is a tablet it returns a number >=1. Normal mice always return 1.
1.41 + * On Linux every device reports one cursor.
1.42 + */
1.43 extern DECLSPEC int SDLCALL SDL_GetCursorsNumber(int index);
1.44
1.45 +/**
1.46 + * \fn int SDL_GetCurrentCursor(int index)
1.47 + *
1.48 + * \brief Returns the index of the current cursor used by a specific pointing
1.49 + * device. Useful only under Windows.
1.50 + *
1.51 + * \param index is the index of the pointing device, which cursor index we want
1.52 + * to receive.
1.53 + *
1.54 + * \return the index of the cursor currently used by a specific pointing device.
1.55 + * Always 0 under Linux. On Windows if the device isn't a tablet it returns 0.
1.56 + * If the device is the tablet it returns the cursor index.
1.57 + * 0 - stylus, 1 - eraser, 2 - cursor.
1.58 + */
1.59 extern DECLSPEC int SDLCALL SDL_GetCurrentCursor(int index);
1.60
1.61 #define SDL_BUTTON(X) (1 << ((X)-1))
2.1 --- a/src/events/SDL_mouse.c Mon Aug 25 17:34:58 2008 +0000
2.2 +++ b/src/events/SDL_mouse.c Mon Aug 25 18:02:14 2008 +0000
2.3 @@ -116,8 +116,8 @@
2.4 /* we're setting the mouse properties */
2.5 length = 0;
2.6 length = SDL_strlen(name);
2.7 - SDL_mice[index]->name = SDL_malloc((length + 1) * sizeof(char));
2.8 - SDL_strlcpy(SDL_mice[index]->name, name, length);
2.9 + SDL_mice[index]->name = SDL_malloc((length + 2) * sizeof(char));
2.10 + SDL_strlcpy(SDL_mice[index]->name, name, length+1);
2.11 SDL_mice[index]->pressure_max = pressure_max;
2.12 SDL_mice[index]->pressure_min = pressure_min;
2.13 SDL_mice[index]->cursor_shown = SDL_TRUE;
2.14 @@ -512,6 +512,10 @@
2.15 mouse->buttonstate |= SDL_BUTTON(button);
2.16 break;
2.17 case SDL_RELEASED:
2.18 + if(!(mouse->buttonstate & SDL_BUTTON(button))) {
2.19 + /* Ignore this event, no state change */
2.20 + return 0;
2.21 + }
2.22 type = SDL_MOUSEBUTTONUP;
2.23 mouse->buttonstate &= ~SDL_BUTTON(button);
2.24 break;
3.1 --- a/src/video/x11/SDL_x11window.c Mon Aug 25 17:34:58 2008 +0000
3.2 +++ b/src/video/x11/SDL_x11window.c Mon Aug 25 18:02:14 2008 +0000
3.3 @@ -483,7 +483,6 @@
3.4 Uint32 fevent = 0;
3.5 pXGetICValues(((SDL_WindowData *) window->driverdata)->ic,
3.6 XNFilterEvents, &fevent, NULL);
3.7 - XMapWindow(data->display, w);
3.8 XSelectInput(data->display, w,
3.9 (FocusChangeMask | EnterWindowMask | LeaveWindowMask |
3.10 ExposureMask | ButtonPressMask | ButtonReleaseMask |
3.11 @@ -492,13 +491,14 @@
3.12 KeymapStateMask | fevent));
3.13 }
3.14 #else
3.15 - XMapWindow(data->display, w);
3.16 - XSelectInput(data->display, w,
3.17 + {
3.18 + XSelectInput(data->display, w,
3.19 (FocusChangeMask | EnterWindowMask | LeaveWindowMask |
3.20 ExposureMask | ButtonPressMask | ButtonReleaseMask |
3.21 PointerMotionMask | KeyPressMask | KeyReleaseMask |
3.22 PropertyChangeMask | StructureNotifyMask |
3.23 KeymapStateMask));
3.24 + }
3.25 #endif
3.26
3.27 /* we're informing the display what extension events we want to receive from it */