aboutsummaryrefslogtreecommitdiff
path: root/xorg-server/dix/dixfonts.c
diff options
context:
space:
mode:
Diffstat (limited to 'xorg-server/dix/dixfonts.c')
-rw-r--r--xorg-server/dix/dixfonts.c109
1 files changed, 74 insertions, 35 deletions
diff --git a/xorg-server/dix/dixfonts.c b/xorg-server/dix/dixfonts.c
index dd9331195..aefd612fc 100644
--- a/xorg-server/dix/dixfonts.c
+++ b/xorg-server/dix/dixfonts.c
@@ -133,6 +133,7 @@ SetDefaultFont(char *defaultfontname)
int err;
FontPtr pf;
XID fid;
+ static FontPtr last_pf;
fid = FakeClientID(0);
err = OpenFont(serverClient, fid, FontLoadAll | FontOpenSync,
@@ -141,9 +142,10 @@ SetDefaultFont(char *defaultfontname)
return FALSE;
err = dixLookupResourceByType((pointer *) &pf, fid, RT_FONT, serverClient,
DixReadAccess);
- if (err != Success)
+ if (err == Success) last_pf = pf;
+ if (last_pf == (FontPtr) NULL)
return FALSE;
- defaultFont = pf;
+ defaultFont = last_pf;
return TRUE;
}
@@ -240,7 +242,8 @@ doOpenFont(ClientPtr client, OFclosurePtr c)
char *alias, *newname;
int newlen;
int aliascount = 20;
-
+ Bool fromDispatch = c->from_dispatch;
+ Bool finished = FALSE;
/*
* Decide at runtime what FontFormat to use.
*/
@@ -264,6 +267,8 @@ doOpenFont(ClientPtr client, OFclosurePtr c)
#endif
BitmapFormatScanlineUnit8;
+ c->from_dispatch = FALSE;
+
if (client->clientGone) {
if (c->current_fpe < c->num_fpes) {
fpe = c->fpe_list[c->current_fpe];
@@ -363,13 +368,16 @@ doOpenFont(ClientPtr client, OFclosurePtr c)
c->fontid, FontToXError(err));
}
ClientWakeup(c->client);
+ finished = TRUE;
xinerama_sleep:
- for (i = 0; i < c->num_fpes; i++) {
- FreeFPE(c->fpe_list[i]);
+ if (finished || fromDispatch) {
+ for (i = 0; i < c->num_fpes; i++) {
+ FreeFPE(c->fpe_list[i]);
+ }
+ free(c->fpe_list);
+ free(c->fontname);
+ free(c);
}
- free(c->fpe_list);
- free(c->fontname);
- free(c);
return TRUE;
}
@@ -441,6 +449,7 @@ OpenFont(ClientPtr client, XID fid, Mask flags, unsigned lenfname,
c->num_fpes = num_fpes;
c->fnamelen = lenfname;
c->flags = flags;
+ c->from_dispatch = TRUE;
c->non_cachable_font = cached;
(void) doOpenFont(client, c);
@@ -567,6 +576,10 @@ doListFontsAndAliases(ClientPtr client, LFclosurePtr c)
char *bufptr;
char *bufferStart;
int aliascount = 0;
+ Bool fromDispatch = c->from_dispatch;
+ Bool finished = FALSE;
+
+ c->from_dispatch = FALSE;
if (client->clientGone) {
if (c->current.current_fpe < c->num_fpes) {
@@ -787,13 +800,16 @@ doListFontsAndAliases(ClientPtr client, LFclosurePtr c)
bail:
ClientWakeup(client);
+ finished = TRUE;
xinerama_sleep:
- for (i = 0; i < c->num_fpes; i++)
- FreeFPE(c->fpe_list[i]);
- free(c->fpe_list);
- free(c->savedName);
- FreeFontNames(names);
- free(c);
+ if (finished || fromDispatch) {
+ for (i = 0; i < c->num_fpes; i++)
+ FreeFPE(c->fpe_list[i]);
+ free(c->fpe_list);
+ free(c->savedName);
+ FreeFontNames(names);
+ free(c);
+ }
free(resolved);
return TRUE;
}
@@ -844,6 +860,7 @@ ListFonts(ClientPtr client, unsigned char *pattern, unsigned length,
c->current.list_started = FALSE;
c->current.private = 0;
c->haveSaved = FALSE;
+ c->from_dispatch = TRUE;
c->savedName = 0;
doListFontsAndAliases(client, c);
return Success;
@@ -855,6 +872,8 @@ doListFontsWithInfo(ClientPtr client, LFWIclosurePtr c)
FontPathElementPtr fpe;
int err = Successful;
char *name;
+ Bool fromDispatch = c->from_dispatch;
+ Bool finished = FALSE;
int namelen;
int numFonts;
FontInfoRec fontInfo, *pFontInfo;
@@ -865,6 +884,8 @@ doListFontsWithInfo(ClientPtr client, LFWIclosurePtr c)
int aliascount = 0;
xListFontsWithInfoReply finalReply;
+ c->from_dispatch = FALSE;
+
if (client->clientGone) {
if (c->current.current_fpe < c->num_fpes) {
fpe = c->fpe_list[c->current.current_fpe];
@@ -1038,13 +1059,16 @@ doListFontsWithInfo(ClientPtr client, LFWIclosurePtr c)
WriteSwappedDataToClient(client, length, &finalReply);
bail:
ClientWakeup(client);
+ finished = TRUE;
xinerama_sleep:
- for (i = 0; i < c->num_fpes; i++)
- FreeFPE(c->fpe_list[i]);
- free(c->reply);
- free(c->fpe_list);
- free(c->savedName);
- free(c);
+ if (finished || fromDispatch) {
+ for (i = 0; i < c->num_fpes; i++)
+ FreeFPE(c->fpe_list[i]);
+ free(c->reply);
+ free(c->fpe_list);
+ free(c->savedName);
+ free(c);
+ }
return TRUE;
}
@@ -1091,6 +1115,7 @@ StartListFontsWithInfo(ClientPtr client, int length, unsigned char *pattern,
c->current.private = 0;
c->savedNumFonts = 0;
c->haveSaved = FALSE;
+ c->from_dispatch = TRUE;
c->savedName = 0;
doListFontsWithInfo(client, c);
return Success;
@@ -1100,7 +1125,7 @@ StartListFontsWithInfo(ClientPtr client, int length, unsigned char *pattern,
#define TextEltHeader 2
#define FontShiftSize 5
-static ChangeGCVal clearGC[] = { {.ptr = NullPixmap} };
+static ChangeGCVal clearGC[] = { NullPixmap };
#define clearGCmask (GCClipMask)
@@ -1113,6 +1138,10 @@ doPolyText(ClientPtr client, PTclosurePtr c)
FontPathElementPtr fpe;
GC *origGC = NULL;
int itemSize = c->reqType == X_PolyText8 ? 1 : 2;
+ Bool fromDispatch = c->from_dispatch;
+ Bool finished = FALSE;
+
+ c->from_dispatch = FALSE;
if (client->clientGone) {
fpe = c->pGC->font->fpe;
@@ -1350,16 +1379,19 @@ doPolyText(ClientPtr client, PTclosurePtr c)
}
if (ClientIsAsleep(client)) {
ClientWakeup(c->client);
+ finished = TRUE;
xinerama_sleep:
- ChangeGC(NullClient, c->pGC, clearGCmask, clearGC);
+ if (finished || fromDispatch) {
+ ChangeGC(NullClient, c->pGC, clearGCmask, clearGC);
- /* Unreference the font from the scratch GC */
- CloseFont(c->pGC->font, (Font) 0);
- c->pGC->font = NullFont;
+ /* Unreference the font from the scratch GC */
+ CloseFont(c->pGC->font, (Font) 0);
+ c->pGC->font = NullFont;
- FreeScratchGC(c->pGC);
- free(c->data);
- free(c);
+ FreeScratchGC(c->pGC);
+ free(c->data);
+ free(c);
+ }
}
return TRUE;
}
@@ -1394,6 +1426,10 @@ doImageText(ClientPtr client, ITclosurePtr c)
int err = Success, lgerr; /* err is in X error, not font error, space */
FontPathElementPtr fpe;
int itemSize = c->reqType == X_ImageText8 ? 1 : 2;
+ Bool fromDispatch = c->from_dispatch;
+ Bool finished = FALSE;
+
+ c->from_dispatch = FALSE;
if (client->clientGone) {
fpe = c->pGC->font->fpe;
@@ -1494,16 +1530,19 @@ doImageText(ClientPtr client, ITclosurePtr c)
}
if (ClientIsAsleep(client)) {
ClientWakeup(c->client);
+ finished = TRUE;
xinerama_sleep:
- ChangeGC(NullClient, c->pGC, clearGCmask, clearGC);
+ if (finished || fromDispatch) {
+ ChangeGC(NullClient, c->pGC, clearGCmask, clearGC);
- /* Unreference the font from the scratch GC */
- CloseFont(c->pGC->font, (Font) 0);
- c->pGC->font = NullFont;
+ /* Unreference the font from the scratch GC */
+ CloseFont(c->pGC->font, (Font) 0);
+ c->pGC->font = NullFont;
- FreeScratchGC(c->pGC);
- free(c->data);
- free(c);
+ FreeScratchGC(c->pGC);
+ free(c->data);
+ free(c);
+ }
}
return TRUE;
}