/* Don't allow a quit within the converter.
When the user types C-g, he would be surprised
if by luck it came during a converter. */
- ptrdiff_t count = SPECPDL_INDEX ();
+ dynwind_begin ();
specbind (Qinhibit_quit, Qt);
CHECK_SYMBOL (target_type);
XCAR (XCDR (local_value)));
else
value = Qnil;
- unbind_to (count, Qnil);
+ dynwind_end ();
}
/* Make sure this value is of a type that we could transmit
Window window = SELECTION_EVENT_REQUESTOR (event);
ptrdiff_t bytes_remaining;
int max_bytes = selection_quantum (display);
- ptrdiff_t count = SPECPDL_INDEX ();
+ dynwind_begin ();
struct selection_data *cs;
reply->type = SelectionNotify;
and then BLOCK again because x_uncatch_errors requires it. */
block_input ();
/* This calls x_uncatch_errors. */
- unbind_to (count, Qnil);
+ dynwind_end ();
unblock_input ();
}
\f
Atom property = SELECTION_EVENT_PROPERTY (event);
Lisp_Object local_selection_data;
int success = 0;
- ptrdiff_t count = SPECPDL_INDEX ();
+ dynwind_begin ();
GCPRO2 (local_selection_data, target_symbol);
if (!dpyinfo) goto DONE;
Frun_hook_with_args (4, args);
}
- unbind_to (count, Qnil);
+ dynwind_end ();
UNGCPRO;
}
static void
wait_for_property_change (struct prop_location *location)
{
- ptrdiff_t count = SPECPDL_INDEX ();
+ dynwind_begin ();
if (property_change_reply_object)
emacs_abort ();
}
}
- unbind_to (count, Qnil);
+ dynwind_end ();
}
/* Called from XTread_socket in response to a PropertyNotify event. */
if (total_size_max < bytes_remaining)
goto size_overflow;
total_size = bytes_remaining;
- data = malloc (total_size + 1);
- if (! data)
- goto memory_exhausted;
+ data = xmalloc_atomic (total_size + 1);
/* Now read, until we've gotten it all. */
while (bytes_remaining)
if (total_size - offset < bytes_gotten)
{
- unsigned char *data1;
ptrdiff_t remaining_lim = total_size_max - offset - bytes_gotten;
if (remaining_lim < 0 || remaining_lim < bytes_remaining)
goto size_overflow;
total_size = offset + bytes_gotten + bytes_remaining;
- data1 = realloc (data, total_size + 1);
- if (! data1)
- goto memory_exhausted;
- data = data1;
+ data = xrealloc (data, total_size + 1);
}
if (BITS_PER_LONG > 32 && *actual_format_ret == 32)
return;
size_overflow:
- free (data);
+ xfree (data);
unblock_input ();
memory_full (SIZE_MAX);
-
- memory_exhausted:
- free (data);
- unblock_input ();
- memory_full (total_size + 1);
}
\f
/* Use xfree, not XFree, to free the data obtained with this function. */
struct prop_location *wait_object;
if (min (PTRDIFF_MAX, SIZE_MAX) < min_size_bytes)
memory_full (SIZE_MAX);
- *data_ret = xmalloc (min_size_bytes);
+ *data_ret = xmalloc_atomic (min_size_bytes);
*size_bytes_ret = min_size_bytes;
TRACE1 ("Read %u bytes incrementally", min_size_bytes);
{
Lisp_Object frame;
XSETFRAME (frame, f);
- RETURN_UNGCPRO (x_get_foreign_selection (selection_symbol, target_type,
- time_stamp, frame));
+ return x_get_foreign_selection (selection_symbol, target_type, time_stamp, frame);
}
if (CONSP (val) && SYMBOLP (XCAR (val)))
if (CONSP (val) && NILP (XCDR (val)))
val = XCAR (val);
}
- RETURN_UNGCPRO (clean_local_selection_data (val));
+ return clean_local_selection_data (val);
}
DEFUN ("x-disown-selection-internal", Fx_disown_selection_internal,
data, size * format_bytes, type, format);
}
-/* Get the mouse position in frame relative coordinates. */
-
-static void
-mouse_position_for_drop (struct frame *f, int *x, int *y)
-{
- Window root, dummy_window;
- int dummy;
-
- block_input ();
-
- XQueryPointer (FRAME_X_DISPLAY (f),
- DefaultRootWindow (FRAME_X_DISPLAY (f)),
-
- /* The root window which contains the pointer. */
- &root,
-
- /* Window pointer is on, not used */
- &dummy_window,
-
- /* The position on that root window. */
- x, y,
-
- /* x/y in dummy_window coordinates, not used. */
- &dummy, &dummy,
-
- /* Modifier keys and pointer buttons, about which
- we don't care. */
- (unsigned int *) &dummy);
-
-
- /* Absolute to relative. */
- *x -= f->left_pos + FRAME_OUTER_TO_INNER_DIFF_X (f);
- *y -= f->top_pos + FRAME_OUTER_TO_INNER_DIFF_Y (f);
-
- unblock_input ();
-}
-
DEFUN ("x-get-atom-name", Fx_get_atom_name,
Sx_get_atom_name, 1, 2, 0,
doc: /* Return the X atom name for VALUE as a string.
event->format,
size));
- mouse_position_for_drop (f, &x, &y);
+ x_relative_mouse_position (f, &x, &y);
bufp->kind = DRAG_N_DROP_EVENT;
bufp->frame_or_window = frame;
bufp->timestamp = CurrentTime;
void
syms_of_xselect (void)
{
- defsubr (&Sx_get_selection_internal);
- defsubr (&Sx_own_selection_internal);
- defsubr (&Sx_disown_selection_internal);
- defsubr (&Sx_selection_owner_p);
- defsubr (&Sx_selection_exists_p);
-
- defsubr (&Sx_get_atom_name);
- defsubr (&Sx_send_client_message);
- defsubr (&Sx_register_dnd_atom);
+#include "xselect.x"
reading_selection_reply = Fcons (Qnil, Qnil);
staticpro (&reading_selection_reply);