/* X Selection processing for Emacs.
Copyright (C) 1993, 1994, 1995, 1996, 1997, 2000, 2001, 2002, 2003,
- 2004, 2005, 2006 Free Software Foundation, Inc.
+ 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
This file is part of GNU Emacs.
static Lisp_Object Vx_lost_selection_functions;
static Lisp_Object Vx_sent_selection_functions;
-/* Coding system for communicating with other X clients via cutbuffer,
- selection, and clipboard. */
+/* Coding system for communicating with other X clients via selection
+ and clipboard. */
static Lisp_Object Vselection_coding_system;
/* Coding system for the next communicating with other X clients. */
break;
/* Now wait for the requester to ack this chunk by deleting the
- property. This can run random lisp code or signal. */
+ property. This can run random lisp code or signal. */
TRACE1 ("Waiting for increment ACK (deletion of %s)",
XGetAtomName (display, reply.property));
wait_for_property_change (wait_object);
Atom type;
int nofree;
+ if (CONSP (converted_selection) && NILP (XCDR (converted_selection)))
+ {
+ x_decline_selection_request (event);
+ goto DONE2;
+ }
+
lisp_data_to_selection_data (SELECTION_EVENT_DISPLAY (event),
converted_selection,
&data, &type, &size, &format, &nofree);
if (!nofree)
xfree (data);
}
+
+ DONE2:
unbind_to (count, Qnil);
DONE:
return ret;
}
-/* Convert an XClientMessageEvent to a Lisp event of type DRAG_N_DROP_EVENT.
- TODO: Check if this client event really is a DND event? */
+DEFUN ("x-register-dnd-atom", Fx_register_dnd_atom,
+ Sx_register_dnd_atom, 1, 2, 0,
+ doc: /* Request that dnd events are made for ClientMessages with ATOM.
+ATOM can be a symbol or a string. The ATOM is interned on the display that
+FRAME is on. If FRAME is nil, the selected frame is used. */)
+ (atom, frame)
+ Lisp_Object atom, frame;
+{
+ Atom x_atom;
+ struct frame *f = check_x_frame (frame);
+ size_t i;
+ struct x_display_info *dpyinfo = FRAME_X_DISPLAY_INFO (f);
+
+
+ if (SYMBOLP (atom))
+ x_atom = symbol_to_x_atom (dpyinfo, FRAME_X_DISPLAY (f), atom);
+ else if (STRINGP (atom))
+ {
+ BLOCK_INPUT;
+ x_atom = XInternAtom (FRAME_X_DISPLAY (f), (char *) SDATA (atom), False);
+ UNBLOCK_INPUT;
+ }
+ else
+ error ("ATOM must be a symbol or a string");
+
+ for (i = 0; i < dpyinfo->x_dnd_atoms_length; ++i)
+ if (dpyinfo->x_dnd_atoms[i] == x_atom)
+ return Qnil;
+
+ if (dpyinfo->x_dnd_atoms_length == dpyinfo->x_dnd_atoms_size)
+ {
+ dpyinfo->x_dnd_atoms_size *= 2;
+ dpyinfo->x_dnd_atoms = xrealloc (dpyinfo->x_dnd_atoms,
+ sizeof (*dpyinfo->x_dnd_atoms)
+ * dpyinfo->x_dnd_atoms_size);
+ }
+
+ dpyinfo->x_dnd_atoms[dpyinfo->x_dnd_atoms_length++] = x_atom;
+ return Qnil;
+}
+
+/* Convert an XClientMessageEvent to a Lisp event of type DRAG_N_DROP_EVENT. */
int
x_handle_dnd_message (f, event, dpyinfo, bufp)
int x, y;
unsigned char *data = (unsigned char *) event->data.b;
int idata[5];
+ size_t i;
+
+ for (i = 0; i < dpyinfo->x_dnd_atoms_length; ++i)
+ if (dpyinfo->x_dnd_atoms[i] == event->message_type) break;
+
+ if (i == dpyinfo->x_dnd_atoms_length) return 0;
XSETFRAME (frame, f);
defsubr (&Sx_get_atom_name);
defsubr (&Sx_send_client_message);
+ defsubr (&Sx_register_dnd_atom);
reading_selection_reply = Fcons (Qnil, Qnil);
staticpro (&reading_selection_reply);
DEFVAR_LISP ("selection-coding-system", &Vselection_coding_system,
doc: /* Coding system for communicating with other X clients.
-When sending or receiving text via cut_buffer, selection, and clipboard,
-the text is encoded or decoded by this coding system.
+When sending or receiving text via selection and clipboard, the text is
+encoded or decoded by this coding system.
The default value is `compound-text-with-extensions'. */);
Vselection_coding_system = intern ("compound-text-with-extensions");