Use XFlush, not XFlushQueue, throughout.
authorRichard M. Stallman <rms@gnu.org>
Sun, 23 Oct 1994 09:38:50 +0000 (09:38 +0000)
committerRichard M. Stallman <rms@gnu.org>
Sun, 23 Oct 1994 09:38:50 +0000 (09:38 +0000)
(Xatom_*): Variables deleted.
Use slots in x_display_info structure instead.
(symbol_to_x_atom, x_atom_to_symbol):
New arg dpyinfo.  All callers changed.
(xatoms_of_xselect): Function deleted.

src/xselect.c

index e99e7af..b34686c 100644 (file)
@@ -38,10 +38,6 @@ x_reply_selection_request  */
 
 #define CUT_BUFFER_SUPPORT
 
-static Atom Xatom_CLIPBOARD, Xatom_TIMESTAMP, Xatom_TEXT, Xatom_DELETE,
-  Xatom_MULTIPLE, Xatom_INCR, Xatom_EMACS_TMP, Xatom_TARGETS, Xatom_NULL,
-  Xatom_ATOM_PAIR;
-
 Lisp_Object QPRIMARY, QSECONDARY, QSTRING, QINTEGER, QCLIPBOARD, QTIMESTAMP,
   QTEXT, QDELETE, QMULTIPLE, QINCR, QEMACS_TMP, QTARGETS, QATOM, QNULL,
   QATOM_PAIR;
@@ -110,7 +106,8 @@ static Lisp_Object x_get_window_property_as_lisp_data ();
    roundtrip whenever possible.  */
 
 static Atom
