Add option to set primary selection for cut text

Previously the incoming clipboard was unconditionally set to both
the PRIMARY and CLIPBOARD selection. This isn't always what the
user want, so make it configurable.
diff --git a/vncviewer/CConn.cxx b/vncviewer/CConn.cxx
index 262dd2c..140b1d6 100644
--- a/vncviewer/CConn.cxx
+++ b/vncviewer/CConn.cxx
@@ -439,7 +439,8 @@
 
   // RFB doesn't have separate selection and clipboard concepts, so we
   // dump the data into both variants.
-  Fl::copy(buffer, ret, 0);
+  if (setPrimary)
+    Fl::copy(buffer, ret, 0);
   Fl::copy(buffer, ret, 1);
 
   delete [] buffer;
diff --git a/vncviewer/OptionsDialog.cxx b/vncviewer/OptionsDialog.cxx
index f112a52..55a366f 100644
--- a/vncviewer/OptionsDialog.cxx
+++ b/vncviewer/OptionsDialog.cxx
@@ -263,6 +263,9 @@
 
   viewOnlyCheckbox->value(viewOnly);
   acceptClipboardCheckbox->value(acceptClipboard);
+#if !defined(WIN32) && !defined(__APPLE__)
+  setPrimaryCheckbox->value(setPrimary);
+#endif
   sendClipboardCheckbox->value(sendClipboard);
 #if !defined(WIN32) && !defined(__APPLE__)
   sendPrimaryCheckbox->value(sendPrimary);
@@ -373,6 +376,9 @@
   /* Input */
   viewOnly.setParam(viewOnlyCheckbox->value());
   acceptClipboard.setParam(acceptClipboardCheckbox->value());
+#if !defined(WIN32) && !defined(__APPLE__)
+  setPrimary.setParam(setPrimaryCheckbox->value());
+#endif
   sendClipboard.setParam(sendClipboardCheckbox->value());
 #if !defined(WIN32) && !defined(__APPLE__)
   sendPrimary.setParam(sendPrimaryCheckbox->value());
@@ -696,6 +702,14 @@
                                                          _("Accept clipboard from server")));
   ty += CHECK_HEIGHT + TIGHT_MARGIN;
 
+#if !defined(WIN32) && !defined(__APPLE__)
+  setPrimaryCheckbox = new Fl_Check_Button(LBLRIGHT(tx + INDENT, ty,
+                                                    CHECK_MIN_WIDTH,
+                                                    CHECK_HEIGHT,
+                                                    _("Also set primary selection")));
+  ty += CHECK_HEIGHT + TIGHT_MARGIN;
+#endif
+
   sendClipboardCheckbox = new Fl_Check_Button(LBLRIGHT(tx, ty,
                                                        CHECK_MIN_WIDTH,
                                                        CHECK_HEIGHT,
diff --git a/vncviewer/OptionsDialog.h b/vncviewer/OptionsDialog.h
index 39bd7af..6984c72 100644
--- a/vncviewer/OptionsDialog.h
+++ b/vncviewer/OptionsDialog.h
@@ -106,6 +106,9 @@
   /* Input */
   Fl_Check_Button *viewOnlyCheckbox;
   Fl_Check_Button *acceptClipboardCheckbox;
+#if !defined(WIN32) && !defined(__APPLE__)
+  Fl_Check_Button *setPrimaryCheckbox;
+#endif
   Fl_Check_Button *sendClipboardCheckbox;
 #if !defined(WIN32) && !defined(__APPLE__)
   Fl_Check_Button *sendPrimaryCheckbox;
diff --git a/vncviewer/parameters.cxx b/vncviewer/parameters.cxx
index 9a9b9fd..1151a7c 100644
--- a/vncviewer/parameters.cxx
+++ b/vncviewer/parameters.cxx
@@ -120,6 +120,9 @@
 BoolParameter acceptClipboard("AcceptClipboard",
                               "Accept clipboard changes from the server",
                               true);
+BoolParameter setPrimary("SetPrimary",
+                         "Set the primary selection as well as the "
+                         "clipboard selection", true);
 BoolParameter sendClipboard("SendClipboard",
                             "Send clipboard changes to the server", true);
 #if !defined(WIN32) && !defined(__APPLE__)
diff --git a/vncviewer/parameters.h b/vncviewer/parameters.h
index e4378c8..682b6d6 100644
--- a/vncviewer/parameters.h
+++ b/vncviewer/parameters.h
@@ -51,6 +51,7 @@
 extern rfb::BoolParameter shared;
 
 extern rfb::BoolParameter acceptClipboard;
+extern rfb::BoolParameter setPrimary;
 extern rfb::BoolParameter sendClipboard;
 #if !defined(WIN32) && !defined(__APPLE__)
 extern rfb::BoolParameter sendPrimary;
diff --git a/vncviewer/vncviewer.man b/vncviewer/vncviewer.man
index 5dd3b45..4b92b61 100644
--- a/vncviewer/vncviewer.man
+++ b/vncviewer/vncviewer.man
@@ -153,6 +153,11 @@
 Accept clipboard changes from the server. Default is on.
 .
 .TP
+.B \-SetPrimary
+Set the primary selection as well as the clipboard selection.
+Default is on.
+.
+.TP
 .B \-SendClipboard
 Send clipboard changes to the server. Default is on.
 .