Commit 649c1752 authored by Ulrich Sibiller's avatar Ulrich Sibiller Committed by Mike Gabriel

Clipboard.c: rename static helpers and macros

drop the nxagent prefix to emphasize they are not called from the outside. Also make them static and add prototypes, if missing.
parent fad1b5f0
...@@ -169,7 +169,7 @@ static char szAgentCLIPBOARD[] = "CLIPBOARD"; ...@@ -169,7 +169,7 @@ static char szAgentCLIPBOARD[] = "CLIPBOARD";
*/ */
#ifdef DEBUG #ifdef DEBUG
const char * GetClientSelectionStageString(int stage) static const char * getClientSelectionStageString(int stage)
{ {
switch(stage) switch(stage)
{ {
...@@ -181,13 +181,13 @@ const char * GetClientSelectionStageString(int stage) ...@@ -181,13 +181,13 @@ const char * GetClientSelectionStageString(int stage)
default: return("UNKNOWN!"); break;; default: return("UNKNOWN!"); break;;
} }
} }
#define SetClientSelectionStage(stage) do {fprintf(stderr, "%s: Changing selection stage from [%s] to [%s]\n", __func__, GetClientSelectionStageString(lastClientStage), GetClientSelectionStageString(SelectionStage##stage)); lastClientStage = SelectionStage##stage;} while (0) #define setClientSelectionStage(stage) do {fprintf(stderr, "%s: Changing selection stage from [%s] to [%s]\n", __func__, getClientSelectionStageString(lastClientStage), getClientSelectionStageString(SelectionStage##stage)); lastClientStage = SelectionStage##stage;} while (0)
#define PrintClientSelectionStage() do {fprintf(stderr, "%s: Current selection stage [%s]\n", __func__, GetClientSelectionStageString(lastClientStage));} while (0) #define printClientSelectionStage() do {fprintf(stderr, "%s: Current selection stage [%s]\n", __func__, getClientSelectionStageString(lastClientStage));} while (0)
#define WINDOWID(ptr) (ptr) ? (ptr->drawable.id) : 0 #define WINDOWID(ptr) (ptr) ? (ptr->drawable.id) : 0
#define CLINDEX(clientptr) (clientptr) ? (clientptr->index) : -1 #define CLINDEX(clientptr) (clientptr) ? (clientptr->index) : -1
#else #else
#define SetClientSelectionStage(stage) do {lastClientStage = SelectionStage##stage;} while (0) #define setClientSelectionStage(stage) do {lastClientStage = SelectionStage##stage;} while (0)
#define PrintClientSelectionStage() #define printClientSelectionStage()
#endif #endif
#ifdef DEBUG #ifdef DEBUG
...@@ -197,7 +197,7 @@ const char * GetClientSelectionStageString(int stage) ...@@ -197,7 +197,7 @@ const char * GetClientSelectionStageString(int stage)
* We use our own version to avoid Xlib doing expensive calls. * We use our own version to avoid Xlib doing expensive calls.
* FIXME: Must check if XGetErrorText() is really causing traffic over the wire. * FIXME: Must check if XGetErrorText() is really causing traffic over the wire.
*/ */
const char * GetXErrorString(int code) const char * getXErrorString(int code)
{ {
switch(code) switch(code)
{ {
...@@ -232,17 +232,32 @@ XFixesAgentInfoRec nxagentXFixesInfo = { -1, -1, -1, 0 }; ...@@ -232,17 +232,32 @@ XFixesAgentInfoRec nxagentXFixesInfo = { -1, -1, -1, 0 };
extern Display *nxagentDisplay; extern Display *nxagentDisplay;
static Bool nxagentValidServerTargets(XlibAtom target); static Bool validServerTargets(XlibAtom target);
static void endTransfer(Bool success); static void endTransfer(Bool success);
#define SELECTION_SUCCESS True #define SELECTION_SUCCESS True
#define SELECTION_FAULT False #define SELECTION_FAULT False
static void nxagentTransferSelection(int resource); static void transferSelection(int resource);
#if 0 #if 0
void nxagentResetSelectionOwner(void); static void resetSelectionOwner(void);
#endif #endif
static void nxagentNotifyConvertFailure(ClientPtr client, Window requestor, static void initSelectionOwner(int index, Atom selection);
Atom selection, Atom target, Time time); static void clearSelectionOwner(int index);
static void nxagentSetSelectionOwner(Selection *pSelection); static void storeSelectionOwner(int index, Selection *sel);
static Bool matchSelectionOwner(int index, ClientPtr pClient, WindowPtr pWindow);
static void notifyConvertFailure(ClientPtr client, Window requestor,
Atom selection, Atom target, Time time);
static void setSelectionOwner(Selection *pSelection);
static int sendEventToClient(ClientPtr client, xEvent *pEvents);
static int sendSelectionNotifyEventToClient(ClientPtr client,
Time time,
Window requestor,
Atom selection,
Atom target,
Atom property);
static Status sendSelectionNotifyEventToServer(XSelectionEvent *event_to_send);
static void printSelectionStat(int sel);
static void replyRequestSelection(XEvent *X, Bool success);
void nxagentPrintClipboardStat(char *); void nxagentPrintClipboardStat(char *);
...@@ -251,7 +266,7 @@ extern unsigned long startTime; ...@@ -251,7 +266,7 @@ extern unsigned long startTime;
#endif #endif
#ifdef DEBUG #ifdef DEBUG
void nxagentPrintSelectionStat(int sel) static void printSelectionStat(int sel)
{ {
SelectionOwner lOwner = lastSelectionOwner[sel]; SelectionOwner lOwner = lastSelectionOwner[sel];
Selection curSel = CurrentSelections[sel]; Selection curSel = CurrentSelections[sel];
...@@ -345,12 +360,12 @@ void nxagentPrintClipboardStat(char *header) ...@@ -345,12 +360,12 @@ void nxagentPrintClipboardStat(char *header)
fprintf(stderr, " lastClientTime (Time) [%u]\n", lastClientTime); fprintf(stderr, " lastClientTime (Time) [%u]\n", lastClientTime);
fprintf(stderr, " lastClientReqTime (Time) [%u]\n", lastClientReqTime); fprintf(stderr, " lastClientReqTime (Time) [%u]\n", lastClientReqTime);
fprintf(stderr, " lastClientPropertySize (unsigned long) [%lu]\n", lastClientPropertySize); fprintf(stderr, " lastClientPropertySize (unsigned long) [%lu]\n", lastClientPropertySize);
fprintf(stderr, " lastClientStage (ClientSelectionStage) [%d][%s]\n", lastClientStage, GetClientSelectionStageString(lastClientStage)); fprintf(stderr, " lastClientStage (ClientSelectionStage) [%d][%s]\n", lastClientStage, getClientSelectionStageString(lastClientStage));
fprintf(stderr, "PRIMARY\n"); fprintf(stderr, "PRIMARY\n");
nxagentPrintSelectionStat(nxagentPrimarySelection); printSelectionStat(nxagentPrimarySelection);
fprintf(stderr, "CLIPBOARD\n"); fprintf(stderr, "CLIPBOARD\n");
nxagentPrintSelectionStat(nxagentClipboardSelection); printSelectionStat(nxagentClipboardSelection);
fprintf(stderr, "Atoms (remote X server)\n"); fprintf(stderr, "Atoms (remote X server)\n");
SAFE_XFree(s); s = XGetAtomName(nxagentDisplay, serverTARGETS); SAFE_XFree(s); s = XGetAtomName(nxagentDisplay, serverTARGETS);
...@@ -398,7 +413,7 @@ int GetWindowProperty(WindowPtr pWin, Atom property, long longOffset, long longL ...@@ -398,7 +413,7 @@ int GetWindowProperty(WindowPtr pWin, Atom property, long longOffset, long longL
* Send a SelectionNotify event to the real X server and do some error * Send a SelectionNotify event to the real X server and do some error
* handling (in DEBUG mode) * handling (in DEBUG mode)
*/ */
Status SendSelectionNotifyEventToServer(XSelectionEvent *event_to_send) static Status sendSelectionNotifyEventToServer(XSelectionEvent *event_to_send)
{ {
Window w = event_to_send->requestor; Window w = event_to_send->requestor;
...@@ -422,7 +437,7 @@ Status SendSelectionNotifyEventToServer(XSelectionEvent *event_to_send) ...@@ -422,7 +437,7 @@ Status SendSelectionNotifyEventToServer(XSelectionEvent *event_to_send)
{ {
if (result == BadValue || result == BadWindow) if (result == BadValue || result == BadWindow)
{ {
fprintf(stderr, "%s: WARNING! XSendEvent to [0x%x] failed: %s\n", __func__, w, GetXErrorString(result)); fprintf(stderr, "%s: WARNING! XSendEvent to [0x%x] failed: %s\n", __func__, w, getXErrorString(result));
} }
else else
{ {
...@@ -436,17 +451,17 @@ Status SendSelectionNotifyEventToServer(XSelectionEvent *event_to_send) ...@@ -436,17 +451,17 @@ Status SendSelectionNotifyEventToServer(XSelectionEvent *event_to_send)
return result; return result;
} }
int SendEventToClient(ClientPtr client, xEvent *pEvents) static int sendEventToClient(ClientPtr client, xEvent *pEvents)
{ {
return TryClientEvents (client, pEvents, 1, NoEventMask, NoEventMask, NullGrab); return TryClientEvents(client, pEvents, 1, NoEventMask, NoEventMask, NullGrab);
} }
int SendSelectionNotifyEventToClient(ClientPtr client, static int sendSelectionNotifyEventToClient(ClientPtr client,
Time time, Time time,
Window requestor, Window requestor,
Atom selection, Atom selection,
Atom target, Atom target,
Atom property) Atom property)
{ {
xEvent x = {0}; xEvent x = {0};
x.u.u.type = SelectionNotify; x.u.u.type = SelectionNotify;
...@@ -465,7 +480,7 @@ int SendSelectionNotifyEventToClient(ClientPtr client, ...@@ -465,7 +480,7 @@ int SendSelectionNotifyEventToClient(ClientPtr client,
CLINDEX(client)); CLINDEX(client));
#endif #endif
return SendEventToClient(client, &x); return sendEventToClient(client, &x);
} }
/* /*
...@@ -473,7 +488,7 @@ int SendSelectionNotifyEventToClient(ClientPtr client, ...@@ -473,7 +488,7 @@ int SendSelectionNotifyEventToClient(ClientPtr client,
* server, like .e.g XA_STRING or UTF8_STRING. Other, non content type * server, like .e.g XA_STRING or UTF8_STRING. Other, non content type
* targets like "TARGETS" or "TIMESTAMP" will return false. * targets like "TARGETS" or "TIMESTAMP" will return false.
*/ */
static Bool nxagentValidServerTargets(XlibAtom target) static Bool validServerTargets(XlibAtom target)
{ {
if (target == XA_STRING) if (target == XA_STRING)
{ {
...@@ -525,7 +540,7 @@ static Bool nxagentValidServerTargets(XlibAtom target) ...@@ -525,7 +540,7 @@ static Bool nxagentValidServerTargets(XlibAtom target)
return False; return False;
} }
void nxagentInitSelectionOwner(int index, Atom selection) static void initSelectionOwner(int index, Atom selection)
{ {
lastSelectionOwner[index].selection = selection; lastSelectionOwner[index].selection = selection;
lastSelectionOwner[index].client = NullClient; lastSelectionOwner[index].client = NullClient;
...@@ -535,7 +550,7 @@ void nxagentInitSelectionOwner(int index, Atom selection) ...@@ -535,7 +550,7 @@ void nxagentInitSelectionOwner(int index, Atom selection)
} }
/* there's no owner on nxagent side anymore */ /* there's no owner on nxagent side anymore */
void nxagentClearSelectionOwner(int index) static void clearSelectionOwner(int index)
{ {
lastSelectionOwner[index].client = NULL; lastSelectionOwner[index].client = NULL;
lastSelectionOwner[index].window = None; lastSelectionOwner[index].window = None;
...@@ -543,7 +558,7 @@ void nxagentClearSelectionOwner(int index) ...@@ -543,7 +558,7 @@ void nxagentClearSelectionOwner(int index)
lastSelectionOwner[index].lastTimeChanged = GetTimeInMillis(); lastSelectionOwner[index].lastTimeChanged = GetTimeInMillis();
} }
void nxagentStoreSelectionOwner(int index, Selection *sel) static void storeSelectionOwner(int index, Selection *sel)
{ {
lastSelectionOwner[index].client = sel->client; lastSelectionOwner[index].client = sel->client;
lastSelectionOwner[index].window = sel->window; lastSelectionOwner[index].window = sel->window;
...@@ -551,7 +566,7 @@ void nxagentStoreSelectionOwner(int index, Selection *sel) ...@@ -551,7 +566,7 @@ void nxagentStoreSelectionOwner(int index, Selection *sel)
lastSelectionOwner[index].lastTimeChanged = GetTimeInMillis(); lastSelectionOwner[index].lastTimeChanged = GetTimeInMillis();
} }
Bool nxagentMatchSelectionOwner(int index, ClientPtr pClient, WindowPtr pWindow) static Bool matchSelectionOwner(int index, ClientPtr pClient, WindowPtr pWindow)
{ {
return ((pClient && lastSelectionOwner[index].client == pClient) || return ((pClient && lastSelectionOwner[index].client == pClient) ||
(pWindow && lastSelectionOwner[index].windowPtr == pWindow)); (pWindow && lastSelectionOwner[index].windowPtr == pWindow));
...@@ -572,17 +587,17 @@ void nxagentClearClipboard(ClientPtr pClient, WindowPtr pWindow) ...@@ -572,17 +587,17 @@ void nxagentClearClipboard(ClientPtr pClient, WindowPtr pWindow)
for (int i = 0; i < nxagentMaxSelections; i++) for (int i = 0; i < nxagentMaxSelections; i++)
{ {
if (nxagentMatchSelectionOwner(i, pClient, pWindow)) if (matchSelectionOwner(i, pClient, pWindow))
{ {
#ifdef TEST #ifdef TEST
fprintf(stderr, "%s: Resetting state with client [%p] window [%p].\n", __func__, fprintf(stderr, "%s: Resetting state with client [%p] window [%p].\n", __func__,
(void *) pClient, (void *) pWindow); (void *) pClient, (void *) pWindow);
#endif #endif
nxagentClearSelectionOwner(i); clearSelectionOwner(i);
lastClientWindowPtr = NULL; lastClientWindowPtr = NULL;
SetClientSelectionStage(None); setClientSelectionStage(None);
lastServerRequestor = None; lastServerRequestor = None;
} }
...@@ -591,7 +606,7 @@ void nxagentClearClipboard(ClientPtr pClient, WindowPtr pWindow) ...@@ -591,7 +606,7 @@ void nxagentClearClipboard(ClientPtr pClient, WindowPtr pWindow)
if (pWindow && pWindow == lastClientWindowPtr) if (pWindow && pWindow == lastClientWindowPtr)
{ {
lastClientWindowPtr = NULL; lastClientWindowPtr = NULL;
SetClientSelectionStage(None); setClientSelectionStage(None);
} }
nxagentPrintClipboardStat("after nxagentClearClipboard"); nxagentPrintClipboardStat("after nxagentClearClipboard");
...@@ -668,7 +683,7 @@ void nxagentClearSelection(XEvent *X) ...@@ -668,7 +683,7 @@ void nxagentClearSelection(XEvent *X)
x.u.selectionClear.window = lastSelectionOwner[i].window; x.u.selectionClear.window = lastSelectionOwner[i].window;
x.u.selectionClear.atom = CurrentSelections[i].selection; x.u.selectionClear.atom = CurrentSelections[i].selection;
SendEventToClient(lastSelectionOwner[i].client, &x); sendEventToClient(lastSelectionOwner[i].client, &x);
} }
/* /*
...@@ -679,11 +694,11 @@ void nxagentClearSelection(XEvent *X) ...@@ -679,11 +694,11 @@ 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(i); clearSelectionOwner(i);
} }
lastClientWindowPtr = NULL; lastClientWindowPtr = NULL;
SetClientSelectionStage(None); setClientSelectionStage(None);
nxagentPrintClipboardStat("after nxagentClearSelection"); nxagentPrintClipboardStat("after nxagentClearSelection");
} }
...@@ -692,7 +707,7 @@ void nxagentClearSelection(XEvent *X) ...@@ -692,7 +707,7 @@ void nxagentClearSelection(XEvent *X)
* event X. If success is True take the property from the event, else * 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) static void replyRequestSelection(XEvent *X, Bool success)
{ {
XSelectionEvent eventSelection = { XSelectionEvent eventSelection = {
.requestor = X->xselectionrequest.requestor, .requestor = X->xselectionrequest.requestor,
...@@ -710,7 +725,7 @@ void nxagentReplyRequestSelection(XEvent *X, Bool success) ...@@ -710,7 +725,7 @@ void nxagentReplyRequestSelection(XEvent *X, Bool success)
eventSelection.property = None; eventSelection.property = None;
} }
SendSelectionNotifyEventToServer(&eventSelection); sendSelectionNotifyEventToServer(&eventSelection);
} }
/* /*
...@@ -760,7 +775,7 @@ void nxagentRequestSelection(XEvent *X) ...@@ -760,7 +775,7 @@ void nxagentRequestSelection(XEvent *X)
fprintf(stderr, "%s: denying additional request during transfer phase.\n", __func__); fprintf(stderr, "%s: denying additional request during transfer phase.\n", __func__);
#endif #endif
nxagentReplyRequestSelection(X, False); replyRequestSelection(X, False);
return; return;
} }
...@@ -773,13 +788,13 @@ void nxagentRequestSelection(XEvent *X) ...@@ -773,13 +788,13 @@ void nxagentRequestSelection(XEvent *X)
fprintf(stderr, "%s: not owning selection [%ld] - denying request.\n", __func__, X->xselectionrequest.selection); fprintf(stderr, "%s: not owning selection [%ld] - denying request.\n", __func__, X->xselectionrequest.selection);
#endif #endif
nxagentReplyRequestSelection(X, False); replyRequestSelection(X, False);
return; return;
} }
} }
/* this is a special request like TARGETS or TIMESTAMP */ /* this is a special request like TARGETS or TIMESTAMP */
if (!nxagentValidServerTargets(X->xselectionrequest.target)) if (!validServerTargets(X->xselectionrequest.target))
{ {
if (X->xselectionrequest.target == serverTARGETS) if (X->xselectionrequest.target == serverTARGETS)
{ {
...@@ -826,7 +841,7 @@ void nxagentRequestSelection(XEvent *X) ...@@ -826,7 +841,7 @@ void nxagentRequestSelection(XEvent *X)
(unsigned char*)&targets, (unsigned char*)&targets,
numTargets); numTargets);
nxagentReplyRequestSelection(X, True); replyRequestSelection(X, True);
} }
else if (X->xselectionrequest.target == serverTIMESTAMP) else if (X->xselectionrequest.target == serverTIMESTAMP)
{ {
...@@ -855,19 +870,19 @@ void nxagentRequestSelection(XEvent *X) ...@@ -855,19 +870,19 @@ void nxagentRequestSelection(XEvent *X)
PropModeReplace, PropModeReplace,
(unsigned char *) &lastSelectionOwner[i].lastTimeChanged, (unsigned char *) &lastSelectionOwner[i].lastTimeChanged,
1); 1);
nxagentReplyRequestSelection(X, True); replyRequestSelection(X, True);
} }
} }
else else
{ {
/* /*
* unknown special request - probably bug! Check if this code handles all cases * unknown special request - probably bug! Check if this code handles all cases
* that are handled in nxagentValidServerTargets! * that are handled in validServerTargets!
*/ */
#ifdef DEBUG #ifdef DEBUG
fprintf(stderr, "%s: unknown special target [%ld] - denying request.\n", __func__, X->xselectionrequest.target); fprintf(stderr, "%s: unknown special target [%ld] - denying request.\n", __func__, X->xselectionrequest.target);
#endif #endif
nxagentReplyRequestSelection(X, False); replyRequestSelection(X, False);
} }
return; return;
} }
...@@ -949,7 +964,7 @@ void nxagentRequestSelection(XEvent *X) ...@@ -949,7 +964,7 @@ void nxagentRequestSelection(XEvent *X)
else else
x.u.selectionRequest.target = XA_STRING; x.u.selectionRequest.target = XA_STRING;
SendEventToClient(lastSelectionOwner[i].client, &x); sendEventToClient(lastSelectionOwner[i].client, &x);
#ifdef DEBUG #ifdef DEBUG
fprintf(stderr, "%s: sent SelectionRequest event to client [%d] property [%d][%s]" \ fprintf(stderr, "%s: sent SelectionRequest event to client [%d] property [%d][%s]" \
...@@ -963,7 +978,7 @@ void nxagentRequestSelection(XEvent *X) ...@@ -963,7 +978,7 @@ void nxagentRequestSelection(XEvent *X)
else else
{ {
/* deny the request */ /* deny the request */
nxagentReplyRequestSelection(X, False); replyRequestSelection(X, False);
} }
} }
} }
...@@ -996,7 +1011,7 @@ static void endTransfer(Bool success) ...@@ -996,7 +1011,7 @@ static void endTransfer(Bool success)
CLINDEX(lastClientClientPtr)); CLINDEX(lastClientClientPtr));
#endif #endif
SendSelectionNotifyEventToClient(lastClientClientPtr, sendSelectionNotifyEventToClient(lastClientClientPtr,
lastClientTime, lastClientTime,
lastClientRequestor, lastClientRequestor,
lastClientSelection, lastClientSelection,
...@@ -1007,10 +1022,10 @@ static void endTransfer(Bool success) ...@@ -1007,10 +1022,10 @@ static void endTransfer(Bool success)
* Enable further requests from clients. * Enable further requests from clients.
*/ */
lastClientWindowPtr = NULL; lastClientWindowPtr = NULL;
SetClientSelectionStage(None); setClientSelectionStage(None);
} }
static void nxagentTransferSelection(int resource) static void transferSelection(int resource)
{ {
if (lastClientClientPtr -> index != resource) if (lastClientClientPtr -> index != resource)
{ {
...@@ -1030,7 +1045,7 @@ static void nxagentTransferSelection(int resource) ...@@ -1030,7 +1045,7 @@ static void nxagentTransferSelection(int resource)
{ {
int result; int result;
PrintClientSelectionStage(); printClientSelectionStage();
/* /*
* Don't get data yet, just get size. We skip this stage in * Don't get data yet, just get size. We skip this stage in
...@@ -1071,7 +1086,7 @@ static void nxagentTransferSelection(int resource) ...@@ -1071,7 +1086,7 @@ static void nxagentTransferSelection(int resource)
return; return;
} }
SetClientSelectionStage(WaitSize); setClientSelectionStage(WaitSize);
NXFlushDisplay(nxagentDisplay, NXFlushLink); NXFlushDisplay(nxagentDisplay, NXFlushLink);
...@@ -1081,7 +1096,7 @@ static void nxagentTransferSelection(int resource) ...@@ -1081,7 +1096,7 @@ static void nxagentTransferSelection(int resource)
{ {
int result; int result;
PrintClientSelectionStage(); printClientSelectionStage();
/* /*
* Request the selection data now. * Request the selection data now.
...@@ -1125,7 +1140,7 @@ static void nxagentTransferSelection(int resource) ...@@ -1125,7 +1140,7 @@ static void nxagentTransferSelection(int resource)
return; return;
} }
SetClientSelectionStage(WaitData); setClientSelectionStage(WaitData);
/* we've seen situations where you had to move the mouse or press a /* we've seen situations where you had to move the mouse or press a
key to let the transfer complete. Flushing here fixed it */ key to let the transfer complete. Flushing here fixed it */
...@@ -1137,7 +1152,7 @@ static void nxagentTransferSelection(int resource) ...@@ -1137,7 +1152,7 @@ static void nxagentTransferSelection(int resource)
{ {
#ifdef DEBUG #ifdef DEBUG
fprintf (stderr, "%s: WARNING! Inconsistent state [%s] for client [%d].\n", __func__, fprintf (stderr, "%s: WARNING! Inconsistent state [%s] for client [%d].\n", __func__,
GetClientSelectionStageString(lastClientStage), CLINDEX(lastClientClientPtr)); getClientSelectionStageString(lastClientStage), CLINDEX(lastClientClientPtr));
#endif #endif
break; break;
...@@ -1198,7 +1213,7 @@ void nxagentCollectPropertyEvent(int resource) ...@@ -1198,7 +1213,7 @@ void nxagentCollectPropertyEvent(int resource)
{ {
case SelectionStageWaitSize: case SelectionStageWaitSize:
{ {
PrintClientSelectionStage(); printClientSelectionStage();
#ifdef DEBUG #ifdef DEBUG
fprintf (stderr, "%s: Got size notify event for client [%d].\n", __func__, fprintf (stderr, "%s: Got size notify event for client [%d].\n", __func__,
CLINDEX(lastClientClientPtr)); CLINDEX(lastClientClientPtr));
...@@ -1222,15 +1237,15 @@ void nxagentCollectPropertyEvent(int resource) ...@@ -1222,15 +1237,15 @@ void nxagentCollectPropertyEvent(int resource)
* Request the selection data now. * Request the selection data now.
*/ */
lastClientPropertySize = ulReturnBytesLeft; lastClientPropertySize = ulReturnBytesLeft;
SetClientSelectionStage(QueryData); setClientSelectionStage(QueryData);
nxagentTransferSelection(resource); transferSelection(resource);
} }
break; break;
} }
case SelectionStageWaitData: case SelectionStageWaitData:
{ {
PrintClientSelectionStage(); printClientSelectionStage();
#ifdef DEBUG #ifdef DEBUG
fprintf (stderr, "%s: Got data notify event for client [%d].\n", __func__, fprintf (stderr, "%s: Got data notify event for client [%d].\n", __func__,
CLINDEX(lastClientClientPtr)); CLINDEX(lastClientClientPtr));
...@@ -1272,7 +1287,7 @@ void nxagentCollectPropertyEvent(int resource) ...@@ -1272,7 +1287,7 @@ void nxagentCollectPropertyEvent(int resource)
{ {
#ifdef DEBUG #ifdef DEBUG
fprintf (stderr, "%s: WARNING! Inconsistent state [%s] for client [%d].\n", __func__, fprintf (stderr, "%s: WARNING! Inconsistent state [%s] for client [%d].\n", __func__,
GetClientSelectionStageString(lastClientStage), CLINDEX(lastClientClientPtr)); getClientSelectionStageString(lastClientStage), CLINDEX(lastClientClientPtr));
#endif #endif
break; break;
} }
...@@ -1310,7 +1325,7 @@ void nxagentHandleSelectionNotifyFromXServer(XEvent *X) ...@@ -1310,7 +1325,7 @@ void nxagentHandleSelectionNotifyFromXServer(XEvent *X)
} }
#endif #endif
PrintClientSelectionStage(); printClientSelectionStage();
if (lastClientWindowPtr != NULL) if (lastClientWindowPtr != NULL)
{ {
...@@ -1341,10 +1356,10 @@ void nxagentHandleSelectionNotifyFromXServer(XEvent *X) ...@@ -1341,10 +1356,10 @@ void nxagentHandleSelectionNotifyFromXServer(XEvent *X)
* tions. * tions.
*/ */
SetClientSelectionStage(QueryData); setClientSelectionStage(QueryData);
lastClientPropertySize = 262144; lastClientPropertySize = 262144;
nxagentTransferSelection(lastClientClientPtr -> index); transferSelection(lastClientClientPtr -> index);
} }
else else
{ {
...@@ -1382,7 +1397,7 @@ void nxagentHandleSelectionNotifyFromXServer(XEvent *X) ...@@ -1382,7 +1397,7 @@ void nxagentHandleSelectionNotifyFromXServer(XEvent *X)
#ifdef DEBUG #ifdef DEBUG
fprintf(stderr, "%s: GetWindowProperty() window [0x%x] property [%d] returned [%s]\n", __func__, fprintf(stderr, "%s: GetWindowProperty() window [0x%x] property [%d] returned [%s]\n", __func__,
lastSelectionOwner[i].window, clientCutProperty, GetXErrorString(result)); lastSelectionOwner[i].window, clientCutProperty, getXErrorString(result));
#endif #endif
if (result == BadAlloc || result == BadAtom || if (result == BadAlloc || result == BadAtom ||
result == BadWindow || result == BadValue) result == BadWindow || result == BadValue)
...@@ -1398,7 +1413,7 @@ void nxagentHandleSelectionNotifyFromXServer(XEvent *X) ...@@ -1398,7 +1413,7 @@ void nxagentHandleSelectionNotifyFromXServer(XEvent *X)
&pszReturnData); &pszReturnData);
#ifdef DEBUG #ifdef DEBUG
fprintf(stderr, "%s: GetWindowProperty() window [0x%x] property [%d] returned [%s]\n", __func__, fprintf(stderr, "%s: GetWindowProperty() window [0x%x] property [%d] returned [%s]\n", __func__,
lastSelectionOwner[i].window, clientCutProperty, GetXErrorString(result)); lastSelectionOwner[i].window, clientCutProperty, getXErrorString(result));
#endif #endif
if (result == BadAlloc || result == BadAtom || if (result == BadAlloc || result == BadAtom ||
...@@ -1465,7 +1480,7 @@ void nxagentHandleSelectionNotifyFromXServer(XEvent *X) ...@@ -1465,7 +1480,7 @@ void nxagentHandleSelectionNotifyFromXServer(XEvent *X)
(void *)eventSelection.requestor); (void *)eventSelection.requestor);
#endif #endif
SendSelectionNotifyEventToServer(&eventSelection); sendSelectionNotifyEventToServer(&eventSelection);
lastServerRequestor = None; /* allow further request */ lastServerRequestor = None; /* allow further request */
} }
...@@ -1480,7 +1495,7 @@ void nxagentHandleSelectionNotifyFromXServer(XEvent *X) ...@@ -1480,7 +1495,7 @@ void nxagentHandleSelectionNotifyFromXServer(XEvent *X)
* the real X server (or its clients) will be sent to this window. The * the real X server (or its clients) will be sent to this window. The
* real X server never communicates with our windows directly. * real X server never communicates with our windows directly.
*/ */
void nxagentResetSelectionOwner(void) static void resetSelectionOwner(void)
{ {
if (lastServerRequestor != None) if (lastServerRequestor != None)
{ {
...@@ -1509,11 +1524,11 @@ void nxagentResetSelectionOwner(void) ...@@ -1509,11 +1524,11 @@ 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(i); clearSelectionOwner(i);
} }
lastClientWindowPtr = NULL; lastClientWindowPtr = NULL;
SetClientSelectionStage(None); setClientSelectionStage(None);
/* Hmm, this is already None when reaching this */ /* Hmm, this is already None when reaching this */
lastServerRequestor = None; lastServerRequestor = None;
...@@ -1571,9 +1586,9 @@ void nxagentSetSelectionCallback(CallbackListPtr *callbacks, void *data, ...@@ -1571,9 +1586,9 @@ void nxagentSetSelectionCallback(CallbackListPtr *callbacks, void *data,
pCurSel->selection == clientCLIPBOARD)) pCurSel->selection == clientCLIPBOARD))
{ {
#ifdef DEBUG #ifdef DEBUG
fprintf(stderr, "%s: calling nxagentSetSelectionOwner\n", __func__); fprintf(stderr, "%s: calling setSelectionOwner\n", __func__);
#endif #endif
nxagentSetSelectionOwner(pCurSel); setSelectionOwner(pCurSel);
} }
} }
else if (info->kind == SelectionWindowDestroy) else if (info->kind == SelectionWindowDestroy)
...@@ -1601,7 +1616,7 @@ void nxagentSetSelectionCallback(CallbackListPtr *callbacks, void *data, ...@@ -1601,7 +1616,7 @@ void nxagentSetSelectionCallback(CallbackListPtr *callbacks, void *data,
* This is called from the nxagentSetSelectionCallback, so it is using * This is called from the nxagentSetSelectionCallback, so it is using
* internal Atoms * internal Atoms
*/ */
static void nxagentSetSelectionOwner(Selection *pSelection) static void setSelectionOwner(Selection *pSelection)
{ {
if (!agentClipboardInitialized) if (!agentClipboardInitialized)
{ {
...@@ -1656,11 +1671,11 @@ static void nxagentSetSelectionOwner(Selection *pSelection) ...@@ -1656,11 +1671,11 @@ static 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(i, pSelection); storeSelectionOwner(i, pSelection);
} }
lastClientWindowPtr = NULL; lastClientWindowPtr = NULL;
SetClientSelectionStage(None); setClientSelectionStage(None);
lastServerRequestor = None; lastServerRequestor = None;
...@@ -1677,7 +1692,7 @@ FIXME ...@@ -1677,7 +1692,7 @@ FIXME
lastSelectionOwnerWindowPtr = pSelection->pWin; lastSelectionOwnerWindowPtr = pSelection->pWin;
lastClientWindowPtr = NULL; lastClientWindowPtr = NULL;
SetClientSelectionStage(None); setClientSelectionStage(None);
lastServerRequestor = None; lastServerRequestor = None;
} }
...@@ -1685,7 +1700,7 @@ FIXME ...@@ -1685,7 +1700,7 @@ FIXME
*/ */
} }
static void nxagentNotifyConvertFailure(ClientPtr client, Window requestor, static void notifyConvertFailure(ClientPtr client, Window requestor,
Atom selection, Atom target, Time time) Atom selection, Atom target, Time time)
{ {
/* /*
...@@ -1700,7 +1715,7 @@ static void nxagentNotifyConvertFailure(ClientPtr client, Window requestor, ...@@ -1700,7 +1715,7 @@ static void nxagentNotifyConvertFailure(ClientPtr client, Window requestor,
return; return;
} }
SendSelectionNotifyEventToClient(client, time, requestor, selection, target, None); sendSelectionNotifyEventToClient(client, time, requestor, selection, target, None);
} }
/* /*
...@@ -1759,11 +1774,11 @@ int nxagentConvertSelection(ClientPtr client, WindowPtr pWin, Atom selection, ...@@ -1759,11 +1774,11 @@ int nxagentConvertSelection(ClientPtr client, WindowPtr pWin, Atom selection,
"notifying failure to client\n", __func__); "notifying failure to client\n", __func__);
#endif #endif
nxagentNotifyConvertFailure(lastClientClientPtr, lastClientRequestor, notifyConvertFailure(lastClientClientPtr, lastClientRequestor,
lastClientSelection, lastClientTarget, lastClientTime); lastClientSelection, lastClientTarget, lastClientTime);
lastClientWindowPtr = NULL; lastClientWindowPtr = NULL;
SetClientSelectionStage(None); setClientSelectionStage(None);
} }
else else
{ {
...@@ -1777,7 +1792,7 @@ int nxagentConvertSelection(ClientPtr client, WindowPtr pWin, Atom selection, ...@@ -1777,7 +1792,7 @@ int nxagentConvertSelection(ClientPtr client, WindowPtr pWin, Atom selection,
"before timeout expired on last request, notifying failure to client\n", __func__); "before timeout expired on last request, notifying failure to client\n", __func__);
#endif #endif
nxagentNotifyConvertFailure(client, requestor, selection, target, time); notifyConvertFailure(client, requestor, selection, target, time);
return 1; return 1;
} }
...@@ -1828,7 +1843,7 @@ int nxagentConvertSelection(ClientPtr client, WindowPtr pWin, Atom selection, ...@@ -1828,7 +1843,7 @@ int nxagentConvertSelection(ClientPtr client, WindowPtr pWin, Atom selection,
&targets, &targets,
1); 1);
SendSelectionNotifyEventToClient(client, time, requestor, selection, target, property); sendSelectionNotifyEventToClient(client, time, requestor, selection, target, property);
return 1; return 1;
} }
...@@ -1864,7 +1879,7 @@ int nxagentConvertSelection(ClientPtr client, WindowPtr pWin, Atom selection, ...@@ -1864,7 +1879,7 @@ int nxagentConvertSelection(ClientPtr client, WindowPtr pWin, Atom selection,
(unsigned char *) &lastSelectionOwner[i].lastTimeChanged, (unsigned char *) &lastSelectionOwner[i].lastTimeChanged,
1); 1);
SendSelectionNotifyEventToClient(client, time, requestor, selection, target, property); sendSelectionNotifyEventToClient(client, time, requestor, selection, target, property);
return 1; return 1;
} }
...@@ -1902,7 +1917,7 @@ int nxagentConvertSelection(ClientPtr client, WindowPtr pWin, Atom selection, ...@@ -1902,7 +1917,7 @@ int nxagentConvertSelection(ClientPtr client, WindowPtr pWin, Atom selection,
target == clientUTF8_STRING) target == clientUTF8_STRING)
{ {
lastClientWindowPtr = pWin; lastClientWindowPtr = pWin;
SetClientSelectionStage(None); setClientSelectionStage(None);
/* /*
* store the original requestor, we need that later after * store the original requestor, we need that later after
* serverTransToAgentProperty contains the desired selection content * serverTransToAgentProperty contains the desired selection content
...@@ -1963,7 +1978,7 @@ int nxagentConvertSelection(ClientPtr client, WindowPtr pWin, Atom selection, ...@@ -1963,7 +1978,7 @@ int nxagentConvertSelection(ClientPtr client, WindowPtr pWin, Atom selection,
fprintf(stderr, "%s: Unsupported target [%d][%s] - denying request\n", __func__, target, fprintf(stderr, "%s: Unsupported target [%d][%s] - denying request\n", __func__, target,
validateString(NameForAtom(target))); validateString(NameForAtom(target)));
#endif #endif
SendSelectionNotifyEventToClient(client, time, requestor, selection, target, None); sendSelectionNotifyEventToClient(client, time, requestor, selection, target, None);
return 1; return 1;
} }
...@@ -2094,7 +2109,7 @@ int nxagentSendNotify(xEvent *event) ...@@ -2094,7 +2109,7 @@ int nxagentSendNotify(xEvent *event)
NameForAtom(event->u.selectionNotify.property)); NameForAtom(event->u.selectionNotify.property));
#endif #endif
SendSelectionNotifyEventToServer(&eventSelection); sendSelectionNotifyEventToServer(&eventSelection);
return 1; return 1;
} }
...@@ -2156,8 +2171,8 @@ Bool nxagentInitClipboard(WindowPtr pWin) ...@@ -2156,8 +2171,8 @@ Bool nxagentInitClipboard(WindowPtr pWin)
{ {
FatalError("nxagentInitClipboard: Failed to allocate memory for the clipboard selections.\n"); FatalError("nxagentInitClipboard: Failed to allocate memory for the clipboard selections.\n");
} }
nxagentInitSelectionOwner(nxagentPrimarySelection, XA_PRIMARY); initSelectionOwner(nxagentPrimarySelection, XA_PRIMARY);
nxagentInitSelectionOwner(nxagentClipboardSelection, nxagentAtoms[10]); /* CLIPBOARD */ initSelectionOwner(nxagentClipboardSelection, nxagentAtoms[10]); /* CLIPBOARD */
} }
else else
{ {
...@@ -2267,13 +2282,13 @@ Bool nxagentInitClipboard(WindowPtr pWin) ...@@ -2267,13 +2282,13 @@ Bool nxagentInitClipboard(WindowPtr pWin)
{ {
for (int i = 0; i < nxagentMaxSelections; i++) for (int i = 0; i < nxagentMaxSelections; i++)
{ {
nxagentClearSelectionOwner(i); clearSelectionOwner(i);
} }
lastServerRequestor = None; lastServerRequestor = None;
lastClientWindowPtr = NULL; lastClientWindowPtr = NULL;
SetClientSelectionStage(None); setClientSelectionStage(None);
lastClientReqTime = GetTimeInMillis(); lastClientReqTime = GetTimeInMillis();
clientTARGETS = MakeAtom(szAgentTARGETS, strlen(szAgentTARGETS), True); clientTARGETS = MakeAtom(szAgentTARGETS, strlen(szAgentTARGETS), True);
......
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