-symbol_to_x_atom (display, sym)
+symbol_to_x_atom (dpyinfo, display, sym)
+     struct x_display_info *dpyinfo;
      Display *display;
      Lisp_Object sym;
 {
@@ -121,15 +118,15 @@ symbol_to_x_atom (display, sym)
   if (EQ (sym, QSTRING))    return XA_STRING;
   if (EQ (sym, QINTEGER))   return XA_INTEGER;
   if (EQ (sym, QATOM))     return XA_ATOM;
-  if (EQ (sym, QCLIPBOARD)) return Xatom_CLIPBOARD;
-  if (EQ (sym, QTIMESTAMP)) return Xatom_TIMESTAMP;
-  if (EQ (sym, QTEXT))     return Xatom_TEXT;
-  if (EQ (sym, QDELETE))    return Xatom_DELETE;
-  if (EQ (sym, QMULTIPLE))  return Xatom_MULTIPLE;
-  if (EQ (sym, QINCR))     return Xatom_INCR;
-  if (EQ (sym, QEMACS_TMP)) return Xatom_EMACS_TMP;
-  if (EQ (sym, QTARGETS))   return Xatom_TARGETS;
-  if (EQ (sym, QNULL))     return Xatom_NULL;
+  if (EQ (sym, QCLIPBOARD)) return dpyinfo->Xatom_CLIPBOARD;
+  if (EQ (sym, QTIMESTAMP)) return dpyinfo->Xatom_TIMESTAMP;
+  if (EQ (sym, QTEXT))     return dpyinfo->Xatom_TEXT;
+  if (EQ (sym, QDELETE))    return dpyinfo->Xatom_DELETE;
+  if (EQ (sym, QMULTIPLE))  return dpyinfo->Xatom_MULTIPLE;
+  if (EQ (sym, QINCR))     return dpyinfo->Xatom_INCR;
+  if (EQ (sym, QEMACS_TMP)) return dpyinfo->Xatom_EMACS_TMP;
+  if (EQ (sym, QTARGETS))   return dpyinfo->Xatom_TARGETS;
+  if (EQ (sym, QNULL))     return dpyinfo->Xatom_NULL;
 #ifdef CUT_BUFFER_SUPPORT
   if (EQ (sym, QCUT_BUFFER0)) return XA_CUT_BUFFER0;
   if (EQ (sym, QCUT_BUFFER1)) return XA_CUT_BUFFER1;
@@ -156,7 +153,8 @@ symbol_to_x_atom (display, sym)
    and calls to intern whenever possible.  */
 
 static Lisp_Object
-x_atom_to_symbol (display, atom)
+x_atom_to_symbol (dpyinfo, display, atom)
+     struct x_display_info *dpyinfo;
      Display *display;
      Atom atom;
 {
@@ -195,23 +193,23 @@ x_atom_to_symbol (display, atom)
 #endif
     }
 
-  if (atom == Xatom_CLIPBOARD)
+  if (atom == dpyinfo->Xatom_CLIPBOARD)
     return QCLIPBOARD;
-  if (atom == Xatom_TIMESTAMP)
+  if (atom == dpyinfo->Xatom_TIMESTAMP)
     return QTIMESTAMP;
-  if (atom == Xatom_TEXT)
+  if (atom == dpyinfo->Xatom_TEXT)
     return QTEXT;
-  if (atom == Xatom_DELETE)
+  if (atom == dpyinfo->Xatom_DELETE)
     return QDELETE;
-  if (atom == Xatom_MULTIPLE)
+  if (atom == dpyinfo->Xatom_MULTIPLE)
     return QMULTIPLE;
-  if (atom == Xatom_INCR)
+  if (atom == dpyinfo->Xatom_INCR)
     return QINCR;
-  if (atom == Xatom_EMACS_TMP)
+  if (atom == dpyinfo->Xatom_EMACS_TMP)
     return QEMACS_TMP;
-  if (atom == Xatom_TARGETS)
+  if (atom == dpyinfo->Xatom_TARGETS)
     return QTARGETS;
-  if (atom == Xatom_NULL)
+  if (atom == dpyinfo->Xatom_NULL)
     return QNULL;
 
   BLOCK_INPUT;
@@ -240,9 +238,10 @@ x_own_selection (selection_name, selection_value)
   Display *display = FRAME_X_DISPLAY (selected_frame);
   Time time = last_event_timestamp;
   Atom selection_atom;
+  struct x_display_info *dpyinfo = FRAME_X_DISPLAY_INFO (selected_frame);
 
   CHECK_SYMBOL (selection_name, 0);
-  selection_atom = symbol_to_x_atom (display, selection_name);
+  selection_atom = symbol_to_x_atom (dpyinfo, display, selection_name);
 
   BLOCK_INPUT;
   x_catch_errors (selected_frame);
@@ -415,7 +414,7 @@ x_decline_selection_request (event)
   BLOCK_INPUT;
   XSendEvent (reply.display, reply.requestor, False, 0L,
              (XEvent *) &reply);
-  XFlushQueue ();
+  XFlush (reply.display);
   UNBLOCK_INPUT;
 }
 
@@ -485,6 +484,7 @@ x_reply_selection_request (event, format, data, size, type)
   int bytes_remaining;
   int format_bytes = format/8;
   int max_bytes = SELECTION_QUANTUM (display);
+  struct x_display_info *dpyinfo = x_display_info_for_display (display);
 
   if (max_bytes > MAX_SELECTION_QUANTUM)
     max_bytes = MAX_SELECTION_QUANTUM;
@@ -516,7 +516,7 @@ x_reply_selection_request (event, format, data, size, type)
                       PropModeReplace, data, size);
       /* At this point, the selection was successfully stored; ack it.  */
       XSendEvent (display, window, False, 0L, (XEvent *) &reply);
-      XFlushQueue ();
+      XFlush (display);
       UNBLOCK_INPUT;
     }
   else
@@ -534,13 +534,13 @@ x_reply_selection_request (event, format, data, size, type)
       wait_object = expect_property_change (display, window, reply.property,
                                            PropertyDelete);
 
