diff src/video/x11/SDL_x11events.c @ 4465:3e69e077cb95

Removed multi-mouse / multi-keyboard support in anticipation of a real multi-mouse and multi-touch API. Plus, this lets me start implementing cursor support.
author Sam Lantinga <slouken@libsdl.org>
date Sun, 09 May 2010 20:47:22 -0700
parents faa9fc8e7f67
children 791b3256fb22
line wrap: on
line diff
--- a/src/video/x11/SDL_x11events.c	Sun May 09 19:55:28 2010 -0700
+++ b/src/video/x11/SDL_x11events.c	Sun May 09 20:47:22 2010 -0700
@@ -23,12 +23,14 @@
 
 #include <sys/types.h>
 #include <sys/time.h>
+#include <signal.h>
 #include <unistd.h>
 
 #include "SDL_x11video.h"
 #include "../../events/SDL_events_c.h"
 #include "../../events/SDL_mouse_c.h"
 
+#include "SDL_timer.h"
 #include "SDL_syswm.h"
 
 static void
@@ -93,13 +95,7 @@
             if (xevent.xcrossing.mode == NotifyUngrab)
                 printf("Mode: NotifyUngrab\n");
 #endif
-#if 1
-            /* FIXME: Should we reset data for all mice? */
-            for (i = 0; i < SDL_GetNumMice(); ++i) {
-                SDL_Mouse *mouse = SDL_GetMouse(i);
-                SDL_SetMouseFocus(mouse->id, data->window);
-            }
-#endif
+            SDL_SetMouseFocus(data->window);
         }
         break;
 
@@ -116,13 +112,7 @@
                 printf("Mode: NotifyUngrab\n");
 #endif
             if (xevent.xcrossing.detail != NotifyInferior) {
-#if 1
-                /* FIXME: Should we reset data for all mice? */
-	        for (i = 0; i < SDL_GetNumMice(); ++i) {
-		    SDL_Mouse *mouse = SDL_GetMouse(i);
-		    SDL_SetMouseFocus(mouse->id, 0);
-	        }
-#endif
+                SDL_SetMouseFocus(NULL);
             }
         }
         break;
@@ -132,7 +122,7 @@
 #ifdef DEBUG_XEVENTS
             printf("FocusIn!\n");
 #endif
-            SDL_SetKeyboardFocus(videodata->keyboard, data->window);
+            SDL_SetKeyboardFocus(data->window);
 #ifdef X_HAVE_UTF8_STRING
             if (data->ic) {
                 XSetICFocus(data->ic);
@@ -146,7 +136,7 @@
 #ifdef DEBUG_XEVENTS
             printf("FocusOut!\n");
 #endif
-            SDL_SetKeyboardFocus(videodata->keyboard, 0);
+            SDL_SetKeyboardFocus(NULL);
 #ifdef X_HAVE_UTF8_STRING
             if (data->ic) {
                 XUnsetICFocus(data->ic);
@@ -185,8 +175,7 @@
 #ifdef DEBUG_XEVENTS
             printf("KeyPress (X11 keycode = 0x%X)\n", xevent.xkey.keycode);
 #endif
-            SDL_SendKeyboardKey(videodata->keyboard, SDL_PRESSED,
-                                videodata->key_layout[keycode]);
+            SDL_SendKeyboardKey(SDL_PRESSED, videodata->key_layout[keycode]);
 #if 0
             if (videodata->key_layout[keycode] == SDLK_UNKNOWN) {
                 int min_keycode, max_keycode;
@@ -210,7 +199,7 @@
             XLookupString(&xevent.xkey, text, sizeof(text), &keysym, NULL);
 #endif
             if (*text) {
-                SDL_SendKeyboardText(videodata->keyboard, text);
+                SDL_SendKeyboardText(text);
             }
         }
         break;
@@ -222,8 +211,7 @@
 #ifdef DEBUG_XEVENTS
             printf("KeyRelease (X11 keycode = 0x%X)\n", xevent.xkey.keycode);
 #endif
-            SDL_SendKeyboardKey(videodata->keyboard, SDL_RELEASED,
-                                videodata->key_layout[keycode]);
+            SDL_SendKeyboardKey(SDL_RELEASED, videodata->key_layout[keycode]);
         }
         break;
 
@@ -280,79 +268,25 @@
         }
         break;
 
