aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUlrich Sibiller <uli42@gmx.de>2019-11-17 19:06:59 +0100
committerMike Gabriel <mike.gabriel@das-netzwerkteam.de>2020-01-05 23:36:02 +0100
commit1d0d547306b6bf124aa06d85f13b8272bfc46e35 (patch)
treec657d5bf9ec68b3e47a41266e2eb15204376b0ee
parent166102e072073282768bd4b66c982b49b490284f (diff)
downloadnx-libs-1d0d547306b6bf124aa06d85f13b8272bfc46e35.tar.gz
nx-libs-1d0d547306b6bf124aa06d85f13b8272bfc46e35.tar.bz2
nx-libs-1d0d547306b6bf124aa06d85f13b8272bfc46e35.zip
Clipboard.c: add more explaining comments
-rw-r--r--nx-X11/programs/Xserver/hw/nxagent/Clipboard.c31
1 files changed, 24 insertions, 7 deletions
diff --git a/nx-X11/programs/Xserver/hw/nxagent/Clipboard.c b/nx-X11/programs/Xserver/hw/nxagent/Clipboard.c
index 5cc59e3b3..12d578f90 100644
--- a/nx-X11/programs/Xserver/hw/nxagent/Clipboard.c
+++ b/nx-X11/programs/Xserver/hw/nxagent/Clipboard.c
@@ -185,6 +185,9 @@ const char * GetClientSelectionStageString(int stage)
/*
* see also nx-X11/lib/src/ErrDes.c
+ *
+ * We use our own version to avoid Xlib doing expensive calls.
+ * FIXME: Must check if XGetErrorText() is really causing traffic over the wire.
*/
const char * GetXErrorString(int code)
{
@@ -668,9 +671,8 @@ void nxagentClearSelection(XEvent *X)
/*
* Send a SelectionNotify event as reply to the RequestSelection
* event X. If success is True take the property from the event, else
- * take None (which reports "failed/denied" to the requestor.
+ * take None (which reports "failed/denied" to the requestor).
*/
-
void nxagentReplyRequestSelection(XEvent *X, Bool success)
{
XSelectionEvent eventSelection = {
@@ -752,8 +754,7 @@ void nxagentRequestSelection(XEvent *X)
{
/*
* the selection request target is TARGETS. The requestor is
- * asking for a list of supported data formats. Currently
- * there's only one format we support: XA_STRING
+ * asking for a list of supported data formats.
*
* The selection does not matter here, we will return this for
* PRIMARY and CLIPBOARD.
@@ -1703,6 +1704,12 @@ int nxagentConvertSelection(ClientPtr client, WindowPtr pWin, Atom selection,
}
}
+ /*
+ * if lastClientWindowPtr is set we are waiting for an answer from
+ * the real X server. If that answer takes more than 5 seconds we
+ * consider the conversion failed and tell our client about that.
+ * The new request that lead us here is then processed.
+ */
if (lastClientWindowPtr != NULL)
{
#ifdef TEST
@@ -1724,6 +1731,11 @@ int nxagentConvertSelection(ClientPtr client, WindowPtr pWin, Atom selection,
}
else
{
+ /*
+ * we got another convert request while already waiting for an
+ * answer from the real X server to a previous convert request,
+ * which we cannot handle (yet). So return an error.
+ */
#ifdef DEBUG
fprintf(stderr, "%s: got request "
"before timeout expired on last request, notifying failure to client\n", __func__);
@@ -1758,7 +1770,7 @@ int nxagentConvertSelection(ClientPtr client, WindowPtr pWin, Atom selection,
* for a list of supported data formats. Currently there's 4 of them.
*
* FIXME: I am wondering if we should align this with
- * nxagentRequestSelection, where we only report one format.
+ * nxagentRequestSelection, where we use another target list.
*/
if (target == clientTARGETS)
{
@@ -1976,9 +1988,9 @@ int nxagentSendNotify(xEvent *event)
* .property must be a server-side Atom. As this property is only
* set on our serverWindow and normally there are no other
* properties except serverCutProperty, the only thing we need to
- * ensure is that the internal Atom clientCutProperty must differ
+ * ensure is that the internal Atom clientCutProperty differs
* from the server-side serverCutProperty Atom. The actual name is
- * not important. To be clean here we use a seperate
+ * not important. To be clean here we use a separate
* serverClientCutProperty.
*/
@@ -2192,6 +2204,11 @@ Bool nxagentInitClipboard(WindowPtr pWin)
for (int i = 0; i < nxagentMaxSelections; i++)
{
+ /*
+ * if we have a selection inform the (new) real Xserver and
+ * claim the ownership. Note that we report our serverWindow as
+ * owner, not the real window!
+ */
if (lastSelectionOwner[i].client && lastSelectionOwner[i].window)
{
XSetSelectionOwner(nxagentDisplay, lastSelectionOwner[i].selection, iWindow, CurrentTime);