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

NXdixfonts.c: mark NX changes

Also add original code to make NX changes obvious. Also change some lines to match original code.
parent 4ad501b3
......@@ -157,8 +157,10 @@ doOpenFont(ClientPtr client, OFclosurePtr c)
*newname;
int newlen;
int aliascount = 20;
#ifdef NXAGENT_SERVER
char nxagentOrigFontName[256];
int nxagentOrigFontNameLen;
#endif
/*
* Decide at runtime what FontFormat to use.
......@@ -191,13 +193,13 @@ doOpenFont(ClientPtr client, OFclosurePtr c)
BitmapFormatScanlineUnit8;
#ifdef NXAGENT_SERVER
nxagentOrigFontNameLen = (c -> origFontNameLen < sizeof(nxagentOrigFontName) ? c -> origFontNameLen : sizeof(nxagentOrigFontName) - 1);
memcpy(nxagentOrigFontName, c -> origFontName, nxagentOrigFontNameLen);
nxagentOrigFontName[nxagentOrigFontNameLen] = 0;
#endif
if (client->clientGone)
{
if (c->current_fpe < c->num_fpes)
......@@ -254,6 +256,7 @@ doOpenFont(ClientPtr client, OFclosurePtr c)
if (!c->slept) {
c->slept = TRUE;
ClientSleep(client, (ClientSleepProcPtr)doOpenFont, (void *) c);
#ifdef NXAGENT_SERVER
#ifdef DEBUG
fprintf(stderr, " NXdixfonts: doOpenFont: client [%lx] sleeping.\n", client);
#endif
......@@ -286,15 +289,22 @@ doOpenFont(ClientPtr client, OFclosurePtr c)
pScr = screenInfo.screens[i];
if (pScr->RealizeFont)
{
#ifdef NXAGENT_SERVER
/* NXAGENT uses useless screen pointer to pass the original font name
* to realizeFont, could be a source of problems in the future.
*/
if (!(*pScr->RealizeFont) ((ScreenPtr)nxagentOrigFontName, pfont))
#else
if (!(*pScr->RealizeFont) (pScr, pfont))
#endif
{
CloseFont (pfont, (Font) 0);
err=BadFontName;
#ifdef NXAGENT_SERVER
err = BadFontName;
#else
err = AllocError;
#endif
goto bail;
}
}
......@@ -304,6 +314,7 @@ doOpenFont(ClientPtr client, OFclosurePtr c)
err = AllocError;
goto bail;
}
#ifdef NXAGENT_SERVER
if( nxagentFontPriv(pfont) -> mirrorID == 0 )
{
extern RESTYPE RT_NX_FONT;
......@@ -315,12 +326,21 @@ doOpenFont(ClientPtr client, OFclosurePtr c)
goto bail;
}
}
#endif
if (patternCache && pfont != c->non_cachable_font)
#ifdef HAS_XFONT2
#ifdef NXAGENT_SERVER
#ifdef HAS_XFONT2
xfont2_cache_font_pattern(patternCache, nxagentOrigFontName, nxagentOrigFontNameLen,
#else
#else
CacheFontPattern(patternCache, nxagentOrigFontName, nxagentOrigFontNameLen,
#endif /* HAS_XFONT2 */
#endif /* HAS_XFONT2 */
#else
#ifdef HAS_XFONT2
xfont2_cache_font_pattern(patternCache, c->origFontName, c->origFontNameLen,
#else
CacheFontPattern(patternCache, c->origFontName, c->origFontNameLen,
#endif /* HAS_XFONT2 */
#endif
pfont);
bail:
if (err != Successful && c->client != serverClient) {
......@@ -328,12 +348,16 @@ bail:
c->fontid, FontToXError(err));
}
if (c->slept)
#ifdef NXAGENT_SERVER
{
ClientWakeup(c->client);
#ifdef DEBUG
fprintf(stderr, " NXdixfonts: doOpenFont: client [%lx] wakeup.\n", client);
#endif
}
#else
ClientWakeup(c->client);
#endif
for (i = 0; i < c->num_fpes; i++) {
FreeFPE(c->fpe_list[i]);
}
......@@ -355,7 +379,7 @@ doListFontsAndAliases(ClientPtr client, LFclosurePtr c)
int nnames;
int stringLens;
int i;
xListFontsReply reply = {0};
xListFontsReply reply;
char *bufptr;
char *bufferStart;
int aliascount = 0;
......@@ -405,9 +429,11 @@ doListFontsAndAliases(ClientPtr client, LFclosurePtr c)
ClientSleep(client,
(ClientSleepProcPtr)doListFontsAndAliases,
(void *) c);
#ifdef NXAGENT_SERVER
#ifdef DEBUG
fprintf(stderr, " NXdixfonts: doListFont (1): client [%lx] sleeping.\n", client);
#endif
#endif
}
return TRUE;
}
......@@ -462,10 +488,12 @@ doListFontsAndAliases(ClientPtr client, LFclosurePtr c)
(ClientSleepProcPtr)doListFontsAndAliases,
(void *) c);
c->slept = TRUE;
#ifdef NXAGENT_SERVER
#ifdef DEBUG
fprintf(stderr, " NXdixfonts: doListFont (2): client [%lx] sleeping.\n", client);
fprintf(stderr, " NXdixfonts: doListFont (3): client [%lx] sleeping.\n", client);
#endif
#endif
}
return TRUE;
}
......@@ -593,13 +621,17 @@ finish:
for (i = 0; i < nnames; i++)
stringLens += (names->length[i] <= 255) ? names->length[i] : 0;
memset(&reply, 0, sizeof(xListFontsReply));
reply.type = X_Reply;
reply.length = (stringLens + nnames + 3) >> 2;
reply.nFonts = nnames;
reply.sequenceNumber = client->sequence;
#ifdef NXAGENT_SERVER
bufptr = bufferStart = (char *) calloc(1, reply.length << 2);
#else
bufptr = bufferStart = (char *) malloc(reply.length << 2);
#endif
if (!bufptr && reply.length) {
SendErrorToClient(client, X_ListFonts, 0, 0, BadAlloc);
goto bail;
......@@ -613,6 +645,7 @@ finish:
reply.nFonts--;
else
{
#ifdef NXAGENT_SERVER
{
/* dirty hack: don't list to client fonts not existing on the remote side */
char tmp[256];
......@@ -631,6 +664,7 @@ finish:
continue;
}
}
#endif
*bufptr++ = names->length[i];
memmove( bufptr, names->names[i], names->length[i]);
bufptr += names->length[i];
......@@ -645,12 +679,16 @@ finish:
bail:
if (c->slept)
#ifdef NXAGENT_SERVER
{
ClientWakeup(client);
#ifdef DEBUG
fprintf(stderr, " NXdixfonts: doListFont: client [%lx] wakeup.\n", client);
#endif
}
#else
ClientWakeup(client);
#endif
for (i = 0; i < c->num_fpes; i++)
FreeFPE(c->fpe_list[i]);
free(c->fpe_list);
......@@ -689,11 +727,19 @@ ListFonts(ClientPtr client, unsigned char *pattern, unsigned length,
free(c);
return BadAlloc;
}
#ifdef HAS_XFONT2
#ifdef NXAGENT_SERVER
#ifdef HAS_XFONT2
c->names = xfont2_make_font_names_record(max_names < nxagentMaxFontNames ? max_names : nxagentMaxFontNames);
#else
#else
c->names = MakeFontNamesRecord(max_names < nxagentMaxFontNames ? max_names : nxagentMaxFontNames);
#endif /* HAS_XFONT2 */
#endif /* HAS_XFONT2 */
#else
#ifdef HAS_XFONT2
c->names = xfont2_make_font_names_record(max_names < 100 ? max_names : 100);
#else
c->names = MakeFontNamesRecord(max_names < 100 ? max_names : 100);
#endif /* HAS_XFONT2 */
#endif
if (!c->names)
{
free(c->fpe_list);
......@@ -734,7 +780,7 @@ doListFontsWithInfo(ClientPtr client, LFWIclosurePtr c)
xFontProp *pFP;
int i;
int aliascount = 0;
xListFontsWithInfoReply finalReply = {0};
xListFontsWithInfoReply finalReply;
if (client->clientGone)
{
......@@ -772,9 +818,11 @@ doListFontsWithInfo(ClientPtr client, LFWIclosurePtr c)
{
ClientSleep(client, (ClientSleepProcPtr)doListFontsWithInfo, c);
c->slept = TRUE;
#ifdef NXAGENT_SERVER
#ifdef DEBUG
fprintf(stderr, " NXdixfonts: doListFontWinfo (1): client [%lx] sleeping.\n", client);
#endif
#endif
}
return TRUE;
}
......@@ -800,9 +848,11 @@ doListFontsWithInfo(ClientPtr client, LFWIclosurePtr c)
(ClientSleepProcPtr)doListFontsWithInfo,
c);
c->slept = TRUE;
#ifdef NXAGENT_SERVER
#ifdef DEBUG
fprintf(stderr, " NXdixfonts: doListFontWinfo (2): client [%lx] sleeping.\n", client);
#endif
#endif
}
return TRUE;
}
......@@ -887,7 +937,7 @@ doListFontsWithInfo(ClientPtr client, LFWIclosurePtr c)
}
else if (err == Successful)
{
#ifdef NXAGENT_SERVER
if (c->haveSaved)
{
numFonts = c->savedNumFonts;
......@@ -903,7 +953,7 @@ doListFontsWithInfo(ClientPtr client, LFWIclosurePtr c)
#endif
continue;
}
#endif
length = sizeof(*reply) + pFontInfo->nprops * sizeof(xFontProp);
reply = c->reply;
if (c->length < length)
......@@ -918,6 +968,14 @@ doListFontsWithInfo(ClientPtr client, LFWIclosurePtr c)
c->reply = reply;
c->length = length;
}
#ifndef NXAGENT_SERVER
if (c->haveSaved)
{
numFonts = c->savedNumFonts;
name = c->savedName;
namelen = strlen(name);
}
#endif
reply->type = X_Reply;
reply->length = (sizeof *reply - sizeof(xGenericReply) +
pFontInfo->nprops * sizeof(xFontProp) +
......@@ -956,6 +1014,7 @@ doListFontsWithInfo(ClientPtr client, LFWIclosurePtr c)
}
finish:
length = sizeof(xListFontsWithInfoReply);
bzero((char *) &finalReply, sizeof(xListFontsWithInfoReply));
finalReply.type = X_Reply;
finalReply.sequenceNumber = client->sequence;
finalReply.length = (sizeof(xListFontsWithInfoReply)
......@@ -963,12 +1022,16 @@ finish:
WriteSwappedDataToClient(client, length, &finalReply);
bail:
if (c->slept)
#ifdef NXAGENT_SERVER
{
ClientWakeup(client);
#ifdef DEBUG
fprintf(stderr, " NXdixfonts: doListFontWinfo: client [%lx] wakeup.\n", client);
#endif
}
#else
ClientWakeup(client);
#endif
for (i = 0; i < c->num_fpes; i++)
FreeFPE(c->fpe_list[i]);
free(c->reply);
......@@ -991,17 +1054,12 @@ typedef struct
OFclosurePtr oc;
} nxFs,*nxFsPtr;
/* this is derived from doListFontsAndAliases */
static Bool
#if NeedFunctionPrototypes
nxdoListFontsAndAliases(ClientPtr client, nxFsPtr fss)
#else
nxdoListFontsAndAliases(client, fss)
ClientPtr client;
nxFsPtr fss;
#endif
{
LFclosurePtr c=fss->c;
OFclosurePtr oc=fss->oc;
LFclosurePtr c = fss->c;
OFclosurePtr oc = fss->oc;
FontPathElementPtr fpe;
int err = Successful;
char *name, *resolved=NULL;
......@@ -1009,7 +1067,7 @@ nxdoListFontsAndAliases(client, fss)
int i;
int aliascount = 0;
char tmp[256];
tmp[0]=0;
tmp[0] = 0;
if (client->clientGone)
{
if (c->current.current_fpe < c->num_fpes)
......@@ -1303,13 +1361,10 @@ finish:
return doOpenFont(client, oc);
}
/* this is derived from OpenFont() */
int
nxOpenFont(client, fid, flags, lenfname, pfontname)
ClientPtr client;
XID fid;
Mask flags;
unsigned lenfname;
char *pfontname;
nxOpenFont(ClientPtr client, XID fid, Mask flags, unsigned lenfname, char *pfontname)
{
nxFsPtr fss;
LFclosurePtr c;
......
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