-    default:{
-            for (i = 0; i < SDL_GetNumMice(); ++i) {
-                SDL_Mouse *mouse;
-#if SDL_VIDEO_DRIVER_X11_XINPUT
-                X11_MouseData *data;
-#endif
-
-                mouse = SDL_GetMouse(i);
-                if (!mouse->driverdata) {
-                    switch (xevent.type) {
-                    case MotionNotify:
-#ifdef DEBUG_MOTION
-                        printf("X11 motion: %d,%d\n", xevent.xmotion.x,
-                               xevent.xmotion.y);
-#endif
-                        SDL_SendMouseMotion(mouse->id, 0, xevent.xmotion.x,
-                                            xevent.xmotion.y, 0);
-                        break;
-
-                    case ButtonPress:
-                        SDL_SendMouseButton(mouse->id, SDL_PRESSED,
-                                            xevent.xbutton.button);
-                        break;
-
-                    case ButtonRelease:
-                        SDL_SendMouseButton(mouse->id, SDL_RELEASED,
-                                            xevent.xbutton.button);
-                        break;
-                    }
-                    continue;
-                }
-#if SDL_VIDEO_DRIVER_X11_XINPUT
-                data = (X11_MouseData *) mouse->driverdata;
-                if (xevent.type == data->motion) {
-                    XDeviceMotionEvent *move =
-                        (XDeviceMotionEvent *) & xevent;
+    case MotionNotify:{
 #ifdef DEBUG_MOTION
-                    printf("X11 motion: %d,%d\n", move->x, move->y);
+            printf("X11 motion: %d,%d\n", xevent.xmotion.x, xevent.xmotion.y);
 #endif
-                    SDL_SendMouseMotion(move->deviceid, 0, move->x, move->y,
-                                        move->axis_data[2]);
-                    return;
-                }
-                if (xevent.type == data->button_pressed) {
-                    XDeviceButtonPressedEvent *pressed =
-                        (XDeviceButtonPressedEvent *) & xevent;
-                    SDL_SendMouseButton(pressed->deviceid, SDL_PRESSED,
-                                        pressed->button);
-                    return;
-                }
-                if (xevent.type == data->button_released) {
-                    XDeviceButtonReleasedEvent *released =
-                        (XDeviceButtonReleasedEvent *) & xevent;
-                    SDL_SendMouseButton(released->deviceid, SDL_RELEASED,
-                                        released->button);
-                    return;
-                }
-                if (xevent.type == data->proximity_in) {
-                    XProximityNotifyEvent *proximity =
-                        (XProximityNotifyEvent *) & xevent;
-                    SDL_SendProximity(proximity->deviceid, proximity->x,
-                                      proximity->y, SDL_PROXIMITYIN);
-                    return;
-                }
-                if (xevent.type == data->proximity_out) {
-                    XProximityNotifyEvent *proximity =
-                        (XProximityNotifyEvent *) & xevent;
-                    SDL_SendProximity(proximity->deviceid, proximity->x,
-                                      proximity->y, SDL_PROXIMITYOUT);
-                    return;
-                }
-#endif
-            }
+            SDL_SendMouseMotion(0, xevent.xmotion.x, xevent.xmotion.y);
+        }
+        break;
+
+    case ButtonPress:{
+            SDL_SendMouseButton(SDL_PRESSED, xevent.xbutton.button);
+        }
+        break;
+
+    case ButtonRelease:{
+            SDL_SendMouseButton(SDL_RELEASED, xevent.xbutton.button);
+        }
+        break;
+
+    default:{
 #ifdef DEBUG_XEVENTS
             printf("Unhandled event %d\n", xevent.type);
 #endif