-      XChangeProperty (display, window, reply.property, Xatom_INCR,
+      XChangeProperty (display, window, reply.property, dpyinfo->Xatom_INCR,
                       32, PropModeReplace, (unsigned char *)
                       &bytes_remaining, 1);
       XSelectInput (display, window, PropertyChangeMask);
       /* Tell 'em the INCR data is there...  */
       (void) XSendEvent (display, window, False, 0L, (XEvent *) &reply);
-      XFlushQueue ();
+      XFlush (display);
       UNBLOCK_INPUT;
 
       /* First, wait for the requestor to ack by deleting the property.
@@ -566,7 +566,7 @@ x_reply_selection_request (event, format, data, size, type)
                           PropModeAppend, data, i / format_bytes);
          bytes_remaining -= i;
          data += i;
-         XFlushQueue ();
+         XFlush (display);
          UNBLOCK_INPUT;
 
          /* Now wait for the requestor to ack this chunk by deleting the
@@ -585,7 +585,7 @@ x_reply_selection_request (event, format, data, size, type)
 
       XChangeProperty (display, window, reply.property, type, format,
                       PropModeReplace, data, 0);
-      XFlushQueue ();
+      XFlush (display);
       UNBLOCK_INPUT;
     }
 }
@@ -605,6 +605,8 @@ x_handle_selection_request (event)
   Time local_selection_time;
   Lisp_Object successful_p;
   int count;
+  struct x_display_info *dpyinfo
+    = x_display_info_for_display (SELECTION_EVENT_DISPLAY (event));
 
   local_selection_data = Qnil;
   target_symbol = Qnil;
@@ -613,7 +615,8 @@ x_handle_selection_request (event)
 
   GCPRO3 (local_selection_data, converted_selection, target_symbol);
 
-  selection_symbol = x_atom_to_symbol (SELECTION_EVENT_DISPLAY (event),
+  selection_symbol = x_atom_to_symbol (dpyinfo,
+                                      SELECTION_EVENT_DISPLAY (event),
                                       SELECTION_EVENT_SELECTION (event));
 
   local_selection_data = assq_no_quit (selection_symbol, Vselection_alist);
@@ -643,7 +646,7 @@ x_handle_selection_request (event)
   x_selection_current_request = event;
   record_unwind_protect (x_selection_request_lisp_error, Qnil);
 
-  target_symbol = x_atom_to_symbol (SELECTION_EVENT_DISPLAY (event),
+  target_symbol = x_atom_to_symbol (dpyinfo, SELECTION_EVENT_DISPLAY (event),
                                    SELECTION_EVENT_TARGET (event));
 
 #if 0 /* #### MULTIPLE doesn't work yet */
@@ -707,8 +710,9 @@ x_handle_selection_clear (event)
   
   Lisp_Object selection_symbol, local_selection_data;
   Time local_selection_time;
+  struct x_display_info *dpyinfo = x_display_info_for_display (display);
 
-  selection_symbol = x_atom_to_symbol (display, selection);
+  selection_symbol = x_atom_to_symbol (dpyinfo, display, selection);
 
   local_selection_data = assq_no_quit (selection_symbol, Vselection_alist);
 
@@ -935,7 +939,7 @@ x_handle_property_notify (event)
 #if 0
          fprintf (stderr, "Saw expected prop-%s on %s\n",
                   (event->state == PropertyDelete ? "delete" : "change"),
-                  (char *) XSYMBOL (x_atom_to_symbol (event->display,
+                  (char *) XSYMBOL (x_atom_to_symbol (dpyinfo, event->display,
                                                       event->atom))
                   ->name->data);
 #endif
@@ -960,7 +964,8 @@ x_handle_property_notify (event)
 #if 0
   fprintf (stderr, "Saw UNexpected prop-%s on %s\n",
           (event->state == PropertyDelete ? "delete" : "change"),
-          (char *) XSYMBOL (x_atom_to_symbol (event->display, event->atom))
+          (char *) XSYMBOL (x_atom_to_symbol (dpyinfo,
+                                              event->display, event->atom))
           ->name->data);
 #endif
 }
@@ -1031,22 +1036,23 @@ x_get_foreign_selection (selection_symbol, target_type)
 {
   Window requestor_window = FRAME_X_WINDOW (selected_frame);
   Display *display = FRAME_X_DISPLAY (selected_frame);
+  struct x_display_info *dpyinfo = FRAME_X_DISPLAY_INFO (selected_frame);
   Time requestor_time = last_event_timestamp;
-  Atom target_property = Xatom_EMACS_TMP;
-  Atom selection_atom = symbol_to_x_atom (display, selection_symbol);
+  Atom target_property = dpyinfo->Xatom_EMACS_TMP;
+  Atom selection_atom = symbol_to_x_atom (dpyinfo, display, selection_symbol);
   Atom type_atom;
   int secs, usecs;
 
   if (CONSP (target_type))
-    type_atom = symbol_to_x_atom (display, XCONS (target_type)->car);
+    type_atom = symbol_to_x_atom (dpyinfo, display, XCONS (target_type)->car);
   else
-    type_atom = symbol_to_x_atom (display, target_type);
+    type_atom = symbol_to_x_atom (dpyinfo, display, target_type);
 
   BLOCK_INPUT;
   x_catch_errors (selected_frame);
   XConvertSelection (display, selection_atom, type_atom, target_property,
                     requestor_window, requestor_time);
-  XFlushQueue ();
+  XFlush (display);
 
   /* Prepare to block until the reply has been read.  */
   reading_selection_window = requestor_window;
@@ -1152,7 +1158,7 @@ x_get_window_property (display, window, property, data_ret, bytes_ret,
       xfree ((char *) tmp_data);
     }
 
-  XFlushQueue ();
+  XFlush (display);
   UNBLOCK_INPUT;
   *bytes_ret = offset;
 }
@@ -1193,7 +1199,7 @@ receive_incremental_selection (display, window, property, target_type,
   XDeleteProperty (display, window, property);
   wait_object = expect_property_change (display, window, property,
                                        PropertyNewValue);
-  XFlushQueue ();
+  XFlush (display);
   UNBLOCK_INPUT;
 
   while (1)
@@ -1225,7 +1231,7 @@ receive_incremental_selection (display, window, property, target_type,
       XDeleteProperty (display, window, property);
       wait_object = expect_property_change (display, window, property,
                                            PropertyNewValue);
-      XFlushQueue ();
+      XFlush (display);
       UNBLOCK_INPUT;
 
 #if 0
@@ -1265,6 +1271,7 @@ x_get_window_property_as_lisp_data (display, window, property, target_type,
   unsigned char *data = 0;
   int bytes = 0;
   Lisp_Object val;
+  struct x_display_info *dpyinfo = x_display_info_for_display (display);
 
   x_get_window_property (display, window, property, &data, &bytes,
                         &actual_type, &actual_format, &actual_size, 1);
@@ -1281,15 +1288,17 @@ x_get_window_property_as_lisp_data (display, window, property, target_type,
                 Fcons (build_string ("selection owner couldn't convert"),
                        actual_type
                        ? Fcons (target_type,
-                                Fcons (x_atom_to_symbol (display, actual_type),
+                                Fcons (x_atom_to_symbol (dpyinfo, display,
+                                                         actual_type),
                                        Qnil))
                        : Fcons (target_type, Qnil))
                 : Fcons (build_string ("no selection"),
-                         Fcons (x_atom_to_symbol (display, selection_atom),
+                         Fcons (x_atom_to_symbol (dpyinfo, display,
+                                                  selection_atom),
                                 Qnil)));
     }
   
-  if (actual_type == Xatom_INCR)
+  if (actual_type == dpyinfo->Xatom_INCR)
     {
       /* That wasn't really the data, just the beginning.  */
 
@@ -1305,7 +1314,7 @@ x_get_window_property_as_lisp_data (display, window, property, target_type,
 
   BLOCK_INPUT;
   XDeleteProperty (display, window, property);
-  XFlushQueue ();
+  XFlush (display);
   UNBLOCK_INPUT;
 
   /* It's been read.  Now convert it to a lisp object in some semi-rational
@@ -1351,8 +1360,9 @@ selection_data_to_lisp_data (display, data, size, type, format)
      Atom type;
      int size, format;
 {
+  struct x_display_info *dpyinfo = x_display_info_for_display (display);
 
-  if (type == Xatom_NULL)
+  if (type == dpyinfo->Xatom_NULL)
     return QNULL;
 
   /* Convert any 8-bit data to a string, for compactness.  */
@@ -1366,12 +1376,13 @@ selection_data_to_lisp_data (display, data, size, type, format)
     {
       int i;
       if (size == sizeof (Atom))
-       return x_atom_to_symbol (display, *((Atom *) data));
+       return x_atom_to_symbol (dpyinfo, display, *((Atom *) data));
       else
        {
          Lisp_Object v = Fmake_vector (size / sizeof (Atom), 0);
          for (i = 0; i < size / sizeof (Atom); i++)
-           Faset (v, i, x_atom_to_symbol (display, ((Atom *) data) [i]));
+           Faset (v, i, x_atom_to_symbol (dpyinfo, display,
+                                          ((Atom *) data) [i]));
          return v;
        }
     }
@@ -1426,6 +1437,7 @@ lisp_data_to_selection_data (display, obj,
      int *nofree_ret;
 {
   Lisp_Object type = Qnil;
+  struct x_display_info *dpyinfo = x_display_info_for_display (display);
 
   *nofree_ret = 0;
 
@@ -1458,7 +1470,7 @@ lisp_data_to_selection_data (display, obj,
       *size_ret = 1;
       *data_ret = (unsigned char *) xmalloc (sizeof (Atom) + 1);
       (*data_ret) [sizeof (Atom)] = 0;
-      (*(Atom **) data_ret) [0] = symbol_to_x_atom (display, obj);
+      (*(Atom **) data_ret) [0] = symbol_to_x_atom (dpyinfo, display, obj);
       if (NILP (type)) type = QATOM;
     }
   else if (INTEGERP (obj)
@@ -1503,7 +1515,7 @@ lisp_data_to_selection_data (display, obj,
          for (i = 0; i < *size_ret; i++)
            if (SYMBOLP (XVECTOR (obj)->contents [i]))
              (*(Atom **) data_ret) [i]
-               = symbol_to_x_atom (display, XVECTOR (obj)->contents [i]);
+               = symbol_to_x_atom (dpyinfo, display, XVECTOR (obj)->contents [i]);
            else
              Fsignal (Qerror, /* Qselection_error */
                       Fcons (build_string
@@ -1530,9 +1542,11 @@ lisp_data_to_selection_data (display, obj,
                                  Fcons (pair, Qnil)));
                
                (*(Atom **) data_ret) [i * 2]
-                 = symbol_to_x_atom (display, XVECTOR (pair)->contents [0]);
+                 = symbol_to_x_atom (dpyinfo, display,
+                                     XVECTOR (pair)->contents [0]);
                (*(Atom **) data_ret) [(i * 2) + 1]
-                 = symbol_to_x_atom (display, XVECTOR (pair)->contents [1]);
+                 = symbol_to_x_atom (dpyinfo, display,
+                                     XVECTOR (pair)->contents [1]);
              }
            else
              Fsignal (Qerror,
@@ -1572,7 +1586,7 @@ lisp_data_to_selection_data (display, obj,
             Fcons (build_string ("unrecognised selection data"),
                    Fcons (obj, Qnil)));
 
-  *type_ret = symbol_to_x_atom (display, type);
+  *type_ret = symbol_to_x_atom (dpyinfo, display, type);
 }
 
 static Lisp_Object
@@ -1710,9 +1724,11 @@ Disowning it means there is no such selection.")
   Atom selection_atom;
   XSelectionClearEvent event;
   Display *display;
+  struct x_display_info *dpyinfo;
 
   check_x ();
   display = FRAME_X_DISPLAY (selected_frame);
+  dpyinfo = FRAME_X_DISPLAY_INFO (selected_frame);
   CHECK_SYMBOL (selection, 0);
   if (NILP (time))
     timestamp = last_event_timestamp;
@@ -1722,7 +1738,7 @@ Disowning it means there is no such selection.")
   if (NILP (assq_no_quit (selection, Vselection_alist)))
     return Qnil;  /* Don't disown the selection when we're not the owner.  */
 
-  selection_atom = symbol_to_x_atom (display, selection);
+  selection_atom = symbol_to_x_atom (dpyinfo, display, selection);
 
   BLOCK_INPUT;
   XSetSelectionOwner (display, selection_atom, None, timestamp);
@@ -1805,7 +1821,8 @@ and t is the same as `SECONDARY'.)")
     return Qt;
   if (EQ (selection, Qnil)) selection = QPRIMARY;
   if (EQ (selection, Qt)) selection = QSECONDARY;
-  atom = symbol_to_x_atom (dpy, selection);
+  atom = symbol_to_x_atom (FRAME_X_DISPLAY_INFO (selected_frame),
+                          dpy, selection);
   if (atom == 0)
     return Qnil;
   BLOCK_INPUT;
@@ -1869,12 +1886,14 @@ DEFUN ("x-get-cut-buffer-internal", Fx_get_cut_buffer_internal,
   unsigned long size;
   Lisp_Object ret;
   Display *display;
+  struct x_display_info *dpyinfo;
 
   check_x ();
   display = FRAME_X_DISPLAY (selected_frame);
+  dpyinfo = FRAME_X_DISPLAY_INFO (selected_frame);
   window = RootWindow (display, 0); /* Cut buffers are on screen 0 */
   CHECK_CUT_BUFFER (buffer, 0);
-  buffer_atom = symbol_to_x_atom (display, buffer);
+  buffer_atom = symbol_to_x_atom (dpyinfo, display, buffer);
 
   x_get_window_property (display, window, buffer_atom, &data, &bytes,
                         &type, &format, &size, 0);
@@ -1883,7 +1902,7 @@ DEFUN ("x-get-cut-buffer-internal", Fx_get_cut_buffer_internal,
   if (format != 8 || type != XA_STRING)
     Fsignal (Qerror,
             Fcons (build_string ("cut buffer doesn't contain 8-bit data"),
-                   Fcons (x_atom_to_symbol (display, type),
+                   Fcons (x_atom_to_symbol (dpyinfo, display, type),
                           Fcons (make_number (format), Qnil))));
 
   ret = (bytes ? make_string ((char *) data, bytes) : Qnil);
@@ -1916,7 +1935,8 @@ DEFUN ("x-store-cut-buffer-internal", Fx_store_cut_buffer_internal,
 
   CHECK_CUT_BUFFER (buffer, 0);
   CHECK_STRING (string, 0);
-  buffer_atom = symbol_to_x_atom (display, buffer);
+  buffer_atom = symbol_to_x_atom (FRAME_X_DISPLAY_INFO (selected_frame),
+                                 display, buffer);
   data = (unsigned char *) XSTRING (string)->data;
   bytes = XSTRING (string)->size;
   bytes_remaining = bytes;
@@ -1983,26 +2003,6 @@ positive means move values forward, negative means backward.")
 
 #endif
 \f
-void
-Xatoms_of_xselect ()
-{
-#define ATOM(x) XInternAtom (x_current_display, (x), False)
-
-  BLOCK_INPUT;
-  /* Non-predefined atoms that we might end up using a lot */
-  Xatom_CLIPBOARD =    ATOM ("CLIPBOARD");
-  Xatom_TIMESTAMP =    ATOM ("TIMESTAMP");
-  Xatom_TEXT =         ATOM ("TEXT");
-  Xatom_DELETE =       ATOM ("DELETE");
-  Xatom_MULTIPLE =     ATOM ("MULTIPLE");
-  Xatom_INCR =         ATOM ("INCR");
-  Xatom_EMACS_TMP =    ATOM ("_EMACS_TMP_");
-  Xatom_TARGETS =      ATOM ("TARGETS");
-  Xatom_NULL =         ATOM ("NULL");
-  Xatom_ATOM_PAIR =    ATOM ("ATOM_PAIR");
-  UNBLOCK_INPUT;
-}
-
 void
 syms_of_xselect ()
 {