http://wilku.ravenlord.ws/doku.php?id=documentation for information how things work. Currently implemented: detecting many pointing devices and pressure detection. Still a bug. Each program has to be comipled with a flag -lXi gsoc2008_manymouse
authorSzymon Wilczek <kazeuser@gmail.com>
Fri, 06 Jun 2008 15:23:29 +0000
branchgsoc2008_manymouse
changeset 3760 64f346a83ed3
parent 3759 064c178558b7
child 3761 e0c95ad1ba87
http://wilku.ravenlord.ws/doku.php?id=documentation for information how things work. Currently implemented: detecting many pointing devices and pressure detection. Still a bug. Each program has to be comipled with a flag -lXi
configure.in
include/SDL_events.h
include/SDL_keysym.h
include/SDL_mouse.h
src/events/SDL_mouse.c
src/events/SDL_mouse_c.h
src/video/x11/SDL_x11dyn.h
src/video/x11/SDL_x11events.c
src/video/x11/SDL_x11mouse.c
src/video/x11/SDL_x11sym.h
src/video/x11/SDL_x11video.c
src/video/x11/SDL_x11video.h
src/video/x11/SDL_x11window.c
--- a/configure.in	Fri Jun 06 14:50:56 2008 +0000
+++ b/configure.in	Fri Jun 06 15:23:29 2008 +0000
@@ -1055,7 +1055,7 @@
                 AC_DEFINE_UNQUOTED(SDL_VIDEO_DRIVER_X11_DYNAMIC_XEXT, "$x11ext_lib")
             else
                 enable_x11_shared=no
-                EXTRA_LDFLAGS="$EXTRA_LDFLAGS $X_LIBS -lX11 -lXext"
+                EXTRA_LDFLAGS="$EXTRA_LDFLAGS $X_LIBS -lX11 -lXext -lXi"
             fi
             have_video=yes
 
--- a/include/SDL_events.h	Fri Jun 06 14:50:56 2008 +0000
+++ b/include/SDL_events.h	Fri Jun 06 15:23:29 2008 +0000
@@ -170,6 +170,7 @@
     Uint8 state;            /**< The current button state */
     int x;                  /**< X coordinate, relative to window */
     int y;                  /**< Y coordinate, relative to window */
+    int z;
     int xrel;               /**< The relative motion in the X direction */
     int yrel;               /**< The relative motion in the Y direction */
     SDL_WindowID windowID;  /**< The window with mouse focus, if any */
--- a/include/SDL_keysym.h	Fri Jun 06 14:50:56 2008 +0000
+++ b/include/SDL_keysym.h	Fri Jun 06 15:23:29 2008 +0000
@@ -242,7 +242,7 @@
     SDLK_KBDILLUMDOWN = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KBDILLUMDOWN),
     SDLK_KBDILLUMUP = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KBDILLUMUP),
     SDLK_EJECT = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_EJECT),
-    SDLK_SLEEP = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_SLEEP),
+    SDLK_SLEEP = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_SLEEP)
 };
 
 /**
--- a/include/SDL_mouse.h	Fri Jun 06 14:50:56 2008 +0000
+++ b/include/SDL_mouse.h	Fri Jun 06 15:23:29 2008 +0000
@@ -203,6 +203,11 @@
    Button 2:	Middle mouse button
    Button 3:	Right mouse button
  */
+
+extern DECLSPEC int SDLCALL SDL_GetNumOfMice(void);
+
+extern DECLSPEC char* SDLCALL SDL_GetMouseName(int index);
+
 #define SDL_BUTTON(X)		(1 << ((X)-1))
 #define SDL_BUTTON_LEFT		1
 #define SDL_BUTTON_MIDDLE	2
--- a/src/events/SDL_mouse.c	Fri Jun 06 14:50:56 2008 +0000
+++ b/src/events/SDL_mouse.c	Fri Jun 06 15:23:29 2008 +0000
@@ -31,6 +31,8 @@
 static int SDL_num_mice;
 static int SDL_current_mouse;
 static SDL_Mouse **SDL_mice;
