Xboard and the clipboard

Discussions about the WinBoard protocol. Here you can also report bugs and request new features.

Moderators: hgm, Andres Valverde

Xboard and the clipboard

Postby Zach Wegner » 06 Nov 2009, 04:11

The xboard copy/paste functions never worked for me, using KDE and netbsd. I finally bothered to figure out why, and fixed it to work in the standard way. Xboard normally works from the PRIMARY buffer, which is set when text is highlighted (rather than copied). Using the CLIPBOARD buffer works as normal, and pgns/fens can be copied and pasted from everywhere. I'm not sure if the PRIMARY worked for other environments (namely gnome), but this should work safely everywhere, AFAIK.

Here's the patch:
Code: Select all
From e3b200b7f42f5edfce6f55fea5b84a718f8f57f8 Mon Sep 17 00:00:00 2001
From: Zach Quad <zach@zachquad.(none)>
Date: Thu, 5 Nov 2009 20:55:29 -0600
Subject: [PATCH] Set copy/paste functions to work with standard clipboard.

---
 xboard.c |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/xboard.c b/xboard.c
index 86fda44..310e40d 100644
--- a/xboard.c
+++ b/xboard.c
@@ -6478,7 +6478,7 @@ void CopyPositionProc(w, event, prms, nprms)
     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,
+    ret = XtOwnSelection(menuBarWidget, XInternAtom(xDisplay, "CLIPBOARD", False),
             CurrentTime,
             SendPositionSelection,
             NULL/* lose_ownership_proc */ ,
@@ -6509,7 +6509,7 @@ void PastePositionProc(w, event, prms, nprms)
   String *prms;
   Cardinal *nprms;
 {
-    XtGetSelectionValue(menuBarWidget, XA_PRIMARY, XA_STRING,
+    XtGetSelectionValue(menuBarWidget, XInternAtom(xDisplay, "CLIPBOARD", False), XA_STRING,
       /* (XtSelectionCallbackProc) */ PastePositionCB,
       NULL, /* client_data passed to PastePositionCB */

@@ -6567,7 +6567,7 @@ void CopyGameProc(w, event, prms, nprms)
   ret = SaveGameToFile(gameCopyFilename, FALSE);
   if (!ret) return;

-  ret = XtOwnSelection(menuBarWidget, XA_PRIMARY,
+  ret = XtOwnSelection(menuBarWidget, XInternAtom(xDisplay, "CLIPBOARD", False),
               CurrentTime,
               SendGameSelection,
               NULL/* lose_ownership_proc */ ,
@@ -6602,7 +6602,7 @@ void PasteGameProc(w, event, prms, nprms)
   String *prms;
   Cardinal *nprms;
 {
-    XtGetSelectionValue(menuBarWidget, XA_PRIMARY, XA_STRING,
+    XtGetSelectionValue(menuBarWidget, XInternAtom(xDisplay, "CLIPBOARD", False), XA_STRING,
       /* (XtSelectionCallbackProc) */ PasteGameCB,
       NULL, /* client_data passed to PasteGameCB */

--
1.6.0.2

User avatar
Zach Wegner
 
Posts: 182
Joined: 26 Sep 2004, 22:02
Location: Austin, Texas, USA

Re: Xboard and the clipboard

Postby H.G.Muller » 06 Nov 2009, 07:27

I think Tim just fixed this in 4.4.1. XBoard now copies both from PRIMARY and CLIPBOARD, and pastes from CLIPBOARD if PRAMARY is empty. The old behavior can be restored through a command-line option.
User avatar
H.G.Muller
 
Posts: 3453
Joined: 16 Nov 2005, 12:02
Location: Diemen, NL

Re: Xboard and the clipboard

Postby Zach Wegner » 06 Nov 2009, 08:18

H.G.Muller wrote:I think Tim just fixed this in 4.4.1. XBoard now copies both from PRIMARY and CLIPBOARD, and pastes from CLIPBOARD if PRAMARY is empty. The old behavior can be restored through a command-line option.

Wow, he did, weird. My git checkout was a couple of weeks old. This behavior has presumably been there forever, and I get around to fixing it about the same time as Tim does, strange coincidence...
User avatar
Zach Wegner
 
Posts: 182
Joined: 26 Sep 2004, 22:02
Location: Austin, Texas, USA

Re: Xboard and the clipboard

Postby H.G.Muller » 06 Nov 2009, 08:31

That is indeed a weird coincidence. I noticed the problem this month, when I could not paste a FEN from XBoard to gedit, and filed a bug report. This is what prompted Tim to fix it.
User avatar
H.G.Muller
 
Posts: 3453
Joined: 16 Nov 2005, 12:02
Location: Diemen, NL


Return to WinBoard development and bugfixing

Who is online

Users browsing this forum: No registered users and 6 guests