* xselect.c (last_event_timestamp): Remove duplicate decl.
[bpt/emacs.git] / src / xselect.c
index 7b91d6f..e279b39 100644 (file)
@@ -1,6 +1,5 @@
 /* X Selection processing for Emacs.
-   Copyright (C) 1993, 1994, 1995, 1996, 1997, 2000, 2001, 2002, 2003,
-                 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
+   Copyright (C) 1993-1997, 2000-2011 Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
@@ -27,9 +26,8 @@ along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.  */
 #ifdef HAVE_SYS_TYPES_H
 #include <sys/types.h>
 #endif
-#ifdef HAVE_UNISTD_H
+
 #include <unistd.h>
-#endif
 
 #include "lisp.h"
 #include "xterm.h"     /* for all of the X includes */
@@ -99,21 +97,18 @@ static Lisp_Object clean_local_selection_data (Lisp_Object);
 #define TRACE0(fmt)            (void) 0
 #define TRACE1(fmt, a0)                (void) 0
 #define TRACE2(fmt, a0, a1)    (void) 0
-#define TRACE3(fmt, a0, a1)    (void) 0
 #endif
 
 
-Lisp_Object QSECONDARY, QSTRING, QINTEGER, QCLIPBOARD, QTIMESTAMP,
+static Lisp_Object QSECONDARY, QSTRING, QINTEGER, QCLIPBOARD, QTIMESTAMP,
   QTEXT, QDELETE, QMULTIPLE, QINCR, QEMACS_TMP, QTARGETS, QATOM, QNULL,
   QATOM_PAIR;
 
-Lisp_Object QCOMPOUND_TEXT;    /* This is a type of selection.  */
-Lisp_Object QUTF8_STRING;      /* This is a type of selection.  */
+static Lisp_Object QCOMPOUND_TEXT;     /* This is a type of selection.  */
+static Lisp_Object QUTF8_STRING;       /* This is a type of selection.  */
 
-Lisp_Object Qcompound_text_with_extensions;
+static Lisp_Object Qcompound_text_with_extensions;
 
-static Lisp_Object Vx_lost_selection_functions;
-static Lisp_Object Vx_sent_selection_functions;
 static Lisp_Object Qforeign_selection;
 
 /* If this is a smaller number than the max-request-size of the display,
@@ -126,10 +121,6 @@ static Lisp_Object Qforeign_selection;
 
 #define SELECTION_QUANTUM(dpy) ((XMaxRequestSize(dpy) << 2) - 100)
 
-/* The timestamp of the last input event Emacs received from the X server.  */
-/* Defined in keyboard.c.  */
-extern unsigned long last_event_timestamp;
-
 /* This is an association list whose elements are of the form
      ( SELECTION-NAME SELECTION-VALUE SELECTION-TIMESTAMP FRAME)
    SELECTION-NAME is a lisp symbol, whose name is the name of an X Atom.
@@ -144,17 +135,6 @@ extern unsigned long last_event_timestamp;
     selection-values.  */
 static Lisp_Object Vselection_alist;
 
