X-Git-Url: http://winboard.nl/cgi-bin?a=blobdiff_plain;f=xboard.c;h=4b34bcdc5c4bea1b08712eb1d37921adec1a6d47;hb=2b102a5aee6ecd7f801208d2c6f6aacf59397ee4;hp=42192a50f05ce5c6351a9c8f41a42cb463c036a2;hpb=4d057f1c54f1904fc7e01828b5896c2a979d15ea;p=xboard.git diff --git a/xboard.c b/xboard.c index 42192a5..4b34bcd 100644 --- a/xboard.c +++ b/xboard.c @@ -144,6 +144,7 @@ extern char *getenv(); #include #include #include +#include #if USE_XAW3D #include #include @@ -1422,6 +1423,9 @@ XtResource clientResources[] = { { "autoDisplayComment", "autoDisplayComment", XtRBoolean, sizeof(Boolean), XtOffset(AppDataPtr, autoDisplayComment), XtRImmediate, (XtPointer) True}, + { "pasteSelection", "pasteSelection", XtRBoolean, + sizeof(Boolean), XtOffset(AppDataPtr, pasteSelection), + XtRImmediate, (XtPointer) False}, }; XrmOptionDescRec shellOptions[] = { @@ -1796,6 +1800,7 @@ XrmOptionDescRec shellOptions[] = { { "-useInternalWrap", "useInternalWrap", XrmoptionSepArg, NULL }, { "-autoDisplayTags", "autoDisplayTags", XrmoptionSepArg, NULL }, { "-autoDisplayComment", "autoDisplayComment", XrmoptionSepArg, NULL }, + { "-pasteSelection", "pasteSelection", XrmoptionSepArg, NULL }, }; XtActionsRec boardActions[] = { @@ -6284,18 +6289,24 @@ void CopyPositionProc(w, event, prms, 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 (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 */ @@ -6318,7 +6329,8 @@ void PastePositionProc(w, event, prms, nprms) 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 */ @@ -6376,11 +6388,21 @@ void CopyGameProc(w, event, prms, nprms) 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 */ @@ -6411,7 +6433,8 @@ void PasteGameProc(w, event, prms, nprms) 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 */