Further x11 code improvments + comments gsoc2008_manymouse
authorSzymon Wilczek
Mon, 04 Aug 2008 11:18:10 +0000
branchgsoc2008_manymouse
changeset 37733b5691f85c0d
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
     1.1 --- a/src/events/SDL_mouse_c.h	Sat Aug 02 17:40:49 2008 +0000
     1.2 +++ b/src/events/SDL_mouse_c.h	Mon Aug 04 11:18:10 2008 +0000
     1.3 @@ -56,6 +56,13 @@
     1.4      /* Free the mouse when it's time */
     1.5      void (*FreeMouse) (SDL_Mouse * mouse);
     1.6  
     1.7 +    /*data common for tablets*/
     1.8 +    int pressure;
     1.9 +    int pressure_max;
    1.10 +    int pressure_min;
    1.11 +    int tilt;/*for future use*/
    1.12 +    int rotation;/*for future use*/
    1.13 +
    1.14      /* Data common to all mice */
    1.15      SDL_WindowID focus;
    1.16      int which;
    1.17 @@ -64,11 +71,7 @@
    1.18      int z;/*for future use*/
    1.19      int xdelta;
    1.20      int ydelta;
    1.21 -    int pressure;
    1.22 -    int pressure_max;
    1.23 -    int pressure_min;
    1.24 -    int tilt;/*for future use*/
    1.25 -    int rotation;/*for future use*/
    1.26 +
    1.27      char* name;
    1.28      Uint8 buttonstate;
    1.29      SDL_bool relative_mode;
     2.1 --- a/src/video/x11/SDL_x11video.c	Sat Aug 02 17:40:49 2008 +0000
     2.2 +++ b/src/video/x11/SDL_x11video.c	Mon Aug 04 11:18:10 2008 +0000
     2.3 @@ -220,7 +220,7 @@
     2.4  int
     2.5  X11_VideoInit(_THIS)
     2.6  {
     2.7 -    int i,index=0,c_not_needed;
     2.8 +    int i,index=0,event_code;
     2.9      XEventClass xEvent;
    2.10      SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
    2.11  
    2.12 @@ -250,90 +250,46 @@
    2.13          return -1;
    2.14      }
    2.15      X11_InitMouse(_this);
    2.16 +
    2.17      /*we're generating the table of events that should be recognized*/
    2.18      for(i=0;i<SDL_NumOfXDevices;++i)
    2.19 -    {   
    2.20 -        DeviceKeyPress(SDL_XDevices[i],c_not_needed,xEvent);
    2.21 -	    if (xEvent) SDL_XEvents[index++] = xEvent;
    2.22 -	    DeviceKeyRelease(SDL_XDevices[i],c_not_needed,xEvent);
    2.23 -	if (xEvent) SDL_XEvents[index++] = xEvent;
    2.24 -
    2.25 -	/*focus events*/
    2.26 -	DeviceFocusIn(SDL_XDevices[i],c_not_needed,xEvent);
    2.27 -	if (xEvent) SDL_XEvents[index++] = xEvent;
    2.28 -	DeviceFocusOut(SDL_XDevices[i],c_not_needed,xEvent);
    2.29 -	if (xEvent) SDL_XEvents[index++] = xEvent;
    2.30 -
    2.31 -	/*button events*/
    2.32 -	DeviceButtonPress(SDL_XDevices[i],c_not_needed,xEvent);
    2.33 -	if (xEvent) 
    2.34 -    {
    2.35 -        SDL_XEvents[index++] = xEvent;
    2.36 -        button_pressed=c_not_needed;
    2.37 -    }
    2.38 -	DeviceButtonRelease(SDL_XDevices[i],c_not_needed,xEvent);
    2.39 -	if (xEvent)
    2.40 -    {
    2.41 -        SDL_XEvents[index++] = xEvent;
    2.42 -        button_released=c_not_needed;
    2.43 -    }
    2.44 +    {  
    2.45 +	    /*button events*/
    2.46 +	    DeviceButtonPress(SDL_XDevices[i],event_code,xEvent);
    2.47 +	    if (xEvent) 
    2.48 +        {
    2.49 +            SDL_XEvents[index++] = xEvent;
    2.50 +            button_pressed=event_code;
    2.51 +        }
    2.52 +	    DeviceButtonRelease(SDL_XDevices[i],event_code,xEvent);
    2.53 +	    if (xEvent)
    2.54 +        {
    2.55 +            SDL_XEvents[index++] = xEvent;
    2.56 +            button_released=event_code;
    2.57 +        }
    2.58  
    2.59 -	/*proximity events*/
    2.60 -	ProximityIn(SDL_XDevices[i],c_not_needed,xEvent);
    2.61 -	if (xEvent)
    2.62 -    {
    2.63 -        SDL_XEvents[index++] = xEvent;
    2.64 -        proximity_in=c_not_needed;
    2.65 -    }
    2.66 -	ProximityOut(SDL_XDevices[i],c_not_needed,xEvent);
    2.67 -	if (xEvent)
    2.68 -    {
    2.69 -        SDL_XEvents[index++] = xEvent;
    2.70 -        proximity_out=c_not_needed;
    2.71 -    }
    2.72 -	/*motion events*/
    2.73 -	DeviceMotionNotify(SDL_XDevices[i],c_not_needed,xEvent);
    2.74 -	if (xEvent) 
    2.75 -    {
    2.76 -        SDL_XEvents[index++] = xEvent;
    2.77 -        motion=c_not_needed;
    2.78 -    }
    2.79 +	    /*proximity events*/
    2.80 +	    ProximityIn(SDL_XDevices[i],event_code,xEvent);
    2.81 +	    if (xEvent)
    2.82 +        {
    2.83 +            SDL_XEvents[index++] = xEvent;
    2.84 +            proximity_in=event_code;
    2.85 +        }
    2.86 +	    ProximityOut(SDL_XDevices[i],event_code,xEvent);
    2.87 +	    if (xEvent)
    2.88 +        {
    2.89 +            SDL_XEvents[index++] = xEvent;
    2.90 +            proximity_out=event_code;
    2.91 +        }
    2.92  
    2.93 -	/*device state*/
    2.94 -	DeviceStateNotify(SDL_XDevices[i],c_not_needed,xEvent);
    2.95 -	if (xEvent) SDL_XEvents[index++] = xEvent;
    2.96 -	DeviceMappingNotify(SDL_XDevices[i],
    2.97 -			c_not_needed,xEvent);
    2.98 -	if (xEvent) SDL_XEvents[index++] = xEvent;
    2.99 -	ChangeDeviceNotify(SDL_XDevices[i],c_not_needed,xEvent);
   2.100 -	if (xEvent) SDL_XEvents[index++] = xEvent;
   2.101 -
   2.102 -#if 0
   2.103 -	/* this cuts the motion data down - not sure if this is useful */
   2.104 -	DevicePointerMotionHint(SDL_XDevices[i],
   2.105 -			c_not_neededINPUTEVENT_DEVICE_POINTER_MOTION_HINT],xEvent);
   2.106 -	if (xEvent) SDL_XEvents[index++] = xEvent;
   2.107 -#endif
   2.108 +	    /*motion events*/
   2.109 +	    DeviceMotionNotify(SDL_XDevices[i],event_code,xEvent);
   2.110 +	    if (xEvent) 
   2.111 +        {
   2.112 +            SDL_XEvents[index++] = xEvent;
   2.113 +            motion=event_code;
   2.114 +        }
   2.115  
   2.116 -	/*button motion*/
   2.117 -	DeviceButtonMotion(SDL_XDevices[i],
   2.118 -			c_not_needed,xEvent);
   2.119 -	if (xEvent) SDL_XEvents[index++] = xEvent;
   2.120 -	DeviceButton1Motion(SDL_XDevices[i],
   2.121 -			c_not_needed,xEvent);
   2.122 -	if (xEvent) SDL_XEvents[index++] = xEvent;
   2.123 -	DeviceButton2Motion(SDL_XDevices[i],
   2.124 -			c_not_needed,xEvent);
   2.125 -	if (xEvent) SDL_XEvents[index++] = xEvent;
   2.126 -	DeviceButton3Motion(SDL_XDevices[i],
   2.127 -			c_not_needed,xEvent);
   2.128 -	if (xEvent) SDL_XEvents[index++] = xEvent;
   2.129 -	DeviceButton4Motion(SDL_XDevices[i],
   2.130 -			c_not_needed,xEvent);
   2.131 -	if (xEvent) SDL_XEvents[index++] = xEvent;
   2.132 -	DeviceButton5Motion(SDL_XDevices[i],
   2.133 -			c_not_needed,xEvent);
   2.134 -	if (xEvent) SDL_XEvents[index++] = xEvent;
   2.135      }
   2.136      SDL_NumOfXEvents=index;
   2.137  
     3.1 --- a/src/video/x11/SDL_x11window.c	Sat Aug 02 17:40:49 2008 +0000
     3.2 +++ b/src/video/x11/SDL_x11window.c	Mon Aug 04 11:18:10 2008 +0000
     3.3 @@ -490,7 +490,6 @@
     3.4                        PointerMotionMask | KeyPressMask | KeyReleaseMask |
     3.5                        PropertyChangeMask | StructureNotifyMask |
     3.6                        KeymapStateMask | fevent));
     3.7 -    XSelectExtensionEvent(data->display, w, SDL_XEvents, SDL_NumOfXEvents);
     3.8      }
     3.9  #else
    3.10      XMapWindow(data->display,w);
    3.11 @@ -500,8 +499,10 @@
    3.12                    PointerMotionMask | KeyPressMask | KeyReleaseMask |
    3.13                    PropertyChangeMask | StructureNotifyMask |
    3.14                    KeymapStateMask));
    3.15 +#endif
    3.16 +
    3.17 +    /*we're informing the display what extension events we want to receive from it*/
    3.18      XSelectExtensionEvent(data->display, w, SDL_XEvents, SDL_NumOfXEvents);
    3.19 -#endif
    3.20  
    3.21      return 0;
    3.22  }