+int *SDL_IdIndex;
+int SDL_highestId;
 
 
 /* Public functions */
@@ -50,11 +52,11 @@
 }
 
 int
-SDL_AddMouse(const SDL_Mouse * mouse, int index)
+SDL_AddMouse(const SDL_Mouse * mouse, int index, char* name)
 {
     SDL_Mouse **mice;
     int selected_mouse;
-
+    char* temp_name;
     /* Add the mouse to the list of mice */
     if (index < 0 || index >= SDL_num_mice || SDL_mice[index]) {
         mice =
@@ -74,8 +76,8 @@
         return -1;
     }
     *SDL_mice[index] = *mouse;
-
-    /* Create the default cursor for the mouse */
+    SDL_mice[index]->name=SDL_malloc(strlen(name)*sizeof(char));
+    strcpy(SDL_mice[index]->name,name);
     SDL_mice[index]->cursor_shown = SDL_TRUE;
     selected_mouse = SDL_SelectMouse(index);
     SDL_mice[index]->cur_cursor = NULL;
@@ -98,6 +100,7 @@
     }
 
     mouse->def_cursor = NULL;
+    SDL_free(mouse->name);
     while (mouse->cursors) {
         SDL_FreeCursor(mouse->cursors);
     }
@@ -266,8 +269,9 @@
 }
 
 void
-SDL_SetMouseFocus(int index, SDL_WindowID windowID)
+SDL_SetMouseFocus(int id, SDL_WindowID windowID)
 {
+    int index = SDL_GetIndexById(id);
     SDL_Mouse *mouse = SDL_GetMouse(index);
     int i;
     SDL_bool focus;
@@ -315,8 +319,9 @@
 }
 
 int
-SDL_SendMouseMotion(int index, int relative, int x, int y)
+SDL_SendMouseMotion(int id, int relative, int x, int y,int z)
 {
+    int index=SDL_GetIndexById(id);
     SDL_Mouse *mouse = SDL_GetMouse(index);
     int posted;
     int xrel;
@@ -352,6 +357,7 @@
     }
     mouse->xdelta += xrel;
     mouse->ydelta += yrel;
+    mouse->z=z;
 
     /* Move the mouse cursor, if needed */
     if (mouse->cursor_shown && !mouse->relative_mode &&
@@ -368,6 +374,7 @@
         event.motion.state = mouse->buttonstate;
         event.motion.x = mouse->x;
         event.motion.y = mouse->y;
+        event.motion.z = mouse->z;
         event.motion.xrel = xrel;
         event.motion.yrel = yrel;
         event.motion.windowID = mouse->focus;
@@ -377,8 +384,9 @@
 }
 
 int
-SDL_SendMouseButton(int index, Uint8 state, Uint8 button)
+SDL_SendMouseButton(int id, Uint8 state, Uint8 button)
 {
+    int index=SDL_GetIndexById(id);
     SDL_Mouse *mouse = SDL_GetMouse(index);
     int posted;
     Uint8 type;
@@ -398,10 +406,10 @@
         mouse->buttonstate |= SDL_BUTTON(button);
         break;
     case SDL_RELEASED:
-        if (!(mouse->buttonstate & SDL_BUTTON(button))) {
-            /* Ignore this event, no state change */
-            return 0;
-        }
+        //if (!(mouse->buttonstate & SDL_BUTTON(button))) {
+        //    /* Ignore this event, no state change */
+        //    return 0;
+        //}*/
         type = SDL_MOUSEBUTTONUP;
         mouse->buttonstate &= ~SDL_BUTTON(button);
         break;
@@ -463,7 +471,7 @@
         mouse->WarpMouse(mouse, windowID, x, y);
     } else {
         SDL_SetMouseFocus(SDL_current_mouse, windowID);
-        SDL_SendMouseMotion(SDL_current_mouse, 0, x, y);
+        SDL_SendMouseMotion(SDL_current_mouse, 0, x, y,0);
     }
 }
 
