Commit fba36716 authored by Ulrich Sibiller's avatar Ulrich Sibiller Committed by Mike Gabriel

Clipboard.c: refactor nxagent*SelectionOwner

expect an index instead of a pointer All calls referenced lastSelectionOwner so let the function directly use it and only pass the required index.
parent 057ce728
...@@ -493,21 +493,30 @@ Bool nxagentValidServerTargets(XlibAtom target) ...@@ -493,21 +493,30 @@ Bool nxagentValidServerTargets(XlibAtom target)
return False; return False;
} }
void nxagentClearSelectionOwner(SelectionOwner *owner) void nxagentInitSelectionOwner(int index, Atom selection)
{ {
/* there's no owner on nxagent side anymore */ lastSelectionOwner[index].selection = selection;
owner->client = NULL; lastSelectionOwner[index].client = NullClient;
owner->window = None; lastSelectionOwner[index].window = screenInfo.screens[0]->root->drawable.id;
owner->lastTimeChanged = GetTimeInMillis(); lastSelectionOwner[index].windowPtr = NULL;
/* FIXME: why is windowPtr not cleared in the function? */ lastSelectionOwner[index].lastTimeChanged = GetTimeInMillis();
} }
void nxagentStoreSelectionOwner(SelectionOwner *owner, Selection *sel) /* there's no owner on nxagent side anymore */
void nxagentClearSelectionOwner(int index)
{ {
owner->client = sel->client; lastSelectionOwner[index].client = NULL;
owner->window = sel->window; lastSelectionOwner[index].window = None;
owner->windowPtr = sel->pWin; lastSelectionOwner[index].lastTimeChanged = GetTimeInMillis();
owner->lastTimeChanged = GetTimeInMillis(); /* FIXME: why is windowPtr not cleared in the function? */
}
void nxagentStoreSelectionOwner(int index, Selection *sel)
{
lastSelectionOwner[index].client = sel->client;
lastSelectionOwner[index].window = sel->window;
lastSelectionOwner[index].windowPtr = sel->pWin;
lastSelectionOwner[index].lastTimeChanged = GetTimeInMillis();
} }
void nxagentClearClipboard(ClientPtr pClient, WindowPtr pWindow) void nxagentClearClipboard(ClientPtr pClient, WindowPtr pWindow)
...@@ -534,7 +543,7 @@ void nxagentClearClipboard(ClientPtr pClient, WindowPtr pWindow) ...@@ -534,7 +543,7 @@ void nxagentClearClipboard(ClientPtr pClient, WindowPtr pWindow)
#endif #endif
/* FIXME: why is windowPtr not cleared in the function? */ /* FIXME: why is windowPtr not cleared in the function? */
nxagentClearSelectionOwner(&lastSelectionOwner[i]); nxagentClearSelectionOwner(i);
lastSelectionOwner[i].windowPtr = NULL; lastSelectionOwner[i].windowPtr = NULL;
lastClientWindowPtr = NULL; lastClientWindowPtr = NULL;
...@@ -618,7 +627,7 @@ void nxagentClearSelection(XEvent *X) ...@@ -618,7 +627,7 @@ void nxagentClearSelection(XEvent *X)
CurrentSelections[i].window = screenInfo.screens[0]->root->drawable.id; CurrentSelections[i].window = screenInfo.screens[0]->root->drawable.id;
CurrentSelections[i].client = NullClient; CurrentSelections[i].client = NullClient;
nxagentClearSelectionOwner(&lastSelectionOwner[i]); nxagentClearSelectionOwner(i);
} }
lastClientWindowPtr = NULL; lastClientWindowPtr = NULL;
...@@ -1418,7 +1427,7 @@ void nxagentResetSelectionOwner(void) ...@@ -1418,7 +1427,7 @@ void nxagentResetSelectionOwner(void)
fprintf(stderr, "%s: Reset selection state for selection [%d].\n", __func__, i); fprintf(stderr, "%s: Reset selection state for selection [%d].\n", __func__, i);
#endif #endif
nxagentClearSelectionOwner(&lastSelectionOwner[i]); nxagentClearSelectionOwner(i);
lastSelectionOwner[i].windowPtr = NULL; lastSelectionOwner[i].windowPtr = NULL;
} }
...@@ -1570,7 +1579,7 @@ void nxagentSetSelectionOwner(Selection *pSelection) ...@@ -1570,7 +1579,7 @@ void nxagentSetSelectionOwner(Selection *pSelection)
* points to the struct that contains all information about the * points to the struct that contains all information about the
* owner window. * owner window.
*/ */
nxagentStoreSelectionOwner(&lastSelectionOwner[i], pSelection); nxagentStoreSelectionOwner(i, pSelection);
} }
} }
...@@ -2009,15 +2018,6 @@ WindowPtr nxagentGetClipboardWindow(Atom property) ...@@ -2009,15 +2018,6 @@ WindowPtr nxagentGetClipboardWindow(Atom property)
} }
} }
void nxagentInitSelectionOwner(SelectionOwner *owner, Atom selection)
{
owner->selection = selection;
owner->client = NullClient;
owner->window = screenInfo.screens[0]->root->drawable.id;
owner->windowPtr = NULL;
owner->lastTimeChanged = GetTimeInMillis();
}
int nxagentInitClipboard(WindowPtr pWin) int nxagentInitClipboard(WindowPtr pWin)
{ {
Window iWindow = nxagentWindow(pWin); Window iWindow = nxagentWindow(pWin);
...@@ -2037,8 +2037,8 @@ int nxagentInitClipboard(WindowPtr pWin) ...@@ -2037,8 +2037,8 @@ int nxagentInitClipboard(WindowPtr pWin)
serverTIMESTAMP = nxagentAtoms[11]; /* TIMESTAMP */ serverTIMESTAMP = nxagentAtoms[11]; /* TIMESTAMP */
nxagentInitSelectionOwner(&lastSelectionOwner[nxagentPrimarySelection], XA_PRIMARY); nxagentInitSelectionOwner(nxagentPrimarySelection, XA_PRIMARY);
nxagentInitSelectionOwner(&lastSelectionOwner[nxagentClipboardSelection], nxagentAtoms[10]); /* CLIPBOARD */ nxagentInitSelectionOwner(nxagentClipboardSelection, nxagentAtoms[10]); /* CLIPBOARD */
#ifdef NXAGENT_TIMESTAMP #ifdef NXAGENT_TIMESTAMP
{ {
...@@ -2143,8 +2143,8 @@ int nxagentInitClipboard(WindowPtr pWin) ...@@ -2143,8 +2143,8 @@ int nxagentInitClipboard(WindowPtr pWin)
} }
else else
{ {
lastSelectionOwner[nxagentPrimarySelection].client = NULL; nxagentClearSelectionOwner(nxagentPrimarySelection);
lastSelectionOwner[nxagentClipboardSelection].client = NULL; nxagentClearSelectionOwner(nxagentClipboardSelection);
lastServerRequestor = None; lastServerRequestor = None;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment