aboutsummaryrefslogtreecommitdiff
path: root/nx-X11/programs/Xserver/hw
diff options
context:
space:
mode:
Diffstat (limited to 'nx-X11/programs/Xserver/hw')
-rw-r--r--nx-X11/programs/Xserver/hw/nxagent/Clipboard.c24
-rw-r--r--nx-X11/programs/Xserver/hw/nxagent/Events.c2
-rw-r--r--nx-X11/programs/Xserver/hw/nxagent/NXdispatch.c4
3 files changed, 16 insertions, 14 deletions
diff --git a/nx-X11/programs/Xserver/hw/nxagent/Clipboard.c b/nx-X11/programs/Xserver/hw/nxagent/Clipboard.c
index d54171a0d..3098ebb49 100644
--- a/nx-X11/programs/Xserver/hw/nxagent/Clipboard.c
+++ b/nx-X11/programs/Xserver/hw/nxagent/Clipboard.c
@@ -735,7 +735,8 @@ void nxagentClearClipboard(ClientPtr pClient, WindowPtr pWindow)
/*
* Find the index of the lastSelectionOwner with the selection
- * sel. sel is an atom on the real X server.
+ * sel. sel is an atom on the real X server. If the index cannot be
+ * determined it will return -1.
*/
int nxagentFindLastSelectionOwnerIndex(XlibAtom sel)
{
@@ -752,12 +753,13 @@ int nxagentFindLastSelectionOwnerIndex(XlibAtom sel)
#ifdef DEBUG
fprintf(stderr, "%s: remote selection [%ld][%s] does not belong to any index!\n", __func__, sel, NameForRemAtom(sel));
#endif
- return nxagentMaxSelections;
+ return -1;
}
/*
* Find the index of CurrentSelection with the selection
- * sel. sel is an internal atom.
+ * sel. sel is an internal atom. If the index cannot be
+ * determined it will return -1.
*/
int nxagentFindCurrentSelectionIndex(Atom sel)
{
@@ -774,7 +776,7 @@ int nxagentFindCurrentSelectionIndex(Atom sel)
#ifdef DEBUG
fprintf(stderr, "%s: selection [%d][%s] does not belong to any index!\n", __func__, sel, NameForIntAtom(sel));
#endif
- return NumCurrentSelections;
+ return -1;
}
void cacheTargetsForInt(int index, Atom* targets, int numTargets)
@@ -861,7 +863,7 @@ void nxagentHandleSelectionClearFromXServer(XEvent *X)
}
int index = nxagentFindLastSelectionOwnerIndex(X->xselectionclear.selection);
- if (index < nxagentMaxSelections)
+ if (index != -1)
{
if (IS_INTERNAL_OWNER(index))
{
@@ -951,7 +953,7 @@ void nxagentHandleSelectionRequestFromXServer(XEvent *X)
/* the selection in this request is none we own. */
int index = nxagentFindLastSelectionOwnerIndex(X->xselectionrequest.selection);
- if (index == nxagentMaxSelections)
+ if (index == -1)
{
#ifdef DEBUG
fprintf(stderr, "%s: not owning selection [%ld] - denying request.\n", __func__, X->xselectionrequest.selection);
@@ -1736,7 +1738,7 @@ void nxagentHandleSelectionNotifyFromXServer(XEvent *X)
/* determine the selection we are talking about here */
int index = nxagentFindLastSelectionOwnerIndex(e->selection);
- if (index == nxagentMaxSelections)
+ if (index == -1)
{
#ifdef DEBUG
fprintf (stderr, "%s: unknown selection [%ld] .\n", __func__, e->selection);
@@ -2162,7 +2164,7 @@ static void setSelectionOwnerOnXServer(Selection *pSelection)
#endif
int index = nxagentFindCurrentSelectionIndex(pSelection->selection);
- if (index < NumCurrentSelections)
+ if (index != -1)
{
#ifdef DEBUG
fprintf(stderr, "%s: lastSelectionOwner.client %s -> %s\n", __func__,
@@ -2294,7 +2296,7 @@ int nxagentConvertSelection(ClientPtr client, WindowPtr pWin, Atom selection,
}
int index = nxagentFindCurrentSelectionIndex(selection);
- if (index == NumCurrentSelections)
+ if (index == -1)
{
#ifdef DEBUG
fprintf(stderr, "%s: cannot find index for selection [%u]\n", __func__, selection);
@@ -2761,7 +2763,7 @@ int nxagentSendNotificationToSelfViaXServer(xEvent *event)
#endif
int index = nxagentFindCurrentSelectionIndex(event->u.selectionNotify.selection);
- if (index == nxagentMaxSelections)
+ if (index == -1)
{
#ifdef DEBUG
fprintf(stderr, "%s: unknown selection [%d]\n", __func__,
@@ -2845,7 +2847,7 @@ WindowPtr nxagentGetClipboardWindow(Atom property)
}
int index = nxagentFindLastSelectionOwnerIndex(serverLastRequestedSelection);
- if (index < nxagentMaxSelections &&
+ if (index != -1 &&
property == clientCutProperty &&
lastSelectionOwner[index].windowPtr != NULL)
{
diff --git a/nx-X11/programs/Xserver/hw/nxagent/Events.c b/nx-X11/programs/Xserver/hw/nxagent/Events.c
index 2ec17c328..d29ed9bcd 100644
--- a/nx-X11/programs/Xserver/hw/nxagent/Events.c
+++ b/nx-X11/programs/Xserver/hw/nxagent/Events.c
@@ -2850,7 +2850,7 @@ int nxagentHandleXFixesSelectionNotify(XEvent *X)
Atom local = nxagentRemoteToLocalAtom(xfixesEvent -> xfixesselection.selection);
int index = nxagentFindCurrentSelectionIndex(local);
- if (index < NumCurrentSelections)
+ if (index != -1)
{
if (CurrentSelections[index].client != 0)
{
diff --git a/nx-X11/programs/Xserver/hw/nxagent/NXdispatch.c b/nx-X11/programs/Xserver/hw/nxagent/NXdispatch.c
index a8739fa3f..ff8330cc7 100644
--- a/nx-X11/programs/Xserver/hw/nxagent/NXdispatch.c
+++ b/nx-X11/programs/Xserver/hw/nxagent/NXdispatch.c
@@ -722,8 +722,8 @@ ProcConvertSelection(register ClientPtr client)
(stuff->selection == MakeAtom("CLIPBOARD", 9, 0))) &&
nxagentOption(Clipboard) != ClipboardNone)
{
- int i = nxagentFindCurrentSelectionIndex(stuff->selection);
- if ((i < NumCurrentSelections) && (CurrentSelections[i].window != None))
+ int index = nxagentFindCurrentSelectionIndex(stuff->selection);
+ if ((index != -1) && (CurrentSelections[index].window != None))
{
if (nxagentConvertSelection(client, pWin, stuff->selection, stuff->requestor,
stuff->property, stuff->target, stuff->time))