diff src/xselect.c @ 90320:8a1ee48a8386

Revision: emacs@sv.gnu.org/emacs--unicode--0--patch-26 Merge from emacs--devo--0 Patches applied: * emacs--devo--0 (patch 119-122) - Update from CVS
author Miles Bader <miles@gnu.org>
date Sun, 26 Feb 2006 07:09:24 +0000
parents c5406394f567 f2147c1027b6
children 5754737d1e04
line wrap: on
line diff
--- a/src/xselect.c	Sun Feb 26 06:32:30 2006 +0000
+++ b/src/xselect.c	Sun Feb 26 07:09:24 2006 +0000
@@ -402,16 +402,15 @@
   Time time = last_event_timestamp;
   Atom selection_atom;
   struct x_display_info *dpyinfo = FRAME_X_DISPLAY_INFO (sf);
-  int count;
 
   CHECK_SYMBOL (selection_name);
   selection_atom = symbol_to_x_atom (dpyinfo, display, selection_name);
 
   BLOCK_INPUT;
-  count = x_catch_errors (display);
+  x_catch_errors (display);
   XSetSelectionOwner (display, selection_atom, selecting_window, time);
   x_check_errors (display, "Can't set selection: %s");
-  x_uncatch_errors (display, count);
+  x_uncatch_errors (display);
   UNBLOCK_INPUT;
 
   /* Now update the local cache */
@@ -572,7 +571,6 @@
      struct input_event *event;
 {
   XSelectionEvent reply;
-  int count;
 
   reply.type = SelectionNotify;
   reply.display = SELECTION_EVENT_DISPLAY (event);
@@ -585,10 +583,10 @@
   /* The reason for the error may be that the receiver has
      died in the meantime.  Handle that case.  */
   BLOCK_INPUT;
-  count = x_catch_errors (reply.display);
+  x_catch_errors (reply.display);
   XSendEvent (reply.display, reply.requestor, False, 0L, (XEvent *) &reply);
   XFlush (reply.display);
-  x_uncatch_errors (reply.display, count);
+  x_uncatch_errors (reply.display);
   UNBLOCK_INPUT;
 }
 
@@ -690,7 +688,7 @@
   int format_bytes = format/8;
   int max_bytes = SELECTION_QUANTUM (display);
   struct x_display_info *dpyinfo = x_display_info_for_display (display);
-  int count;
+  int count = SPECPDL_INDEX ();
 
   if (max_bytes > MAX_SELECTION_QUANTUM)
     max_bytes = MAX_SELECTION_QUANTUM;
@@ -707,7 +705,7 @@
 
   /* #### XChangeProperty can generate BadAlloc, and we must handle it! */
   BLOCK_INPUT;
-  count = x_catch_errors (display);
+  x_catch_errors (display);
 
 #ifdef TRACE_SELECTION
   {
@@ -860,7 +858,9 @@
      UNBLOCK to enter the event loop and get possible errors delivered,
      and then BLOCK again because x_uncatch_errors requires it.  */
   BLOCK_INPUT;
-  x_uncatch_errors (display, count);
+
+  unbind_to (count, Qnil);
+  x_uncatch_errors (display);
   UNBLOCK_INPUT;
 }
 
@@ -1392,7 +1392,7 @@
 
   BLOCK_INPUT;
 
-  count = x_catch_errors (display);
+  x_catch_errors (display);
 
   TRACE2 ("Get selection %s, type %s",
 	  XGetAtomName (display, type_atom),
@@ -1409,6 +1409,8 @@
 
   frame = some_frame_on_display (dpyinfo);
 
+  count = SPECPDL_INDEX ();
+
   /* If the display no longer has frames, we can't expect
      to get many more selection requests from it, so don't
      bother trying to queue them.  */
@@ -1430,8 +1432,9 @@
   TRACE1 ("  Got event = %d", !NILP (XCAR (reading_selection_reply)));
 
   BLOCK_INPUT;
+  unbind_to (count, Qnil);
   x_check_errors (display, "Cannot get selection: %s");
-  x_uncatch_errors (display, count);
+  x_uncatch_errors (display);
   UNBLOCK_INPUT;
 
   if (NILP (XCAR (reading_selection_reply)))
@@ -2650,7 +2653,6 @@
   struct frame *f = check_x_frame (frame);
   char *name = 0;
   Lisp_Object ret = Qnil;
-  int count;
   Display *dpy = FRAME_X_DISPLAY (f);
   Atom atom;
 
@@ -2664,14 +2666,14 @@
     error ("Wrong type, value must be number or cons");
 
   BLOCK_INPUT;
-  count = x_catch_errors (dpy);
+  x_catch_errors (dpy);
 
   name = atom ? XGetAtomName (dpy, atom) : "";
 
   if (! x_had_errors_p (dpy))
     ret = make_string (name, strlen (name));
 
-  x_uncatch_errors (dpy, count);
+  x_uncatch_errors (dpy);
 
   if (atom && name) XFree (name);
   if (NILP (ret)) ret = make_string ("", 0);
@@ -2771,7 +2773,6 @@
   Lisp_Object cons;
   int size;
   struct frame *f = check_x_frame (from);
-  int count;
   int to_root;
 
   CHECK_STRING (message_type);
@@ -2841,14 +2842,14 @@
      the destination window.  But if we are sending to the root window,
      there is no such client.  Then we set the event mask to 0xffff.  The
      event then goes to clients selecting for events on the root window.  */
-  count = x_catch_errors (dpyinfo->display);
+  x_catch_errors (dpyinfo->display);
   {
     int propagate = to_root ? False : True;
     unsigned mask = to_root ? 0xffff : 0;
     XSendEvent (dpyinfo->display, wdest, propagate, mask, &event);
     XFlush (dpyinfo->display);
   }
-  x_uncatch_errors (dpyinfo->display, count);
+  x_uncatch_errors (dpyinfo->display);
   UNBLOCK_INPUT;
 
   return Qnil;