Mercurial > sdl-ios-xcode
comparison src/video/x11/SDL_x11events.c @ 4508:15d2c6f40c48
Added X11 clipboard support.
As far as I know there isn't any real way to tell when the clipboard contents have changed without polling them, so I didn't implement the clipboard update event on X11.
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Mon, 12 Jul 2010 00:36:55 -0700 |
parents | 9322f7db8603 |
children | a956a315fe67 03dcb795c583 |
comparison
equal
deleted
inserted
replaced
4507:dbf3fa541096 | 4508:15d2c6f40c48 |
---|---|
23 | 23 |
24 #include <sys/types.h> | 24 #include <sys/types.h> |
25 #include <sys/time.h> | 25 #include <sys/time.h> |
26 #include <signal.h> | 26 #include <signal.h> |
27 #include <unistd.h> | 27 #include <unistd.h> |
28 #include <limits.h> /* For INT_MAX */ | |
28 | 29 |
29 #include "SDL_x11video.h" | 30 #include "SDL_x11video.h" |
30 #include "../../events/SDL_events_c.h" | 31 #include "../../events/SDL_events_c.h" |
31 #include "../../events/SDL_mouse_c.h" | 32 #include "../../events/SDL_mouse_c.h" |
32 | 33 |
33 #include "SDL_timer.h" | 34 #include "SDL_timer.h" |
34 #include "SDL_syswm.h" | 35 #include "SDL_syswm.h" |
36 | |
37 /*#define DEBUG_XEVENTS*/ | |
35 | 38 |
36 static void | 39 static void |
37 X11_DispatchEvent(_THIS) | 40 X11_DispatchEvent(_THIS) |
38 { | 41 { |
39 SDL_VideoData *videodata = (SDL_VideoData *) _this->driverdata; | 42 SDL_VideoData *videodata = (SDL_VideoData *) _this->driverdata; |
284 case ButtonRelease:{ | 287 case ButtonRelease:{ |
285 SDL_SendMouseButton(data->window, SDL_RELEASED, xevent.xbutton.button); | 288 SDL_SendMouseButton(data->window, SDL_RELEASED, xevent.xbutton.button); |
286 } | 289 } |
287 break; | 290 break; |
288 | 291 |
292 /* Copy the selection from XA_CUT_BUFFER0 to the requested property */ | |
293 case SelectionRequest: { | |
294 Display *display = videodata->display; | |
295 XSelectionRequestEvent *req; | |
296 XEvent sevent; | |
297 int seln_format; | |
298 unsigned long nbytes; | |
299 unsigned long overflow; | |
300 unsigned char *seln_data; | |
301 | |
302 req = &xevent.xselectionrequest; | |
303 #ifdef DEBUG_XEVENTS | |
304 printf("SelectionRequest (requestor = %ld, target = %ld)\n", | |
305 req->requestor, req->target); | |
306 #endif | |
307 | |
308 sevent.xselection.type = SelectionNotify; | |
309 sevent.xselection.display = req->display; | |
310 sevent.xselection.selection = req->selection; | |
311 sevent.xselection.target = None; | |
312 sevent.xselection.property = None; | |
313 sevent.xselection.requestor = req->requestor; | |
314 sevent.xselection.time = req->time; | |
315 if (XGetWindowProperty(display, DefaultRootWindow(display), | |
316 XA_CUT_BUFFER0, 0, INT_MAX/4, False, req->target, | |
317 &sevent.xselection.target, &seln_format, &nbytes, | |
318 &overflow, &seln_data) == Success) { | |
319 if (sevent.xselection.target == req->target) { | |
320 XChangeProperty(display, req->requestor, req->property, | |
321 sevent.xselection.target, seln_format, PropModeReplace, | |
322 seln_data, nbytes); | |
323 sevent.xselection.property = req->property; | |
324 } | |
325 XFree(seln_data); | |
326 } | |
327 XSendEvent(display, req->requestor, False, 0, &sevent); | |
328 XSync(display, False); | |
329 } | |
330 break; | |
331 | |
332 case SelectionNotify: { | |
333 #ifdef DEBUG_XEVENTS | |
334 printf("SelectionNotify (requestor = %ld, target = %ld)\n", | |
335 xevent.xselection.requestor, xevent.xselection.target); | |
336 #endif | |
337 videodata->selection_waiting = SDL_FALSE; | |
338 } | |
339 break; | |
340 | |
289 default:{ | 341 default:{ |
290 #ifdef DEBUG_XEVENTS | 342 #ifdef DEBUG_XEVENTS |
291 printf("Unhandled event %d\n", xevent.type); | 343 printf("Unhandled event %d\n", xevent.type); |
292 #endif | 344 #endif |
293 } | 345 } |