Fixed bug 2676 - xdnd_version check issue in case ClientMessage
authorSam Lantinga <slouken@libsdl.org>
Fri, 28 Nov 2014 04:42:46 -0800
changeset 9245104f3bcfbf45
parent 9244 9f8962b9b09e
child 9246 a761913e5e91
Fixed bug 2676 - xdnd_version check issue in case ClientMessage

Nitz

I added xdnd_version check to XdndPosition case also
under DEBUG_XEVENTS macro.
by this we can get the action requested by user.

I analysed further and found out that removing xdnd_version check at XdndDrop case is a bad idea because
in XConvertSelection API timestamp should be passed if(xdnd_version >= 1)
otherwise CurrentTime should be passed
So xdnd_version check is important at XdndDrop case

I made xdnd_version as a static so that it can store the version in other cases also.
src/video/x11/SDL_x11events.c
     1.1 --- a/src/video/x11/SDL_x11events.c	Fri Nov 28 04:37:50 2014 -0800
     1.2 +++ b/src/video/x11/SDL_x11events.c	Fri Nov 28 04:42:46 2014 -0800
     1.3 @@ -866,12 +866,19 @@
     1.4          /* Have we been requested to quit (or another client message?) */
     1.5      case ClientMessage:{
     1.6  
     1.7 -            int xdnd_version=0;
     1.8 +            static int xdnd_version=0;
     1.9  
    1.10              if (xevent.xclient.message_type == videodata->XdndEnter) {
    1.11 +
    1.12                  SDL_bool use_list = xevent.xclient.data.l[1] & 1;
    1.13                  data->xdnd_source = xevent.xclient.data.l[0];
    1.14                  xdnd_version = ( xevent.xclient.data.l[1] >> 24);
    1.15 +#ifdef DEBUG_XEVENTS
    1.16 +                printf("XID of source window : %ld\n", data->xdnd_source);
    1.17 +                printf("Protocol version to use : %ld\n", xdnd_version);
    1.18 +                printf("More then 3 data types : %ld\n", use_list); 
    1.19 +#endif
    1.20 + 
    1.21                  if (use_list) {
    1.22                      /* fetch conversion targets */
    1.23                      SDL_x11Prop p;
    1.24 @@ -885,6 +892,15 @@
    1.25                  }
    1.26              }
    1.27              else if (xevent.xclient.message_type == videodata->XdndPosition) {
    1.28 +            
    1.29 +#ifdef DEBUG_XEVENTS
    1.30 +                Atom act= videodata->XdndActionCopy;
    1.31 +                if(xdnd_version >= 2) {
    1.32 +                    act = xevent.xclient.data.l[4];
    1.33 +                }
    1.34 +                printf("Action requested by user is : %s\n", X11_XGetAtomName(display , act));
    1.35 +#endif
    1.36 +                
    1.37  
    1.38                  /* reply with status */
    1.39                  memset(&m, 0, sizeof(XClientMessageEvent));