Unverified Commit fdd1e538 authored by Mike Gabriel's avatar Mike Gabriel

Merge branch 'uli42-pr/simplify_nxdispatch' into 3.6.x

parents 718a58fb 0fb6af25
...@@ -213,16 +213,18 @@ UpdateCurrentTimeIf() ...@@ -213,16 +213,18 @@ UpdateCurrentTimeIf()
currentTime = systime; currentTime = systime;
} }
#ifndef NXAGENT_SERVER
void void
InitSelections() #ifdef NXAGENT_SERVER
xorg_InitSelections(void)
#else
InitSelections(void)
#endif
{ {
if (CurrentSelections) if (CurrentSelections)
free(CurrentSelections); free(CurrentSelections);
CurrentSelections = (Selection *)NULL; CurrentSelections = (Selection *)NULL;
NumCurrentSelections = 0; NumCurrentSelections = 0;
} }
#endif /* NXAGENT_SERVER */
#undef SMART_DEBUG #undef SMART_DEBUG
...@@ -3478,11 +3480,14 @@ InitProcVectors(void) ...@@ -3478,11 +3480,14 @@ InitProcVectors(void)
* then killed again, the client is really destroyed. * then killed again, the client is really destroyed.
*********************/ *********************/
#ifndef NXAGENT_SERVER
char dispatchExceptionAtReset = DE_RESET; char dispatchExceptionAtReset = DE_RESET;
void void
CloseDownClient(register ClientPtr client) #ifdef NXAGENT_SERVER
xorg_CloseDownClient(ClientPtr client)
#else
CloseDownClient(ClientPtr client)
#endif
{ {
Bool really_close_down = client->clientGone || Bool really_close_down = client->clientGone ||
client->closeDownMode == DestroyAll; client->closeDownMode == DestroyAll;
...@@ -3567,7 +3572,6 @@ CloseDownClient(register ClientPtr client) ...@@ -3567,7 +3572,6 @@ CloseDownClient(register ClientPtr client)
currentMaxClients--; currentMaxClients--;
} }
} }
#endif /* NXAGENT_SERVER */
static void static void
KillAllClients() KillAllClients()
...@@ -3644,9 +3648,12 @@ void InitClient(ClientPtr client, int i, void * ospriv) ...@@ -3644,9 +3648,12 @@ void InitClient(ClientPtr client, int i, void * ospriv)
client->clientIds = NULL; client->clientIds = NULL;
} }
#ifndef NXAGENT_SERVER
int int
#ifdef NXAGENT_SERVER
xorg_InitClientPrivates(ClientPtr client)
#else
InitClientPrivates(ClientPtr client) InitClientPrivates(ClientPtr client)
#endif
{ {
register char *ptr; register char *ptr;
DevUnion *ppriv; DevUnion *ppriv;
...@@ -3690,7 +3697,6 @@ InitClientPrivates(ClientPtr client) ...@@ -3690,7 +3697,6 @@ InitClientPrivates(ClientPtr client)
} }
return 1; return 1;
} }
#endif /* NXAGENT_SERVER */
/************************ /************************
* int NextAvailableClient(ospriv) * int NextAvailableClient(ospriv)
......
...@@ -128,8 +128,6 @@ Equipment Corporation. ...@@ -128,8 +128,6 @@ Equipment Corporation.
const int nxagentMaxFontNames = 10000; const int nxagentMaxFontNames = 10000;
char dispatchExceptionAtReset = DE_RESET;
/* /*
* This allows the agent to exit if no * This allows the agent to exit if no
* client is connected within a timeout. * client is connected within a timeout.
...@@ -203,12 +201,9 @@ extern int nxagentMaxSelections; ...@@ -203,12 +201,9 @@ extern int nxagentMaxSelections;
extern int nxOpenFont(ClientPtr, XID, Mask, unsigned, char*); extern int nxOpenFont(ClientPtr, XID, Mask, unsigned, char*);
void void
InitSelections() InitSelections(void)
{ {
if (CurrentSelections) xorg_InitSelections();
free(CurrentSelections);
CurrentSelections = (Selection *)NULL;
NumCurrentSelections = 0;
#ifdef NXAGENT_CLIPBOARD #ifdef NXAGENT_CLIPBOARD
{ {
...@@ -232,7 +227,6 @@ InitSelections() ...@@ -232,7 +227,6 @@ InitSelections()
CurrentSelections[nxagentClipboardSelection].client = NullClient; CurrentSelections[nxagentClipboardSelection].client = NullClient;
} }
#endif #endif
} }
#define MAJOROP ((xReq *)client->requestBuffer)->reqType #define MAJOROP ((xReq *)client->requestBuffer)->reqType
...@@ -635,12 +629,17 @@ ProcQueryTree(register ClientPtr client) ...@@ -635,12 +629,17 @@ ProcQueryTree(register ClientPtr client)
reply.parent = (Window)None; reply.parent = (Window)None;
pHead = RealChildHead(pWin); pHead = RealChildHead(pWin);
for (pChild = pWin->lastChild; pChild != pHead; pChild = pChild->prevSib) for (pChild = pWin->lastChild; pChild != pHead; pChild = pChild->prevSib)
#ifdef NXAGENT_SERVER
{ {
if (!IsViewportFrame(pChild)) if (!IsViewportFrame(pChild))
{ {
numChildren++; numChildren++;
} }
} }
#else
numChildren++;
#endif
if (numChildren) if (numChildren)
{ {
int curChild = 0; int curChild = 0;
...@@ -649,12 +648,16 @@ ProcQueryTree(register ClientPtr client) ...@@ -649,12 +648,16 @@ ProcQueryTree(register ClientPtr client)
if (!childIDs) if (!childIDs)
return BadAlloc; return BadAlloc;
for (pChild = pWin->lastChild; pChild != pHead; pChild = pChild->prevSib) for (pChild = pWin->lastChild; pChild != pHead; pChild = pChild->prevSib)
{ #ifdef NXAGENT_SERVER
if (!IsViewportFrame(pChild)) {
{ if (!IsViewportFrame(pChild))
childIDs[curChild++] = pChild->drawable.id; {
} childIDs[curChild++] = pChild->drawable.id;
}
} }
#else
childIDs[curChild++] = pChild->drawable.id;
#endif
} }
reply.nChildren = numChildren; reply.nChildren = numChildren;
...@@ -713,8 +716,12 @@ ProcConvertSelection(register ClientPtr client) ...@@ -713,8 +716,12 @@ ProcConvertSelection(register ClientPtr client)
i = 0; i = 0;
while ((i < NumCurrentSelections) && while ((i < NumCurrentSelections) &&
CurrentSelections[i].selection != stuff->selection) i++; CurrentSelections[i].selection != stuff->selection) i++;
if ((i < NumCurrentSelections) && if ((i < NumCurrentSelections) &&
#ifdef NXAGENT_SERVER
(CurrentSelections[i].window != None) && (CurrentSelections[i].client != NullClient) (CurrentSelections[i].window != None) && (CurrentSelections[i].client != NullClient)
#else
(CurrentSelections[i].window != None))
#endif
#ifdef XCSECURITY #ifdef XCSECURITY
&& (!client->CheckAccess || && (!client->CheckAccess ||
(* client->CheckAccess)(client, CurrentSelections[i].window, (* client->CheckAccess)(client, CurrentSelections[i].window,
...@@ -722,7 +729,6 @@ ProcConvertSelection(register ClientPtr client) ...@@ -722,7 +729,6 @@ ProcConvertSelection(register ClientPtr client)
CurrentSelections[i].pWin)) CurrentSelections[i].pWin))
#endif #endif
) )
{ {
memset(&event, 0, sizeof(xEvent)); memset(&event, 0, sizeof(xEvent));
event.u.u.type = SelectionRequest; event.u.u.type = SelectionRequest;
...@@ -761,13 +767,14 @@ int ...@@ -761,13 +767,14 @@ int
ProcOpenFont(register ClientPtr client) ProcOpenFont(register ClientPtr client)
{ {
int err; int err;
char fontReq[256];
REQUEST(xOpenFontReq); REQUEST(xOpenFontReq);
REQUEST_FIXED_SIZE(xOpenFontReq, stuff->nbytes); REQUEST_FIXED_SIZE(xOpenFontReq, stuff->nbytes);
client->errorValue = stuff->fid; client->errorValue = stuff->fid;
LEGAL_NEW_RESOURCE(stuff->fid, client); LEGAL_NEW_RESOURCE(stuff->fid, client);
#ifdef NXAGENT_SERVER
char fontReq[256];
memcpy(fontReq,(char *)&stuff[1],(stuff->nbytes<256)?stuff->nbytes:255); memcpy(fontReq,(char *)&stuff[1],(stuff->nbytes<256)?stuff->nbytes:255);
fontReq[stuff->nbytes]=0; fontReq[stuff->nbytes]=0;
if (strchr(fontReq,'*') || strchr(fontReq,'?')) if (strchr(fontReq,'*') || strchr(fontReq,'?'))
...@@ -780,6 +787,7 @@ ProcOpenFont(register ClientPtr client) ...@@ -780,6 +787,7 @@ ProcOpenFont(register ClientPtr client)
stuff->nbytes, (char *)&stuff[1]); stuff->nbytes, (char *)&stuff[1]);
} }
else else
#endif
err = OpenFont(client, stuff->fid, (Mask) 0, err = OpenFont(client, stuff->fid, (Mask) 0,
stuff->nbytes, (char *)&stuff[1]); stuff->nbytes, (char *)&stuff[1]);
if (err == Success) if (err == Success)
...@@ -850,11 +858,12 @@ ProcCloseFont(register ClientPtr client) ...@@ -850,11 +858,12 @@ ProcCloseFont(register ClientPtr client)
int int
ProcListFonts(register ClientPtr client) ProcListFonts(register ClientPtr client)
{ {
char tmp[256];
REQUEST(xListFontsReq); REQUEST(xListFontsReq);
REQUEST_FIXED_SIZE(xListFontsReq, stuff->nbytes); REQUEST_FIXED_SIZE(xListFontsReq, stuff->nbytes);
#ifdef NXAGENT_SERVER
char tmp[256];
memcpy(tmp,(unsigned char *) &stuff[1],(stuff->nbytes<256)?stuff->nbytes:255); memcpy(tmp,(unsigned char *) &stuff[1],(stuff->nbytes<256)?stuff->nbytes:255);
tmp[stuff->nbytes]=0; tmp[stuff->nbytes]=0;
...@@ -862,6 +871,8 @@ ProcListFonts(register ClientPtr client) ...@@ -862,6 +871,8 @@ ProcListFonts(register ClientPtr client)
fprintf(stderr, "Dispatch: ListFont request with pattern %s max_names=%d\n",tmp,stuff->maxNames); fprintf(stderr, "Dispatch: ListFont request with pattern %s max_names=%d\n",tmp,stuff->maxNames);
#endif #endif
nxagentListRemoteFonts(tmp, stuff -> maxNames < nxagentMaxFontNames ? nxagentMaxFontNames : stuff->maxNames); nxagentListRemoteFonts(tmp, stuff -> maxNames < nxagentMaxFontNames ? nxagentMaxFontNames : stuff->maxNames);
#endif
return ListFonts(client, (unsigned char *) &stuff[1], stuff->nbytes, return ListFonts(client, (unsigned char *) &stuff[1], stuff->nbytes,
stuff->maxNames); stuff->maxNames);
} }
...@@ -869,23 +880,24 @@ ProcListFonts(register ClientPtr client) ...@@ -869,23 +880,24 @@ ProcListFonts(register ClientPtr client)
int int
ProcListFontsWithInfo(register ClientPtr client) ProcListFontsWithInfo(register ClientPtr client)
{ {
char tmp[256];
REQUEST(xListFontsWithInfoReq); REQUEST(xListFontsWithInfoReq);
REQUEST_FIXED_SIZE(xListFontsWithInfoReq, stuff->nbytes); REQUEST_FIXED_SIZE(xListFontsWithInfoReq, stuff->nbytes);
#ifdef NXAGENT_SERVER
char tmp[256];
memcpy(tmp,(unsigned char *) &stuff[1],(stuff->nbytes<256)?stuff->nbytes:255); memcpy(tmp,(unsigned char *) &stuff[1],(stuff->nbytes<256)?stuff->nbytes:255);
tmp[stuff->nbytes]=0; tmp[stuff->nbytes]=0;
#ifdef NXAGENT_FONTMATCH_DEBUG #ifdef NXAGENT_FONTMATCH_DEBUG
fprintf(stderr, "Dispatch: ListFont with info request with pattern %s max_names=%d\n",tmp,stuff->maxNames); fprintf(stderr, "Dispatch: ListFont with info request with pattern %s max_names=%d\n",tmp,stuff->maxNames);
#endif #endif
nxagentListRemoteFonts(tmp, stuff -> maxNames < nxagentMaxFontNames ? nxagentMaxFontNames :stuff->maxNames); nxagentListRemoteFonts(tmp, stuff -> maxNames < nxagentMaxFontNames ? nxagentMaxFontNames :stuff->maxNames);
#endif
return StartListFontsWithInfo(client, stuff->nbytes, return StartListFontsWithInfo(client, stuff->nbytes,
(unsigned char *) &stuff[1], stuff->maxNames); (unsigned char *) &stuff[1], stuff->maxNames);
} }
int int
ProcFreePixmap(register ClientPtr client) ProcFreePixmap(register ClientPtr client)
{ {
...@@ -977,6 +989,7 @@ ProcSetScreenSaver (register ClientPtr client) ...@@ -977,6 +989,7 @@ ProcSetScreenSaver (register ClientPtr client)
return BadValue; return BadValue;
} }
#ifdef NXAGENT_SERVER
/* /*
* The NX agent uses the screen saver procedure * The NX agent uses the screen saver procedure
* to monitor the user activities and launch its * to monitor the user activities and launch its
...@@ -991,6 +1004,7 @@ ProcSetScreenSaver (register ClientPtr client) ...@@ -991,6 +1004,7 @@ ProcSetScreenSaver (register ClientPtr client)
if (nxagentOption(Timeout) == 0) if (nxagentOption(Timeout) == 0)
{ {
#endif
if (blankingOption == DefaultBlanking) if (blankingOption == DefaultBlanking)
{ {
ScreenSaverBlanking = defaultScreenSaverBlanking; ScreenSaverBlanking = defaultScreenSaverBlanking;
...@@ -1028,7 +1042,9 @@ ProcSetScreenSaver (register ClientPtr client) ...@@ -1028,7 +1042,9 @@ ProcSetScreenSaver (register ClientPtr client)
} }
SetScreenSaverTimer(); SetScreenSaverTimer();
#ifdef NXAGENT_SERVER
} }
#ifdef TEST #ifdef TEST
else else
...@@ -1038,7 +1054,7 @@ ProcSetScreenSaver (register ClientPtr client) ...@@ -1038,7 +1054,7 @@ ProcSetScreenSaver (register ClientPtr client)
} }
#endif #endif
#endif
return (client->noClientException); return (client->noClientException);
} }
...@@ -1056,6 +1072,7 @@ int ProcForceScreenSaver(register ClientPtr client) ...@@ -1056,6 +1072,7 @@ int ProcForceScreenSaver(register ClientPtr client)
return BadValue; return BadValue;
} }
#ifdef NXAGENT_SERVER
/* /*
* The NX agent uses the screen saver procedure * The NX agent uses the screen saver procedure
* to monitor the user activities and launch its * to monitor the user activities and launch its
...@@ -1066,7 +1083,9 @@ int ProcForceScreenSaver(register ClientPtr client) ...@@ -1066,7 +1083,9 @@ int ProcForceScreenSaver(register ClientPtr client)
if (nxagentOption(Timeout) == 0) if (nxagentOption(Timeout) == 0)
{ {
#endif
SaveScreens(SCREEN_SAVER_FORCER, (int)stuff->mode); SaveScreens(SCREEN_SAVER_FORCER, (int)stuff->mode);
#ifdef NXAGENT_SERVER
} }
#ifdef TEST #ifdef TEST
...@@ -1078,6 +1097,7 @@ int ProcForceScreenSaver(register ClientPtr client) ...@@ -1078,6 +1097,7 @@ int ProcForceScreenSaver(register ClientPtr client)
} }
#endif #endif
#endif
return client->noClientException; return client->noClientException;
} }
...@@ -1093,9 +1113,7 @@ int ProcForceScreenSaver(register ClientPtr client) ...@@ -1093,9 +1113,7 @@ int ProcForceScreenSaver(register ClientPtr client)
void void
CloseDownClient(register ClientPtr client) CloseDownClient(register ClientPtr client)
{ {
Bool really_close_down = client->clientGone || #ifdef NXAGENT_SERVER
client->closeDownMode == DestroyAll;
/* /*
* There must be a better way to hook a * There must be a better way to hook a
* call-back function to be called any * call-back function to be called any
...@@ -1117,126 +1135,27 @@ CloseDownClient(register ClientPtr client) ...@@ -1117,126 +1135,27 @@ CloseDownClient(register ClientPtr client)
*/ */
nxagentCheckIfShadowAgent(client); nxagentCheckIfShadowAgent(client);
#endif
if (!client->clientGone) xorg_CloseDownClient(client);
{
/* ungrab server if grabbing client dies */
if (grabState != GrabNone && grabClient == client)
{
UngrabServer(client);
}
BITCLEAR(grabWaiters, client->index);
DeleteClientFromAnySelections(client);
ReleaseActiveGrabs(client);
DeleteClientFontStuff(client);
if (!really_close_down)
{
/* This frees resources that should never be retained
* no matter what the close down mode is. Actually we
* could do this unconditionally, but it's probably
* better not to traverse all the client's resources
* twice (once here, once a few lines down in
* FreeClientResources) in the common case of
* really_close_down == TRUE.
*/
FreeClientNeverRetainResources(client);
client->clientState = ClientStateRetained;
if (ClientStateCallback)
{
NewClientInfoRec clientinfo;
clientinfo.client = client;
clientinfo.prefix = (xConnSetupPrefix *)NULL;
clientinfo.setup = (xConnSetup *) NULL;
CallCallbacks((&ClientStateCallback), (void *)&clientinfo);
}
}
client->clientGone = TRUE; /* so events aren't sent to client */
if (ClientIsAsleep(client))
ClientSignal (client);
ProcessWorkQueueZombies();
CloseDownConnection(client);
/* If the client made it to the Running stage, nClients has
* been incremented on its behalf, so we need to decrement it
* now. If it hasn't gotten to Running, nClients has *not*
* been incremented, so *don't* decrement it.
*/
if (client->clientState != ClientStateInitial &&
client->clientState != ClientStateAuthenticating )
{
--nClients;
}
}
if (really_close_down)
{
if (client->clientState == ClientStateRunning && nClients == 0)
dispatchException |= dispatchExceptionAtReset;
client->clientState = ClientStateGone;
if (ClientStateCallback)
{
NewClientInfoRec clientinfo;
clientinfo.client = client;
clientinfo.prefix = (xConnSetupPrefix *)NULL;
clientinfo.setup = (xConnSetup *) NULL;
CallCallbacks((&ClientStateCallback), (void *)&clientinfo);
}
FreeClientResources(client);
/* Disable client ID tracking. This must be done after
* ClientStateCallback. */
ReleaseClientIds(client);
if (client->index < nextFreeClientID)
nextFreeClientID = client->index;
clients[client->index] = NullClient;
SmartLastClient = NullClient;
free(client);
while (!clients[currentMaxClients-1])
currentMaxClients--;
}
} }
int int
InitClientPrivates(ClientPtr client) InitClientPrivates(ClientPtr client)
{ {
register char *ptr; int ret = xorg_InitClientPrivates(client);
DevUnion *ppriv;
register unsigned *sizes; #ifdef NXAGENT_SERVER
register unsigned size; if (ret == 1)
register int i;
if (totalClientSize == sizeof(ClientRec))
ppriv = (DevUnion *)NULL;
else if (client->index)
ppriv = (DevUnion *)(client + 1);
else
{
ppriv = (DevUnion *)malloc(totalClientSize - sizeof(ClientRec));
if (!ppriv)
return 0;
}
client->devPrivates = ppriv;
sizes = clientPrivateSizes;
ptr = (char *)(ppriv + clientPrivateLen);
for (i = clientPrivateLen; --i >= 0; ppriv++, sizes++)
{ {
if ( (size = *sizes) )
{
ppriv->ptr = (void *)ptr;
ptr += size;
}
else
ppriv->ptr = (void *)NULL;
}
/* /*
* Initialize the private members. * Initialize the private members.
*/ */
nxagentInitClientPrivates(client); nxagentInitClientPrivates(client);
}
#endif
return 1; return ret;
} }
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