diff --git a/doc/nxagent/README.keystrokes b/doc/nxagent/README.keystrokes
index e916bddc0f..90a6b48bc6 100644
--- a/doc/nxagent/README.keystrokes
+++ b/doc/nxagent/README.keystrokes
@@ -133,6 +133,18 @@ dump_clipboard
print the current internal clipboard state (for debugging) to the
log.
+clipboard_both
+ allow copy/paste from/to real X server
+
+clipboard_client
+ allow copy/paste from real X server
+
+clipboard_server
+ allow copy/paste to real X server
+
+clipboard_none
+ forbid copy/paste from/to real X server
+
force_synchronization
Forces immediate drawing of elements to be synchronized which can
fix some visual bugs.
diff --git a/etc/keystrokes.cfg b/etc/keystrokes.cfg
index ea9feeea6e..4c8b735e69 100644
--- a/etc/keystrokes.cfg
+++ b/etc/keystrokes.cfg
@@ -26,4 +26,8 @@
+
+
+
+
diff --git a/nx-X11/programs/Xserver/hw/nxagent/Clipboard.c b/nx-X11/programs/Xserver/hw/nxagent/Clipboard.c
index a45cab01e6..1117a74b2f 100644
--- a/nx-X11/programs/Xserver/hw/nxagent/Clipboard.c
+++ b/nx-X11/programs/Xserver/hw/nxagent/Clipboard.c
@@ -253,6 +253,18 @@ static char szAgentCLIPBOARD[] = "CLIPBOARD";
* Some helpers for debugging output
*/
+static const char * getClipboardModeString(int mode)
+{
+ switch(mode)
+ {
+ case ClipboardBoth: return("[Both]"); break;;
+ case ClipboardClient: return("[Client]"); break;;
+ case ClipboardServer: return("[Server]"); break;;
+ case ClipboardNone: return("[None]"); break;;
+ default: return("[UNKNOWN] (FAIL!)"); break;;
+ }
+}
+
static const char * getClientSelectionStageString(int stage)
{
switch(stage)
@@ -438,14 +450,7 @@ void nxagentDumpClipboardStat(void)
fprintf(stderr, " serverWindow (XlibWindow) [0x%lx]\n", serverWindow);
fprintf(stderr, " Clipboard mode ");
- switch(nxagentOption(Clipboard))
- {
- case ClipboardBoth: fprintf(stderr, "[Both]"); break;;
- case ClipboardClient: fprintf(stderr, "[Client]"); break;;
- case ClipboardServer: fprintf(stderr, "[Server]"); break;;
- case ClipboardNone: fprintf(stderr, "[None]"); break;;
- default: fprintf(stderr, "[UNKNOWN] (FAIL!)"); break;;
- }
+ fprintf(stderr, getClipboardModeString(nxagentOption(Clipboard)));
fprintf(stderr, "\n");
if (serverLastRequestedSelection == -1)
@@ -514,6 +519,16 @@ void nxagentDumpClipboardStat(void)
fprintf(stderr, "\\------------------------------------------------------------------------------\n");
}
+void nxagentSwitchClipboardMode(int new_mode) {
+ int old_mode = nxagentOption(Clipboard);
+ if (old_mode == new_mode)
+ return;
+ nxagentChangeOption(Clipboard, new_mode);
+ fprintf(stderr, "Switched clipboard mode from %s to %s.\n",
+ getClipboardModeString(old_mode),
+ getClipboardModeString(new_mode));
+}
+
/*
* Helper to handle data transfer
*/
diff --git a/nx-X11/programs/Xserver/hw/nxagent/Clipboard.h b/nx-X11/programs/Xserver/hw/nxagent/Clipboard.h
index 4518595d1b..7e38e51698 100644
--- a/nx-X11/programs/Xserver/hw/nxagent/Clipboard.h
+++ b/nx-X11/programs/Xserver/hw/nxagent/Clipboard.h
@@ -82,5 +82,6 @@ extern WindowPtr nxagentGetClipboardWindow(Atom property);
extern int nxagentSendNotificationToSelfViaXServer(xEvent *event);
extern void nxagentDumpClipboardStat(void);
+extern void nxagentSwitchClipboardMode(int new_mode);
#endif /* __Clipboard_H__ */
diff --git a/nx-X11/programs/Xserver/hw/nxagent/Events.c b/nx-X11/programs/Xserver/hw/nxagent/Events.c
index 7cadb987b1..b37fc5ecf0 100644
--- a/nx-X11/programs/Xserver/hw/nxagent/Events.c
+++ b/nx-X11/programs/Xserver/hw/nxagent/Events.c
@@ -1071,6 +1071,14 @@ void nxagentDispatchEvents(PredicateFuncPtr predicate)
nxagentDumpClipboardStat();
break;
}
+ case doClipboardBoth:
+ case doClipboardClient:
+ case doClipboardServer:
+ case doClipboardNone:
+ {
+ nxagentSwitchClipboardMode(ClipboardBoth + result - doClipboardBoth);
+ break;
+ }
default:
{
FatalError("nxagentDispatchEvent: handleKeyPress returned unknown value\n");
diff --git a/nx-X11/programs/Xserver/hw/nxagent/Events.h b/nx-X11/programs/Xserver/hw/nxagent/Events.h
index a334897ec3..1f0d88b3c8 100644
--- a/nx-X11/programs/Xserver/hw/nxagent/Events.h
+++ b/nx-X11/programs/Xserver/hw/nxagent/Events.h
@@ -52,7 +52,11 @@ enum HandleEventResult
doSwitchResizeMode,
doSwitchDeferMode,
doAutoGrab,
- doDumpClipboard
+ doDumpClipboard,
+ doClipboardBoth,
+ doClipboardClient,
+ doClipboardServer,
+ doClipboardNone
};
extern CARD32 nxagentLastEventTime;
diff --git a/nx-X11/programs/Xserver/hw/nxagent/Keystroke.c b/nx-X11/programs/Xserver/hw/nxagent/Keystroke.c
index 5196e28b70..de03576a88 100644
--- a/nx-X11/programs/Xserver/hw/nxagent/Keystroke.c
+++ b/nx-X11/programs/Xserver/hw/nxagent/Keystroke.c
@@ -103,6 +103,10 @@ char * nxagentSpecialKeystrokeNames[] = {
"autograb",
"dump_clipboard",
+ "clipboard_both",
+ "clipboard_client",
+ "clipboard_server",
+ "clipboard_none",
NULL,
};
@@ -145,6 +149,10 @@ struct nxagentSpecialKeystrokeMap default_map[] = {
{KEYSTROKE_REREAD_KEYSTROKES, ControlMask, True, XK_k},
{KEYSTROKE_AUTOGRAB, ControlMask, True, XK_g},
{KEYSTROKE_DUMP_CLIPBOARD, ControlMask | ShiftMask, True, XK_c},
+ {KEYSTROKE_SET_CLIPBOARD_BOTH, ControlMask | ShiftMask, True, XK_1},
+ {KEYSTROKE_SET_CLIPBOARD_CLIENT, ControlMask | ShiftMask, True, XK_2},
+ {KEYSTROKE_SET_CLIPBOARD_SERVER, ControlMask | ShiftMask, True, XK_3},
+ {KEYSTROKE_SET_CLIPBOARD_NONE, ControlMask | ShiftMask, True, XK_4},
{KEYSTROKE_END_MARKER, 0, False, NoSymbol},
};
struct nxagentSpecialKeystrokeMap *map = default_map;
@@ -725,6 +733,12 @@ Bool nxagentCheckSpecialKeystroke(XKeyEvent *X, enum HandleEventResult *result)
case KEYSTROKE_DUMP_CLIPBOARD:
*result = doDumpClipboard;
break;
+ case KEYSTROKE_SET_CLIPBOARD_BOTH:
+ case KEYSTROKE_SET_CLIPBOARD_CLIENT:
+ case KEYSTROKE_SET_CLIPBOARD_SERVER:
+ case KEYSTROKE_SET_CLIPBOARD_NONE:
+ *result = doClipboardBoth + stroke - KEYSTROKE_SET_CLIPBOARD_BOTH;
+ break;
case KEYSTROKE_NOTHING: /* do nothing. difference to KEYSTROKE_IGNORE is the return value */
case KEYSTROKE_END_MARKER: /* just to make gcc STFU */
case KEYSTROKE_MAX:
diff --git a/nx-X11/programs/Xserver/hw/nxagent/Keystroke.h b/nx-X11/programs/Xserver/hw/nxagent/Keystroke.h
index a5a6fbcf14..79c0e0d745 100644
--- a/nx-X11/programs/Xserver/hw/nxagent/Keystroke.h
+++ b/nx-X11/programs/Xserver/hw/nxagent/Keystroke.h
@@ -79,6 +79,10 @@ enum nxagentSpecialKeystroke {
KEYSTROKE_AUTOGRAB,
KEYSTROKE_DUMP_CLIPBOARD,
+ KEYSTROKE_SET_CLIPBOARD_BOTH,
+ KEYSTROKE_SET_CLIPBOARD_CLIENT,
+ KEYSTROKE_SET_CLIPBOARD_SERVER,
+ KEYSTROKE_SET_CLIPBOARD_NONE,
/* insert more here and in the string translation */
diff --git a/nx-X11/programs/Xserver/hw/nxagent/man/nxagent.1 b/nx-X11/programs/Xserver/hw/nxagent/man/nxagent.1
index f373cb2391..788605d6bb 100644
--- a/nx-X11/programs/Xserver/hw/nxagent/man/nxagent.1
+++ b/nx-X11/programs/Xserver/hw/nxagent/man/nxagent.1
@@ -706,6 +706,7 @@ model. Using \fIoff\fR this conversion can be suppressed and with
.TP 8
.B clipboard=
+Set initial clipboard mode. Can be toggled during session via keystroke.
.BR both | client | server | none