* Massachusetts.
*
* Enhancements Copyright 1992-2001, 2002, 2003, 2004, 2005, 2006,
- * 2007, 2008, 2009 Free Software Foundation, Inc.
+ * 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
*
* The following terms apply to Digital Equipment Corporation's copyright
* interest in XBoard:
#include <X11/Shell.h>
#include <X11/cursorfont.h>
#include <X11/Xatom.h>
+#include <X11/Xmu/Atoms.h>
#if USE_XAW3D
#include <X11/Xaw3d/Dialog.h>
#include <X11/Xaw3d/Form.h>
{ "autoDisplayComment", "autoDisplayComment", XtRBoolean,
sizeof(Boolean), XtOffset(AppDataPtr, autoDisplayComment),
XtRImmediate, (XtPointer) True},
+ { "pasteSelection", "pasteSelection", XtRBoolean,
+ sizeof(Boolean), XtOffset(AppDataPtr, pasteSelection),
+ XtRImmediate, (XtPointer) False},
};
XrmOptionDescRec shellOptions[] = {
{ "-useInternalWrap", "useInternalWrap", XrmoptionSepArg, NULL },
{ "-autoDisplayTags", "autoDisplayTags", XrmoptionSepArg, NULL },
{ "-autoDisplayComment", "autoDisplayComment", XrmoptionSepArg, NULL },
+ { "-pasteSelection", "pasteSelection", XrmoptionSepArg, NULL },
};
XtActionsRec boardActions[] = {
if (hi1X >= 0 && hi1Y >= 0) {
drawHighlight(hi1X, hi1Y, lineGC);
}
+ } // [HGM] first erase both, then draw new!
+ if (hi2X != toX || hi2Y != toY) {
+ if (hi2X >= 0 && hi2Y >= 0) {
+ drawHighlight(hi2X, hi2Y, lineGC);
+ }
+ }
+ if (hi1X != fromX || hi1Y != fromY) {
if (fromX >= 0 && fromY >= 0) {
drawHighlight(fromX, fromY, highlineGC);
}
}
if (hi2X != toX || hi2Y != toY) {
- if (hi2X >= 0 && hi2Y >= 0) {
- drawHighlight(hi2X, hi2Y, lineGC);
- }
if (toX >= 0 && toY >= 0) {
drawHighlight(toX, toY, highlineGC);
}
char *selection_tmp;
if (!selected_fen_position) return False; /* should never happen */
- if (*target == XA_STRING){
+ if (*target == XA_STRING || *target == XA_UTF8_STRING(xDisplay)){
/* note: since no XtSelectionDoneProc was registered, Xt will
* automatically call XtFree on the value returned. So have to
* make a copy of it allocated with XtMalloc */
*value_return=selection_tmp;
*length_return=strlen(selection_tmp);
- *type_return=XA_STRING;
+ *type_return=*target;
*format_return = 8; /* bits per byte */
return True;
+ } else if (*target == XA_TARGETS(xDisplay)) {
+ Atom *targets_tmp = (Atom *) XtMalloc(2 * sizeof(Atom));
+ targets_tmp[0] = XA_UTF8_STRING(xDisplay);
+ targets_tmp[1] = XA_STRING;
+ *value_return = targets_tmp;
+ *type_return = XA_ATOM;
+ *length_return = 2;
+ *format_return = 8 * sizeof(Atom);
+ if (*format_return > 32) {
+ *length_return *= *format_return / 32;
+ *format_return = 32;
+ }
+ return True;
} else {
return False;
}
String *prms;
Cardinal *nprms;
{
- int ret;
-
+ /*
+ * Set both PRIMARY (the selection) and CLIPBOARD, since we don't
+ * have a notion of a position that is selected but not copied.
+ * See http://www.freedesktop.org/wiki/Specifications/ClipboardsWiki
+ */
+ if(gameMode == EditPosition) EditPositionDone(TRUE);
if (selected_fen_position) free(selected_fen_position);
selected_fen_position = (char *)PositionToFEN(currentMove, NULL);
if (!selected_fen_position) return;
- ret = XtOwnSelection(menuBarWidget, XA_PRIMARY,
- CurrentTime,
- SendPositionSelection,
- NULL/* lose_ownership_proc */ ,
- NULL/* transfer_done_proc */);
- if (!ret) {
- free(selected_fen_position);
- selected_fen_position=NULL;
- }
+ XtOwnSelection(menuBarWidget, XA_PRIMARY,
+ CurrentTime,
+ SendPositionSelection,
+ NULL/* lose_ownership_proc */ ,
+ NULL/* transfer_done_proc */);
+ XtOwnSelection(menuBarWidget, XA_CLIPBOARD(xDisplay),
+ CurrentTime,
+ SendPositionSelection,
+ NULL/* lose_ownership_proc */ ,
+ NULL/* transfer_done_proc */);
}
/* function called when the data to Paste is ready */
String *prms;
Cardinal *nprms;
{
- XtGetSelectionValue(menuBarWidget, XA_PRIMARY, XA_STRING,
+ XtGetSelectionValue(menuBarWidget,
+ appData.pasteSelection ? XA_PRIMARY: XA_CLIPBOARD(xDisplay), XA_STRING,
/* (XtSelectionCallbackProc) */ PastePositionCB,
NULL, /* client_data passed to PastePositionCB */
{
char *selection_tmp;
- if (*target == XA_STRING){
+ if (*target == XA_STRING || *target == XA_UTF8_STRING(xDisplay)){
FILE* f = fopen(gameCopyFilename, "r");
long len;
size_t count;
selection_tmp[len] = NULLCHAR;
*value_return = selection_tmp;
*length_return = len;
- *type_return = XA_STRING;
+ *type_return = *target;
*format_return = 8; /* bits per byte */
return True;
+ } else if (*target == XA_TARGETS(xDisplay)) {
+ Atom *targets_tmp = (Atom *) XtMalloc(2 * sizeof(Atom));
+ targets_tmp[0] = XA_UTF8_STRING(xDisplay);
+ targets_tmp[1] = XA_STRING;
+ *value_return = targets_tmp;
+ *type_return = XA_ATOM;
+ *length_return = 2;
+ *format_return = 8 * sizeof(Atom);
+ if (*format_return > 32) {
+ *length_return *= *format_return / 32;
+ *format_return = 32;
+ }
+ return True;
} else {
return False;
}
ret = SaveGameToFile(gameCopyFilename, FALSE);
if (!ret) return;
- ret = XtOwnSelection(menuBarWidget, XA_PRIMARY,
- CurrentTime,
- SendGameSelection,
- NULL/* lose_ownership_proc */ ,
- NULL/* transfer_done_proc */);
+ /*
+ * Set both PRIMARY (the selection) and CLIPBOARD, since we don't
+ * have a notion of a game that is selected but not copied.
+ * See http://www.freedesktop.org/wiki/Specifications/ClipboardsWiki
+ */
+ XtOwnSelection(menuBarWidget, XA_PRIMARY,
+ CurrentTime,
+ SendGameSelection,
+ NULL/* lose_ownership_proc */ ,
+ NULL/* transfer_done_proc */);
+ XtOwnSelection(menuBarWidget, XA_CLIPBOARD(xDisplay),
+ CurrentTime,
+ SendGameSelection,
+ NULL/* lose_ownership_proc */ ,
+ NULL/* transfer_done_proc */);
}
/* function called when the data to Paste is ready */
String *prms;
Cardinal *nprms;
{
- XtGetSelectionValue(menuBarWidget, XA_PRIMARY, XA_STRING,
+ XtGetSelectionValue(menuBarWidget,
+ appData.pasteSelection ? XA_PRIMARY: XA_CLIPBOARD(xDisplay), XA_STRING,
/* (XtSelectionCallbackProc) */ PasteGameCB,
NULL, /* client_data passed to PasteGameCB */
String *prms;
Cardinal *nprms;
{
- Arg args[16];
-
appData.showThinking = !appData.showThinking; // [HGM] thinking: tken out of ShowThinkingEvent
ShowThinkingEvent();
}