comparison src/video/x11/SDL_x11events.c @ 2710:44e49d3fa6cf

Final merge of Google Summer of Code 2008 work... Many-mouse and tablet support by Szymon Wilczek, mentored by Ryan C. Gordon Everything concerning the project is noted on the wiki: http://wilku.ravenlord.ws/doku.php?id=start
author Sam Lantinga <slouken@libsdl.org>
date Mon, 25 Aug 2008 06:33:00 +0000
parents 91e601d9df8b
children 79c1bd651f04
comparison
equal deleted inserted replaced
2709:fd3f0f1147e7 2710:44e49d3fa6cf
26 #include <unistd.h> 26 #include <unistd.h>
27 27
28 #include "SDL_syswm.h" 28 #include "SDL_syswm.h"
29 #include "SDL_x11video.h" 29 #include "SDL_x11video.h"
30 #include "../../events/SDL_events_c.h" 30 #include "../../events/SDL_events_c.h"
31
32 extern int motion; /* the motion event id defined by an XInput function */
33 extern int button_pressed; /* the button_pressed event id defined by an XInput function */
34 extern int button_released; /* the button_released event id defined by an XInput function */
35 extern int proximity_in; /* the proximity in event defined by an XInput function */
36 extern int proximity_out; /* the proximity out event defined by an XInput function */
31 37
32 static void 38 static void
33 X11_DispatchEvent(_THIS) 39 X11_DispatchEvent(_THIS)
34 { 40 {
35 SDL_VideoData *videodata = (SDL_VideoData *) _this->driverdata; 41 SDL_VideoData *videodata = (SDL_VideoData *) _this->driverdata;
89 if (xevent.xcrossing.mode == NotifyUngrab) 95 if (xevent.xcrossing.mode == NotifyUngrab)
90 printf("Mode: NotifyUngrab\n"); 96 printf("Mode: NotifyUngrab\n");
91 #endif 97 #endif
92 if ((xevent.xcrossing.mode != NotifyGrab) && 98 if ((xevent.xcrossing.mode != NotifyGrab) &&
93 (xevent.xcrossing.mode != NotifyUngrab)) { 99 (xevent.xcrossing.mode != NotifyUngrab)) {
94 SDL_SetMouseFocus(videodata->mouse, data->windowID); 100 XDeviceMotionEvent *move = (XDeviceMotionEvent *) & xevent;
95 SDL_SendMouseMotion(videodata->mouse, 0, xevent.xcrossing.x, 101 SDL_SetMouseFocus(move->deviceid, data->windowID);
96 xevent.xcrossing.y); 102 SDL_SendMouseMotion(move->deviceid, 0, move->x,
103 move->y, move->axis_data[2]);
97 } 104 }
98 } 105 }
99 break; 106 break;
100 107
101 /* Losing mouse coverage? */ 108 /* Losing mouse coverage? */
109 printf("Mode: NotifyUngrab\n"); 116 printf("Mode: NotifyUngrab\n");
110 #endif 117 #endif
111 if ((xevent.xcrossing.mode != NotifyGrab) && 118 if ((xevent.xcrossing.mode != NotifyGrab) &&
112 (xevent.xcrossing.mode != NotifyUngrab) && 119 (xevent.xcrossing.mode != NotifyUngrab) &&
113 (xevent.xcrossing.detail != NotifyInferior)) { 120 (xevent.xcrossing.detail != NotifyInferior)) {
114 SDL_SendMouseMotion(videodata->mouse, 0, 121 XDeviceMotionEvent *move = (XDeviceMotionEvent *) & xevent;
115 xevent.xcrossing.x, xevent.xcrossing.y); 122 SDL_SetMouseFocus(move->deviceid, 0);
116 SDL_SetMouseFocus(videodata->mouse, 0);
117 } 123 }
118 } 124 }
119 break; 125 break;
120 126
121 /* Gaining input focus? */ 127 /* Gaining input focus? */
161 case MappingNotify:{ 167 case MappingNotify:{
162 #ifdef DEBUG_XEVENTS 168 #ifdef DEBUG_XEVENTS
163 printf("MappingNotify!\n"); 169 printf("MappingNotify!\n");
164 #endif 170 #endif
165 X11_UpdateKeymap(_this); 171 X11_UpdateKeymap(_this);
166 }
167 break;
168
169 /* Mouse motion? */
170 case MotionNotify:{
171 #ifdef DEBUG_MOTION
172 printf("X11 motion: %d,%d\n", xevent.xmotion.x, xevent.xmotion.y);
173 #endif
174 SDL_SendMouseMotion(videodata->mouse, 0, xevent.xmotion.x,
175 xevent.xmotion.y);
176 }
177 break;
178
179 /* Mouse button press? */
180 case ButtonPress:{
181 SDL_SendMouseButton(videodata->mouse, SDL_PRESSED,
182 xevent.xbutton.button);
183 }
184 break;
185
186 /* Mouse button release? */
187 case ButtonRelease:{
188 SDL_SendMouseButton(videodata->mouse, SDL_RELEASED,
189 xevent.xbutton.button);
190 } 172 }
191 break; 173 break;
192 174
193 /* Key press? */ 175 /* Key press? */
194 case KeyPress:{ 176 case KeyPress:{
299 0); 281 0);
300 } 282 }
301 break; 283 break;
302 284
303 default:{ 285 default:{
304 #ifdef DEBUG_XEVENTS 286 if (xevent.type == motion) { /* MotionNotify */
305 printf("Unhandled event %d\n", xevent.type); 287 #ifdef DEBUG_MOTION
288 printf("X11 motion: %d,%d\n", xevent.xmotion.x,
289 xevent.xmotion.y);
290 #endif
291 XWindowAttributes attrib;
292 XGetWindowAttributes(videodata->display,
293 ((XAnyEvent *) & xevent)->window,
294 &attrib);
295 SDL_UpdateCoordinates(attrib.width, attrib.height);
296 XDeviceMotionEvent *move = (XDeviceMotionEvent *) & xevent;
297 SDL_SendMouseMotion(move->deviceid, 0, move->x,
298 move->y, move->axis_data[2]);
299 } else if (xevent.type == button_pressed) { /* ButtonPress */
300 XDeviceButtonPressedEvent *pressed =
301 (XDeviceButtonPressedEvent *) & xevent;
302 SDL_SendMouseButton(pressed->deviceid, SDL_PRESSED,
303 pressed->button);
304 } else if (xevent.type == button_released) { /* ButtonRelease */
305 XDeviceButtonReleasedEvent *released =
306 (XDeviceButtonReleasedEvent *) & xevent;
307 SDL_SendMouseButton(released->deviceid, SDL_RELEASED,
308 released->button);
309 } else if (xevent.type == proximity_in) {
310 XProximityNotifyEvent *proximity =
311 (XProximityNotifyEvent *) & xevent;
312 SDL_SendProximity(proximity->deviceid, proximity->x,
313 proximity->y, SDL_PROXIMITYIN);
314 } else if (xevent.type == proximity_out) {
315 XProximityNotifyEvent *proximity =
316 (XProximityNotifyEvent *) & xevent;
317 SDL_SendProximity(proximity->deviceid, proximity->x,
318 proximity->y, SDL_PROXIMITYOUT);
319 }
320 #ifdef DEBUG_XEVENTS
321 else {
322 printf("Unhandled event %d\n", xevent.type);
323 }
306 #endif 324 #endif
307 } 325 }
308 break; 326 break;
309 } 327 }
310 } 328 }