comparison 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
comparison
equal deleted inserted replaced
2939:084e5b4fc5be 2940:b93965a16fe0
22 #include "SDL_config.h" 22 #include "SDL_config.h"
23 23
24 #include "SDL_syswm.h" 24 #include "SDL_syswm.h"
25 #include "../SDL_sysvideo.h" 25 #include "../SDL_sysvideo.h"
26 #include "../../events/SDL_keyboard_c.h" 26 #include "../../events/SDL_keyboard_c.h"
27 #include "../../events/SDL_mouse_c.h"
27 28
28 #include "SDL_x11video.h" 29 #include "SDL_x11video.h"
30 #include "SDL_x11mouse.h"
29 #include "../Xext/extensions/StdCmap.h" 31 #include "../Xext/extensions/StdCmap.h"
30 32
31 static void 33 static void
32 X11_GetDisplaySize(_THIS, SDL_Window * window, int *w, int *h) 34 X11_GetDisplaySize(_THIS, SDL_Window * window, int *w, int *h)
33 { 35 {
170 int x, y; 172 int x, y;
171 Window w; 173 Window w;
172 XSizeHints *sizehints; 174 XSizeHints *sizehints;
173 XWMHints *wmhints; 175 XWMHints *wmhints;
174 XClassHint *classhints; 176 XClassHint *classhints;
175 extern XEventClass SDL_XEvents[];
176 extern int SDL_NumOfXEvents;
177 177
178 #if SDL_VIDEO_DRIVER_X11_XINERAMA 178 #if SDL_VIDEO_DRIVER_X11_XINERAMA
179 /* FIXME 179 /* FIXME
180 if ( use_xinerama ) { 180 if ( use_xinerama ) {
181 x = xinerama_info.x_org; 181 x = xinerama_info.x_org;
521 PropertyChangeMask | StructureNotifyMask | 521 PropertyChangeMask | StructureNotifyMask |
522 KeymapStateMask)); 522 KeymapStateMask));
523 } 523 }
524 #endif 524 #endif
525 525
526 #if SDL_VIDEO_DRIVER_X11_XINPUT
526 /* we're informing the display what extension events we want to receive from it */ 527 /* we're informing the display what extension events we want to receive from it */
527 XSelectExtensionEvent(data->display, w, SDL_XEvents, SDL_NumOfXEvents); 528 {
529 int i, j, n = 0;
530 XEventClass xevents[256];
531
532 for (i = 0; i < SDL_GetNumMice(); ++i) {
533 SDL_Mouse *mouse;
534 X11_MouseData *data;
535
536 mouse = SDL_GetMouse(i);
537 data = (X11_MouseData *)mouse->driverdata;
538 if (!data) {
539 continue;
540 }
541
542 for (j = 0; j < data->num_xevents; ++j) {
543 xevents[n++] = data->xevents[j];
544 }
545 }
546 if (n > 0) {
547 XSelectExtensionEvent(data->display, w, xevents, n);
548 }
549 }
550 #endif
528 551
529 return 0; 552 return 0;
530 } 553 }
531 554
532 int 555 int