diff options
author | Mike Gabriel <mike.gabriel@das-netzwerkteam.de> | 2019-06-11 12:24:44 +0200 |
---|---|---|
committer | Mike Gabriel <mike.gabriel@das-netzwerkteam.de> | 2019-06-11 12:24:44 +0200 |
commit | c0754a35755cdd4e25386abc6378e07605845948 (patch) | |
tree | 556107b4e0267c6985f1dc8c7960502b88733983 /nx-X11/programs/Xserver/hw/nxagent/Clipboard.c | |
parent | 58cd35745086567b5b1fa0fc7a295e849ac070ce (diff) | |
parent | 848dee5c42bffdf19c4b9f01c38334bf53fefa49 (diff) | |
download | nx-libs-c0754a35755cdd4e25386abc6378e07605845948.tar.gz nx-libs-c0754a35755cdd4e25386abc6378e07605845948.tar.bz2 nx-libs-c0754a35755cdd4e25386abc6378e07605845948.zip |
Merge branch 'uli42-pr/use_selection_callback' into 3.6.x
Attributes GH PR #814: https://github.com/ArcticaProject/nx-libs/pull/814
Diffstat (limited to 'nx-X11/programs/Xserver/hw/nxagent/Clipboard.c')
-rw-r--r-- | nx-X11/programs/Xserver/hw/nxagent/Clipboard.c | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/nx-X11/programs/Xserver/hw/nxagent/Clipboard.c b/nx-X11/programs/Xserver/hw/nxagent/Clipboard.c index 824c1dc47..9c518801b 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Clipboard.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Clipboard.c @@ -1257,6 +1257,75 @@ void nxagentResetSelectionOwner(void) return; } +#ifdef NXAGENT_CLIPBOARD +void nxagentSetSelectionCallback(CallbackListPtr *callbacks, void *data, + void *args) +{ + /* + * Only act if the Trap is unset. The trap indicates that we are + * triggered by a clipboard event originating from the real X + * server. In that case we do not want to propagate back changes to + * the real X server, because it already knows about them and we + * would end up in an infinite loop of events. If there was a better + * way to identify that situation during Callback processing we + * could get rid of the Trap... + */ + if (nxagentExternalClipboardEventTrap != 0) + { + #ifdef DEBUG + fprintf(stderr, "%s: Trap is set, doing nothing\n", __func__); + #endif + return; + } + + SelectionInfoRec *info = (SelectionInfoRec *)args; + + Selection * pCurSel = (Selection *)info->selection; + + #ifdef DEBUG + fprintf(stderr, "%s: pCurSel->lastTimeChanged [%d]\n", __func__, pCurSel->lastTimeChanged.milliseconds); + #endif + + if (info->kind == SelectionSetOwner) + { + #ifdef DEBUG + fprintf(stderr, "%s: called with SelectionCallbackKind SelectionSetOwner\n", __func__); + fprintf(stderr, "%s: pCurSel->pWin [0x%x]\n", __func__, pCurSel->pWin ? pCurSel->pWin->drawable.id : NULL); + fprintf(stderr, "%s: pCurSel->selection [%s]\n", __func__, NameForAtom(pCurSel->selection)); + #endif + + if ((pCurSel->pWin != NULL) && + (nxagentOption(Clipboard) != ClipboardNone) && + ((pCurSel->selection == XA_PRIMARY) || + (pCurSel->selection == MakeAtom("CLIPBOARD", 9, 0)))) + { + #ifdef DEBUG + fprintf(stderr, "%s: calling nxagentSetSelectionOwner\n", __func__); + #endif + nxagentSetSelectionOwner(pCurSel); + } + } + else if (info->kind == SelectionWindowDestroy) + { + #ifdef DEBUG + fprintf(stderr, "%s: called with SelectionCallbackKind SelectionWindowDestroy\n", __func__); + #endif + } + else if (info->kind == SelectionClientClose) + { + #ifdef DEBUG + fprintf(stderr, "%s: called with SelectionCallbackKind SelectionClientClose\n", __func__); + #endif + } + else + { + #ifdef DEBUG + fprintf(stderr, "%s: called with unknown SelectionCallbackKind\n", __func__); + #endif + } +} +#endif + void nxagentSetSelectionOwner(Selection *pSelection) { #ifdef DEBUG |