/* X Selection processing for emacs
- Copyright (C) 1990 Free Software Foundation.
+ Copyright (C) 1990, 1992 Free Software Foundation.
This file is part of GNU Emacs.
GNU Emacs is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 1, or (at your option)
+the Free Software Foundation; either version 2, or (at your option)
any later version.
GNU Emacs is distributed in the hope that it will be useful,
#define MAX_SELECTION(dpy) (((dpy)->max_request_size << 2) - 100)
#define SELECTION_LENGTH(len,format) ((len) * ((format) >> 2))
-/* The last 23 bits of the timestamp of the last mouse button event. */
-extern Time mouse_timestamp;
+/* The timestamp of the last input event we received from the X server. */
+unsigned long last_event_timestamp;
/* t if a mouse button is depressed. */
extern Lisp_Object Vmouse_grabbed;
/* The value of the current SECONDARY selection. */
Lisp_Object Vx_secondary_selection_value;
-/* Types of selections we may make. */
-Lisp_Object Qprimary, Qsecondary, Qclipboard;
+/* Types of selections we may make. Note that Qcut_buffer0 isn't really
+ a selection, but it acts like one for the sake of Fx_own_selection and
+ Fx_selection_value. */
+Lisp_Object Qprimary, Qsecondary, Qclipboard, Qcut_buffer0;
/* Emacs' selection property identifiers. */
Atom Xatom_emacs_selection;
selecting_window, time);
owner_window = XGetSelectionOwner (x_current_display, selection_type);
- if (owner_window != selecting_window)
+ if (owner_window != selecting_window)
return 0;
return 1;
DEFUN ("x-own-selection", Fx_own_selection, Sx_own_selection,
1, 2, "",
"Make STRING the selection value. Default is the primary selection,\n\
-but optional second argument TYPE may specify secondary or clipboard.")
+but optional second argument TYPE may specify secondary or clipboard.\n\
+\n\
+TYPE may also be cut-buffer0, indicating that Emacs should set the X\n\
+cut buffer 0 to STRING. This is for compatibility with older X\n\
+applications which still use the cut buffers; new applications should\n\
+use X selections.")
(string, type)
register Lisp_Object string, type;
{
Atom selection_type;
Lisp_Object val;
- Time event_time = mouse_timestamp;
+ Time event_time = last_event_timestamp;
CHECK_STRING (string, 0);
if (NILP (type) || EQ (type, Qprimary))
}
UNBLOCK_INPUT;
}
+ else if (EQ (type, Qcut_buffer0))
+ {
+ BLOCK_INPUT;
+ XStoreBytes (x_current_display,
+ (char *) XSTRING (string)->data,
+ XSTRING (string)->size);
+ UNBLOCK_INPUT;
+ }
else
error ("Invalid X selection type");
int x_converting_selection;
/* Reply to some client's request for our selection data. Data is
- placed in a propery supplied by the requesting window.
+ placed in a property supplied by the requesting window.
If the data exceeds the maximum amount the server can send,
then prepare to send it incrementally, and reply to the client with
Window requestor_window;
BLOCK_INPUT;
- requestor_time = mouse_timestamp;
+ requestor_time = last_event_timestamp;
requestor_window = selected_screen->display.x->window_desc;
XConvertSelection (x_current_display, type, XA_STRING,
Xatom_emacs_selection, requestor_window, requestor_time);
if (NILP (type) || EQ (type, Qprimary))
{
if (!NILP (Vx_selection_value))
- return Vx_selection_value;
+ return Vx_selection_value;
return get_selection_value (XA_PRIMARY);
}
return get_selection_value (Xatom_clipboard);
}
+ else if (EQ (type, Qcut_buffer0))
+ {
+ char *data;
+ int size;
+ Lisp_Object string;
+
+ BLOCK_INPUT;
+ data = XFetchBytes (x_current_display, &size);
+ if (data == 0)
+ string = Qnil;
+ else
+ string = make_string (data, size);
+ UNBLOCK_INPUT;
+
+ return string;
+ }
else
error ("Invalid X selection type");
}
staticpro (&Qsecondary);
Qclipboard = intern ("clipboard");
staticpro (&Qclipboard);
+ Qcut_buffer0 = intern ("cut-buffer0");
+ staticpro (&Qcut_buffer0);
defsubr (&Sx_own_selection);
defsubr (&Sx_selection_value);