Further x11 code improvments + comments gsoc2008_manymouse
authorSzymon Wilczek <kazeuser@gmail.com>
Mon, 04 Aug 2008 11:18:10 +0000
branchgsoc2008_manymouse
changeset 3773 3b5691f85c0d
parent 3772 9087a84cba51
child 3774 8b5b67000dc0
Further x11 code improvments + comments
src/events/SDL_mouse_c.h
src/video/x11/SDL_x11video.c
src/video/x11/SDL_x11window.c
--- a/src/events/SDL_mouse_c.h	Sat Aug 02 17:40:49 2008 +0000
+++ b/src/events/SDL_mouse_c.h	Mon Aug 04 11:18:10 2008 +0000
@@ -56,6 +56,13 @@
     /* Free the mouse when it's time */
     void (*FreeMouse) (SDL_Mouse * mouse);
 
+    /*data common for tablets*/
+    int pressure;
+    int pressure_max;
+    int pressure_min;
+    int tilt;/*for future use*/
+    int rotation;/*for future use*/
+
     /* Data common to all mice */
     SDL_WindowID focus;
     int which;
@@ -64,11 +71,7 @@
     int z;/*for future use*/
     int xdelta;
     int ydelta;
-    int pressure;
-    int pressure_max;
-    int pressure_min;
-    int tilt;/*for future use*/
-    int rotation;/*for future use*/
+
     char* name;
     Uint8 buttonstate;
     SDL_bool relative_mode;
--- a/src/video/x11/SDL_x11video.c	Sat Aug 02 17:40:49 2008 +0000
+++ b/src/video/x11/SDL_x11video.c	Mon Aug 04 11:18:10 2008 +0000
@@ -220,7 +220,7 @@
 int
 X11_VideoInit(_THIS)
 {
-    int i,index=0,c_not_needed;
+    int i,index=0,event_code;
     XEventClass xEvent;
     SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
 
@@ -250,90 +250,46 @@
         return -1;
     }
     X11_InitMouse(_this);
+
     /*we're generating the table of events that should be recognized*/
     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;
-        button_pressed=c_not_needed;
-    }
-	DeviceButtonRelease(SDL_XDevices[i],c_not_needed,xEvent);
-	if (xEvent)
-    {
-        SDL_XEvents[index++] = xEvent;
-        button_released=c_not_needed;
-    }
+    {  
+	    /*button events*/
+	    DeviceButtonPress(SDL_XDevices[i],event_code,xEvent);
+	    if (xEvent) 
+        {
+            SDL_XEvents[index++] = xEvent;
+            button_pressed=event_code;
+        }
+	    DeviceButtonRelease(SDL_XDevices[i],event_code,xEvent);
+	    if (xEvent)
+        {
+            SDL_XEvents[index++] = xEvent;
+            button_released=event_code;
+        }
 
-	/*proximity events*/
-	ProximityIn(SDL_XDevices[i],c_not_needed,xEvent);
-	if (xEvent)
-    {
-        SDL_XEvents[index++] = xEvent;
-        proximity_in=c_not_needed;
-    }
-	ProximityOut(SDL_XDevices[i],c_not_needed,xEvent);
-	if (xEvent)
-    {
-        SDL_XEvents[index++] = xEvent;
-        proximity_out=c_not_needed;
-    }
-	/*motion events*/
-	DeviceMotionNotify(SDL_XDevices[i],c_not_needed,xEvent);
-	if (xEvent) 
-    {
-        SDL_XEvents[index++] = xEvent;
-        motion=c_not_needed;
-    }
+	    /*proximity events*/
+	    ProximityIn(SDL_XDevices[i],event_code,xEvent);
+	    if (xEvent)
+        {
+            SDL_XEvents[index++] = xEvent;
+            proximity_in=event_code;
+        }
+	    ProximityOut(SDL_XDevices[i],event_code,xEvent);
+	    if (xEvent)
+        {
+            SDL_XEvents[index++] = xEvent;
+            proximity_out=event_code;
+        }
 
-	/*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
+	    /*motion events*/
+	    DeviceMotionNotify(SDL_XDevices[i],event_code,xEvent);
+	    if (xEvent) 
+        {
+            SDL_XEvents[index++] = xEvent;
+            motion=event_code;
+        }
 
-	/*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;
 
--- a/src/video/x11/SDL_x11window.c	Sat Aug 02 17:40:49 2008 +0000
+++ b/src/video/x11/SDL_x11window.c	Mon Aug 04 11:18:10 2008 +0000
@@ -490,7 +490,6 @@
                       PointerMotionMask | KeyPressMask | KeyReleaseMask |
                       PropertyChangeMask | StructureNotifyMask |
                       KeymapStateMask | fevent));
-    XSelectExtensionEvent(data->display, w, SDL_XEvents, SDL_NumOfXEvents);
     }
 #else
     XMapWindow(data->display,w);
@@ -500,8 +499,10 @@
                   PointerMotionMask | KeyPressMask | KeyReleaseMask |
                   PropertyChangeMask | StructureNotifyMask |
                   KeymapStateMask));
+#endif
+
+    /*we're informing the display what extension events we want to receive from it*/
     XSelectExtensionEvent(data->display, w, SDL_XEvents, SDL_NumOfXEvents);
-#endif
 
     return 0;
 }