From f862c2e8f4a783b74b3b813c95101e4e4427893b Mon Sep 17 00:00:00 2001 From: Pierre Ossman Date: Tue, 29 Mar 2016 14:15:38 +0200 Subject: [PATCH] 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. --- vncviewer/CConn.cxx | 3 ++- vncviewer/OptionsDialog.cxx | 14 ++++++++++++++ vncviewer/OptionsDialog.h | 3 +++ vncviewer/parameters.cxx | 3 +++ vncviewer/parameters.h | 1 + vncviewer/vncviewer.man | 5 +++++ 6 files changed, 28 insertions(+), 1 deletion(-) diff --git a/vncviewer/CConn.cxx b/vncviewer/CConn.cxx index 262dd2ce..140b1d65 100644 --- a/vncviewer/CConn.cxx +++ b/vncviewer/CConn.cxx @@ -439,7 +439,8 @@ void CConn::serverCutText(const char* str, rdr::U32 len) // 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 f112a529..55a366f1 100644 --- a/vncviewer/OptionsDialog.cxx +++ b/vncviewer/OptionsDialog.cxx @@ -263,6 +263,9 @@ void OptionsDialog::loadOptions(void) 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 @@ void OptionsDialog::storeOptions(void) /* 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 @@ void OptionsDialog::createInputPage(int tx, int ty, int tw, int th) _("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 39bd7afa..6984c72f 100644 --- a/vncviewer/OptionsDialog.h +++ b/vncviewer/OptionsDialog.h @@ -106,6 +106,9 @@ protected: /* 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 9a9b9fd7..1151a7c8 100644 --- a/vncviewer/parameters.cxx +++ b/vncviewer/parameters.cxx @@ -120,6 +120,9 @@ BoolParameter shared("Shared", 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 e4378c85..682b6d69 100644 --- a/vncviewer/parameters.h +++ b/vncviewer/parameters.h @@ -51,6 +51,7 @@ extern rfb::BoolParameter viewOnly; 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 5dd3b453..4b92b611 100644 --- a/vncviewer/vncviewer.man +++ b/vncviewer/vncviewer.man @@ -153,6 +153,11 @@ combined with 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. . -- 2.39.5