emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] Changes to emacs/src/xfns.c


From: Jan Djärv
Subject: [Emacs-diffs] Changes to emacs/src/xfns.c
Date: Mon, 07 Feb 2005 15:00:07 -0500

Index: emacs/src/xfns.c
diff -c emacs/src/xfns.c:1.629 emacs/src/xfns.c:1.630
*** emacs/src/xfns.c:1.629      Mon Feb  7 12:50:16 2005
--- emacs/src/xfns.c    Mon Feb  7 20:00:07 2005
***************
*** 4067,4074 ****
          data = (unsigned char *) xmalloc (nelements);
        else if (element_format == 16)
          data = (unsigned char *) xmalloc (nelements*2);
!       else
!         data = (unsigned char *) xmalloc (nelements*4);
  
        x_fill_property_data (FRAME_X_DISPLAY (f), value, data, element_format);
      }
--- 4067,4079 ----
          data = (unsigned char *) xmalloc (nelements);
        else if (element_format == 16)
          data = (unsigned char *) xmalloc (nelements*2);
!       else /* format == 32 */
!         /* The man page for XChangeProperty:
!                "If the specified format is 32, the property data must be a
!                 long array."
!            This applies even if long is more than 64 bits.  The X library
!            converts to 32 bits before sending to the X server.  */
!         data = (unsigned char *) xmalloc (nelements * sizeof(long));
  
        x_fill_property_data (FRAME_X_DISPLAY (f), value, data, element_format);
      }
***************
*** 4203,4208 ****
--- 4208,4237 ----
                               (unsigned char **) &tmp_data);
        if (rc == Success && tmp_data)
          {
+           /* The man page for XGetWindowProperty says:
+              "If the returned format is 32, the returned data is represented
+              as a long array and should be cast to that type to obtain the
+              elements."
+              This applies even if long is more than 32 bits, the X library
+              converts from 32 bit elements received from the X server to long
+              and passes the long array to us.  Thus, for that case bcopy can 
not
+              be used.  We convert to a 32 bit type here, because so much code
+              assume on that.
+ 
+              The bytes and offsets passed to XGetWindowProperty refers to the
+              property and those are indeed in 32 bit quantities if format is
+              32.  */
+ 
+           if (actual_format == 32 && actual_format < BITS_PER_LONG)
+             {
+               unsigned long i;
+               int  *idata = (int *) tmp_data;
+               long *ldata = (long *) tmp_data;
+ 
+               for (i = 0; i < actual_size; ++i)
+                 idata[i]= (int) ldata[i];
+             }
+ 
            if (NILP (vector_ret_p))
              prop_value = make_string (tmp_data, size);
            else




reply via email to

[Prev in Thread] Current Thread [Next in Thread]