aboutsummaryrefslogtreecommitdiff
path: root/nx-X11/programs/Xserver/hw/nxagent
diff options
context:
space:
mode:
authorMike Gabriel <mike.gabriel@das-netzwerkteam.de>2017-02-09 14:05:57 +0100
committerMike Gabriel <mike.gabriel@das-netzwerkteam.de>2017-04-10 16:09:20 +0200
commitf4c80a78ce0e5648334fc43e5c93a068ed3ec5be (patch)
tree109fac35d5025730fc3bbce7b135118b233878e5 /nx-X11/programs/Xserver/hw/nxagent
parentf743f9f743362c891f049a514cdcf3d39546194b (diff)
downloadnx-libs-f4c80a78ce0e5648334fc43e5c93a068ed3ec5be.tar.gz
nx-libs-f4c80a78ce0e5648334fc43e5c93a068ed3ec5be.tar.bz2
nx-libs-f4c80a78ce0e5648334fc43e5c93a068ed3ec5be.zip
Xserver: Support building against libXfont2 (v2) API and old libXfont(1) API alike.
Fixes ArcticaProject/nx-libs#296. Inspired by the following X.org commit. Other than X.org, we will continue support for building nx-libs against libXfont1 for a while. commit 05a793f5b3c40747d5a92a076def7f4fb673c7e7 Author: Keith Packard <keithp@keithp.com> Date: Tue Sep 1 18:50:55 2015 -0700 dix: Switch to the libXfont2 API (v2) This new libXfont API eliminates exposing internal X server symbols to the font library, replacing those with a struct full of the entire API needed to use that library. v2: Use libXfont2 instead of libXfont_2 Signed-off-by: Keith Packard <keithp@keithp.com> Reviewed-by: Adam Jackson <ajax@redhat.com>
Diffstat (limited to 'nx-X11/programs/Xserver/hw/nxagent')
-rw-r--r--nx-X11/programs/Xserver/hw/nxagent/Font.c13
-rw-r--r--nx-X11/programs/Xserver/hw/nxagent/Imakefile6
-rw-r--r--nx-X11/programs/Xserver/hw/nxagent/Init.c5
-rw-r--r--nx-X11/programs/Xserver/hw/nxagent/NXdixfonts.c106
4 files changed, 128 insertions, 2 deletions
diff --git a/nx-X11/programs/Xserver/hw/nxagent/Font.c b/nx-X11/programs/Xserver/hw/nxagent/Font.c
index e1f12e733..f9c682765 100644
--- a/nx-X11/programs/Xserver/hw/nxagent/Font.c
+++ b/nx-X11/programs/Xserver/hw/nxagent/Font.c
@@ -41,6 +41,7 @@ is" without express or implied warranty.
#include "dixstruct.h"
#include <X11/fonts/font.h>
#include <X11/fonts/fontstruct.h>
+#include "dixfontstr.h"
#include "misc.h"
#include "miscstruct.h"
#include "opaque.h"
@@ -495,7 +496,11 @@ Bool nxagentRealizeFont(ScreenPtr pScreen, FontPtr pFont)
const char *name;
char *origName = (char*) pScreen;
+#ifdef HAS_XFONT2
+ xfont2_font_set_private(pFont, nxagentFontPrivateIndex, NULL);
+#else
FontSetPrivate(pFont, nxagentFontPrivateIndex, NULL);
+#endif /* HAS_XFONT2 */
if (requestingClient && XpClientIsPrintClient(requestingClient, NULL))
return True;
@@ -540,7 +545,11 @@ Bool nxagentRealizeFont(ScreenPtr pScreen, FontPtr pFont)
}
priv = (void *)malloc(sizeof(nxagentPrivFont));
+#ifdef HAS_XFONT2
+ xfont2_font_set_private(pFont, nxagentFontPrivateIndex, priv);
+#else
FontSetPrivate(pFont, nxagentFontPrivateIndex, priv);
+#endif /* HAS_XFONT2 */
nxagentFontPriv(pFont) -> mirrorID = 0;
@@ -688,7 +697,11 @@ Bool nxagentUnrealizeFont(ScreenPtr pScreen, FontPtr pFont)
FreeResource(nxagentFontPriv(pFont) -> mirrorID, RT_NONE);
free(nxagentFontPriv(pFont));
+#ifdef HAS_XFONT2
+ xfont2_font_set_private(pFont, nxagentFontPrivateIndex, NULL);
+#else
FontSetPrivate(pFont, nxagentFontPrivateIndex, NULL);
+#endif /* HAS_XFONT2 */
}
return True;
diff --git a/nx-X11/programs/Xserver/hw/nxagent/Imakefile b/nx-X11/programs/Xserver/hw/nxagent/Imakefile
index e9e076e0a..e9175df72 100644
--- a/nx-X11/programs/Xserver/hw/nxagent/Imakefile
+++ b/nx-X11/programs/Xserver/hw/nxagent/Imakefile
@@ -257,7 +257,11 @@ all:: $(OBJS)
LinkSourceFile(stubs.c,$(SERVERSRC)/Xi)
LinkSourceFile(xpstubs.c,$(SERVERSRC)/dix)
-SpecialCObjectRule(Init,$(ICONFIGFILES),$(_NOOP_))
+SpecialCObjectRule(Init,$(ICONFIGFILES),$(FONT_DEFINES))
+SpecialCObjectRule(Font,$(ICONFIGFILES),$(FONT_DEFINES))
+SpecialCObjectRule(NXdamage,$(ICONFIGFILES),$(FONT_DEFINES))
+SpecialCObjectRule(NXdispatch,$(ICONFIGFILES),$(FONT_DEFINES))
+SpecialCObjectRule(NXdixfonts,$(ICONFIGFILES),$(FONT_DEFINES))
LinkSourceFile(miinitext.c,$(SERVERSRC)/mi)
SpecialCObjectRule(miinitext,$(ICONFIGFILES), $(_NOOP_))
diff --git a/nx-X11/programs/Xserver/hw/nxagent/Init.c b/nx-X11/programs/Xserver/hw/nxagent/Init.c
index 014ab17f9..a35e3d5a8 100644
--- a/nx-X11/programs/Xserver/hw/nxagent/Init.c
+++ b/nx-X11/programs/Xserver/hw/nxagent/Init.c
@@ -51,6 +51,7 @@ is" without express or implied warranty.
#include "servermd.h"
#include "mi.h"
#include <X11/fonts/fontstruct.h>
+#include "dixfontstr.h"
#include "Agent.h"
#include "Display.h"
@@ -367,7 +368,11 @@ FIXME: These variables, if not removed at all because have probably
nxagentWindowPrivateIndex = AllocateWindowPrivateIndex();
nxagentGCPrivateIndex = AllocateGCPrivateIndex();
RT_NX_GC = CreateNewResourceType(nxagentDestroyNewGCResourceType);
+#ifdef HAS_XFONT2
+ nxagentFontPrivateIndex = xfont2_allocate_font_private_index();
+#else
nxagentFontPrivateIndex = AllocateFontPrivateIndex();
+#endif /* HAS_XFONT2 */
RT_NX_FONT = CreateNewResourceType(nxagentDestroyNewFontResourceType);
nxagentClientPrivateIndex = AllocateClientPrivateIndex();
nxagentPixmapPrivateIndex = AllocatePixmapPrivateIndex();
diff --git a/nx-X11/programs/Xserver/hw/nxagent/NXdixfonts.c b/nx-X11/programs/Xserver/hw/nxagent/NXdixfonts.c
index 1b7ce114b..49d864887 100644
--- a/nx-X11/programs/Xserver/hw/nxagent/NXdixfonts.c
+++ b/nx-X11/programs/Xserver/hw/nxagent/NXdixfonts.c
@@ -210,14 +210,22 @@ doOpenFont(ClientPtr client, OFclosurePtr c)
if (c->current_fpe < c->num_fpes)
{
fpe = c->fpe_list[c->current_fpe];
+#ifdef HAS_XFONT2
+ (*fpe_functions[fpe->type]->client_died) ((void *) client, fpe);
+#else
(*fpe_functions[fpe->type].client_died) ((void *) client, fpe);
+#endif /* HAS_XFONT2 */
}
err = Successful;
goto bail;
}
while (c->current_fpe < c->num_fpes) {
fpe = c->fpe_list[c->current_fpe];
+#ifdef HAS_XFONT2
+ err = (*fpe_functions[fpe->type]->open_font)
+#else
err = (*fpe_functions[fpe->type].open_font)
+#endif /* HAS_XFONT2 */
((void *) client, fpe, c->flags,
c->fontname, c->fnamelen, FontFormat,
BitmapFormatMaskByte |
@@ -314,7 +322,11 @@ doOpenFont(ClientPtr client, OFclosurePtr c)
}
}
if (patternCache && pfont != c->non_cachable_font)
+#ifdef HAS_XFONT2
+ xfont2_cache_font_pattern(patternCache, nxagentOrigFontName, nxagentOrigFontNameLen,
+#else
CacheFontPattern(patternCache, nxagentOrigFontName, nxagentOrigFontNameLen,
+#endif /* HAS_XFONT2 */
pfont);
bail:
if (err != Successful && c->client != serverClient) {
@@ -359,7 +371,11 @@ doListFontsAndAliases(ClientPtr client, LFclosurePtr c)
if (c->current.current_fpe < c->num_fpes)
{
fpe = c->fpe_list[c->current.current_fpe];
+#ifdef HAS_XFONT2
+ (*fpe_functions[fpe->type]->client_died) ((void *) client, fpe);
+#else
(*fpe_functions[fpe->type].client_died) ((void *) client, fpe);
+#endif /* HAS_XFONT2 */
}
err = Successful;
goto bail;
@@ -372,11 +388,19 @@ doListFontsAndAliases(ClientPtr client, LFclosurePtr c)
fpe = c->fpe_list[c->current.current_fpe];
err = Successful;
+#ifdef HAS_XFONT2
+ if (!fpe_functions[fpe->type]->start_list_fonts_and_aliases)
+#else
if (!fpe_functions[fpe->type].start_list_fonts_and_aliases)
+#endif /* HAS_XFONT2 */
{
/* This FPE doesn't support/require list_fonts_and_aliases */
+#ifdef HAS_XFONT2
+ err = (*fpe_functions[fpe->type]->list_fonts)
+#else
err = (*fpe_functions[fpe->type].list_fonts)
+#endif /* HAS_XFONT2 */
((void *) c->client, fpe, c->current.pattern,
c->current.patlen, c->current.max_names - c->names->nnames,
c->names);
@@ -408,7 +432,11 @@ doListFontsAndAliases(ClientPtr client, LFclosurePtr c)
the FPEs. */
if (!c->current.list_started) {
+#ifdef HAS_XFONT2
+ err = (*fpe_functions[fpe->type]->start_list_fonts_and_aliases)
+#else
err = (*fpe_functions[fpe->type].start_list_fonts_and_aliases)
+#endif /* HAS_XFONT2 */
((void *) c->client, fpe, c->current.pattern,
c->current.patlen, c->current.max_names - c->names->nnames,
&c->current.private);
@@ -427,7 +455,11 @@ doListFontsAndAliases(ClientPtr client, LFclosurePtr c)
if (err == Successful) {
char *tmpname;
name = 0;
+#ifdef HAS_XFONT2
+ err = (*fpe_functions[fpe->type]->list_next_font_or_alias)
+#else
err = (*fpe_functions[fpe->type].list_next_font_or_alias)
+#endif /* HAS_XFONT2 */
((void *) c->client, fpe, &name, &namelen, &tmpname,
&resolvedlen, c->current.private);
if (err == Suspended) {
@@ -458,11 +490,19 @@ doListFontsAndAliases(ClientPtr client, LFclosurePtr c)
if (c->haveSaved)
{
if (c->savedName)
+#ifdef HAS_XFONT2
+ (void)xfont2_add_font_names_name(c->names, c->savedName,
+#else
(void)AddFontNamesName(c->names, c->savedName,
+#endif /* HAS_XFONT2 */
c->savedNameLen);
}
else
+#ifdef HAS_XFONT2
+ (void)xfont2_add_font_names_name(c->names, name, namelen);
+#else
(void)AddFontNamesName(c->names, name, namelen);
+#endif /* HAS_XFONT2 */
}
/*
@@ -487,7 +527,11 @@ doListFontsAndAliases(ClientPtr client, LFclosurePtr c)
int tmpnamelen;
tmpname = 0;
+#ifdef HAS_XFONT2
+ (void) (*fpe_functions[fpe->type]->list_next_font_or_alias)
+#else
(void) (*fpe_functions[fpe->type].list_next_font_or_alias)
+#endif /* HAS_XFONT2 */
((void *) c->client, fpe, &tmpname, &tmpnamelen,
&tmpname, &tmpnamelen, c->current.private);
if (--aliascount <= 0)
@@ -621,7 +665,11 @@ bail:
FreeFPE(c->fpe_list[i]);
free(c->fpe_list);
if (c->savedName) free(c->savedName);
+#ifdef HAS_XFONT2
+ xfont2_free_font_names(names);
+#else
FreeFontNames(names);
+#endif /* HAS_XFONT2 */
free(c);
if (resolved) free(resolved);
return TRUE;
@@ -651,7 +699,11 @@ ListFonts(ClientPtr client, unsigned char *pattern, unsigned length,
free(c);
return BadAlloc;
}
+#ifdef HAS_XFONT2
+ c->names = xfont2_make_font_names_record(max_names < nxagentMaxFontNames ? max_names : nxagentMaxFontNames);
+#else
c->names = MakeFontNamesRecord(max_names < nxagentMaxFontNames ? max_names : nxagentMaxFontNames);
+#endif /* HAS_XFONT2 */
if (!c->names)
{
free(c->fpe_list);
@@ -699,7 +751,11 @@ doListFontsWithInfo(ClientPtr client, LFWIclosurePtr c)
if (c->current.current_fpe < c->num_fpes)
{
fpe = c->fpe_list[c->current.current_fpe];
+#ifdef HAS_XFONT2
+ (*fpe_functions[fpe->type]->client_died) ((void *) client, fpe);
+#else
(*fpe_functions[fpe->type].client_died) ((void *) client, fpe);
+#endif /* HAS_XFONT2 */
}
err = Successful;
goto bail;
@@ -713,7 +769,11 @@ doListFontsWithInfo(ClientPtr client, LFWIclosurePtr c)
err = Successful;
if (!c->current.list_started)
{
+#ifdef HAS_XFONT2
+ err = (*fpe_functions[fpe->type]->start_list_fonts_with_info)
+#else
err = (*fpe_functions[fpe->type].start_list_fonts_with_info)
+#endif /* HAS_XFONT2 */
(client, fpe, c->current.pattern, c->current.patlen,
c->current.max_names, &c->current.private);
if (err == Suspended)
@@ -735,7 +795,11 @@ doListFontsWithInfo(ClientPtr client, LFWIclosurePtr c)
{
name = 0;
pFontInfo = &fontInfo;
+#ifdef HAS_XFONT2
+ err = (*fpe_functions[fpe->type]->list_next_font_with_info)
+#else
err = (*fpe_functions[fpe->type].list_next_font_with_info)
+#endif /* HAS_XFONT2 */
(client, fpe, &name, &namelen, &pFontInfo,
&numFonts, c->current.private);
if (err == Suspended)
@@ -775,7 +839,11 @@ doListFontsWithInfo(ClientPtr client, LFWIclosurePtr c)
tmpname = 0;
tmpFontInfo = &fontInfo;
- (void) (*fpe_functions[fpe->type].list_next_font_with_info)
+#ifdef HAS_XFONT2
+ (void) (*fpe_functions[fpe->type]->list_next_font_with_info)
+#else
+ (void) (*fpe_functions[fpe->type].list_next_font_with_info)
+#endif /* HAS_XFONT2 */
(client, fpe, &tmpname, &tmpnamelen, &tmpFontInfo,
&numFonts, c->current.private);
if (--aliascount <= 0)
@@ -1028,7 +1096,11 @@ nxdoListFontsAndAliases(client, fss)
if (c->current.current_fpe < c->num_fpes)
{
fpe = c->fpe_list[c->current.current_fpe];
+#ifdef HAS_XFONT2
+ (*fpe_functions[fpe->type]->client_died) ((void *) client, fpe);
+#else
(*fpe_functions[fpe->type].client_died) ((void *) client, fpe);
+#endif /* HAS_XFONT2 */
}
err = Successful;
goto bail;
@@ -1041,11 +1113,19 @@ nxdoListFontsAndAliases(client, fss)
fpe = c->fpe_list[c->current.current_fpe];
err = Successful;
+#ifdef HAS_XFONT2
+ if (!fpe_functions[fpe->type]->start_list_fonts_and_aliases)
+#else
if (!fpe_functions[fpe->type].start_list_fonts_and_aliases)
+#endif /* HAS_XFONT2 */
{
/* This FPE doesn't support/require list_fonts_and_aliases */
+#ifdef HAS_XFONT2
+ err = (*fpe_functions[fpe->type]->list_fonts)
+#else
err = (*fpe_functions[fpe->type].list_fonts)
+#endif /* HAS_XFONT2 */
((void *) c->client, fpe, c->current.pattern,
c->current.patlen, c->current.max_names - c->names->nnames,
c->names);
@@ -1077,7 +1157,11 @@ nxdoListFontsAndAliases(client, fss)
the FPEs. */
if (!c->current.list_started) {
+#ifdef HAS_XFONT2
+ err = (*fpe_functions[fpe->type]->start_list_fonts_and_aliases)
+#else
err = (*fpe_functions[fpe->type].start_list_fonts_and_aliases)
+#endif /* HAS_XFONT2 */
((void *) c->client, fpe, c->current.pattern,
c->current.patlen, c->current.max_names - c->names->nnames,
&c->current.private);
@@ -1099,7 +1183,11 @@ nxdoListFontsAndAliases(client, fss)
if (err == Successful) {
char *tmpname;
name = 0;
+#ifdef HAS_XFONT2
+ err = (*fpe_functions[fpe->type]->list_next_font_or_alias)
+#else
err = (*fpe_functions[fpe->type].list_next_font_or_alias)
+#endif /* HAS_XFONT2 */
((void *) c->client, fpe, &name, &namelen, &tmpname,
&resolvedlen, c->current.private);
if (err == Suspended) {
@@ -1170,7 +1258,11 @@ nxdoListFontsAndAliases(client, fss)
int tmpnamelen;
tmpname = 0;
+#ifdef HAS_XFONT2
+ (void) (*fpe_functions[fpe->type]->list_next_font_or_alias)
+#else
(void) (*fpe_functions[fpe->type].list_next_font_or_alias)
+#endif /* HAS_XFONT2 */
((void *) c->client, fpe, &tmpname, &tmpnamelen,
&tmpname, &tmpnamelen, c->current.private);
if (--aliascount <= 0)
@@ -1281,7 +1373,11 @@ finish:
FreeFPE(c->fpe_list[i]);
free(c->fpe_list);
if (c->savedName) free(c->savedName);
+#ifdef HAS_XFONT2
+ xfont2_free_font_names(c->names);
+#else
FreeFontNames(c->names);
+#endif /* HAS_XFONT2 */
free(c);
free(fss);
if (resolved) free(resolved);
@@ -1333,7 +1429,11 @@ nxOpenFont(client, fid, flags, lenfname, pfontname)
** having to create another instance of a font that already exists.
*/
+#ifdef HAS_XFONT2
+ cached = xfont2_find_cached_font_pattern(patternCache, pfontname, lenfname);
+#else
cached = FindCachedFontPattern(patternCache, pfontname, lenfname);
+#endif /* HAS_XFONT2 */
if (cached && cached->info.cachable)
{
if (!AddResource(fid, RT_FONT, (void *) cached))
@@ -1357,7 +1457,11 @@ nxOpenFont(client, fid, flags, lenfname, pfontname)
free(fss);
return BadAlloc;
}
+#ifdef HAS_XFONT2
+ c->names = xfont2_make_font_names_record(100);
+#else
c->names = MakeFontNamesRecord(100);
+#endif /* HAS_XFONT2 */
if (!c->names)
{
free(c->fpe_list);