-/* This is an alist whose CARs are selection-types (whose names are the same
-   as the names of X Atoms) and whose CDRs are the names of Lisp functions to
-   call to convert the given Emacs selection value to a string representing
-   the given selection type.  This is for Lisp-level extension of the emacs
-   selection handling.  */
-static Lisp_Object Vselection_converter_alist;
-
-/* If the selection owner takes too long to reply to a selection request,
-   we give up on it.  This is in milliseconds (0 = no timeout.)  */
-static EMACS_INT x_selection_timeout;
-
 
 \f
 /* Define a queue to save up SELECTION_REQUEST_EVENT events for later
@@ -185,7 +165,7 @@ x_queue_event (struct input_event *event)
     {
       if (!memcmp (&queue_tmp->event, event, sizeof (*event)))
        {
-         TRACE1 ("DECLINE DUP SELECTION EVENT %08lx", (unsigned long)queue_tmp);
+         TRACE1 ("DECLINE DUP SELECTION EVENT %p", queue_tmp);
          x_decline_selection_request (event);
          return;
        }
@@ -196,7 +176,7 @@ x_queue_event (struct input_event *event)
 
   if (queue_tmp != NULL)
     {
-      TRACE1 ("QUEUE SELECTION EVENT %08lx", (unsigned long)queue_tmp);
+      TRACE1 ("QUEUE SELECTION EVENT %p", queue_tmp);
       queue_tmp->event = *event;
       queue_tmp->next = selection_queue;
       selection_queue = queue_tmp;
@@ -229,7 +209,7 @@ x_stop_queuing_selection_requests (void)
   while (selection_queue != NULL)
     {
       struct selection_event_queue *queue_tmp = selection_queue;
-      TRACE1 ("RESTORE SELECTION EVENT %08lx", (unsigned long)queue_tmp);
+      TRACE1 ("RESTORE SELECTION EVENT %p", queue_tmp);
       kbd_buffer_unget_event (&queue_tmp->event);
       selection_queue = queue_tmp->next;
       xfree ((char *)queue_tmp);
@@ -263,9 +243,9 @@ symbol_to_x_atom (struct x_display_info *dpyinfo, Display *display, Lisp_Object
   if (EQ (sym, QNULL))     return dpyinfo->Xatom_NULL;
   if (!SYMBOLP (sym)) abort ();
 
-  TRACE1 (" XInternAtom %s", (char *) SDATA (SYMBOL_NAME (sym)));
+  TRACE1 (" XInternAtom %s", SSDATA (SYMBOL_NAME (sym)));
   BLOCK_INPUT;
-  val = XInternAtom (display, (char *) SDATA (SYMBOL_NAME (sym)), False);
+  val = XInternAtom (display, SSDATA (SYMBOL_NAME (sym)), False);
   UNBLOCK_INPUT;
   return val;
 }
@@ -345,7 +325,7 @@ x_own_selection (Lisp_Object selection_name, Lisp_Object selection_value)
   struct frame *sf = SELECTED_FRAME ();
   Window selecting_window;
   Display *display;
-  Time time = last_event_timestamp;
+  Time timestamp = last_event_timestamp;
   Atom selection_atom;
   struct x_display_info *dpyinfo;
 
@@ -361,7 +341,7 @@ x_own_selection (Lisp_Object selection_name, Lisp_Object selection_value)
 
   BLOCK_INPUT;
   x_catch_errors (display);
-  XSetSelectionOwner (display, selection_atom, selecting_window, time);
+  XSetSelectionOwner (display, selection_atom, selecting_window, timestamp);
   x_check_errors (display, "Can't set selection: %s");
   x_uncatch_errors ();
   UNBLOCK_INPUT;
@@ -372,7 +352,7 @@ x_own_selection (Lisp_Object selection_name, Lisp_Object selection_value)
     Lisp_Object selection_data;
     Lisp_Object prev_value;
 
-    selection_time = long_to_cons ((unsigned long) time);
+    selection_time = long_to_cons ((unsigned long) timestamp);
     selection_data = list4 (selection_name, selection_value,
                            selection_time, selected_frame);
     prev_value = assq_no_quit (selection_name, Vselection_alist);
@@ -407,7 +387,7 @@ static Lisp_Object
 x_get_local_selection (Lisp_Object selection_symbol, Lisp_Object target_type, int local_request)
 {
   Lisp_Object local_value;
-  Lisp_Object handler_fn, value, type, check;
+  Lisp_Object handler_fn, value, check;
   int count;
 
   local_value = assq_no_quit (selection_symbol, Vselection_alist);
@@ -439,7 +419,7 @@ x_get_local_selection (Lisp_Object selection_symbol, Lisp_Object target_type, in
       int size;
       int i;
       pairs = XCDR (target_type);
-      size = XVECTOR (pairs)->size;
+      size = ASIZE (pairs);
       /* If the target is MULTIPLE, then target_type looks like
          (MULTIPLE . [[SELECTION1 TARGET1] [SELECTION2 TARGET2] ... ])
         We modify the second element of each pair in the vector and
@@ -485,7 +465,6 @@ x_get_local_selection (Lisp_Object selection_symbol, Lisp_Object target_type, in
   check = value;
   if (CONSP (value)
       && SYMBOLP (XCAR (value)))
-    type = XCAR (value),
     check = XCDR (value);
 
   if (STRINGP (check)
@@ -516,22 +495,23 @@ x_get_local_selection (Lisp_Object selection_symbol, Lisp_Object target_type, in
 static void
 x_decline_selection_request (struct input_event *event)
 {
-  XSelectionEvent reply;
+  XEvent reply_base;
+  XSelectionEvent *reply = &(reply_base.xselection);
 
-  reply.type = SelectionNotify;
-  reply.display = SELECTION_EVENT_DISPLAY (event);
-  reply.requestor = SELECTION_EVENT_REQUESTOR (event);
-  reply.selection = SELECTION_EVENT_SELECTION (event);
-  reply.time = SELECTION_EVENT_TIME (event);
-  reply.target = SELECTION_EVENT_TARGET (event);
-  reply.property = None;
+  reply->type = SelectionNotify;
+  reply->display = SELECTION_EVENT_DISPLAY (event);
+  reply->requestor = SELECTION_EVENT_REQUESTOR (event);
+  reply->selection = SELECTION_EVENT_SELECTION (event);
+  reply->time = SELECTION_EVENT_TIME (event);
+  reply->target = SELECTION_EVENT_TARGET (event);
+  reply->property = None;
 
   /* The reason for the error may be that the receiver has
      died in the meantime.  Handle that case.  */
   BLOCK_INPUT;