@@ -649,4 +657,54 @@
     return shown;
 }
 
+void SDL_SetIndexId(int id, int index)
+{
+    if(id>SDL_highestId)
+    {
+        int *indexes;
+        indexes =
+            (int*) SDL_realloc(SDL_IdIndex,
+                                       (id + 1) * sizeof(int));
+        if (!indexes) {
+            SDL_OutOfMemory();
+            return -1;
+        }
+        SDL_IdIndex=indexes;
+        SDL_IdIndex[id]=index;
+        SDL_highestId=id;
+    }
+    else
+    {
+        SDL_IdIndex[id]=index;
+    }
+}
+
+int SDL_GetIndexById(int id)
+{
+    if(id>SDL_highestId)
+    {
+        return -1;
+    }
+    else
+    {
+        return SDL_IdIndex[id];
+    }
+}
+
+int SDL_GetNumOfMice(void)
+{
+    return SDL_num_mice;
+}
+
+char* SDL_GetMouseName(int index)
+{
+    SDL_Mouse* mouse = SDL_GetMouse(index);
+    if(!mouse)
+    {
+        return NULL;
+    }
+    return mouse->name;
+}
+
+
 /* vi: set ts=4 sw=4 expandtab: */
--- a/src/events/SDL_mouse_c.h	Fri Jun 06 14:50:56 2008 +0000
+++ b/src/events/SDL_mouse_c.h	Fri Jun 06 15:23:29 2008 +0000
@@ -58,10 +58,13 @@
 
     /* Data common to all mice */
     SDL_WindowID focus;
+    int which;
     int x;
     int y;
+    int z;
     int xdelta;
     int ydelta;
+    char* name;
     Uint8 buttonstate;
     SDL_bool relative_mode;
     SDL_bool flush_motion;
@@ -84,7 +87,7 @@
 /* Add a mouse, possibly reattaching at a particular index (or -1),
    returning the index of the mouse, or -1 if there was an error.
  */
-extern int SDL_AddMouse(const SDL_Mouse * mouse, int index);
+extern int SDL_AddMouse(const SDL_Mouse * mouse, int index, char* name);
 
 /* Remove a mouse at an index, clearing the slot for later */
 extern void SDL_DelMouse(int index);
@@ -96,7 +99,7 @@
 extern void SDL_SetMouseFocus(int index, SDL_WindowID windowID);
 
 /* Send a mouse motion event for a mouse at an index */
-extern int SDL_SendMouseMotion(int index, int relative, int x, int y);
+extern int SDL_SendMouseMotion(int index, int relative, int x, int y, int z);
 
 /* Send a mouse button event for a mouse at an index */
 extern int SDL_SendMouseButton(int index, Uint8 state, Uint8 button);
@@ -107,6 +110,16 @@
 /* Shutdown the mouse subsystem */
 extern void SDL_MouseQuit(void);
 
+extern int SDL_GetIndexById(int id);
+
+extern void SDL_SetIndexId(int id, int index);
+
+extern int SDL_GetNumOfMice(void);
+
+extern char* SDL_GetMouseName(int index);
+
+
+
 #endif /* _SDL_mouse_c_h */
 
 /* vi: set ts=4 sw=4 expandtab: */
--- a/src/video/x11/SDL_x11dyn.h	Fri Jun 06 14:50:56 2008 +0000
+++ b/src/video/x11/SDL_x11dyn.h	Fri Jun 06 15:23:29 2008 +0000
@@ -29,7 +29,7 @@
 #include <X11/Xatom.h>
 #include <X11/Xlibint.h>
 #include <X11/Xproto.h>
-
+//#include <X11/extensions/XInput.h>
 #include "../Xext/extensions/Xext.h"
 #include "../Xext/extensions/extutil.h"
 
