sequences and control characters, in which case you may need to use
\cw{-C} to disable conversion to compound text.
+\dt \cw{-b}
+
+\dd Causes \cw{xcopy} to read or write the clipboard instead of the
+selection. (Modern GNOME and KDE-style programs can often interact
+with both. The \e{selection} is the traditional X-style storage
+location which you typically copy things into just by selecting them
+with the mouse, and paste with the middle mouse button. The
+\e{clipboard} is a more Windows-like location which you access using
+explicit Cut, Copy and Paste commands in your application.)
+
\U BUGS
Occasionally \cw{xcopy -r} completely fails to notice selection data
/* set from command-line parameters */
char *display = NULL;
enum { STRING, CTEXT, UTF8 } mode = STRING;
+int use_clipboard = False;
/* selection data */
char *seltext;
" -u work with UTF8_STRING type selections\n"
" -c work with COMPOUND_TEXT type selections\n"
" -C suppress automatic conversion to COMPOUND_TEXT\n"
+ " -b read the CLIPBOARD rather than the PRIMARY selection\n"
" also: xcopy --version report version number\n"
" xcopy --help display this help text\n"
" xcopy --licence display the (MIT) licence text\n"
mode = CTEXT;
} else if (!strcmp(p, "-C")) {
convert_to_ctext = False;
+ } else if (!strcmp(p, "-b")) {
+ use_clipboard = True;
} else if (!strcmp(p, "--help")) {
usage();
return 0;
int screen, wwidth, wheight;
Atom strtype = XA_STRING;
+Atom sel_atom = XA_PRIMARY;
/*
* Returns TRUE if we need to enter an event loop, FALSE otherwise.
targets_atom = XInternAtom(disp, "TARGETS", False);
if (!targets_atom)
error ("unable to get TARGETS property");
+ if (use_clipboard) {
+ sel_atom = XInternAtom(disp, "CLIPBOARD", False);
+ if (!sel_atom)
+ error ("unable to get CLIPBOARD property");
+ }
/* get the screen and root-window */
screen = DefaultScreen (disp);
/*
* We are reading the selection, so we must FIXME.
*/
- if (XGetSelectionOwner(disp, XA_PRIMARY) == None) {
+ if (XGetSelectionOwner(disp, sel_atom) == None) {
/* No primary selection, so use the cut buffer. */
do_paste(DefaultRootWindow(disp), XA_CUT_BUFFER0, False);
return False;
} else {
Atom sel_property = XInternAtom(disp, "VT_SELECTION", False);
- XConvertSelection(disp, XA_PRIMARY, strtype,
+ XConvertSelection(disp, sel_atom, strtype,
sel_property, ourwin, CurrentTime);
return True;
}
* CUT_BUFFER0, if it isn't of an exotic type (cut buffers
* can only take ordinary string data, it turns out).
*/
- XSetSelectionOwner (disp, XA_PRIMARY, ourwin, CurrentTime);
- if (XGetSelectionOwner (disp, XA_PRIMARY) != ourwin)
+ XSetSelectionOwner (disp, sel_atom, ourwin, CurrentTime);
+ if (XGetSelectionOwner (disp, sel_atom) != ourwin)
error ("unable to obtain primary X selection\n");
compound_text_atom = XInternAtom(disp, "COMPOUND_TEXT", False);
if (strtype == XA_STRING) {