Mercurial > sdl-ios-xcode
diff src/video/x11/SDL_x11window.c @ 2940:b93965a16fe0
Fixed X11 mouse motion/button events - it's not actually safe to cast mouse events to device events.
Fixed building SDL without XInput support
Simplified the process of registering a mouse device
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Thu, 01 Jan 2009 07:59:08 +0000 |
parents | e705adf6f3dc |
children | 1e431c2631ee |
line wrap: on
line diff
--- a/src/video/x11/SDL_x11window.c Thu Jan 01 07:58:20 2009 +0000 +++ b/src/video/x11/SDL_x11window.c Thu Jan 01 07:59:08 2009 +0000 @@ -24,8 +24,10 @@ #include "SDL_syswm.h" #include "../SDL_sysvideo.h" #include "../../events/SDL_keyboard_c.h" +#include "../../events/SDL_mouse_c.h" #include "SDL_x11video.h" +#include "SDL_x11mouse.h" #include "../Xext/extensions/StdCmap.h" static void @@ -172,8 +174,6 @@ XSizeHints *sizehints; XWMHints *wmhints; XClassHint *classhints; - extern XEventClass SDL_XEvents[]; - extern int SDL_NumOfXEvents; #if SDL_VIDEO_DRIVER_X11_XINERAMA /* FIXME @@ -523,8 +523,31 @@ } #endif +#if SDL_VIDEO_DRIVER_X11_XINPUT /* we're informing the display what extension events we want to receive from it */ - XSelectExtensionEvent(data->display, w, SDL_XEvents, SDL_NumOfXEvents); + { + int i, j, n = 0; + XEventClass xevents[256]; + + for (i = 0; i < SDL_GetNumMice(); ++i) { + SDL_Mouse *mouse; + X11_MouseData *data; + + mouse = SDL_GetMouse(i); + data = (X11_MouseData *)mouse->driverdata; + if (!data) { + continue; + } + + for (j = 0; j < data->num_xevents; ++j) { + xevents[n++] = data->xevents[j]; + } + } + if (n > 0) { + XSelectExtensionEvent(data->display, w, xevents, n); + } + } +#endif return 0; }