--- a/src/video/x11/SDL_x11events.c	Fri Jun 06 14:50:56 2008 +0000
+++ b/src/video/x11/SDL_x11events.c	Fri Jun 06 15:23:29 2008 +0000
@@ -29,13 +29,16 @@
 #include "SDL_x11video.h"
 #include "../../events/SDL_events_c.h"
 
+//XEventClass *SDL_XEvents;
+//int SDL_numOfEvents;
+
 static void
 X11_DispatchEvent(_THIS)
 {
     SDL_VideoData *videodata = (SDL_VideoData *) _this->driverdata;
     SDL_WindowData *data;
     XEvent xevent;
-    int i;
+    int i,z;
 
     SDL_zero(xevent);           /* valgrind fix. --ryan. */
     XNextEvent(videodata->display, &xevent);
@@ -91,9 +94,10 @@
 #endif
             if ((xevent.xcrossing.mode != NotifyGrab) &&
                 (xevent.xcrossing.mode != NotifyUngrab)) {
-                SDL_SetMouseFocus(videodata->mouse, data->windowID);
-                SDL_SendMouseMotion(videodata->mouse, 0, xevent.xcrossing.x,
-                                    xevent.xcrossing.y);
+			    XDeviceMotionEvent* move=(XDeviceMotionEvent*)&xevent;
+                SDL_SetMouseFocus(move->deviceid, data->windowID);
+                SDL_SendMouseMotion(move->deviceid, 0, move->x,
+                                    move->y,move->axis_data[2]);
             }
         }
         break;
@@ -111,9 +115,10 @@
             if ((xevent.xcrossing.mode != NotifyGrab) &&
                 (xevent.xcrossing.mode != NotifyUngrab) &&
                 (xevent.xcrossing.detail != NotifyInferior)) {
-                SDL_SendMouseMotion(videodata->mouse, 0,
-                                    xevent.xcrossing.x, xevent.xcrossing.y);
-                SDL_SetMouseFocus(videodata->mouse, 0);
+			    XDeviceMotionEvent* move=(XDeviceMotionEvent*)&xevent;
+                SDL_SendMouseMotion(move->deviceid, 0,
+                                    move->x, move->y,move->axis_data[2]);
+                SDL_SetMouseFocus(move->deviceid, 0);
             }
         }
         break;
@@ -167,26 +172,30 @@
         break;
 
         /* Mouse motion? */
