Much better debugging of property changes
authorSam Lantinga
Wed, 14 Jul 2010 00:08:46 -0700
changeset 45200c67c4328678
parent 4519 62d693e01a24
child 4521 50125e8aab94
Much better debugging of property changes
src/video/x11/SDL_x11events.c
src/video/x11/SDL_x11window.c
     1.1 --- a/src/video/x11/SDL_x11events.c	Tue Jul 13 23:14:00 2010 -0700
     1.2 +++ b/src/video/x11/SDL_x11events.c	Wed Jul 14 00:08:46 2010 -0700
     1.3 @@ -292,51 +292,77 @@
     1.4  
     1.5      case PropertyNotify:{
     1.6  #ifdef DEBUG_XEVENTS
     1.7 +            unsigned char *propdata;
     1.8 +            int status, real_format;
     1.9 +            Atom real_type;
    1.10 +            unsigned long items_read, items_left, i;
    1.11 +
    1.12              char *name = XGetAtomName(display, xevent.xproperty.atom);
    1.13 -            printf("PropertyNotify (atom = %s)\n", name ? name : "NULL");
    1.14              if (name) {
    1.15 +                printf("PropertyNotify: %s\n", name);
    1.16                  XFree(name);
    1.17              }
    1.18 +
    1.19 +            status = XGetWindowProperty(display, data->xwindow, xevent.xproperty.atom, 0L, 8192L, False, AnyPropertyType, &real_type, &real_format, &items_read, &items_left, &propdata);
    1.20 +            if (status == Success) {
    1.21 +                if (real_type == XA_INTEGER) {
    1.22 +                    int *values = (int *)propdata;
    1.23 +
    1.24 +                    printf("{");
    1.25 +                    for (i = 0; i < items_read; i++) {
    1.26 +                        printf(" %d", values[i]);
    1.27 +                    }
    1.28 +                    printf(" }\n");
    1.29 +                } else if (real_type == XA_CARDINAL) {
    1.30 +                    if (real_format == 32) {
    1.31 +                        Uint32 *values = (Uint32 *)propdata;
    1.32 +
    1.33 +                        printf("{");
    1.34 +                        for (i = 0; i < items_read; i++) {
    1.35 +                            printf(" %d", values[i]);
    1.36 +                        }
    1.37 +                        printf(" }\n");
    1.38 +                    } else if (real_format == 16) {
    1.39 +                        Uint16 *values = (Uint16 *)propdata;
    1.40 +
    1.41 +                        printf("{");
    1.42 +                        for (i = 0; i < items_read; i++) {
    1.43 +                            printf(" %d", values[i]);
    1.44 +                        }
    1.45 +                        printf(" }\n");
    1.46 +                    } else if (real_format == 8) {
    1.47 +                        Uint8 *values = (Uint8 *)propdata;
    1.48 +
    1.49 +                        printf("{");
    1.50 +                        for (i = 0; i < items_read; i++) {
    1.51 +                            printf(" %d", values[i]);
    1.52 +                        }
    1.53 +                        printf(" }\n");
    1.54 +                    }
    1.55 +                } else if (real_type == XA_STRING ||
    1.56 +                           real_type == videodata->UTF8_STRING) {
    1.57 +                    printf("{ \"%s\" }\n", propdata);
    1.58 +                } else if (real_type == XA_ATOM) {
    1.59 +                    Atom *atoms = (Atom *)propdata;
    1.60 +
    1.61 +                    printf("{");
    1.62 +                    for (i = 0; i < items_read; i++) {
    1.63 +                        char *name = XGetAtomName(display, atoms[i]);
    1.64 +                        if (name) {
    1.65 +                            printf(" %s", name);
    1.66 +                            XFree(name);
    1.67 +                        }
    1.68 +                    }
    1.69 +                    printf(" }\n");
    1.70 +                } else {
    1.71 +                    char *name = XGetAtomName(display, real_type);
    1.72 +                    printf("Unknown type: %ld (%s)\n", real_type, name ? name : "UNKNOWN");
    1.73 +                    if (name) {
    1.74 +                        XFree(name);
    1.75 +                    }
    1.76 +                }
    1.77 +            }
    1.78  #endif
    1.79 -            if (xevent.xproperty.atom == videodata->_NET_WM_STATE) {
    1.80 -                unsigned char *propdata;
    1.81 -                int status, real_format;
    1.82 -                Atom real_type;
    1.83 -                unsigned long items_read, items_left, i;
    1.84 -
    1.85 -#ifdef DEBUG_XEVENTS
    1.86 -                printf("_NET_WM_STATE: {");
    1.87 -#endif
    1.88 -                status = XGetWindowProperty(display, data->xwindow, videodata->_NET_WM_STATE, 0L, 8192L, False, XA_ATOM, &real_type, &real_format, &items_read, &items_left, &propdata);
    1.89 -                if (status == Success) {
    1.90 -                    Atom *atoms = (Atom *)propdata;
    1.91 -                    for (i = 0; i < items_read; i++) {
    1.92 -                        if (atoms[i] == videodata->_NET_WM_STATE_HIDDEN) {
    1.93 -#ifdef DEBUG_XEVENTS
    1.94 -                            printf(" _NET_WM_STATE_HIDDEN");
    1.95 -#endif
    1.96 -                        }
    1.97 -                        if (atoms[i] == videodata->_NET_WM_STATE_MAXIMIZED_HORZ) {
    1.98 -#ifdef DEBUG_XEVENTS
    1.99 -                            printf(" _NET_WM_STATE_MAXIMIZED_HORZ");
   1.100 -#endif
   1.101 -                        }
   1.102 -                        if (atoms[i] == videodata->_NET_WM_STATE_MAXIMIZED_VERT) {
   1.103 -#ifdef DEBUG_XEVENTS
   1.104 -                            printf(" _NET_WM_STATE_MAXIMIZED_VERT");
   1.105 -#endif
   1.106 -                        }
   1.107 -                        if (atoms[i] == videodata->_NET_WM_STATE_FULLSCREEN) {
   1.108 -#ifdef DEBUG_XEVENTS
   1.109 -                            printf(" _NET_WM_STATE_FULLSCREEN");
   1.110 -#endif
   1.111 -                        }
   1.112 -                    }
   1.113 -                }
   1.114 -#ifdef DEBUG_XEVENTS
   1.115 -                printf(" }\n");
   1.116 -#endif
   1.117 -            }
   1.118          }
   1.119          break;
   1.120  
   1.121 @@ -355,8 +381,7 @@
   1.122                  req->requestor, req->target);
   1.123  #endif
   1.124  
   1.125 -            sevent.xselection.type = SelectionNotify;
   1.126 -            sevent.xselection.display = req->display;
   1.127 +            sevent.xany.type = SelectionNotify;
   1.128              sevent.xselection.selection = req->selection;
   1.129              sevent.xselection.target = None;
   1.130              sevent.xselection.property = None;
     2.1 --- a/src/video/x11/SDL_x11window.c	Tue Jul 13 23:14:00 2010 -0700
     2.2 +++ b/src/video/x11/SDL_x11window.c	Wed Jul 14 00:08:46 2010 -0700
     2.3 @@ -682,8 +682,6 @@
     2.4          XEvent e;
     2.5  
     2.6          e.xany.type = ClientMessage;
     2.7 -        e.xclient.display = data->display;
     2.8 -        e.xclient.window = w;
     2.9          e.xclient.message_type = _NET_WM_STATE;
    2.10          e.xclient.format = 32;
    2.11          e.xclient.data.l[0] = _NET_WM_STATE_ADD;
    2.12 @@ -955,8 +953,6 @@
    2.13      XEvent e;
    2.14  
    2.15      e.xany.type = ClientMessage;
    2.16 -    e.xclient.display = display;
    2.17 -    e.xclient.window = data->xwindow;
    2.18      e.xclient.message_type = _NET_WM_STATE;
    2.19      e.xclient.format = 32;
    2.20      e.xclient.data.l[0] =