comparison src/video/x11/SDL_x11events.c @ 4520:0c67c4328678

Much better debugging of property changes
author Sam Lantinga <slouken@libsdl.org>
date Wed, 14 Jul 2010 00:08:46 -0700
parents 62d693e01a24
children a256e1dadf3f
comparison
equal deleted inserted replaced
4519:62d693e01a24 4520:0c67c4328678
290 } 290 }
291 break; 291 break;
292 292
293 case PropertyNotify:{ 293 case PropertyNotify:{
294 #ifdef DEBUG_XEVENTS 294 #ifdef DEBUG_XEVENTS
295 unsigned char *propdata;
296 int status, real_format;
297 Atom real_type;
298 unsigned long items_read, items_left, i;
299
295 char *name = XGetAtomName(display, xevent.xproperty.atom); 300 char *name = XGetAtomName(display, xevent.xproperty.atom);
296 printf("PropertyNotify (atom = %s)\n", name ? name : "NULL");
297 if (name) { 301 if (name) {
302 printf("PropertyNotify: %s\n", name);
298 XFree(name); 303 XFree(name);
299 } 304 }
300 #endif 305
301 if (xevent.xproperty.atom == videodata->_NET_WM_STATE) { 306 status = XGetWindowProperty(display, data->xwindow, xevent.xproperty.atom, 0L, 8192L, False, AnyPropertyType, &real_type, &real_format, &items_read, &items_left, &propdata);
302 unsigned char *propdata; 307 if (status == Success) {
303 int status, real_format; 308 if (real_type == XA_INTEGER) {
304 Atom real_type; 309 int *values = (int *)propdata;
305 unsigned long items_read, items_left, i; 310
306 311 printf("{");
307 #ifdef DEBUG_XEVENTS 312 for (i = 0; i < items_read; i++) {
308 printf("_NET_WM_STATE: {"); 313 printf(" %d", values[i]);
309 #endif 314 }
310 status = XGetWindowProperty(display, data->xwindow, videodata->_NET_WM_STATE, 0L, 8192L, False, XA_ATOM, &real_type, &real_format, &items_read, &items_left, &propdata); 315 printf(" }\n");
311 if (status == Success) { 316 } else if (real_type == XA_CARDINAL) {
317 if (real_format == 32) {
318 Uint32 *values = (Uint32 *)propdata;
319
320 printf("{");
321 for (i = 0; i < items_read; i++) {
322 printf(" %d", values[i]);
323 }
324 printf(" }\n");
325 } else if (real_format == 16) {
326 Uint16 *values = (Uint16 *)propdata;
327
328 printf("{");
329 for (i = 0; i < items_read; i++) {
330 printf(" %d", values[i]);
331 }
332 printf(" }\n");
333 } else if (real_format == 8) {
334 Uint8 *values = (Uint8 *)propdata;
335
336 printf("{");
337 for (i = 0; i < items_read; i++) {
338 printf(" %d", values[i]);
339 }
340 printf(" }\n");
341 }
342 } else if (real_type == XA_STRING ||
343 real_type == videodata->UTF8_STRING) {
344 printf("{ \"%s\" }\n", propdata);
345 } else if (real_type == XA_ATOM) {
312 Atom *atoms = (Atom *)propdata; 346 Atom *atoms = (Atom *)propdata;
347
348 printf("{");
313 for (i = 0; i < items_read; i++) { 349 for (i = 0; i < items_read; i++) {
314 if (atoms[i] == videodata->_NET_WM_STATE_HIDDEN) { 350 char *name = XGetAtomName(display, atoms[i]);
315 #ifdef DEBUG_XEVENTS 351 if (name) {
316 printf(" _NET_WM_STATE_HIDDEN"); 352 printf(" %s", name);
317 #endif 353 XFree(name);
318 }
319 if (atoms[i] == videodata->_NET_WM_STATE_MAXIMIZED_HORZ) {
320 #ifdef DEBUG_XEVENTS
321 printf(" _NET_WM_STATE_MAXIMIZED_HORZ");
322 #endif
323 }
324 if (atoms[i] == videodata->_NET_WM_STATE_MAXIMIZED_VERT) {
325 #ifdef DEBUG_XEVENTS
326 printf(" _NET_WM_STATE_MAXIMIZED_VERT");
327 #endif
328 }
329 if (atoms[i] == videodata->_NET_WM_STATE_FULLSCREEN) {
330 #ifdef DEBUG_XEVENTS
331 printf(" _NET_WM_STATE_FULLSCREEN");
332 #endif
333 } 354 }
334 } 355 }
356 printf(" }\n");
357 } else {
358 char *name = XGetAtomName(display, real_type);
359 printf("Unknown type: %ld (%s)\n", real_type, name ? name : "UNKNOWN");
360 if (name) {
361 XFree(name);
362 }
335 } 363 }
336 #ifdef DEBUG_XEVENTS 364 }
337 printf(" }\n"); 365 #endif
338 #endif
339 }
340 } 366 }
341 break; 367 break;
342 368
343 /* Copy the selection from XA_CUT_BUFFER0 to the requested property */ 369 /* Copy the selection from XA_CUT_BUFFER0 to the requested property */
344 case SelectionRequest: { 370 case SelectionRequest: {
353 #ifdef DEBUG_XEVENTS 379 #ifdef DEBUG_XEVENTS
354 printf("SelectionRequest (requestor = %ld, target = %ld)\n", 380 printf("SelectionRequest (requestor = %ld, target = %ld)\n",
355 req->requestor, req->target); 381 req->requestor, req->target);
356 #endif 382 #endif
357 383
358 sevent.xselection.type = SelectionNotify; 384 sevent.xany.type = SelectionNotify;
359 sevent.xselection.display = req->display;
360 sevent.xselection.selection = req->selection; 385 sevent.xselection.selection = req->selection;
361 sevent.xselection.target = None; 386 sevent.xselection.target = None;
362 sevent.xselection.property = None; 387 sevent.xselection.property = None;
363 sevent.xselection.requestor = req->requestor; 388 sevent.xselection.requestor = req->requestor;
364 sevent.xselection.time = req->time; 389 sevent.xselection.time = req->time;