-    case MotionNotify:{
+    case 103:{ //MotionNotify
 #ifdef DEBUG_MOTION
             printf("X11 motion: %d,%d\n", xevent.xmotion.x, xevent.xmotion.y);
 #endif
-            SDL_SendMouseMotion(videodata->mouse, 0, xevent.xmotion.x,
-                                xevent.xmotion.y);
+			XDeviceMotionEvent* move=(XDeviceMotionEvent*)&xevent;
+            SDL_SendMouseMotion(move->deviceid, 0, move->x,
+                                move->y,move->axis_data[2]);
         }
         break;
+    /*case MotionNotify:{
 
         /* Mouse button press? */
-    case ButtonPress:{
-            SDL_SendMouseButton(videodata->mouse, SDL_PRESSED,
-                                xevent.xbutton.button);
+    case 101:{//ButtonPress
+			XDeviceButtonPressedEvent* pressed=(XDeviceButtonPressedEvent*)&xevent;
+            SDL_SendMouseButton(pressed->deviceid, SDL_PRESSED,
+                                pressed->button);
         }
         break;
 
         /* Mouse button release? */
-    case ButtonRelease:{
-            SDL_SendMouseButton(videodata->mouse, SDL_RELEASED,
-                                xevent.xbutton.button);
+    case 102:{//ButtonRelease
+			XDeviceButtonReleasedEvent* released=(XDeviceButtonReleasedEvent*)&xevent;
+            SDL_SendMouseButton(released->deviceid, SDL_RELEASED,
+                                released->button);
         }
         break;
 
--- a/src/video/x11/SDL_x11mouse.c	Fri Jun 06 14:50:56 2008 +0000
+++ b/src/video/x11/SDL_x11mouse.c	Fri Jun 06 15:23:29 2008 +0000
@@ -28,11 +28,45 @@
 void
 X11_InitMouse(_THIS)
 {
+    extern XDevice **SDL_XDevices;
+    XDevice **newDevices;
+    int i,j,index=0, numOfDevices;
+    extern int SDL_NumOfXDevices;
+    XDeviceInfo *DevList;
+    XAnyClassPtr deviceClass;
     SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
-    SDL_Mouse mouse;
+   
+    DevList=XListInputDevices(data->display, &numOfDevices);
 
-    SDL_zero(mouse);
-    data->mouse = SDL_AddMouse(&mouse, -1);
+    for(i=0;i<numOfDevices;++i)
+    {
+        if((DevList[i].use!=IsXPointer && DevList[i].use!=IsXKeyboard))
+        {
+            deviceClass=DevList[i].inputclassinfo;
+            for(j=0;j<DevList[i].num_classes;++j)
+            {
+                if(deviceClass->class==ValuatorClass)
+                {
+                    newDevices= (XDevice**) SDL_realloc(SDL_XDevices, (index+1)*sizeof(*newDevices));
+                    if(!newDevices)
+                    {
+                        SDL_OutOfMemory();
+                        return -1;
+                    }
+                    SDL_XDevices=newDevices;
+                    SDL_XDevices[index]=XOpenDevice(data->display,DevList[i].id);
+                    SDL_Mouse mouse;
+                    SDL_zero(mouse);
+                    SDL_SetIndexId(DevList[i].id,index);
+                    data->mouse = SDL_AddMouse(&mouse, index++,DevList[i].name);
+                    break;
+                }
+                deviceClass=(XAnyClassPtr)((char*)deviceClass + deviceClass->length);
+            }
+        }
+    }
+    XFreeDeviceList(DevList);
+    SDL_NumOfXDevices=index;
 }
 
 void
@@ -40,7 +74,7 @@
 {
     SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
 
-    SDL_DelMouse(data->mouse);
+    SDL_MouseQuit();
 }
 
 /* vi: set ts=4 sw=4 expandtab: */
--- a/src/video/x11/SDL_x11sym.h	Fri Jun 06 14:50:56 2008 +0000
+++ b/src/video/x11/SDL_x11sym.h	Fri Jun 06 15:23:29 2008 +0000
@@ -144,6 +144,11 @@
 SDL_X11_SYM(SDL_X11_XESetEventToWireRetType,XESetEventToWire,(Display* a,int b,SDL_X11_XESetEventToWireRetType c),(a,b,c),return)
 SDL_X11_SYM(XExtensionErrorHandler,XSetExtensionErrorHandler,(XExtensionErrorHandler a),(a),return)
 
+/*SDL_X11_SYM(XDeviceInfo* , XListInputDevices, (Display* a, int* b), (a,b),return)
+SDL_X11_SYM(void, XFreeDeviceList, (XDeviceInfo* a), (a),)
+SDL_X11_SYM(int, XSelectExtensionEvent,(Display* a, Window b, XEventClass* c, int d),(a,b,c,d),return)
+SDL_X11_SYM(XDevice* ,XOpenDevice,(Display* a, XID b), (a,b),return)*/
+
 #if NeedWidePrototypes
 SDL_X11_SYM(KeySym,XKeycodeToKeysym,(Display* a,unsigned int b,int c),(a,b,c),return)
 #else
--- a/src/video/x11/SDL_x11video.c	Fri Jun 06 14:50:56 2008 +0000
+++ b/src/video/x11/SDL_x11video.c	Fri Jun 06 15:23:29 2008 +0000
@@ -30,6 +30,11 @@
 //#include "SDL_d3drender.h"
 //#include "SDL_gdirender.h"
 
+XDevice **SDL_XDevices;
+int SDL_NumOfXDevices;
+XEventClass SDL_XEvents[256];
+int SDL_NumOfXEvents;
+
 /* Initialization/Query functions */
 static int X11_VideoInit(_THIS);
 static void X11_VideoQuit(_THIS);
@@ -96,8 +101,8 @@
 static void
 X11_DeleteDevice(SDL_VideoDevice * device)
 {
+    int i;
     SDL_VideoData *data = (SDL_VideoData *) device->driverdata;
-
     if (data->display) {
         XCloseDisplay(data->display);
     }
@@ -212,6 +217,8 @@
 int
 X11_VideoInit(_THIS)
 {
+    int i,index=0,c_not_needed;
+    XEventClass xEvent;
     SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
 
     /* Get the window class name, usually the name of the application */
@@ -240,6 +247,72 @@
         return -1;
     }
     X11_InitMouse(_this);
+    for(i=0;i<SDL_NumOfXDevices;++i)
+    {   
+        DeviceKeyPress(SDL_XDevices[i],c_not_needed,xEvent);
+	    if (xEvent) SDL_XEvents[index++] = xEvent;
+	    DeviceKeyRelease(SDL_XDevices[i],c_not_needed,xEvent);
+	if (xEvent) SDL_XEvents[index++] = xEvent;
+
+	/* focus events */
+	DeviceFocusIn(SDL_XDevices[i],c_not_needed,xEvent);
+	if (xEvent) SDL_XEvents[index++] = xEvent;
+	DeviceFocusOut(SDL_XDevices[i],c_not_needed,xEvent);
+	if (xEvent) SDL_XEvents[index++] = xEvent;
+
+	/* button events */
+	DeviceButtonPress(SDL_XDevices[i],c_not_needed,xEvent);
+	if (xEvent) SDL_XEvents[index++] = xEvent;
+	DeviceButtonRelease(SDL_XDevices[i],c_not_needed,xEvent);
+	if (xEvent) SDL_XEvents[index++] = xEvent;
+
+	/* proximity events */
+	ProximityIn(SDL_XDevices[i],c_not_needed,xEvent);
+	if (xEvent) SDL_XEvents[index++] = xEvent;
+	ProximityOut(SDL_XDevices[i],c_not_needed,xEvent);
+	if (xEvent) SDL_XEvents[index++] = xEvent;
+
+	/* motion events */
+	DeviceMotionNotify(SDL_XDevices[i],c_not_needed,xEvent);
+	if (xEvent) SDL_XEvents[index++] = xEvent;
+
+	/* device state */
+	DeviceStateNotify(SDL_XDevices[i],c_not_needed,xEvent);
+	if (xEvent) SDL_XEvents[index++] = xEvent;
+	DeviceMappingNotify(SDL_XDevices[i],
+			c_not_needed,xEvent);
+	if (xEvent) SDL_XEvents[index++] = xEvent;
+	ChangeDeviceNotify(SDL_XDevices[i],c_not_needed,xEvent);
+	if (xEvent) SDL_XEvents[index++] = xEvent;
+
+#if 0
+	/* this cuts the motion data down - not sure if this is useful */
+	DevicePointerMotionHint(SDL_XDevices[i],
+			c_not_neededINPUTEVENT_DEVICE_POINTER_MOTION_HINT],xEvent);
+	if (xEvent) SDL_XEvents[index++] = xEvent;
+#endif
+
+	/* button motion */
+	DeviceButtonMotion(SDL_XDevices[i],
+			c_not_needed,xEvent);
+	if (xEvent) SDL_XEvents[index++] = xEvent;
+	DeviceButton1Motion(SDL_XDevices[i],
+			c_not_needed,xEvent);
+	if (xEvent) SDL_XEvents[index++] = xEvent;
+	DeviceButton2Motion(SDL_XDevices[i],
+			c_not_needed,xEvent);
+	if (xEvent) SDL_XEvents[index++] = xEvent;
+	DeviceButton3Motion(SDL_XDevices[i],
+			c_not_needed,xEvent);
+	if (xEvent) SDL_XEvents[index++] = xEvent;
+	DeviceButton4Motion(SDL_XDevices[i],
+			c_not_needed,xEvent);
+	if (xEvent) SDL_XEvents[index++] = xEvent;
+	DeviceButton5Motion(SDL_XDevices[i],
+			c_not_needed,xEvent);
+	if (xEvent) SDL_XEvents[index++] = xEvent;
+    }
+    SDL_NumOfXEvents=index;
 
     return 0;
 }
@@ -247,6 +320,8 @@
 void
 X11_VideoQuit(_THIS)
 {
+    int i;
+
     SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
 
     if (data->classname) {
@@ -263,6 +338,7 @@
     X11_QuitModes(_this);
     X11_QuitKeyboard(_this);
     X11_QuitMouse(_this);
+    free(SDL_XDevices);
 }
 
 /* vim: set ts=4 sw=4 expandtab: */
--- a/src/video/x11/SDL_x11video.h	Fri Jun 06 14:50:56 2008 +0000
+++ b/src/video/x11/SDL_x11video.h	Fri Jun 06 15:23:29 2008 +0000
@@ -29,6 +29,7 @@
 #include <X11/Xlib.h>
 #include <X11/Xutil.h>
 #include <X11/Xatom.h>
+#include <X11/extensions/XInput.h>
 
 #if SDL_VIDEO_DRIVER_X11_XINERAMA
 #include "../Xext/extensions/Xinerama.h"
@@ -68,7 +69,7 @@
     int numwindows;
     SDL_WindowData **windowlist;
     int windowlistlength;
-    int mouse;
+    int *mouse;
     int keyboard;
     Atom WM_DELETE_WINDOW;
     SDL_scancode key_layout[256];
--- a/src/video/x11/SDL_x11window.c	Fri Jun 06 14:50:56 2008 +0000
+++ b/src/video/x11/SDL_x11window.c	Fri Jun 06 15:23:29 2008 +0000
@@ -153,6 +153,8 @@
     XSizeHints *sizehints;
     XWMHints *wmhints;
     XClassHint *classhints;
+    extern XEventClass SDL_XEvents[];
+    extern int SDL_NumOfXEvents;
 
 #if SDL_VIDEO_DRIVER_X11_XINERAMA
 /* FIXME
@@ -481,20 +483,24 @@
         Uint32 fevent = 0;
         pXGetICValues(((SDL_WindowData *) window->driverdata)->ic,
                       XNFilterEvents, &fevent, NULL);
+        XMapWindow(data->display,w);
         XSelectInput(data->display, w,
                      (FocusChangeMask | EnterWindowMask | LeaveWindowMask |
                       ExposureMask | ButtonPressMask | ButtonReleaseMask |
                       PointerMotionMask | KeyPressMask | KeyReleaseMask |
                       PropertyChangeMask | StructureNotifyMask |
                       KeymapStateMask | fevent));
+    XSelectExtensionEvent(data->display, w, SDL_XEvents, SDL_NumOfXEvents);
     }
 #else
+    XMapWindow(data->display,w);
     XSelectInput(data->display, w,
                  (FocusChangeMask | EnterWindowMask | LeaveWindowMask |
                   ExposureMask | ButtonPressMask | ButtonReleaseMask |
                   PointerMotionMask | KeyPressMask | KeyReleaseMask |
                   PropertyChangeMask | StructureNotifyMask |
                   KeymapStateMask));
+    XSelectExtensionEvent(data->display, w, SDL_XEvents, SDL_NumOfXEvents);
 #endif
 
     return 0;