-  x_catch_errors (reply.display);
-  XSendEvent (reply.display, reply.requestor, False, 0L, (XEvent *) &reply);
-  XFlush (reply.display);
+  x_catch_errors (reply->display);
+  XSendEvent (reply->display, reply->requestor, False, 0L, &reply_base);
+  XFlush (reply->display);
   x_uncatch_errors ();
   UNBLOCK_INPUT;
 }
@@ -634,7 +614,8 @@ static int x_reply_selection_request_cnt;
 static void
 x_reply_selection_request (struct input_event *event, int format, unsigned char *data, int size, Atom type)
 {
-  XSelectionEvent reply;
+  XEvent reply_base;
+  XSelectionEvent *reply = &(reply_base.xselection);
   Display *display = SELECTION_EVENT_DISPLAY (event);
   Window window = SELECTION_EVENT_REQUESTOR (event);
   int bytes_remaining;
@@ -646,15 +627,15 @@ x_reply_selection_request (struct input_event *event, int format, unsigned char
   if (max_bytes > MAX_SELECTION_QUANTUM)
     max_bytes = MAX_SELECTION_QUANTUM;
 
-  reply.type = SelectionNotify;
-  reply.display = display;
-  reply.requestor = window;
-  reply.selection = SELECTION_EVENT_SELECTION (event);
-  reply.time = SELECTION_EVENT_TIME (event);
-  reply.target = SELECTION_EVENT_TARGET (event);
-  reply.property = SELECTION_EVENT_PROPERTY (event);
-  if (reply.property == None)
-    reply.property = reply.target;
+  reply->type = SelectionNotify;
+  reply->display = display;
+  reply->requestor = window;
+  reply->selection = SELECTION_EVENT_SELECTION (event);
+  reply->time = SELECTION_EVENT_TIME (event);
+  reply->target = SELECTION_EVENT_TARGET (event);
+  reply->property = SELECTION_EVENT_PROPERTY (event);
+  if (reply->property == None)
+    reply->property = reply->target;
 
   BLOCK_INPUT;
   /* The protected block contains wait_for_property_change, which can
@@ -665,8 +646,8 @@ x_reply_selection_request (struct input_event *event, int format, unsigned char
 
 #ifdef TRACE_SELECTION
   {
-    char *sel = XGetAtomName (display, reply.selection);
-    char *tgt = XGetAtomName (display, reply.target);
+    char *sel = XGetAtomName (display, reply->selection);
+    char *tgt = XGetAtomName (display, reply->target);
     TRACE3 ("%s, target %s (%d)", sel, tgt, ++x_reply_selection_request_cnt);
     if (sel) XFree (sel);
     if (tgt) XFree (tgt);
@@ -681,10 +662,10 @@ x_reply_selection_request (struct input_event *event, int format, unsigned char
     {
       /* Send all the data at once, with minimal handshaking.  */
       TRACE1 ("Sending all %d bytes", bytes_remaining);
-      XChangeProperty (display, window, reply.property, type, format,
+      XChangeProperty (display, window, reply->property, type, format,
                       PropModeReplace, data, size);
       /* At this point, the selection was successfully stored; ack it.  */
-      XSendEvent (display, window, False, 0L, (XEvent *) &reply);
+      XSendEvent (display, window, False, 0L, &reply_base);
     }
   else
     {
@@ -710,19 +691,19 @@ x_reply_selection_request (struct input_event *event, int format, unsigned char
        error ("Attempt to transfer an INCR to ourself!");
 
       TRACE2 ("Start sending %d bytes incrementally (%s)",
-             bytes_remaining,  XGetAtomName (display, reply.property));
-      wait_object = expect_property_change (display, window, reply.property,
+             bytes_remaining,  XGetAtomName (display, reply->property));
+      wait_object = expect_property_change (display, window, reply->property,
                                            PropertyDelete);
 
       TRACE1 ("Set %s to number of bytes to send",
-             XGetAtomName (display, reply.property));
+             XGetAtomName (display, reply->property));
       {
         /* XChangeProperty expects an array of long even if long is more than
            32 bits.  */
         long value[1];
 
         value[0] = bytes_remaining;
-        XChangeProperty (display, window, reply.property, dpyinfo->Xatom_INCR,
+        XChangeProperty (display, window, reply->property, dpyinfo->Xatom_INCR,
                          32, PropModeReplace,
                          (unsigned char *) value, 1);
       }
@@ -731,7 +712,7 @@ x_reply_selection_request (struct input_event *event, int format, unsigned char
 
       /* Tell 'em the INCR data is there...  */
       TRACE0 ("Send SelectionNotify event");
-      XSendEvent (display, window, False, 0L, (XEvent *) &reply);
+      XSendEvent (display, window, False, 0L, &reply_base);
       XFlush (display);
 
       had_errors = x_had_errors_p (display);
@@ -742,7 +723,7 @@ x_reply_selection_request (struct input_event *event, int format, unsigned char
       if (! had_errors)
        {
          TRACE1 ("Waiting for ACK (deletion of %s)",
-                 XGetAtomName (display, reply.property));
+                 XGetAtomName (display, reply->property));
          wait_for_property_change (wait_object);
        }
       else
@@ -758,15 +739,15 @@ x_reply_selection_request (struct input_event *event, int format, unsigned char
          BLOCK_INPUT;
 
          wait_object
-           = expect_property_change (display, window, reply.property,
+           = expect_property_change (display, window, reply->property,
                                      PropertyDelete);
 
          TRACE1 ("Sending increment of %d elements", i);
          TRACE1 ("Set %s to increment data",
-                 XGetAtomName (display, reply.property));
+                 XGetAtomName (display, reply->property));
 
          /* Append the next chunk of data to the property.  */
-         XChangeProperty (display, window, reply.property, type, format,
+         XChangeProperty (display, window, reply->property, type, format,
                           PropModeAppend, data, i);
          bytes_remaining -= i * format_bytes;
          if (format == 32)
@@ -783,7 +764,7 @@ x_reply_selection_request (struct input_event *event, int format, unsigned char
          /* Now wait for the requester to ack this chunk by deleting the
             property.  This can run random lisp code or signal.  */
          TRACE1 ("Waiting for increment ACK (deletion of %s)",
-                 XGetAtomName (display, reply.property));
+                 XGetAtomName (display, reply->property));
          wait_for_property_change (wait_object);
        }
 
@@ -794,8 +775,8 @@ x_reply_selection_request (struct input_event *event, int format, unsigned char
        XSelectInput (display, window, 0L);
 
       TRACE1 ("Set %s to a 0-length chunk to indicate EOF",
-             XGetAtomName (display, reply.property));
-      XChangeProperty (display, window, reply.property, type, format,
+             XGetAtomName (display, reply->property));
+      XChangeProperty (display, window, reply->property, type, format,
                       PropModeReplace, data, 0);
       TRACE0 ("Done sending incrementally");
     }
@@ -1219,9 +1200,9 @@ wait_for_property_change (struct prop_location *location)
 void
 x_handle_property_notify (XPropertyEvent *event)
 {
-  struct prop_location *prev = 0, *rest = property_change_wait_list;
+  struct prop_location *rest;
 
-  while (rest)
+  for (rest = property_change_wait_list; rest; rest = rest->next)
     {
       if (!rest->arrived
          && rest->property == event->atom
@@ -1242,9 +1223,6 @@ x_handle_property_notify (XPropertyEvent *event)
 
          return;
        }
-
-      prev = rest;
-      rest = rest->next;
     }
 }
 
@@ -1279,12 +1257,12 @@ copy_multiple_data (obj)
     return Fcons (XCAR (obj), copy_multiple_data (XCDR (obj)));
 
   CHECK_VECTOR (obj);
-  vec = Fmake_vector (size = XVECTOR (obj)->size, Qnil);
+  vec = Fmake_vector (size = ASIZE (obj), Qnil);
   for (i = 0; i < size; i++)
     {
       Lisp_Object vec2 = XVECTOR (obj)->contents [i];
       CHECK_VECTOR (vec2);
-      if (XVECTOR (vec2)->size != 2)
+      if (ASIZE (vec2) != 2)
        /* ??? Confusing error message */
        signal_error ("Vectors must be of length 2", vec2);
       XVECTOR (vec)->contents [i] = Fmake_vector (2, Qnil);
@@ -1462,7 +1440,7 @@ x_get_window_property (Display *display, Window window, Atom property,
   while (bytes_remaining)
     {
 #ifdef TRACE_SELECTION
-      int last = bytes_remaining;
+      unsigned long last = bytes_remaining;
 #endif
       result
        = XGetWindowProperty (display, window, property,
@@ -1472,7 +1450,7 @@ x_get_window_property (Display *display, Window window, Atom property,
                              actual_type_ret, actual_format_ret,
                              actual_size_ret, &bytes_remaining, &tmp_data);
 
-      TRACE2 ("Read %ld bytes from property %s",
+      TRACE2 ("Read %lu bytes from property %s",
              last - bytes_remaining,
              XGetAtomName (display, property));
 
@@ -1495,7 +1473,7 @@ x_get_window_property (Display *display, Window window, Atom property,
          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_ret == 32 && *actual_format_ret < BITS_PER_LONG)
+      if (32 < BITS_PER_LONG && *actual_format_ret == 32)
         {
           unsigned long i;
           int  *idata = (int *) ((*data_ret) + offset);
@@ -1896,7 +1874,7 @@ lisp_data_to_selection_data (Display *display, Lisp_Object obj,
        /* This vector is an ATOM set */
        {
          if (NILP (type)) type = QATOM;
-         *size_ret = XVECTOR (obj)->size;
+         *size_ret = ASIZE (obj);
          *format_ret = 32;
          *data_ret = (unsigned char *) xmalloc ((*size_ret) * sizeof (Atom));
          for (i = 0; i < *size_ret; i++)
@@ -1911,7 +1889,7 @@ lisp_data_to_selection_data (Display *display, Lisp_Object obj,
        /* This vector is an ATOM_PAIR set */
        {
          if (NILP (type)) type = QATOM_PAIR;
-         *size_ret = XVECTOR (obj)->size;
+         *size_ret = ASIZE (obj);
          *format_ret = 32;
          *data_ret = (unsigned char *)
            xmalloc ((*size_ret) * sizeof (Atom) * 2);
@@ -1919,7 +1897,7 @@ lisp_data_to_selection_data (Display *display, Lisp_Object obj,
            if (VECTORP (XVECTOR (obj)->contents [i]))
              {
                Lisp_Object pair = XVECTOR (obj)->contents [i];
-               if (XVECTOR (pair)->size != 2)
+               if (ASIZE (pair) != 2)
                  signal_error (
        "Elements of the vector must be vectors of exactly two elements",
                                pair);
@@ -1941,7 +1919,7 @@ lisp_data_to_selection_data (Display *display, Lisp_Object obj,
        /* This vector is an INTEGER set, or something like it */
        {
           int data_size = 2;
-         *size_ret = XVECTOR (obj)->size;
+         *size_ret = ASIZE (obj);
          if (NILP (type)) type = QINTEGER;
          *format_ret = 16;
          for (i = 0; i < *size_ret; i++)
@@ -1994,7 +1972,7 @@ clean_local_selection_data (Lisp_Object obj)
   if (VECTORP (obj))
     {
       int i;
-      int size = XVECTOR (obj)->size;
+      int size = ASIZE (obj);
       Lisp_Object copy;
       if (size == 1)
        return clean_local_selection_data (XVECTOR (obj)->contents [0]);
@@ -2100,7 +2078,7 @@ DEFUN ("x-disown-selection-internal", Fx_disown_selection_internal,
        Sx_disown_selection_internal, 1, 2, 0,
        doc: /* If we own the selection SELECTION, disown it.
 Disowning it means there is no such selection.  */)
-  (Lisp_Object selection, Lisp_Object time)
+  (Lisp_Object selection, Lisp_Object time_object)
 {
   Time timestamp;
   Atom selection_atom;
@@ -2119,10 +2097,10 @@ Disowning it means there is no such selection.  */)
   display = FRAME_X_DISPLAY (sf);
   dpyinfo = FRAME_X_DISPLAY_INFO (sf);
   CHECK_SYMBOL (selection);
-  if (NILP (time))
+  if (NILP (time_object))
     timestamp = last_event_timestamp;
   else
-    timestamp = cons_to_long (time);
+    timestamp = cons_to_long (time_object);
 
   if (NILP (assq_no_quit (selection, Vselection_alist)))
     return Qnil;  /* Don't disown the selection when we're not the owner.  */
@@ -2146,26 +2124,6 @@ Disowning it means there is no such selection.  */)
   return Qt;
 }
 
-/* Get rid of all the selections in buffer BUFFER.
-   This is used when we kill a buffer.  */
-
-void
-x_disown_buffer_selections (Lisp_Object buffer)
-{
-  Lisp_Object tail;
-  struct buffer *buf = XBUFFER (buffer);
-
-  for (tail = Vselection_alist; CONSP (tail); tail = XCDR (tail))
-    {
-      Lisp_Object elt, value;
-      elt = XCAR (tail);
-      value = XCDR (elt);
-      if (CONSP (value) && MARKERP (XCAR (value))
-         && XMARKER (XCAR (value))->buffer == buf)
-       Fx_disown_selection_internal (XCAR (elt), Qnil);
-    }
-}
-
 DEFUN ("x-selection-owner-p", Fx_selection_owner_p, Sx_selection_owner_p,
        0, 1, 0,
        doc: /* Whether the current Emacs process owns the given X Selection.
@@ -2226,7 +2184,8 @@ and t is the same as `SECONDARY'.  */)
 ***********************************************************************/
 /* Check that lisp values are of correct type for x_fill_property_data.
    That is, number, string or a cons with two numbers (low and high 16
-   bit parts of a 32 bit number).  */
+   bit parts of a 32 bit number).  Return the number of items in DATA,
+   or -1 if there is an error.  */
 
 int
 x_check_property_data (Lisp_Object data)
@@ -2234,15 +2193,16 @@ x_check_property_data (Lisp_Object data)
   Lisp_Object iter;
   int size = 0;
 
-  for (iter = data; CONSP (iter) && size != -1; iter = XCDR (iter), ++size)
+  for (iter = data; CONSP (iter); iter = XCDR (iter))
     {
       Lisp_Object o = XCAR (iter);
 
       if (! NUMBERP (o) && ! STRINGP (o) && ! CONSP (o))
-        size = -1;
+        return -1;
       else if (CONSP (o) &&
                (! NUMBERP (XCAR (o)) || ! NUMBERP (XCDR (o))))
-        size = -1;
+        return -1;
+      size++;
     }
 
   return size;
@@ -2283,7 +2243,7 @@ x_fill_property_data (Display *dpy, Lisp_Object data, void *ret, int format)
       else if (STRINGP (o))
         {
           BLOCK_INPUT;
-          val = (long) XInternAtom (dpy, (char *) SDATA (o), False);
+          val = (long) XInternAtom (dpy, SSDATA (o), False);
           UNBLOCK_INPUT;
         }
       else
@@ -2420,7 +2380,7 @@ FRAME is on.  If FRAME is nil, the selected frame is used.  */)
   else if (STRINGP (atom))
     {
       BLOCK_INPUT;
-      x_atom = XInternAtom (FRAME_X_DISPLAY (f), (char *) SDATA (atom), False);
+      x_atom = XInternAtom (FRAME_X_DISPLAY (f), SSDATA (atom), False);
       UNBLOCK_INPUT;
     }
   else
@@ -2468,9 +2428,8 @@ x_handle_dnd_message (struct frame *f, XClientMessageEvent *event, struct x_disp
      function expects them to be of size int (i.e. 32).  So to be able to
      use that function, put the data in the form it expects if format is 32. */
 
-  if (event->format == 32 && event->format < BITS_PER_LONG)
+  if (32 < BITS_PER_LONG && event->format == 32)
     {
-      int i;
       for (i = 0; i < 5; ++i) /* There are only 5 longs in a ClientMessage. */
         idata[i] = (int) event->data.l[i];
       data = (unsigned char *) idata;
@@ -2531,7 +2490,7 @@ are ignored.  */)
   CHECK_STRING (message_type);
   x_send_client_event(display, dest, from,
                       XInternAtom (dpyinfo->display,
-                                   SDATA (message_type),
+                                   SSDATA (message_type),
                                    False),
                       format, values);
 
@@ -2567,9 +2526,9 @@ x_send_client_event (Lisp_Object display, Lisp_Object dest, Lisp_Object from, At
     }
   else if (STRINGP (dest))
     {
-      if (strcmp (SDATA (dest), "PointerWindow") == 0)
+      if (strcmp (SSDATA (dest), "PointerWindow") == 0)
         wdest = PointerWindow;
-      else if (strcmp (SDATA (dest), "InputFocus") == 0)
+      else if (strcmp (SSDATA (dest), "InputFocus") == 0)
         wdest = InputFocus;
       else
         error ("DEST as a string must be one of PointerWindow or InputFocus");
@@ -2647,7 +2606,7 @@ syms_of_xselect (void)
   Vselection_alist = Qnil;
   staticpro (&Vselection_alist);
 
-  DEFVAR_LISP ("selection-converter-alist", &Vselection_converter_alist,
+  DEFVAR_LISP ("selection-converter-alist", Vselection_converter_alist,
               doc: /* An alist associating X Windows selection-types with functions.
 These functions are called to convert the selection, with three args:
 the name of the selection (typically `PRIMARY', `SECONDARY', or `CLIPBOARD');
@@ -2662,7 +2621,7 @@ means that a side-effect was executed,
 and there is no meaningful selection value.  */);
   Vselection_converter_alist = Qnil;
 
-  DEFVAR_LISP ("x-lost-selection-functions", &Vx_lost_selection_functions,
+  DEFVAR_LISP ("x-lost-selection-functions", Vx_lost_selection_functions,
               doc: /* A list of functions to be called when Emacs loses an X selection.
 \(This happens when some other X client makes its own selection
 or when a Lisp program explicitly clears the selection.)
@@ -2670,7 +2629,7 @@ The functions are called with one argument, the selection type
 \(a symbol, typically `PRIMARY', `SECONDARY', or `CLIPBOARD').  */);
   Vx_lost_selection_functions = Qnil;
 
-  DEFVAR_LISP ("x-sent-selection-functions", &Vx_sent_selection_functions,
+  DEFVAR_LISP ("x-sent-selection-functions", Vx_sent_selection_functions,
               doc: /* A list of functions to be called when Emacs answers a selection request.
 The functions are called with four arguments:
   - the selection name (typically `PRIMARY', `SECONDARY', or `CLIPBOARD');
@@ -2684,7 +2643,7 @@ This hook doesn't let you change the behavior of Emacs's selection replies,
 it merely informs you that they have happened.  */);
   Vx_sent_selection_functions = Qnil;
 
-  DEFVAR_INT ("x-selection-timeout", &x_selection_timeout,
+  DEFVAR_INT ("x-selection-timeout", x_selection_timeout,
              doc: /* Number of milliseconds to wait for a selection reply.
 If the selection owner doesn't reply in this time, we give up.
 A value of 0 means wait as long as necessary.  This is initialized from the
@@ -2714,6 +2673,3 @@ A value of 0 means wait as long as necessary.  This is initialized from the
   Qforeign_selection = intern_c_string ("foreign-selection");
   staticpro (&Qforeign_selection);
 }
-
-/* arch-tag: 7c293b0f-9918-4f69-8ac7-03e142307236
-   (do not change this comment) */